LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* RE: [LinuxBIOS] [linux-usb-devel] [RFC][PATCH 0/2] x86_64 Early usb debug port support.
@ 2006-12-05 23:29 Lu, Yinghai
  2006-12-05 23:50 ` Eric W. Biederman
  0 siblings, 1 reply; 18+ messages in thread
From: Lu, Yinghai @ 2006-12-05 23:29 UTC (permalink / raw)
  To: ebiederm, David Brownell
  Cc: Peter Stuge, linux-usb-devel, Stefan Reinauer, Greg KH,
	linux-kernel, linuxbios, Andi Kleen



-----Original Message-----
From: linuxbios-bounces@linuxbios.org
[mailto:linuxbios-bounces@linuxbios.org] On Behalf Of
ebiederm@xmission.com
Sent: Tuesday, December 05, 2006 3:01 AM

>+static int ehci_wait_for_port(int port)
>+{
>+	unsigned status;
>+	int ret, reps;
>+	for (reps = 0; reps >= 0; reps++) {
>+		status = readl(&ehci_regs->status);
>+		if (status & STS_PCD) {
>+			ret = ehci_reset_port(port);
>+			if (ret == 0)
>+				return 0;
>+		}
>+	}
>+	return -ENOTCONN;
>+}
>+

What do you mean by
+	for (reps = 0; reps >= 0; reps++) {
?

YH




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [LinuxBIOS] [linux-usb-devel] [RFC][PATCH 0/2] x86_64 Early usb debug port support.
  2006-12-05 23:29 [LinuxBIOS] [linux-usb-devel] [RFC][PATCH 0/2] x86_64 Early usb debug port support Lu, Yinghai
@ 2006-12-05 23:50 ` Eric W. Biederman
  2006-12-06 15:31   ` Segher Boessenkool
  0 siblings, 1 reply; 18+ messages in thread
From: Eric W. Biederman @ 2006-12-05 23:50 UTC (permalink / raw)
  To: Lu, Yinghai
  Cc: David Brownell, Peter Stuge, linux-usb-devel, Stefan Reinauer,
	Greg KH, linux-kernel, linuxbios, Andi Kleen

"Lu, Yinghai" <yinghai.lu@amd.com> writes:

> -----Original Message-----
> From: linuxbios-bounces@linuxbios.org
> [mailto:linuxbios-bounces@linuxbios.org] On Behalf Of
> ebiederm@xmission.com
> Sent: Tuesday, December 05, 2006 3:01 AM
>
>>+static int ehci_wait_for_port(int port)
>>+{
>>+	unsigned status;
>>+	int ret, reps;
>>+	for (reps = 0; reps >= 0; reps++) {
>>+		status = readl(&ehci_regs->status);
>>+		if (status & STS_PCD) {
>>+			ret = ehci_reset_port(port);
>>+			if (ret == 0)
>>+				return 0;
>>+		}
>>+	}
>>+	return -ENOTCONN;
>>+}
>>+
>
> What do you mean by
> +	for (reps = 0; reps >= 0; reps++) {
> ?

If you will not reps is negative.  Roughly it is a loop
that will timeout eventually if a usb debug cable is not present.
Putting some deliberate delays in there so I could be certain
of timing out after a second or two would probably be better, but
I don't have anything that resembles a good timer at that point.

The problem is you have to wait until the ehci notices your usb
debug cable before you reset it and get it going and that can be a
non-trivial amount of time.  So the loop is 100% necessary.

So since I didn't know how many loop iterations made sense I allowed
it to loop for 2^31 times or until reps goes negative.

Eric

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [LinuxBIOS] [linux-usb-devel] [RFC][PATCH 0/2] x86_64 Early usb debug port support.
  2006-12-05 23:50 ` Eric W. Biederman
@ 2006-12-06 15:31   ` Segher Boessenkool
  0 siblings, 0 replies; 18+ messages in thread
From: Segher Boessenkool @ 2006-12-06 15:31 UTC (permalink / raw)
  To: Eric W. Biederman
  Cc: Lu, Yinghai, Peter Stuge, linux-usb-devel, Stefan Reinauer,
	Greg KH, linux-kernel, Andi Kleen, David Brownell, linuxbios

>> What do you mean by
>> +	for (reps = 0; reps >= 0; reps++) {
>> ?
>
> If you will not reps is negative.  Roughly it is a loop
> that will timeout eventually if a usb debug cable is not present.

> So since I didn't know how many loop iterations made sense I allowed
> it to loop for 2^31 times or until reps goes negative.

This doesn't work however.  Signed overflow in C is undefined,
and GCC actually optimises accordingly (unless -fwrapv is used).


Segher


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [LinuxBIOS] [linux-usb-devel] [RFC][PATCH 0/2] x86_64 Early usb debug port support.
  2006-12-13 10:09           ` Yinghai Lu
@ 2006-12-13 10:41             ` Yinghai Lu
  0 siblings, 0 replies; 18+ messages in thread
From: Yinghai Lu @ 2006-12-13 10:41 UTC (permalink / raw)
  To: Eric W. Biederman
  Cc: Greg KH, Peter Stuge, linux-usb-devel, Stefan Reinauer,
	linux-kernel, linuxbios, Andi Kleen, David Brownell

wakeup_level4_pgt need to be updated in addtion to boot_level4_pgt?

also comment could be updated for good unstanding too.

YH

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [LinuxBIOS] [linux-usb-devel] [RFC][PATCH 0/2] x86_64 Early usb debug port support.
  2006-12-13  7:29         ` Eric W. Biederman
@ 2006-12-13 10:09           ` Yinghai Lu
  2006-12-13 10:41             ` Yinghai Lu
  0 siblings, 1 reply; 18+ messages in thread
From: Yinghai Lu @ 2006-12-13 10:09 UTC (permalink / raw)
  To: Eric W. Biederman
  Cc: Greg KH, Peter Stuge, linux-usb-devel, Stefan Reinauer,
	linux-kernel, linuxbios, Andi Kleen, David Brownell

On 12/12/06, Eric W. Biederman <ebiederm@xmission.com> wrote:
> diff --git a/arch/x86_64/kernel/head.S b/arch/x86_64/kernel/head.S
> index 1e6f808..2f65469 100644
> --- a/arch/x86_64/kernel/head.S
> +++ b/arch/x86_64/kernel/head.S
> @@ -328,9 +328,9 @@ ENTRY(wakeup_level4_pgt)
>         .align PAGE_SIZE
>  ENTRY(boot_level4_pgt)
>         .quad   phys_level3_ident_pgt | 0x007
> -       .fill   255,8,0
> +       .fill   257,8,0
>         .quad   phys_level3_physmem_pgt | 0x007
> -       .fill   254,8,0
> +       .fill   252,8,0
>         /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
>         .quad   phys_level3_kernel_pgt | 0x007
>

Good, it seems __PAGE_OFFSET used to be 0xfff800000000000
and then 1<<40, and then 0xfff810000000000

