From patchwork Sun Sep 13 21:59:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 11772481 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BE0B2746 for ; Sun, 13 Sep 2020 22:00:00 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6AA3320756 for ; Sun, 13 Sep 2020 22:00:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="pbixRBC9"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b="UhBk9scm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6AA3320756 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=alliedtelesis.co.nz Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=L5V8zBZSAvu++yQf9XNWB8hqpWXLWgf9T9QC/5RDU6c=; b=pbixRBC9aoXV+MJ/SKqK1bQTiV x6kBnNsnpLdiHh/FS41qnC5o+qJr9Yt6IWYz4GWNNglBmQpDbsaKkRp8N+0VeuqOldhajUiLlASCF bAciSn3Vu3kExDkJpV39BMdgX9NLOYM5LsMMaxECpULWjAuSsbkcL2AvkaA+IIf3qt7uUGsyOSs0E 41/Y8D3wpbiHyt8YviI9W4Gc+38ziJbcJxVV0EkpiaA9dIC0kHrZPEuMIYr0gNy4qYGDy3C/Ah088 1uGFmXcnIzjuti2j/sSzKMN+HMhFq+jy+G41tMZG3rMKYaOXnbtuiVgjymowBYkWhdyUDw+S0vdJI dSe5Mjew==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHa2E-0001nB-Q7; Sun, 13 Sep 2020 21:59:46 +0000 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHa2B-0001m5-2w for linux-arm-kernel@lists.infradead.org; Sun, 13 Sep 2020 21:59:44 +0000 Received: from mmarshal3.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id 9D8748364F; Mon, 14 Sep 2020 09:59:30 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1600034370; bh=ZjWQGtSyO0kEk9NqvK9evB+O0jozNr23w3ubWZ7l71E=; h=From:To:Cc:Subject:Date; b=UhBk9scmYbdl/hg/DhTenluoKLbbIvMiM2C92q00CQJMjXhb7Vxqq1rn6PivDfzBj mMY4k6WdUHH0EXD9IgavaGk+rgWXpeLb/GSaEqVmjjZvRqV50I9BlCaLdd5m24GtT0 0jzVRdkLNrxu1SHrc34+A+bTT2LvcxWOKZGihLrSdkAZHR3/NRMGg0R7MyrpK/mvC1 olzjIm3u6TocPOprtKXsnZCIxGxZ5miDUq9BiYuwEQ1QIzRfqmVRCmHjSFUwTy8JpF jv0pilA9oEHakjn69UPsinBeOkwS/cPnFnNafbiXcjfQCSi1aLHkaHru+z0EXll+SF TwUGH090fOZuA== Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7, 5, 8, 10121) id ; Mon, 14 Sep 2020 09:59:31 +1200 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.20]) by smtp (Postfix) with ESMTP id BB17F13EED0; Mon, 14 Sep 2020 09:59:28 +1200 (NZST) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id E148228008F; Mon, 14 Sep 2020 09:59:28 +1200 (NZST) From: Chris Packham To: stern@rowland.harvard.edu, linux@prisktech.co.nz, gregkh@linuxfoundation.org Subject: [PATCH v2] usb: host: ehci-platform: Add workaround for brcm, xgs-iproc-ehci Date: Mon, 14 Sep 2020 09:59:26 +1200 Message-Id: <20200913215926.29880-1-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 x-atlnz-ls: pat X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200913_175943_823418_4B701F9E X-CRM114-Status: GOOD ( 22.92 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-usb@vger.kernel.org, Chris Packham , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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 Acked-by: Alan Stern --- 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. Changes in v2: - move workaround to ehci_platform_reset - cosmetic changes suggested by Alan drivers/usb/host/ehci-platform.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c index 006c4f6188a5..9804ffa9e67f 100644 --- a/drivers/usb/host/ehci-platform.c +++ b/drivers/usb/host/ehci-platform.c @@ -42,6 +42,9 @@ #define EHCI_MAX_CLKS 4 #define hcd_to_ehci_priv(h) ((struct ehci_platform_priv *)hcd_to_ehci(h)->priv) +#define BCM_USB_FIFO_THRESHOLD 0x00800040 +#define bcm_iproc_insnreg01 hostpc[0] + struct ehci_platform_priv { struct clk *clks[EHCI_MAX_CLKS]; struct reset_control *rsts; @@ -75,6 +78,11 @@ static int ehci_platform_reset(struct usb_hcd *hcd) if (pdata->no_io_watchdog) ehci->need_io_watchdog = 0; + + if (of_device_is_compatible(pdev->dev.of_node, "brcm,xgs-iproc-ehci")) + ehci_writel(ehci, BCM_USB_FIFO_THRESHOLD, + &ehci->regs->bcm_iproc_insnreg01); + return 0; }