Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1164312pxk; Thu, 10 Sep 2020 08:32:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6+5JceNfleyt3dOHXk6meq1ngiAip3s2jPtcAz4ZfDODMWf98H+APp56NeYzAx+FRv2px X-Received: by 2002:aa7:c693:: with SMTP id n19mr10199289edq.101.1599751922670; Thu, 10 Sep 2020 08:32:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599751922; cv=none; d=google.com; s=arc-20160816; b=1DKvJ0C+oC2LOdE0W1wL+wwvO9Ooas0qzNyRbD0TaREdp4P1YvbT9vtcfxZLkfPo71 wKC0Ho8eXFzw/OSNnRuKIipkk0fAOFuQhzoZdXVMPFfVbITV4YDm+BSxXZdUvlqJJGO9 lFBy+NcqoiPkkIENDnL5dYZU0mztTPGl+rWrvrfrj/iLpLCueaAKFMgRtbgv2LfDRqA5 o70KvN92N6IufA9PiW5l1Prl5L4xdYzjGUDO3SZJZvslxYu+6vHxzmJGV+6Lz8f6He3U 3Rn8Oz2lZn58TdBMNayIEDf/lPvz0D2Oqw26vfF8JG/3slP92G96SNJZkGrPP5Ge13Vm Z1gQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=A7k4G6dBY3dLd94sfJWr4umbsJPxJYI/SU4uvW8esJY=; b=i4mYnSNKevbmhuYPA0MZiWVNw2ANlcUgqPkTOrPGLt4WTYJo2YNu6Ao9sb4uU2VLAg N5QPgSuexVU29BQw5PEdN7KF27a5pIvY2aLzaB3fbEDDZbNft3ITJGOkAJB8VMWig0ig aLPYpZMHdDYhJZ3LzS2vlgoqT3VRE3OZ/091BgrCAiD9cjVfoDLmb2as8WFCRoIvPRxx CYEvnpt8s+Szuk7EHbxFzTrniXfKmS8ugGRV37vwUTn0tf6CBQgWZ0jnj811hwfWYzz8 RhzOe3tssN/jRuGo+kcbZZMZuKty8KVe+VI0Jb7u8q5UBocUp6lZo5hrQ6uauutEn1ox b/6Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id do18si3935729ejc.13.2020.09.10.08.31.38; Thu, 10 Sep 2020 08:32:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731294AbgIJPaG (ORCPT + 99 others); Thu, 10 Sep 2020 11:30:06 -0400 Received: from netrider.rowland.org ([192.131.102.5]:34871 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1731243AbgIJP2G (ORCPT ); Thu, 10 Sep 2020 11:28:06 -0400 Received: (qmail 851550 invoked by uid 1000); 10 Sep 2020 11:27:34 -0400 Date: Thu, 10 Sep 2020 11:27:34 -0400 From: Alan Stern To: Chris Packham Cc: linux@prisktech.co.nz, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] usb: host: ehci-platform: Add workaround for brcm,xgs-iproc-ehci Message-ID: <20200910152734.GB849569@rowland.harvard.edu> References: <20200910025154.20848-1-chris.packham@alliedtelesis.co.nz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200910025154.20848-1-chris.packham@alliedtelesis.co.nz> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > > 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 >