YH

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [LinuxBIOS] [linux-usb-devel] [RFC][PATCH 0/2] x86_64 Early usb debug port support.
  2006-12-13  7:00       ` Yinghai Lu
@ 2006-12-13  7:29         ` Eric W. Biederman
  2006-12-13 10:09           ` Yinghai Lu
  0 siblings, 1 reply; 18+ messages in thread
From: Eric W. Biederman @ 2006-12-13  7:29 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Greg KH, Peter Stuge, linux-usb-devel, Stefan Reinauer,
	linux-kernel, linuxbios, Andi Kleen, David Brownell

"Yinghai Lu" <yinghai.lu@amd.com> writes:

> On 12/8/06, Eric W. Biederman <ebiederm@xmission.com> wrote:
>>
>> Your or I missed a bug fix/enhancement in there somewhere.
>>
>
> I found the problem. the __set_fixmap need to __va, so the entries
> will be referred from PAGE_OFFSET.
>
> solution will be
> 1. move enable_dbgp_console from setup_early_printk, and call it from
> setup_arch after init_memory_mapping.
> 2. or make __set_fixmap can use __pa or pa()+__START_KERNEL_map in
> addtion to _va.

3.  Make __va always work.  I had this in my tree and I guess it didn't get
   into my big rollup patch.

Eric


x86_64: Fix the memory mapping in the early page table

diff --git a/arch/x86_64/kernel/head.S b/arch/x86_64/kernel/head.S
index 1e6f808..2f65469 100644
--- a/arch/x86_64/kernel/head.S
+++ b/arch/x86_64/kernel/head.S
@@ -328,9 +328,9 @@ ENTRY(wakeup_level4_pgt)
        .align PAGE_SIZE
 ENTRY(boot_level4_pgt)
        .quad   phys_level3_ident_pgt | 0x007
-       .fill   255,8,0
+       .fill   257,8,0
        .quad   phys_level3_physmem_pgt | 0x007
-       .fill   254,8,0
+       .fill   252,8,0
        /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
        .quad   phys_level3_kernel_pgt | 0x007
 



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [LinuxBIOS] [linux-usb-devel] [RFC][PATCH 0/2] x86_64 Early usb debug port support.
  2006-12-08  9:07     ` Eric W. Biederman
@ 2006-12-13  7:00       ` Yinghai Lu
  2006-12-13  7:29         ` Eric W. Biederman
  0 siblings, 1 reply; 18+ messages in thread
From: Yinghai Lu @ 2006-12-13  7:00 UTC (permalink / raw)
  To: Eric W. Biederman
  Cc: Greg KH, Peter Stuge, linux-usb-devel, Stefan Reinauer,
	linux-kernel, linuxbios, Andi Kleen, David Brownell

