[U-Boot] [patch 0/1] fix hangup during boot when USB is used.

A recent commit (936897d4d1365452bbbdf8430db5e7769ef08d38) enabled the usb_stop() command in common/cmd_bootm.c which was not enabled for some time, because no board did actually set the CFG_CMD_USB flag. So, now the usb_stop() is executed before loading the linux kernel, which will result in a hangup during boot when USB has been started and stopped already (on AT91SAM).

A recent commit (936897d4d1365452bbbdf8430db5e7769ef08d38) enabled the usb_stop() command in common/cmd_bootm.c which was not enabled for some time, because no board did actually set the CFG_CMD_USB flag. So, now the usb_stop() is executed before loading the linux kernel.
However, the usb_ohci driver hangs up (at least on AT91SAM) if the driver is stopped twice (e.g. the peripheral clock is stopped on AT91). If some other piece of code calls usb_stop() before the bootm command, this command will hangup the system during boot. (usb start and stop is typically used while booting from usb memory stick)
But, stopping the usb stack twice is useless anyway, and a flag already existed that kept track on the usb_init()/usb_stop() calls. So, we now check if the usb stack is really started before we stop it.
This problem is now fixed in both the upper as low-level layer.
Signed-off-by: Remy Bohmer linux@bohmer.net --- common/usb.c | 13 +++++++++---- drivers/usb/usb_ohci.c | 4 +++- 2 files changed, 12 insertions(+), 5 deletions(-)
Index: u-boot-1.3.4/common/usb.c =================================================================== --- u-boot-1.3.4.orig/common/usb.c 2008-07-21 11:53:22.000000000 +0200 +++ u-boot-1.3.4/common/usb.c 2008-08-19 20:53:44.000000000 +0200 @@ -128,10 +128,15 @@ int usb_init(void) */ int usb_stop(void) { - asynch_allowed=1; - usb_started = 0; - usb_hub_reset(); - return usb_lowlevel_stop(); + int res = 0; + + if (usb_started) { + asynch_allowed = 1; + usb_started = 0; + usb_hub_reset(); + res = usb_lowlevel_stop(); + } + return res; }
/* Index: u-boot-1.3.4/drivers/usb/usb_ohci.c =================================================================== --- u-boot-1.3.4.orig/drivers/usb/usb_ohci.c 2008-07-21 11:53:23.000000000 +0200 +++ u-boot-1.3.4/drivers/usb/usb_ohci.c 2008-08-19 21:15:31.000000000 +0200 @@ -1907,7 +1907,9 @@ int usb_lowlevel_stop(void) if(usb_cpu_stop()) return -1; #endif - + /* This driver is no longer initialised. It needs a new low-level + * init (board/cpu) before it can be used again. */ + ohci_inited = 0; return 0; } #endif /* CONFIG_USB_OHCI_NEW */

On Wed, Aug 20, 2008 at 11:22:02AM +0200, Remy Bohmer wrote:
A recent commit (936897d4d1365452bbbdf8430db5e7769ef08d38) enabled the usb_stop() command in common/cmd_bootm.c which was not enabled for some time, because no board did actually set the CFG_CMD_USB flag. So, now the usb_stop() is executed before loading the linux kernel.
However, the usb_ohci driver hangs up (at least on AT91SAM) if the driver is stopped twice (e.g. the peripheral clock is stopped on AT91). If some other piece of code calls usb_stop() before the bootm command, this command will hangup the system during boot. (usb start and stop is typically used while booting from usb memory stick)
But, stopping the usb stack twice is useless anyway, and a flag already existed that kept track on the usb_init()/usb_stop() calls. So, we now check if the usb stack is really started before we stop it.
This problem is now fixed in both the upper as low-level layer.
Signed-off-by: Remy Bohmer linux@bohmer.net
Acked-by: Markus Klotzbuecher mk@denx.de
Wolfgang, please apply!
Best regards
Markus

Dear Markus =?iso-8859-1?Q?Klotzb=FCcher?=,
In message 20080909143500.GA11987@lisa you wrote:
This problem is now fixed in both the upper as low-level layer.
Signed-off-by: Remy Bohmer linux@bohmer.net
Acked-by: Markus Klotzbuecher mk@denx.de
Wolfgang, please apply!
Done. Thanks!
Best regards,
Wolfgang Denk

Dear Remy Bohmer,
In message 20080820092551.478336687@bohmer.net> you wrote:
A recent commit (936897d4d1365452bbbdf8430db5e7769ef08d38) enabled the usb_stop() command in common/cmd_bootm.c which was not enabled for some time, because no board did actually set the CFG_CMD_USB flag. So, now the usb_stop() is executed before loading the linux kernel.
However, the usb_ohci driver hangs up (at least on AT91SAM) if the driver is stopped twice (e.g. the peripheral clock is stopped on AT91). If some other piece of code calls usb_stop() before the bootm command, this command will hangup the system during boot. (usb start and stop is typically used while booting from usb memory stick)
But, stopping the usb stack twice is useless anyway, and a flag already existed that kept track on the usb_init()/usb_stop() calls. So, we now check if the usb stack is really started before we stop it.
This problem is now fixed in both the upper as low-level layer.
Signed-off-by: Remy Bohmer linux@bohmer.net
common/usb.c | 13 +++++++++---- drivers/usb/usb_ohci.c | 4 +++- 2 files changed, 12 insertions(+), 5 deletions(-)
Aplied, thanks.
Best regards,
Wolfgang Denk
participants (3)
-
Markus Klotzbücher
-
Remy Bohmer
-
Wolfgang Denk