Question: issues for usb keyboard work with OHCI HCD
Subsystems (2)
Hi All,
Now, I test usb host support with Atmel boards, for example,
at91sam9x5ek board.
When test OHCI USB host with usb keyboard. I meet the following issue.
--->8---
U-Boot 2013.04-dirty (May 03 2013 - 11:00:34)
CPU: AT91SAM9G35 Crystal frequency: 12 MHz CPU clock : 400 MHz Master clock : 133.333 MHz DRAM: 128 MiB WARNING: Caches not enabled NAND: 256 MiB MMC: mci: 0 In: serial Out: serial Err: serial Net: macb0 Hit any key to stop autoboot: 0
U-Boot> usb start
(Re)start USB...
USB0: scanning bus 0 for devices... 2 USB Device(s) found
scanning usb for storage devices... 0 Storage Device(s) found
U-Boot> setenv stdin usbkbd
U-Boot> ERROR: sohci_submit_job: ENOMEM
ERROR: sohci_submit_job failed
... ...
(repeat to print these two error line)
---<8---
After dig the usb ohci-hcd.c driver, I found every time it callsubmit_int_msg -->submit_common_msg --> sohci_submit_job, it will allocate memory for td (just call td_alloc),
however nowhere free the td. So, after allocate 64 times (#define NUM_TD 64),
all the ptd[i].usb_dev is not NULL. So, it will report: ENOMEM.
I don't know why in sohci_return_job it call td_submit_job again?
--->8---
static inline int sohci_return_job(struct ohci *hc, urb_priv_t *urb)
{
struct ohci_regs *regs = hc->regs;
switch (usb_pipetype(urb->pipe)) {
case PIPE_INTERRUPT:
/* implicitly requeued */
if (urb->dev->irq_handle &&
(urb->dev->irq_act_len = urb->actual_length)) {
ohci_writel(OHCI_INTR_WDH, ®s->intrenable);
ohci_readl(®s->intrenable); /* PCI posting flush */
urb->dev->irq_handle(urb->dev);
ohci_writel(OHCI_INTR_WDH, ®s->intrdisable);
ohci_readl(®s->intrdisable); /* PCI posting flush */
}
urb->actual_length = 0;
td_submit_job(
urb->dev,
urb->pipe,
urb->transfer_buffer,
urb->transfer_buffer_length,
NULL,
urb,
urb->interval);
break---<8---
Add where should we free the allocated td to fix the issue?
Thanks.
Best Regards,
Bo Shen
Dear Bo Shen,
Quoted 21 lines
Hi All,
Now, I test usb host support with Atmel boards, for example,
at91sam9x5ek board.When test OHCI USB host with usb keyboard. I meet the following issue.
--->8---
U-Boot 2013.04-dirty (May 03 2013 - 11:00:34)CPU: AT91SAM9G35 Crystal frequency: 12 MHz CPU clock : 400 MHz Master clock : 133.333 MHz DRAM: 128 MiB WARNING: Caches not enabled NAND: 256 MiB MMC: mci: 0 In: serial Out: serial Err: serial Net: macb0 Hit any key to stop autoboot: 0
Quoted 9 lines
U-Boot> usb start
(Re)start USB...
USB0: scanning bus 0 for devices... 2 USB Device(s) found
scanning usb for storage devices... 0 Storage Device(s) found
U-Boot> setenv stdin usbkbd
U-Boot> ERROR:sohci_submit_job: ENOMEM
ERROR:sohci_submit_jobfailed
... ...
(repeat to print these two error line)
So the USB subsystem is leaking memory? Or do you only have too small MALLOC area?
Quoted 37 lines
---<8---
After dig the usb
ohci-hcd.cdriver, I found every time it callsubmit_int_msg-->submit_common_msg-->sohci_submit_job, it will allocate memory for td (just calltd_alloc),
however nowhere free the td. So, after allocate 64 times (#defineNUM_TD64),
all the ptd[i].usb_dev is not NULL. So, it will report: ENOMEM.I don't know why in
sohci_return_jobit calltd_submit_jobagain?
--->8---
static inline intsohci_return_job(struct ohci *hc, urb_priv_t *urb){ struct ohci_regs *regs = hc->regs; switch (usb_pipetype(urb->pipe)) { case PIPE_INTERRUPT: /* implicitly requeued */ if (urb->dev->irq_handle && (urb->dev->irq_act_len = urb->actual_length)) { ohci_writel(OHCI_INTR_WDH, ®s->intrenable); ohci_readl(®s->intrenable); /* PCI posting flush */ urb->dev->irq_handle(urb->dev); ohci_writel(OHCI_INTR_WDH, ®s->intrdisable); ohci_readl(®s->intrdisable); /* PCI posting flush */ } urb->actual_length = 0; td_submit_job( urb->dev, urb->pipe, urb->transfer_buffer, urb->transfer_buffer_length, NULL, urb, urb->interval); break
Quoted 8 lines
---<8---
Add where should we free the allocated td to fix the issue?
Thanks.
Best Regards,
Bo Shen
Best regards,
Marek Vasut
Hi Marek,
Quoted 33 lines · Marek Vasut
Dear Bo Shen,
Quoted 21 lines
Hi All,
Now, I test usb host support with Atmel boards, for example,
at91sam9x5ek board.When test OHCI USB host with usb keyboard. I meet the following issue.
--->8---
U-Boot 2013.04-dirty (May 03 2013 - 11:00:34)CPU: AT91SAM9G35 Crystal frequency: 12 MHz CPU clock : 400 MHz Master clock : 133.333 MHz DRAM: 128 MiB WARNING: Caches not enabled NAND: 256 MiB MMC: mci: 0 In: serial Out: serial Err: serial Net: macb0 Hit any key to stop autoboot: 0Quoted 9 lines
U-Boot> usb start
(Re)start USB...
USB0: scanning bus 0 for devices... 2 USB Device(s) found
scanning usb for storage devices... 0 Storage Device(s) found
U-Boot> setenv stdin usbkbd
U-Boot> ERROR:sohci_submit_job: ENOMEM
ERROR:sohci_submit_jobfailed
... ...
(repeat to print these two error line)
Quoted 2 lines
So the USB subsystem is leaking memory? Or do you only have too small MALLOC area?
I am not sure whether USB subsystem is leaking memory. I am digging it.
This issue is not relative with MALLOC area.
This issue come out when all ptd[i].usb_dev (the maximum value of i is
64) is not NULL. Each time to call td_alloc, it will check whether ptd[i].usb_dev is NULL (i from 0 to 63), if not find one of ptd[i].usb_dev is NULL, then report ENOMEM.
Quoted 11 lines
Quoted 11 lines
---<8---
After dig the usb
ohci-hcd.cdriver, I found every time it callsubmit_int_msg-->submit_common_msg-->sohci_submit_job, it will allocate memory for td (just calltd_alloc),
however nowhere free the td. So, after allocate 64 times (#defineNUM_TD64),
all the ptd[i].usb_dev is not NULL. So, it will report: ENOMEM.I don't know why in
sohci_return_jobit calltd_submit_jobagain?
Any advice for this question?
Quoted 20 lines
Quoted 20 lines
--->8---
static inline intsohci_return_job(struct ohci *hc, urb_priv_t *urb){ struct ohci_regs *regs = hc->regs; switch (usb_pipetype(urb->pipe)) { case PIPE_INTERRUPT: /* implicitly requeued */ if (urb->dev->irq_handle && (urb->dev->irq_act_len = urb->actual_length)) { ohci_writel(OHCI_INTR_WDH, ®s->intrenable); ohci_readl(®s->intrenable); /* PCI posting flush */ urb->dev->irq_handle(urb->dev); ohci_writel(OHCI_INTR_WDH, ®s->intrdisable); ohci_readl(®s->intrdisable); /* PCI posting flush */ } urb->actual_length = 0; td_submit_job( urb->dev, urb->pipe,
Quoted 8 lines
Quoted 8 lines
urb->transfer_buffer, urb->transfer_buffer_length, NULL, urb, urb->interval); break---<8---
Add where should we free the allocated td to fix the issue?
If I comment the td_submit_job and add urb_free_priv(urb) here, then usb keyboard work properly. It looks like
--->8---
drivers/usb/host/ohci-hcd.c +0 -0
@@ -516,6 +516,7 @@ static inline int sohci_return_job(struct ohci *hc,
urb_priv_t *urb)
ohci_readl(®s->intrdisable); /* PCI posting
flush */
}
urb->actual_length = 0;
+#if 0
td_submit_job(
urb->dev,
urb->pipe,
@@ -524,6 +525,8 @@ static inline int sohci_return_job(struct ohci *hc,
urb_priv_t *urb)
NULL,
urb,
urb->interval);+#endif
+ urb_free_priv(urb);
---<8---
Quoted 8 lines
Quoted 4 lines
Thanks.
Best Regards,
Bo ShenBest regards,
Marek Vasut
Best Regards,
Bo Shen
Hi All,
Quoted 41 lines · Bo Shen
Hi Marek,
Quoted 34 lines · Marek Vasut
Dear Bo Shen,
Quoted 22 lines
Hi All,
Now, I test usb host support with Atmel boards, for example,
at91sam9x5ek board.When test OHCI USB host with usb keyboard. I meet the following
issue.
--->8---
U-Boot 2013.04-dirty (May 03 2013 - 11:00:34)CPU: AT91SAM9G35 Crystal frequency: 12 MHz CPU clock : 400 MHz Master clock : 133.333 MHz DRAM: 128 MiB WARNING: Caches not enabled NAND: 256 MiB MMC: mci: 0 In: serial Out: serial Err: serial Net: macb0 Hit any key to stop autoboot: 0Quoted 9 lines
U-Boot> usb start
(Re)start USB...
USB0: scanning bus 0 for devices... 2 USB Device(s) found
scanning usb for storage devices... 0 Storage Device(s) found
U-Boot> setenv stdin usbkbd
U-Boot> ERROR:sohci_submit_job: ENOMEM
ERROR:sohci_submit_jobfailed
... ...
(repeat to print these two error line)Quoted 3 lines
So the USB subsystem is leaking memory? Or do you only have too small MALLOC
area?
Quoted 7 lines
I am not sure whether USB subsystem is leaking memory. I am digging it.
This issue is not relative with MALLOC area.
This issue come out when all ptd[i].usb_dev (the maximum value of i is
64) is not NULL. Each time to calltd_alloc, it will check whether ptd[i].usb_dev is NULL (i from 0 to 63), if not find one of ptd[i].usb_dev is NULL, then report ENOMEM.
All clue for this issue?
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
---<8---
After dig the usb
ohci-hcd.cdriver, I found every time it callsubmit_int_msg-->submit_common_msg-->sohci_submit_job, it will allocate memory for td (just calltd_alloc),
however nowhere free the td. So, after allocate 64 times (#defineNUM_TD64),
all the ptd[i].usb_dev is not NULL. So, it will report: ENOMEM.
Quoted 3 lines
Quoted 1 line
Quoted 1 line
I don't know why in
sohci_return_jobit calltd_submit_jobagain?Any advice for this question?
Any clue for this question?
Quoted 48 lines
Quoted 20 lines
Quoted 20 lines
--->8---
static inline intsohci_return_job(struct ohci *hc, urb_priv_t *urb){ struct ohci_regs *regs = hc->regs; switch (usb_pipetype(urb->pipe)) { case PIPE_INTERRUPT: /* implicitly requeued */ if (urb->dev->irq_handle && (urb->dev->irq_act_len = urb->actual_length)) { ohci_writel(OHCI_INTR_WDH, ®s->intrenable); ohci_readl(®s->intrenable); /* PCI posting flush */ urb->dev->irq_handle(urb->dev); ohci_writel(OHCI_INTR_WDH, ®s->intrdisable); ohci_readl(®s->intrdisable); /* PCI posting flush */ } urb->actual_length = 0; td_submit_job( urb->dev, urb->pipe,Quoted 8 lines
Quoted 8 lines
urb->transfer_buffer, urb->transfer_buffer_length, NULL, urb, urb->interval); break---<8---
Add where should we free the allocated td to fix the issue?If I comment the
td_submit_joband addurb_free_priv(urb)here, then usb keyboard work properly. It looks like--->8---
drivers/usb/host/ohci-hcd.c +0
-0@@ -516,6 +516,7 @@ static inline int sohci_return_job(struct ohci *hc, urb_priv_t *urb) ohci_readl(®s->intrdisable); /* PCI postingflush */
} urb->actual_length = 0;drivers/usb/host/ohci-hcd.c +1
-0+#if 0 td_submit_job( urb->dev, urb->pipe,
drivers/usb/host/ohci-hcd.c static inline int sohci_return_job(struct ohci *hc, · line 531
Quoted 8 lines
drivers/usb/host/ohci-hcd.c +2
-1@@ -524,6 +525,8 @@ static inline int sohci_return_job(struct ohci *hc, urb_priv_t *urb)NULL , urb, urb->interval); +#endif +urb_free_priv (urb); ---<8---
After digging more about the USB HCD driver, I don't find any better solution for this issue, except this one.
So, may I submit this as an RFC patch?
Best Regards,
Bo Shen
Dear Bo Shen,
Quoted 51 lines
Hi All,
Quoted 48 lines · Bo Shen
Hi Marek,
Quoted 39 lines · Marek Vasut
Dear Bo Shen,
Quoted 29 lines
Hi All,
Now, I test usb host support with Atmel boards, for example,
at91sam9x5ek board.
When test OHCI USB host with usb keyboard. I meet the following
issue.
--->8---
U-Boot 2013.04-dirty (May 03 2013 - 11:00:34)CPU: AT91SAM9G35 Crystal frequency: 12 MHz CPU clock : 400 MHz Master clock : 133.333 MHz DRAM: 128 MiB WARNING: Caches not enabled NAND: 256 MiB MMC: mci: 0 In: serial Out: serial Err: serial Net: macb0 Hit any key to stop autoboot: 0U-Boot> usb start
(Re)start USB...
USB0: scanning bus 0 for devices... 2 USB Device(s) foundQuoted 7 lines
scanning usb for storage devices... 0 Storage Device(s) found
U-Boot> setenv stdin usbkbd
U-Boot> ERROR:sohci_submit_job: ENOMEM
ERROR:sohci_submit_jobfailed
... ...
(repeat to print these two error line)Quoted 3 lines
So the USB subsystem is leaking memory? Or do you only have too small MALLOC
area?I am not sure whether USB subsystem is leaking memory. I am digging it.
Quoted 7 lines
Quoted 5 lines
This issue is not relative with MALLOC area.
This issue come out when all ptd[i].usb_dev (the maximum value of i is
64) is not NULL. Each time to calltd_alloc, it will check whether ptd[i].usb_dev is NULL (i from 0 to 63), if not find one of ptd[i].usb_dev is NULL, then report ENOMEM.All clue for this issue?
I assume you mean the TDs are all used up then? Are they not free'd ?
Best regards,
Marek Vasut
Hi Marek,
Quoted 59 lines · Marek Vasut
Dear Bo Shen,
Quoted 57 lines
Hi All,
Quoted 53 lines · Bo Shen
Hi Marek,
Quoted 39 lines · Marek Vasut
Dear Bo Shen,
Quoted 29 lines
Hi All,
Now, I test usb host support with Atmel boards, for example,
at91sam9x5ek board.
When test OHCI USB host with usb keyboard. I meet the following
issue.
--->8---
U-Boot 2013.04-dirty (May 03 2013 - 11:00:34)CPU: AT91SAM9G35 Crystal frequency: 12 MHz CPU clock : 400 MHz Master clock : 133.333 MHz DRAM: 128 MiB WARNING: Caches not enabled NAND: 256 MiB MMC: mci: 0 In: serial Out: serial Err: serial Net: macb0 Hit any key to stop autoboot: 0U-Boot> usb start
(Re)start USB...
USB0: scanning bus 0 for devices... 2 USB Device(s) foundQuoted 7 lines
scanning usb for storage devices... 0 Storage Device(s) found
U-Boot> setenv stdin usbkbd
U-Boot> ERROR:sohci_submit_job: ENOMEM
ERROR:sohci_submit_jobfailed
... ...
(repeat to print these two error line)Quoted 3 lines
So the USB subsystem is leaking memory? Or do you only have too small MALLOC
area?I am not sure whether USB subsystem is leaking memory. I am digging it.
This issue is not relative with MALLOC area.
This issue come out when all ptd[i].usb_dev (the maximum value of i is
64) is not NULL. Each time to calltd_alloc, it will check whether ptd[i].usb_dev is NULL (i from 0 to 63), if not find one of ptd[i].usb_dev is NULL, then report ENOMEM.
Quoted 3 lines
Quoted 1 line
All clue for this issue?
I assume you mean the TDs are all used up then? Are they not free'd ?
Yes, that's true, all TDs are used. Nowhere free them, so I use urb_free_priv() to free urb in sohci_return_job() instead of td_submit_job(), then it works well.
Quoted 2 lines
Best regards,
Marek Vasut
Best Regards,
Bo Shen
Dear Bo Shen,
Quoted 63 lines
Hi Marek,
Quoted 60 lines · Marek Vasut
Dear Bo Shen,
Quoted 58 lines
Hi All,
Quoted 54 lines · Bo Shen
Hi Marek,
Quoted 40 lines · Marek Vasut
Dear Bo Shen,
Quoted 29 lines
Hi All,
Now, I test usb host support with Atmel boards, for example,
at91sam9x5ek board.
When test OHCI USB host with usb keyboard. I meet the following
issue.
--->8---
U-Boot 2013.04-dirty (May 03 2013 - 11:00:34)CPU: AT91SAM9G35 Crystal frequency: 12 MHz CPU clock : 400 MHz Master clock : 133.333 MHz DRAM: 128 MiB WARNING: Caches not enabled NAND: 256 MiB MMC: mci: 0 In: serial Out: serial Err: serial Net: macb0 Hit any key to stop autoboot: 0U-Boot> usb start
(Re)start USB...
USB0: scanning bus 0 for devices... 2 USB Device(s) foundQuoted 8 lines
scanning usb for storage devices... 0 Storage Device(s) found
U-Boot> setenv stdin usbkbd
U-Boot> ERROR:sohci_submit_job: ENOMEM
ERROR:sohci_submit_jobfailed
... ...
(repeat to print these two error line)Quoted 3 lines
So the USB subsystem is leaking memory? Or do you only have too small MALLOC
area?I am not sure whether USB subsystem is leaking memory. I am digging it.
This issue is not relative with MALLOC area.
This issue come out when all ptd[i].usb_dev (the maximum value of i is
64) is not NULL. Each time to calltd_alloc, it will check whether ptd[i].usb_dev is NULL (i from 0 to 63), if not find one of ptd[i].usb_dev is NULL, then report ENOMEM.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
All clue for this issue?
I assume you mean the TDs are all used up then? Are they not free'd ?
Yes, that's true, all TDs are used. Nowhere free them, so I use
urb_free_priv()to free urb insohci_return_job()instead oftd_submit_job(), then it works well.
Benoit, you were the last one to plumb in it, right?
Best regards,
Marek Vasut
Hi Marek,
Quoted 67 lines · Marek Vasut
Dear Bo Shen,
Quoted 65 lines
Hi Marek,
Quoted 62 lines · Marek Vasut
Dear Bo Shen,
Quoted 59 lines
Hi All,
Quoted 47 lines · Bo Shen
Hi Marek,
Quoted 40 lines · Marek Vasut
Dear Bo Shen,
Quoted 29 lines
Hi All,
Now, I test usb host support with Atmel boards, for example,
at91sam9x5ek board.
When test OHCI USB host with usb keyboard. I meet the following
issue.
--->8---
U-Boot 2013.04-dirty (May 03 2013 - 11:00:34)CPU: AT91SAM9G35 Crystal frequency: 12 MHz CPU clock : 400 MHz Master clock : 133.333 MHz DRAM: 128 MiB WARNING: Caches not enabled NAND: 256 MiB MMC: mci: 0 In: serial Out: serial Err: serial Net: macb0 Hit any key to stop autoboot: 0U-Boot> usb start
(Re)start USB...
USB0: scanning bus 0 for devices... 2 USB Device(s) foundQuoted 8 lines
scanning usb for storage devices... 0 Storage Device(s) found
U-Boot> setenv stdin usbkbd
U-Boot> ERROR:sohci_submit_job: ENOMEM
ERROR:sohci_submit_jobfailed
... ...
(repeat to print these two error line)Quoted 3 lines
So the USB subsystem is leaking memory? Or do you only have too small MALLOC
area?Quoted 7 lines
I am not sure whether USB subsystem is leaking memory. I am digging it.
This issue is not relative with MALLOC area.
This issue come out when all ptd[i].usb_dev (the maximum value of i is
64) is not NULL. Each time to calltd_alloc, it will check whether ptd[i].usb_dev is NULL (i from 0 to 63), if not find one of ptd[i].usb_dev is NULL, then report ENOMEM.All clue for this issue?
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
I assume you mean the TDs are all used up then? Are they not free'd ?
Yes, that's true, all TDs are used. Nowhere free them, so I use
urb_free_priv()to free urb insohci_return_job()instead oftd_submit_job(), then it works well.Benoit, you were the last one to plumb in it, right?
No. That was for EHCI, not OHCI.
Best regards,
Beno?t
Dear Beno?t Th?baudeau,
Quoted 74 lines
Hi Marek,
Quoted 71 lines · Marek Vasut
Dear Bo Shen,
Quoted 69 lines
Hi Marek,
Quoted 65 lines · Marek Vasut
Dear Bo Shen,
Quoted 54 lines
Hi All,
Quoted 51 lines · Bo Shen
Hi Marek,
Quoted 41 lines · Marek Vasut
Dear Bo Shen,
Quoted 30 lines
Hi All,
Now, I test usb host support with Atmel boards, for example,
at91sam9x5ek board.
When test OHCI USB host with usb keyboard. I meet the following
issue.
--->8---
U-Boot 2013.04-dirty (May 03 2013 - 11:00:34)CPU: AT91SAM9G35 Crystal frequency: 12 MHz CPU clock : 400 MHz Master clock : 133.333 MHz DRAM: 128 MiB WARNING: Caches not enabled NAND: 256 MiB MMC: mci: 0 In: serial Out: serial Err: serial Net: macb0 Hit any key to stop autoboot: 0U-Boot> usb start
(Re)start USB...
USB0: scanning bus 0 for devices... 2 USB Device(s) foundQuoted 8 lines
scanning usb for storage devices... 0 Storage Device(s) found
U-Boot> setenv stdin usbkbd
U-Boot> ERROR:sohci_submit_job: ENOMEM
ERROR:sohci_submit_jobfailed
... ...
(repeat to print these two error line)Quoted 3 lines
So the USB subsystem is leaking memory? Or do you only have too small MALLOC
area?I am not sure whether USB subsystem is leaking memory. I am digging it.
Quoted 7 lines
Quoted 5 lines
This issue is not relative with MALLOC area.
This issue come out when all ptd[i].usb_dev (the maximum value of i is 64) is not NULL. Each time to calltd_alloc, it will check whether ptd[i].usb_dev is NULL (i from 0 to 63), if not find one of ptd[i].usb_dev is NULL, then report ENOMEM.All clue for this issue?
I assume you mean the TDs are all used up then? Are they not free'd ?
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Yes, that's true, all TDs are used. Nowhere free them, so I use
urb_free_priv()to free urb insohci_return_job()instead oftd_submit_job(), then it works well.Benoit, you were the last one to plumb in it, right?
No. That was for EHCI, not OHCI.
Hmmm ... I don't have any OHCI device. Bo, maybe you can try tracing it and fixing it?
Best regards,
Marek Vasut