[-- Attachment #1: Type: text/plain, Size: 506 bytes --]

On 12/8/06, Eric W. Biederman <ebiederm@xmission.com> wrote:
>
> Your or I missed a bug fix/enhancement in there somewhere.
>

I found the problem. the __set_fixmap need to __va, so the entries
will be referred from PAGE_OFFSET.

solution will be
1. move enable_dbgp_console from setup_early_printk, and call it from
setup_arch after init_memory_mapping.
2. or make __set_fixmap can use __pa or pa()+__START_KERNEL_map in
addtion to _va.

please check attached updated patch that is your patch plus 1.

YH

[-- Attachment #2: usb_debug.patch --]
[-- Type: text/x-patch, Size: 21884 bytes --]

diff --git a/arch/i386/kernel/head.S b/arch/i386/kernel/head.S
index edef508..c8b1ec9 100644
--- a/arch/i386/kernel/head.S
+++ b/arch/i386/kernel/head.S
@@ -141,6 +141,12 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
 	jb 10b
 	movl %edi,(init_pg_tables_end - __PAGE_OFFSET)
 
+	/* Do an early initialization of the fixmap area */
+	movl $(swapper_pg_dir - __PAGE_OFFSET), %edx
+	movl $(swapper_pg_pmd - __PAGE_OFFSET), %eax
+	addl $0x007, %eax			/* 0x007 = PRESENT+RW+USER */
+	movl %eax, 4092(%edx)
+
 #ifdef CONFIG_SMP
 	xorl %ebx,%ebx				/* This is the boot CPU (BSP) */
 	jmp 3f
@@ -531,6 +537,8 @@ ENTRY(_stext)
 .section ".bss.page_aligned","w"
 ENTRY(swapper_pg_dir)
 	.fill 1024,4,0
+ENTRY(swapper_pg_pmd)
+	.fill 1024,4,0	
 ENTRY(empty_zero_page)
 	.fill 4096,1,0
 
diff --git a/arch/x86_64/kernel/early_printk.c b/arch/x86_64/kernel/early_printk.c
index 47b6d90..8b4c6f4 100644
--- a/arch/x86_64/kernel/early_printk.c
+++ b/arch/x86_64/kernel/early_printk.c
@@ -3,9 +3,19 @@
 #include <linux/init.h>
 #include <linux/string.h>
 #include <linux/screen_info.h>
+#include <linux/usb_ch9.h>
+#include <linux/pci_regs.h>
+#include <linux/pci_ids.h>
+#include <linux/errno.h>
 #include <asm/io.h>
 #include <asm/processor.h>
 #include <asm/fcntl.h>
+#include <asm/pci-direct.h>
+#include <asm/pgtable.h>
+#include <asm/fixmap.h>
+#define EARLY_PRINTK
+#include "../../../drivers/usb/host/ehci.h"
+
 
 /* Simple VGA output */
 
@@ -156,6 +166,562 @@ static struct console early_serial_console = {
 	.index =	-1,
 };
 
+
+static struct ehci_caps __iomem *ehci_caps;
+static struct ehci_regs __iomem *ehci_regs;
+static struct ehci_dbg_port __iomem *ehci_debug;
+static unsigned dbgp_endpoint_out;
+
+#define USB_DEBUG_DEVNUM 127
+
+#define DBGP_DATA_TOGGLE	0x8800
+#define DBGP_PID_UPDATE(x, tok) \
+	((((x) ^ DBGP_DATA_TOGGLE) & 0xffff00) | ((tok) & 0xff))
+
+#define DBGP_LEN_UPDATE(x, len) (((x) & ~0x0f) | ((len) & 0x0f))
+/*
+ * USB Packet IDs (PIDs)
+ */
+
+/* token */
+#define USB_PID_OUT		0xe1
+#define USB_PID_IN		0x69
+#define USB_PID_SOF		0xa5
+#define USB_PID_SETUP		0x2d
+/* handshake */
+#define USB_PID_ACK		0xd2
+#define USB_PID_NAK		0x5a
+#define USB_PID_STALL		0x1e
+#define USB_PID_NYET		0x96
+/* data */
+#define USB_PID_DATA0		0xc3
+#define USB_PID_DATA1		0x4b
+#define USB_PID_DATA2		0x87
+#define USB_PID_MDATA		0x0f
+/* Special */
+#define USB_PID_PREAMBLE	0x3c
+#define USB_PID_ERR		0x3c
+#define USB_PID_SPLIT		0x78
+#define USB_PID_PING		0xb4
+#define USB_PID_UNDEF_0		0xf0
+
+#define USB_PID_DATA_TOGGLE	0x88
+#define DBGP_CLAIM (DBGP_OWNER | DBGP_ENABLED | DBGP_INUSE)
+
+#define PCI_CAP_ID_EHCI_DEBUG	0xa
+
+#define HUB_ROOT_RESET_TIME	50	/* times are in msec */
+#define HUB_SHORT_RESET_TIME	10
+#define HUB_LONG_RESET_TIME	200
+#define HUB_RESET_TIMEOUT	500
+
+#define DBGP_MAX_PACKET		8
+
+static int dbgp_wait_until_complete(void)
+{
+	unsigned ctrl;
+	for (;;) {
+		ctrl = readl(&ehci_debug->control);
+		/* Stop when the transaction is finished */
+		if (ctrl & DBGP_DONE)
+			break;
+	}
+	/* Now that we have observed the completed transaction,
+	 * clear the done bit.
+	 */
+	writel(ctrl | DBGP_DONE, &ehci_debug->control);
+	return (ctrl & DBGP_ERROR) ? -DBGP_ERRCODE(ctrl) : DBGP_LEN(ctrl);
+}
+
+static void dbgp_mdelay(int ms)
+{
+	int i;
+	while (ms--) {
+		for (i = 0; i < 1000; i++)
+			outb(0x1, 0x80);
+	}
+}
+
+static void dbgp_breath(void)
+{
+	/* Sleep to give the debug port a chance to breathe */
+}
+
+static int dbgp_wait_until_done(unsigned ctrl)
+{
+	unsigned pids, lpid;
+	int ret;
+
+retry:
+	writel(ctrl | DBGP_GO, &ehci_debug->control);
+	ret = dbgp_wait_until_complete();
+	pids = readl(&ehci_debug->pids);
+	lpid = DBGP_PID_GET(pids);
+
+	if (ret < 0)
+		return ret;
+
+	/* If the port is getting full or it has dropped data
+	 * start pacing ourselves, not necessary but it's friendly.
+	 */
+	if ((lpid == USB_PID_NAK) || (lpid == USB_PID_NYET))
+		dbgp_breath();
+	
+	/* If I get a NACK reissue the transmission */
+	if (lpid == USB_PID_NAK)
+		goto retry;
+
+	return ret;
+}
+
+static void dbgp_set_data(const void *buf, int size)
+{
+	const unsigned char *bytes = buf;
+	unsigned lo, hi;
+	int i;
+	lo = hi = 0;
+	for (i = 0; i < 4 && i < size; i++)
+		lo |= bytes[i] << (8*i);
+	for (; i < 8 && i < size; i++)
+		hi |= bytes[i] << (8*(i - 4));
+	writel(lo, &ehci_debug->data03);
+	writel(hi, &ehci_debug->data47);
+}
+
+static void dbgp_get_data(void *buf, int size)
+{
+	unsigned char *bytes = buf;
+	unsigned lo, hi;
+	int i;
+	lo = readl(&ehci_debug->data03);
+	hi = readl(&ehci_debug->data47);
+	for (i = 0; i < 4 && i < size; i++)
+		bytes[i] = (lo >> (8*i)) & 0xff;
+	for (; i < 8 && i < size; i++)
+		bytes[i] = (hi >> (8*(i - 4))) & 0xff;
+}
+
+static int dbgp_bulk_write(unsigned devnum, unsigned endpoint, const char *bytes, int size)
+{
+	unsigned pids, addr, ctrl;
+	int ret;
+	if (size > DBGP_MAX_PACKET)
+		return -1;
+
+	addr = DBGP_EPADDR(devnum, endpoint);
+
+	pids = readl(&ehci_debug->pids);
+	pids = DBGP_PID_UPDATE(pids, USB_PID_OUT);
+	
+	ctrl = readl(&ehci_debug->control);
+	ctrl = DBGP_LEN_UPDATE(ctrl, size);
+	ctrl |= DBGP_OUT;
+	ctrl |= DBGP_GO;
+
+	dbgp_set_data(bytes, size);
+	writel(addr, &ehci_debug->address);
+	writel(pids, &ehci_debug->pids);
+
+	ret = dbgp_wait_until_done(ctrl);
+	if (ret < 0) {
+		return ret;
+	}
+	return ret;
+}
+
+static int dbgp_bulk_read(unsigned devnum, unsigned endpoint, void *data, int size)
+{
+	unsigned pids, addr, ctrl;
+	int ret;
+
+	if (size > DBGP_MAX_PACKET)
+		return -1;
+
+	addr = DBGP_EPADDR(devnum, endpoint);
+
+	pids = readl(&ehci_debug->pids);
+	pids = DBGP_PID_UPDATE(pids, USB_PID_IN);
+		
+	ctrl = readl(&ehci_debug->control);
+	ctrl = DBGP_LEN_UPDATE(ctrl, size);
+	ctrl &= ~DBGP_OUT;
+	ctrl |= DBGP_GO;
+		
+	writel(addr, &ehci_debug->address);
+	writel(pids, &ehci_debug->pids);
+	ret = dbgp_wait_until_done(ctrl);
+	if (ret < 0)
+		return ret;
+	if (size > ret)
+		size = ret;
+	dbgp_get_data(data, size);
+	return ret;
+}
+
+static int dbgp_control_msg(unsigned devnum, int requesttype, int request, 
+	int value, int index, void *data, int size)
+{
+	unsigned pids, addr, ctrl;
+	struct usb_ctrlrequest req;
+	int read;
+	int ret;
+
+	read = (requesttype & USB_DIR_IN) != 0;
+	if (size > (read?DBGP_MAX_PACKET:0))
+		return -1;
+	
+	/* Compute the control message */
+	req.bRequestType = requesttype;
+	req.bRequest = request;
+	req.wValue = value;
+	req.wIndex = index;
+	req.wLength = size;
+
+	pids = DBGP_PID_SET(USB_PID_DATA0, USB_PID_SETUP);
+	addr = DBGP_EPADDR(devnum, 0);
+
+	ctrl = readl(&ehci_debug->control);
+	ctrl = DBGP_LEN_UPDATE(ctrl, sizeof(req));
+	ctrl |= DBGP_OUT;
+	ctrl |= DBGP_GO;
+
+	/* Send the setup message */
+	dbgp_set_data(&req, sizeof(req));
+	writel(addr, &ehci_debug->address);
+	writel(pids, &ehci_debug->pids);
+	ret = dbgp_wait_until_done(ctrl);
+	if (ret < 0)
+		return ret;
+
+
+	/* Read the result */
+	ret = dbgp_bulk_read(devnum, 0, data, size);
+	return ret;
+}
+
+
+/* Find a PCI capability */
+static __u32 __init find_cap(int num, int slot, int func, int cap) 
+{ 
+	u8 pos;
+	int bytes;
+	if (!(read_pci_config_16(num,slot,func,PCI_STATUS) & PCI_STATUS_CAP_LIST))
+		return 0;
+	pos = read_pci_config_byte(num,slot,func,PCI_CAPABILITY_LIST);
+	for (bytes = 0; bytes < 48 && pos >= 0x40; bytes++) { 
+		u8 id;
+		pos &= ~3; 
+		id = read_pci_config_byte(num,slot,func,pos+PCI_CAP_LIST_ID);
+		if (id == 0xff)
+			break;
+		if (id == cap) 
+			return pos; 
+		pos = read_pci_config_byte(num,slot,func,pos+PCI_CAP_LIST_NEXT); 
+	} 
+	return 0;
+} 
+
+static __u32 __init find_dbgp(int ehci_num, unsigned *rbus, unsigned *rslot, unsigned *rfunc)
+{
+	unsigned bus, slot, func;
+	
+	for (bus = 0; bus < 256; bus++) {
+		for (slot = 0; slot < 32; slot++) {
+			for (func = 0; func < 8; func++) {
+				u32 class;
+				unsigned cap;
+				class = read_pci_config(bus, slot, func, PCI_CLASS_REVISION);
+				if ((class >> 8) != PCI_CLASS_SERIAL_USB_EHCI)
+					continue;
+				cap = find_cap(bus, slot, func, PCI_CAP_ID_EHCI_DEBUG);
+				if (!cap)
+					continue;
+				if (ehci_num-- != 0)
+					continue;
+				*rbus = bus;
+				*rslot = slot;
+				*rfunc = func;
+				return cap;
+			}
+		}
+	}
+	return 0;
+}
+
+static int ehci_reset_port(int port)
+{
+	unsigned portsc;
+	unsigned delay_time, delay;
+
+	/* Reset the usb debug port */
+	portsc = readl(&ehci_regs->port_status[port - 1]);
+	portsc &= ~PORT_PE;
+	portsc |= PORT_RESET;
+	writel(portsc, &ehci_regs->port_status[port - 1]);
+
+	delay = HUB_ROOT_RESET_TIME;
+	for (delay_time = 0; delay_time < HUB_RESET_TIMEOUT;
+	     delay_time += delay) {
+		dbgp_mdelay(delay);
+
+		portsc = readl(&ehci_regs->port_status[port - 1]);
+		if (portsc & PORT_RESET) {
+			/* force reset to complete */
+			writel(portsc & ~(PORT_RWC_BITS | PORT_RESET), 
+				&ehci_regs->port_status[port - 1]);
+			while (portsc & PORT_RESET)
+				portsc = readl(&ehci_regs->port_status[port - 1]);
+		}
+
+		/* Device went away? */
+		if (!(portsc & PORT_CONNECT))
+			return -ENOTCONN;
+
+		/* bomb out completely if something weird happend */
+		if ((portsc & PORT_CSC))
+			return -EINVAL;
+
+		/* If we've finished resetting, then break out of the loop */
+		if (!(portsc & PORT_RESET) && (portsc & PORT_PE))
+			return 0;
+	}
+	return -EBUSY;
+}
+
+static int ehci_wait_for_port(int port)
+{
+	unsigned status;
+	int ret, reps;
+	for (reps = 0; reps >= 0; reps++) {
+		status = readl(&ehci_regs->status);
+		if (status & STS_PCD) {
+			ret = ehci_reset_port(port);
+			if (ret == 0)
+				return 0;
+		}
+	}
+	return -ENOTCONN;
+}
+
+
+#define DBGP_DEBUG 1
+#if DBGP_DEBUG
+void early_printk(const char *fmt, ...);
+# define dbgp_printk early_printk
+#else
+static inline void dbgp_printk(const char *fmt, ...) { }
+#endif
+
+static int ehci_setup(void)
+{
+	unsigned cmd, ctrl, status, portsc, hcs_params, debug_port, n_ports;
+	int ret;
+
+	hcs_params = readl(&ehci_caps->hcs_params);
+	debug_port = HCS_DEBUG_PORT(hcs_params);
+	n_ports    = HCS_N_PORTS(hcs_params);
+
+	dbgp_printk("debug_port: %d\n", debug_port);
+	dbgp_printk("n_ports:    %d\n", n_ports);
+
+#if 0
+	/* Reset the EHCI controller */
+	cmd = readl(&ehci_regs->command);
+	cmd |=CMD_RESET;
+	writel(cmd, &ehci_regs->command);
+	while (cmd & CMD_RESET)
+		cmd = readl(&ehci_regs->command);
+#endif
+
+	/* Claim ownership, but do not enable yet */
+	ctrl = readl(&ehci_debug->control);
+	ctrl |= DBGP_OWNER;
+	ctrl &= ~(DBGP_ENABLED | DBGP_INUSE);
+	writel(ctrl, &ehci_debug->control);
+
+	/* Start the ehci running */
+	cmd = readl(&ehci_regs->command);
+	cmd &= ~(CMD_LRESET | CMD_IAAD | CMD_PSE | CMD_ASE | CMD_RESET);
+	cmd |= CMD_RUN;
+	writel(cmd, &ehci_regs->command);
+
+	/* Ensure everything is routed to the EHCI */
+	writel(FLAG_CF, &ehci_regs->configured_flag);
+
+	/* Wait until the controller is no longer halted */
+	do {
+		status = readl(&ehci_regs->status);
+	} while (status & STS_HALT);
+
+	/* Wait for a device to show up in the debug port */
+	ret = ehci_wait_for_port(debug_port);
+	if (ret < 0) {
+		dbgp_printk("No device found in debug port\n");
+		return -1;
+	}
+
+	/* Enable the debug port */
+	ctrl = readl(&ehci_debug->control);
+	ctrl |= DBGP_CLAIM;
+	writel(ctrl, &ehci_debug->control);
+	ctrl = readl(&ehci_debug->control);
+	if ((ctrl & DBGP_CLAIM) != DBGP_CLAIM) {
+		dbgp_printk("No device in debug port\n");
+		writel(ctrl & ~DBGP_CLAIM, &ehci_debug->control);
+		return -1;
+
+	}
+
+	/* Completely transfer the debug device to the debug controller */
+	portsc = readl(&ehci_regs->port_status[debug_port - 1]);
+	portsc &= ~PORT_PE;
+	writel(portsc, &ehci_regs->port_status[debug_port - 1]);
+
+	return 0;
+}
+
+static __init void early_dbgp_init(unsigned dbgp_num)
+{
+	struct usb_debug_descriptor dbgp_desc;
+	void __iomem *ehci_bar;
+	unsigned ctrl, devnum;
+	unsigned bus, slot, func, cap;
+	unsigned debug_port, bar, offset;
+	unsigned bar_val;
+	int ret;
+
+	if (!early_pci_allowed())
+		return;
+
+	dbgp_printk("dbgp_num: %d\n", dbgp_num);
+	cap = find_dbgp(dbgp_num, &bus, &slot, &func);
+	if (!cap)
+		return;
+
+	dbgp_printk("Found EHCI debug port\n");
+
+	debug_port = read_pci_config(bus, slot, func, cap);
+	bar = (debug_port >> 29) & 0x7;
+	bar = (bar * 4) + 0xc;
+	offset = (debug_port >> 16) & 0xfff;
+	dbgp_printk("bar: %02x offset: %03x\n", bar, offset);
+	if (bar != PCI_BASE_ADDRESS_0) {
+		dbgp_printk("only debug ports on bar 1 handled.\n");
+		return;
+	}
+
+	bar_val = read_pci_config(bus, slot, func, PCI_BASE_ADDRESS_0);
+	dbgp_printk("bar_val: %02x offset: %03x\n", bar_val, offset);
+	if (bar_val & ~PCI_BASE_ADDRESS_MEM_MASK) {
+		dbgp_printk("only simple 32bit mmio bars supported\n");
+		return;
+	}
+		
+
+	/* FIXME I don't have the bar size so just guess PAGE_SIZE is more
+	 * than enough.  1K is the biggest I have seen.
+	 */
+	dbgp_printk("dbgp pre-set_fixmap_nocache\n");
+	set_fixmap_nocache(FIX_DBGP_BASE, bar_val & PAGE_MASK);
+	dbgp_printk("dbgp post-set_fixmap_nocache\n");
+	ehci_bar = (void __iomem *)__fix_to_virt(FIX_DBGP_BASE);
+	ehci_bar += bar_val & ~PAGE_MASK;
+	dbgp_printk("ehci_bar: %p\n", ehci_bar);
+
+	ehci_caps  = ehci_bar;
+	ehci_regs  = ehci_bar + HC_LENGTH(readl(&ehci_caps->hc_capbase));
+	ehci_debug = ehci_bar + offset;
+
+	ret = ehci_setup();
+	if (ret < 0) {
+		dbgp_printk("ehci_setup failed\n");
+		ehci_debug = 0;
+		return;
+	}
+
+	/* Find the debug device and make it device number 127 */
+	for (devnum = 0; devnum <= 127; devnum++) {
+		ret = dbgp_control_msg(devnum,
+			USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE,
+			USB_REQ_GET_DESCRIPTOR, (USB_DT_DEBUG << 8), 0,
+			&dbgp_desc, sizeof(dbgp_desc));
+		if (ret > 0)
+			break;
+	}
+	if (devnum > 127) {
+		dbgp_printk("Could not find attached debug device\n");
+		goto err;
+	}
+	if (ret < 0) {
+		dbgp_printk("Attached device is not a debug device\n");
+		goto err;
+	}
+	dbgp_endpoint_out = dbgp_desc.bDebugOutEndpoint;
+
+	/* Move the device to 127 if it isn't already there */
+	if (devnum != USB_DEBUG_DEVNUM) {
+		ret = dbgp_control_msg(devnum,
+			USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE,
+			USB_REQ_SET_ADDRESS, USB_DEBUG_DEVNUM, 0, NULL, 0);
+		if (ret < 0) {
+			dbgp_printk("Could not move attached device to %d\n", 
+				USB_DEBUG_DEVNUM);
+			goto err;
+		}
+		devnum = USB_DEBUG_DEVNUM;
+	}
+
+	/* Enable the debug interface */
+	ret = dbgp_control_msg(USB_DEBUG_DEVNUM,
+		USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE,
+		USB_REQ_SET_FEATURE, USB_DEVICE_DEBUG_MODE, 0, NULL, 0);
+	if (ret < 0) {
+		dbgp_printk(" Could not enable the debug device\n");
+		goto err;
+	}
+
+	/* Perform a small write to get the even/odd data state in sync
+	 */
+	ret = dbgp_bulk_write(USB_DEBUG_DEVNUM, dbgp_endpoint_out, " ",1);
+	if (ret < 0) {
+		dbgp_printk("dbgp_bulk_write failed: %d\n", ret);
+		goto err;
+	}
+
+
+	return;
+err:
+	/* Things didn't work so remove my claim */
+	ctrl = readl(&ehci_debug->control);
+	ctrl &= ~(DBGP_CLAIM | DBGP_OUT);
+	writel(ctrl, &ehci_debug->control);
+	ehci_debug = 0;
+	return;
+}
+
+static void early_dbgp_write(struct console *con, const char *str, unsigned n)
+{
+	int chunk, ret;
+	if (!ehci_debug)
+		return;
+	while (n > 0) {
+		chunk = n;
+		if (chunk > DBGP_MAX_PACKET)
+			chunk = DBGP_MAX_PACKET;
+		ret = dbgp_bulk_write(USB_DEBUG_DEVNUM, 
+			dbgp_endpoint_out, str, chunk);
+		str += chunk;
+		n -= chunk;
+	}
+}
+
+static struct console early_dbgp_console = {
+	.name =		"earlydbg",
+	.write =	early_dbgp_write,
+	.flags = 	CON_PRINTBUFFER,
+	.index = 	-1,
+};
+
 /* Console interface to a host file on AMD's SimNow! */
 
 static int simnow_fd;
@@ -200,6 +766,7 @@ static struct console simnow_console = {
 /* Direct interface for emergencies */
 struct console *early_console = &early_vga_console;
 static int early_console_initialized = 0;
+static int early_console_dbgp_num = -1;
 
 void early_printk(const char *fmt, ...)
 {
@@ -243,12 +810,44 @@ static int __init setup_early_printk(char *buf)
  		simnow_init(buf + 6);
  		early_console = &simnow_console;
  		keep_early = 1;
+	} else if (!strncmp(buf, "dbgp", 4)) {
+		char *e;
+		early_console_initialized = 0;
+		early_console_dbgp_num = 0;
+		if (*(buf+4)) {
+			early_console_dbgp_num = simple_strtoul(buf+4, &e, 10);
+		}
 	}
-	register_console(early_console);
+
+	if(early_console_initialized)	
+		register_console(early_console);
+
 	return 0;
 }
 
 early_param("earlyprintk", setup_early_printk);
+void __init enable_dbgp_console(void)
+{
+	static const char dbgp_test_str[] = 
+		"The quick brown fox jumped over the lazy dog!\n";
+	
+#if DBGP_DEBUG
+	early_console_dbgp_num = 0;
+#endif
+	if(early_console_dbgp_num == -1) return;
+
+	early_dbgp_init(early_console_dbgp_num);
+	early_dbgp_write(&early_dbgp_console, 
+		dbgp_test_str, sizeof(dbgp_test_str) - 1);
+
+	if(early_console_initialized && early_console)	
+		unregister_console(early_console);
+
+	early_console_initialized = 1;
+	early_console = &early_dbgp_console;
+	keep_early = 1;
+	register_console(early_console);
+}
 
 void __init disable_early_printk(void)
 {
diff --git a/arch/x86_64/kernel/head.S b/arch/x86_64/kernel/head.S
index 1e6f808..d7e759b 100644
--- a/arch/x86_64/kernel/head.S
+++ b/arch/x86_64/kernel/head.S
@@ -271,7 +271,16 @@ NEXT_PAGE(level3_kernel_pgt)
 	.fill	510,8,0
 	/* (2^48-(2*1024*1024*1024)-((2^39)*511))/(2^30) = 510 */
 	.quad	phys_level2_kernel_pgt | 0x007
-	.fill	1,8,0
+	.quad	phys_level2_fixmap_pgt | 0x007
+
+NEXT_PAGE(level2_fixmap_pgt)
+	.fill	506,8,0
+	.quad	phys_level1_fixmap_pgt | 0x007
+	/* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
+	.fill	5,8,0
+
+NEXT_PAGE(level1_fixmap_pgt)
+	.fill	512,8,0
 
 NEXT_PAGE(level2_ident_pgt)
 	/* 40MB for bootup. 	*/
diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c
index af425a8..f70fd1c 100644
--- a/arch/x86_64/kernel/setup.c
+++ b/arch/x86_64/kernel/setup.c
@@ -341,6 +341,8 @@ static void discover_ebda(void)
 		ebda_size = 64*1024;
 }
 
+extern void __init enable_dbgp_console(void);
+
 void __init setup_arch(char **cmdline_p)
 {
 	printk(KERN_INFO "Command line: %s\n", saved_command_line);
@@ -394,6 +396,11 @@ void __init setup_arch(char **cmdline_p)
 
 	init_memory_mapping(0, (end_pfn_map << PAGE_SHIFT));
 
+	/* we need to call __set_fixmap for dbpg init, and it need _va 
+	 * so wait direct mapping from PAGE_OFFSET is set
+	 */
+	enable_dbgp_console();
+
 	dmi_scan_machine();
 
 	zap_low_mappings(0);
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index 74dbc6c..11e729c 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -46,6 +46,7 @@ struct ehci_stats {
 
 #define	EHCI_MAX_ROOT_PORTS	15		/* see HCS_N_PORTS */
 
+#ifndef EARLY_PRINTK
 struct ehci_hcd {			/* one per controller */
 	/* glue to PCI and HCD framework */
 	struct ehci_caps __iomem *caps;
@@ -161,6 +162,7 @@ timer_action (struct ehci_hcd *ehci, enum ehci_timer_action action)
 		mod_timer (&ehci->watchdog, t);
 	}
 }
+#endif /* EARLY_PRINTK */
 
 /*-------------------------------------------------------------------------*/
 
@@ -300,6 +302,8 @@ struct ehci_dbg_port {
 
 #define	QTD_NEXT(dma)	cpu_to_le32((u32)dma)
 
+#ifndef EARLY_PRINTK
+
 /*
  * EHCI Specification 0.95 Section 3.5
  * QTD: describe data transfer components (buffer, direction, ...)
@@ -335,7 +339,7 @@ struct ehci_qtd {
 	struct urb		*urb;			/* qtd's urb */
 	size_t			length;			/* length of buffer */
 } __attribute__ ((aligned (32)));
-
+#endif
 /* mask NakCnt+T in qh->hw_alt_next */
 #define QTD_MASK __constant_cpu_to_le32 (~0x1f)
 
@@ -385,6 +389,7 @@ union ehci_shadow {
  * These appear in both the async and (for interrupt) periodic schedules.
  */
 
+#ifndef EARLY_PRINTK
 struct ehci_qh {
 	/* first part defined by EHCI spec */
 	__le32			hw_next;	 /* see EHCI 3.6.1 */
@@ -433,6 +438,7 @@ struct ehci_qh {
 #define NO_FRAME ((unsigned short)~0)			/* pick new start */
 	struct usb_device	*dev;		/* access to TT */
 } __attribute__ ((aligned (32)));
+#endif /* EARLY_PRITNK */
 
 /*-------------------------------------------------------------------------*/
 
@@ -446,6 +452,7 @@ struct ehci_iso_packet {
 	u32			buf1;
 };
 
+#ifndef EARLY_PRINTK
 /* temporary schedule data for packets from iso urbs (both speeds)
  * each packet is one logical usb transaction to the device (not TT),
  * beginning at stream->next_uframe
@@ -581,6 +588,7 @@ struct ehci_sitd {
 	unsigned		frame;
 	unsigned		index;
 } __attribute__ ((aligned (32)));
+#endif
 
 /*-------------------------------------------------------------------------*/
 
@@ -602,6 +610,8 @@ struct ehci_fstn {
 	union ehci_shadow	fstn_next;	/* ptr to periodic q entry */
 } __attribute__ ((aligned (32)));
 
+#ifndef EARLY_PRINTK
+
 /*-------------------------------------------------------------------------*/
 
 #ifdef CONFIG_USB_EHCI_ROOT_HUB_TT
@@ -660,4 +670,6 @@ ehci_port_speed(struct ehci_hcd *ehci, unsigned int portsc)
 
 /*-------------------------------------------------------------------------*/
 
+#endif /* EARLY_PRINTK */
+
 #endif /* __LINUX_EHCI_HCD_H */
diff --git a/include/asm-i386/fixmap.h b/include/asm-i386/fixmap.h
index 02428cb..ea08885 100644
--- a/include/asm-i386/fixmap.h
+++ b/include/asm-i386/fixmap.h
@@ -56,6 +56,7 @@ extern unsigned long __FIXADDR_TOP;
 enum fixed_addresses {
 	FIX_HOLE,
 	FIX_VDSO,
+	FIX_DBGP_BASE,
 #ifdef CONFIG_X86_LOCAL_APIC
 	FIX_APIC_BASE,	/* local (CPU) APIC) -- required for SMP or not */
 #endif
diff --git a/include/asm-x86_64/fixmap.h b/include/asm-x86_64/fixmap.h
index 1b620db..1f2978a 100644
--- a/include/asm-x86_64/fixmap.h
+++ b/include/asm-x86_64/fixmap.h
@@ -36,6 +36,7 @@ enum fixed_addresses {
 	VSYSCALL_LAST_PAGE,
 	VSYSCALL_FIRST_PAGE = VSYSCALL_LAST_PAGE + ((VSYSCALL_END-VSYSCALL_START) >> PAGE_SHIFT) - 1,
 	VSYSCALL_HPET,
+	FIX_DBGP_BASE,
 	FIX_HPET_BASE,
 	FIX_APIC_BASE,	/* local (CPU) APIC) -- required for SMP or not */
 	FIX_IO_APIC_BASE_0,

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [LinuxBIOS] [linux-usb-devel] [RFC][PATCH 0/2] x86_64 Early usb debug port support.
  2006-12-09  3:16 Lu, Yinghai
@ 2006-12-09 10:54 ` Peter Stuge
  0 siblings, 0 replies; 18+ messages in thread
From: Peter Stuge @ 2006-12-09 10:54 UTC (permalink / raw)
  To: linuxbios
  Cc: linux-usb-devel, Greg KH, linux-kernel, Andi Kleen, David Brownell

On Fri, Dec 08, 2006 at 07:16:09PM -0800, Lu, Yinghai wrote:
> It works in LinuxBIOS now.

Cool, can't wait to try it out.

Good work!


//Peter

^ permalink raw reply	[flat|nested] 18+ messages in thread

* RE: [LinuxBIOS] [linux-usb-devel] [RFC][PATCH 0/2] x86_64 Early usb debug port support.
@ 2006-12-09  3:16 Lu, Yinghai
  2006-12-09 10:54 ` Peter Stuge
  0 siblings, 1 reply; 18+ messages in thread
From: Lu, Yinghai @ 2006-12-09  3:16 UTC (permalink / raw)
  To: ebiederm
  Cc: Greg KH, Peter Stuge, linux-usb-devel, Stefan Reinauer,
	linux-kernel, linuxbios, Andi Kleen, David Brownell

-----Original Message-----
From: ebiederm@xmission.com [mailto:ebiederm@xmission.com] 
Sent: Thursday, December 07, 2006 11:42 PM
>> With Eric code in LinuxBIOS, it will report "No device found in debug
>> port"
>Hmm.  At least this is partial progress :)

It works in LinuxBIOS now. It will loop all connected port and find
debug device.
Will check in the code together with MCP55.

YH



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [LinuxBIOS] [linux-usb-devel] [RFC][PATCH 0/2] x86_64 Early usb debug port support.
  2006-12-08  8:53   ` Yinghai Lu
@ 2006-12-08  9:07     ` Eric W. Biederman
  2006-12-13  7:00       ` Yinghai Lu
  0 siblings, 1 reply; 18+ messages in thread
From: Eric W. Biederman @ 2006-12-08  9:07 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Greg KH, Peter Stuge, linux-usb-devel, Stefan Reinauer,
	linux-kernel, linuxbios, Andi Kleen, David Brownell

"Yinghai Lu" <yinghai.lu@amd.com> writes:

> On 12/7/06, Eric W. Biederman <ebiederm@xmission.com> wrote:
>> Ugh.  I'd check the code.  But it looks like my tweak to the
>> early fixmap code.  But my hunch is that my tweak to __fixmap
>> so that it's pud and pmd were prepopulated didn't take on
>> your build.
>
> I missed some options?

Your or I missed a bug fix/enhancement in there somewhere.

Basically my very early setup of the fixmap failed.
Now.  I thought I had that covered by preallocated the pud and the pmd
entries.   So the only thing missing was the pte entries.

If that is not a big enough hint I will look into it in a bit...

I'm starting to become a big fan of constant initializers.  So our
core subsystems don't need initialization code to be useful.  All of
these early things are just a pain.

Eric

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [LinuxBIOS] [linux-usb-devel] [RFC][PATCH 0/2] x86_64 Early usb debug port support.
  2006-12-08  7:42 ` Eric W. Biederman
@ 2006-12-08  8:53   ` Yinghai Lu
  2006-12-08  9:07     ` Eric W. Biederman
  0 siblings, 1 reply; 18+ messages in thread
From: Yinghai Lu @ 2006-12-08  8:53 UTC (permalink / raw)
  To: Eric W. Biederman
  Cc: Greg KH, Peter Stuge, linux-usb-devel, Stefan Reinauer,
	linux-kernel, linuxbios, Andi Kleen, David Brownell

On 12/7/06, Eric W. Biederman <ebiederm@xmission.com> wrote:
> Ugh.  I'd check the code.  But it looks like my tweak to the
> early fixmap code.  But my hunch is that my tweak to __fixmap
> so that it's pud and pmd were prepopulated didn't take on
> your build.

I missed some options?

YH

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [LinuxBIOS] [linux-usb-devel] [RFC][PATCH 0/2] x86_64 Early usb debug port support.
  2006-12-08  7:14 ` Greg KH
@ 2006-12-08  8:52   ` Yinghai Lu
  0 siblings, 0 replies; 18+ messages in thread
From: Yinghai Lu @ 2006-12-08  8:52 UTC (permalink / raw)
  To: Greg KH
  Cc: ebiederm, Peter Stuge, linux-usb-devel, Stefan Reinauer,
	linux-kernel, linuxbios, Andi Kleen, David Brownell

On 12/7/06, Greg KH <gregkh@suse.de> wrote:
> Ugh, no, never use the usb-serial driver as a console device.
>
> That was a bad hack done as a bet many years ago.  For many obvious
> reasons it does not work well.
understood, I found with usb_serial convertor could lose some chatacter.
but the usb-debug cable seem it keep all character.
>
> > host with cat /dev/ttyUSB0
> > But if use minicom in host, it will not show '\r', I guess the usb debug
> > cable eat return char. Greg, Can you add that back in usb_debug by
> > replacing '\n' with '\r', '\n'?
>
> The usb-serial console code should handle this, I thought we fixed it a
> while ago.
Is it in the git tree?
>
> But this kind of interface is not what these devices are good for.  They
> are for the debug port information, not as a usb-serial console device.
> Otherwise they are way too expensive of a device...
the problem is some "modern" PC will left out serial port. then the cable
could get cheap.

YH

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [LinuxBIOS] [linux-usb-devel] [RFC][PATCH 0/2] x86_64 Early usb debug port support.
  2006-12-08  3:48 Lu, Yinghai
  2006-12-08  7:14 ` Greg KH
@ 2006-12-08  7:42 ` Eric W. Biederman
  2006-12-08  8:53   ` Yinghai Lu
  1 sibling, 1 reply; 18+ messages in thread
From: Eric W. Biederman @ 2006-12-08  7:42 UTC (permalink / raw)
  To: Lu, Yinghai
  Cc: Greg KH, Peter Stuge, linux-usb-devel, Stefan Reinauer,
	linux-kernel, linuxbios, Andi Kleen, David Brownell

"Lu, Yinghai" <yinghai.lu@amd.com> writes:

> -----Original Message-----
> From: linuxbios-bounces@linuxbios.org
> [mailto:linuxbios-bounces@linuxbios.org] On Behalf Of
> ebiederm@xmission.com
>
>
>>Ok due to popular demands here is the slightly fixed patch that works
>>on both i386 and x86_64.  For the i386 version you must not have
>>HIGHMEM64G enabled. 
>
>>I just rolled it all into one patch as I'm to lazy to transmit all
>>3 of them.
>
>
> I got
>
> Firmware type: LinuxBIOS
> Linux version 2.6.19-smp-gc9976797-dirty (root@lbsrv) (gcc version
> 4.0.2) #196 6
> Command line: earlyprintk=ttyS0,115200 apic=debug pci=noacpi,routeirq
> snd-hda-i
> BIOS-provided physical RAM map:
>  BIOS-e820: 0000000000000000 - 0000000000001000 (reserved)
>  BIOS-e820: 0000000000001000 - 00000000000a0000 (usable)
>  BIOS-e820: 00000000000c0000 - 00000000000f0000 (usable)
>  BIOS-e820: 00000000000f0000 - 0000000000100000 (reserved)
>  BIOS-e820: 0000000000100000 - 00000000c0000000 (usable)
>  BIOS-e820: 0000000100000000 - 0000000240000000 (usable)
> dbgp_num: 0
> Found EHCI debug port
> bar: 10 offset: 098
> bar: 10 offset: 098
> dbgp pre-set_fixmap_nocache
> PANIC: early exception rip ffffffff809c24b4 error 0 cr2 ffff810000203ff8
>
> Call Trace:
>  [<ffffffff809c24b4>] __set_fixmap+0x84/0x202
>  [<ffffffff809c05bb>] early_dbgp_init+0x259/0x55c
>  [<ffffffff8022d958>] __call_console_drivers+0x64/0x72
>  [<ffffffff809b242b>] do_early_param+0x0/0x57
>  [<ffffffff809c0a20>] setup_early_printk+0x162/0x17e
>  [<ffffffff809b2459>] do_early_param+0x2e/0x57
>  [<ffffffff8023d051>] parse_args+0x159/0x1f3
>  [<ffffffff809b24c2>] parse_early_param+0x40/0x4c
>  [<ffffffff809b88ca>] setup_arch+0x1c1/0x636
>  [<ffffffff809b2534>] start_kernel+0x55/0x208
>  [<ffffffff809b2173>] _sinittext+0x173/0x177
>
> RIP __set_fixmap+0x84/0x202

Ugh.  I'd check the code.  But it looks like my tweak to the
early fixmap code.  But my hunch is that my tweak to __fixmap
so that it's pud and pmd were prepopulated didn't take on
your build.

> With Eric code in LinuxBIOS, it will report "No device found in debug
> port"

Hmm.  At least this is partial progress :)

Eric


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [LinuxBIOS] [linux-usb-devel] [RFC][PATCH 0/2] x86_64 Early usb debug port support.
  2006-12-08  3:48 Lu, Yinghai
@ 2006-12-08  7:14 ` Greg KH
  2006-12-08  8:52   ` Yinghai Lu
  2006-12-08  7:42 ` Eric W. Biederman
  1 sibling, 1 reply; 18+ messages in thread
From: Greg KH @ 2006-12-08  7:14 UTC (permalink / raw)
  To: Lu, Yinghai
  Cc: ebiederm, Peter Stuge, linux-usb-devel, Stefan Reinauer,
	linux-kernel, linuxbios, Andi Kleen, David Brownell

On Thu, Dec 07, 2006 at 07:48:17PM -0800, Lu, Yinghai wrote:
> With Greg's USB Debug, host and target can talk.
> target with console=ttyUSB0,115200n8

Ugh, no, never use the usb-serial driver as a console device.

That was a bad hack done as a bet many years ago.  For many obvious
reasons it does not work well.

> host with cat /dev/ttyUSB0
> But if use minicom in host, it will not show '\r', I guess the usb debug
> cable eat return char. Greg, Can you add that back in usb_debug by
> replacing '\n' with '\r', '\n'?

The usb-serial console code should handle this, I thought we fixed it a
while ago.

But this kind of interface is not what these devices are good for.  They
are for the debug port information, not as a usb-serial console device.
Otherwise they are way too expensive of a device...

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 18+ messages in thread

* RE: [LinuxBIOS] [linux-usb-devel] [RFC][PATCH 0/2] x86_64 Early usb debug port support.
@ 2006-12-08  3:48 Lu, Yinghai
  2006-12-08  7:14 ` Greg KH
  2006-12-08  7:42 ` Eric W. Biederman
  0 siblings, 2 replies; 18+ messages in thread
From: Lu, Yinghai @ 2006-12-08  3:48 UTC (permalink / raw)
  To: Greg KH, ebiederm
  Cc: Peter Stuge, linux-usb-devel, Stefan Reinauer, linux-kernel,
	linuxbios, Andi Kleen, David Brownell

-----Original Message-----
From: linuxbios-bounces@linuxbios.org
[mailto:linuxbios-bounces@linuxbios.org] On Behalf Of
ebiederm@xmission.com


>Ok due to popular demands here is the slightly fixed patch that works
>on both i386 and x86_64.  For the i386 version you must not have
>HIGHMEM64G enabled. 

>I just rolled it all into one patch as I'm to lazy to transmit all
>3 of them.


I got

Firmware type: LinuxBIOS
Linux version 2.6.19-smp-gc9976797-dirty (root@lbsrv) (gcc version
4.0.2) #196 6
Command line: earlyprintk=ttyS0,115200 apic=debug pci=noacpi,routeirq
snd-hda-i
BIOS-provided physical RAM map:
 BIOS-e820: 0000000000000000 - 0000000000001000 (reserved)
 BIOS-e820: 0000000000001000 - 00000000000a0000 (usable)
 BIOS-e820: 00000000000c0000 - 00000000000f0000 (usable)
 BIOS-e820: 00000000000f0000 - 0000000000100000 (reserved)
 BIOS-e820: 0000000000100000 - 00000000c0000000 (usable)
 BIOS-e820: 0000000100000000 - 0000000240000000 (usable)
dbgp_num: 0
Found EHCI debug port
bar: 10 offset: 098
bar: 10 offset: 098
dbgp pre-set_fixmap_nocache
PANIC: early exception rip ffffffff809c24b4 error 0 cr2 ffff810000203ff8

Call Trace:
 [<ffffffff809c24b4>] __set_fixmap+0x84/0x202
 [<ffffffff809c05bb>] early_dbgp_init+0x259/0x55c
 [<ffffffff8022d958>] __call_console_drivers+0x64/0x72
 [<ffffffff809b242b>] do_early_param+0x0/0x57
 [<ffffffff809c0a20>] setup_early_printk+0x162/0x17e
 [<ffffffff809b2459>] do_early_param+0x2e/0x57
 [<ffffffff8023d051>] parse_args+0x159/0x1f3
 [<ffffffff809b24c2>] parse_early_param+0x40/0x4c
 [<ffffffff809b88ca>] setup_arch+0x1c1/0x636
 [<ffffffff809b2534>] start_kernel+0x55/0x208
 [<ffffffff809b2173>] _sinittext+0x173/0x177

RIP __set_fixmap+0x84/0x202

With Greg's USB Debug, host and target can talk.
target with console=ttyUSB0,115200n8
host with cat /dev/ttyUSB0
But if use minicom in host, it will not show '\r', I guess the usb debug
cable eat return char. Greg, Can you add that back in usb_debug by
replacing '\n' with '\r', '\n'?

With Eric code in LinuxBIOS, it will report "No device found in debug
port"

YH





^ permalink raw reply	[flat|nested] 18+ messages in thread

* RE: [LinuxBIOS] [linux-usb-devel] [RFC][PATCH 0/2] x86_64 Early usb debug port support.
@ 2006-12-07 22:06 Lu, Yinghai
  0 siblings, 0 replies; 18+ messages in thread
From: Lu, Yinghai @ 2006-12-07 22:06 UTC (permalink / raw)
  To: Peter Stuge, linuxbios
  Cc: David Brownell, linux-kernel, Greg KH, Andi Kleen, linux-usb-devel

Two side are identical if two side are connected.

YH



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [LinuxBIOS] [linux-usb-devel] [RFC][PATCH 0/2] x86_64 Early usb debug port support.
  2006-12-06 21:08 Lu, Yinghai
@ 2006-12-07  9:51 ` Peter Stuge
  0 siblings, 0 replies; 18+ messages in thread
From: Peter Stuge @ 2006-12-07  9:51 UTC (permalink / raw)
  To: linuxbios
  Cc: Andi Kleen, linux-usb-devel, Greg KH, linux-kernel, David Brownell

On Wed, Dec 06, 2006 at 01:08:14PM -0800, Lu, Yinghai wrote:
> -----Original Message-----
> From: Andi Kleen [mailto:ak@suse.de] 
> Sent: Wednesday, December 06, 2006 12:59 PM
> 
> >I haven't looked how the other usb_debug works -- if it's polled
> >too then it wouldn't have much advantage.
> 
> Need to verify if the two sides of debug cable are identical. 

I got my device yesterday and after a small plugfest I can confirm
that only one end of the device enumerates when connected to an ICH7
EHCI driven by 2.6.19.

--8<--
Bus 001 Device 027: ID 0525:127a Netchip Technology, Inc. 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass          255 Vendor Specific Class
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x0525 Netchip Technology, Inc.
  idProduct          0x127a 
  bcdDevice            1.01
  iManufacturer           1 NetChip
  iProduct                2 NetChip TurboCONNECT 2.0
  iSerial                 3 1
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           32
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xc0
      Self Powered
    MaxPower                0mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass          255 Vendor Specific Class
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  bNumConfigurations      1
Debug descriptor:
  bLength                 4
  bDescriptorType        10
  bDebugInEndpoint     0x82
  bDebugOutEndpoint    0x01
-->8--

The device is in fact not self-powered.

My theory is that the same set of descriptors are used for both ends,
but one end has been locked to address 127 in order to work with
simpler debug port drivers that assume it will be there.

I guess that the self-powered error is also to simplify life for
debug port drivers. IIRC most if not all USB power management
concerns are noops for debug ports.


//Peter

^ permalink raw reply	[flat|nested] 18+ messages in thread

* RE: [LinuxBIOS] [linux-usb-devel] [RFC][PATCH 0/2] x86_64 Early usb debug port support.
@ 2006-12-06  0:00 Lu, Yinghai
  0 siblings, 0 replies; 18+ messages in thread
From: Lu, Yinghai @ 2006-12-06  0:00 UTC (permalink / raw)
  To: ebiederm
  Cc: David Brownell, Peter Stuge, linux-usb-devel, Stefan Reinauer,
	Greg KH, linux-kernel, linuxbios, Andi Kleen



-----Original Message-----
From: ebiederm@xmission.com [mailto:ebiederm@xmission.com] 
Sent: Tuesday, December 05, 2006 3:50 PM


>If you will not reps is negative.  Roughly it is a loop
>that will timeout eventually if a usb debug cable is not present.
>Putting some deliberate delays in there so I could be certain
>of timing out after a second or two would probably be better, but
>I don't have anything that resembles a good timer at that point.

You have dbgp_mdelay in your code.

YH



^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2006-12-13 10:41 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-05 23:29 [LinuxBIOS] [linux-usb-devel] [RFC][PATCH 0/2] x86_64 Early usb debug port support Lu, Yinghai
2006-12-05 23:50 ` Eric W. Biederman
2006-12-06 15:31   ` Segher Boessenkool
2006-12-06  0:00 Lu, Yinghai
2006-12-06 21:08 Lu, Yinghai
2006-12-07  9:51 ` [LinuxBIOS] " Peter Stuge
2006-12-07 22:06 Lu, Yinghai
2006-12-08  3:48 Lu, Yinghai
2006-12-08  7:14 ` Greg KH
2006-12-08  8:52   ` Yinghai Lu
2006-12-08  7:42 ` Eric W. Biederman
2006-12-08  8:53   ` Yinghai Lu
2006-12-08  9:07     ` Eric W. Biederman
2006-12-13  7:00       ` Yinghai Lu
2006-12-13  7:29         ` Eric W. Biederman
2006-12-13 10:09           ` Yinghai Lu
2006-12-13 10:41             ` Yinghai Lu
2006-12-09  3:16 Lu, Yinghai
2006-12-09 10:54 ` Peter Stuge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).