Re: [Linux-usb-users] OHCI root_port_reset() deadly loop...

David Brownell <[email protected]> Tue, 09 Oct 2007 11:59:57 -0700
Newsgroups gmane.linux.kernel,gmane.linux.usb.user
Message-ID <20071009185957.94150236A37@adsl-69-226-248-13.dsl.pltn13.pacbell.net>
> Here is a proposed patch.  I haven't tried running it, but it compiles 
> okay.

Looks about right, too; thanks.  Minor comments:

> --- usb-2.6.orig/drivers/usb/core/hcd.h
> +++ usb-2.6/drivers/usb/core/hcd.h
> @@ -470,5 +472,9 @@ static inline void usbmon_urb_complete(s
>  		: (in_interrupt () ? "in_interrupt" : "can sleep"))
>  
>  
> -#endif /* __KERNEL__ */
> +/* Mutual exclusion for EHCI CF initialization.  This interferes with
> + * port reset on some companion controllers.
> + */
> +extern struct rw_semaphore ehci_cf_port_reset_rwsem;

You have two copies of that comment; I'd drop this one, and add a
better one around CF initialization.

What I'd have here is a comment that this symbol is exported ONLY
for use by the EHCI driver, trespassers will be violated, etc.


> --- usb-2.6.orig/drivers/usb/host/ehci-hcd.c
> +++ usb-2.6/drivers/usb/host/ehci-hcd.c
> @@ -646,9 +646,11 @@ static int ehci_run (struct usb_hcd *hcd
>  	 * involved with the root hub.  (Except where one is integrated,
>  	 * and there's no companion controller unless maybe for USB OTG.)
>  	 */
> +	down_write(&ehci_cf_port_reset_rwsem);
>  	hcd->state = HC_STATE_RUNNING;
>  	ehci_writel(ehci, FLAG_CF, &ehci->regs->configured_flag);
>  	ehci_readl(ehci, &ehci->regs->command);	/* unblock posted writes */
> +	up_write(&ehci_cf_port_reset_rwsem);

That deserves a comment about how CF and companion port resets
don't mix well.

... assuming this does check out as the problem, which I expect
it will.

- Dave

>  
>  	temp = HC_VERSION(ehci_readl(ehci, &ehci->caps->hc_capbase));
>  	ehci_info (ehci,
>