[PATCH] usb: host: ehci-platform: Add workaround for brcm,xgs-iproc-ehci

Alan Stern stern at rowland.harvard.edu
Thu Sep 10 11:27:34 EDT 2020


On Thu, Sep 10, 2020 at 02:51:53PM +1200, Chris Packham wrote:
> The ehci controller found in some Broadcom switches with integrated SoCs
> has an issue which causes a soft lockup with large transfers like you
> see when running ext4 on USB3 flash drive.
> 
> Port the fix from the Broadcom XLDK to increase the OUT_THRESHOLD to
> avoid the problem.
> 
> Signed-off-by: Chris Packham <chris.packham at alliedtelesis.co.nz>
> ---
> 
> I don't have much data on what this change does. I can say it is needed to
> avoid a soft lockup when using a USB3 Flash drive formatted has ext4 (USB2 +
> ext4 is OK, USB3 + fat is OK). I presume the affected combination ends up using
> larger transfers triggering the problem.
> 
> The equivalent change in the Broadcom XLDK is
> 
> 	if (IS_ENABLED(CONFIG_USB_EHCI_XGS_IPROC))
> 		ehci_writel(ehci, BCM_USB_FIFO_THRESHOLD,
> 				&ehci->regs->reserved4[6]);
> 
> This is problematic because it would unconditionally apply to all ehci
> controllers whenever CONFIG_USB_EHCI_XGS_IPROC is enabled (also reserved4 only
> goes to 6 so technically it's indexing off the end of the array).
> 
> I wasn't sure if I should add a new property or somehow detect the affected
> host controller. I settled on using of_device_is_compatible() as that seemed
> the simplest thing to do.

Reasonable.

>  drivers/usb/host/ehci-platform.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c
> index 006c4f6188a5..0d2de8faa3c1 100644
> --- a/drivers/usb/host/ehci-platform.c
> +++ b/drivers/usb/host/ehci-platform.c
> @@ -53,6 +53,9 @@ struct ehci_platform_priv {
>  
>  static const char hcd_name[] = "ehci-platform";
>  
> +#define bcm_iproc_insnreg01	hostpc
> +#define BCM_USB_FIFO_THRESHOLD	0x00800040

Minor nit: Since hostpc is nominally an array, IMO it would be a little 
clearer to define bcm_iproc_insnreg01 as hostpc[0] and then do the 
ehci_writel to &ehci->regs->bcm_iproc_insnreg01.  That makes it look 
more like an ordinary structure member.

Also IMO, it's better to put the #define's before the structure 
definitions.

> +
>  static int ehci_platform_reset(struct usb_hcd *hcd)
>  {
>  	struct platform_device *pdev = to_platform_device(hcd->self.controller);
> @@ -358,6 +361,9 @@ static int ehci_platform_probe(struct platform_device *dev)
>  
>  	device_wakeup_enable(hcd->self.controller);
>  	device_enable_async_suspend(hcd->self.controller);
> +	if (of_device_is_compatible(dev->dev.of_node, "brcm,xgs-iproc-ehci"))
> +		ehci_writel(ehci, BCM_USB_FIFO_THRESHOLD,
> +			    ehci->regs->bcm_iproc_insnreg01);

In theory, this should go before the usb_add_hcd() call because 
afterward the controller is active.  But you can't put it before 
ehci->regs has been assigned, which happens in ehci_setup().  Probably 
the best place is at the end of ehci_platform_reset().

Alan Stern

>  	platform_set_drvdata(dev, hcd);
>  
>  	if (priv->quirk_poll)
> -- 
> 2.28.0
> 



More information about the linux-arm-kernel mailing list