From patchwork Fri Dec 1 03:32:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2h1bmZlbmcgWXVuICjkupHmmKXls7Ap?= X-Patchwork-Id: 10086109 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8425960327 for ; Fri, 1 Dec 2017 03:32:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B38E29F0B for ; Fri, 1 Dec 2017 03:32:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3DE7829F24; Fri, 1 Dec 2017 03:32:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E6C3D29F0B for ; Fri, 1 Dec 2017 03:32:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Date:To:From:Subject:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=o5Xj/e3k5DFoGxmvEfDCNYyMtFiylmGrZ46u+jgYS4k=; b=REtqG0gOLHmkqs MFB+QHhn97HneL8CqMg92kLNVNehHZ+153q3Nyw8WwO+wPaSixCmjXK97A1kPknXxhgedl3A9pAtm CTWkUp/50A9ZcP6JbGLPQyTi3F8oY9+rX9iQXJo+ntwTQ8CxHp0mbi01rtrBm8AV1zSR6AMfPXStD NqKV4XipOLY5+CjHe2MyHCwNUxuZJUWW7vQ1dEJxic9Y0ik5sQ1414b1QpRQN3jd2hHBwmxaujJt8 P4x6kPIxspTBhjtyGgczQTZFHJ176eO3a84HZY4RecrbEYLD8xdu1atXr0nr6caNl1dHmUdbyCQdj +fkqDW+GQbXtP0KJOhLg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eKc48-0001JG-IP; Fri, 01 Dec 2017 03:32:40 +0000 Received: from [218.249.47.110] (helo=mailgw01.mediatek.com) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eKc43-0001ID-I7; Fri, 01 Dec 2017 03:32:39 +0000 X-UUID: f45ade4f0bc444bfbbdd3dc8b4e175d0-20171201 Received: from mtkcas34.mediatek.inc [(172.27.4.250)] by mailgw01.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLS) with ESMTP id 1235463116; Fri, 01 Dec 2017 11:32:06 +0800 Received: from MTKCAS32.mediatek.inc (172.27.4.184) by MTKMBS33N1.mediatek.inc (172.27.4.75) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Fri, 1 Dec 2017 11:32:05 +0800 Received: from [10.17.3.153] (10.17.3.153) by MTKCAS32.mediatek.inc (172.27.4.170) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Fri, 1 Dec 2017 11:32:05 +0800 Message-ID: <1512099124.17567.156.camel@mhfsdcap03> Subject: Re: [PATCH v2] usb: xhci: allow imod-interval to be configurable From: Chunfeng Yun To: Adam Wallis Date: Fri, 1 Dec 2017 11:32:04 +0800 In-Reply-To: <1511970775-11103-1-git-send-email-awallis@codeaurora.org> References: <1511970775-11103-1-git-send-email-awallis@codeaurora.org> X-Mailer: Evolution 3.2.3-0ubuntu6 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171130_193235_995542_CC43E5FF X-CRM114-Status: GOOD ( 26.64 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Mathias Nyman , Greg Kroah-Hartman , timur@codeaurora.org, linux-usb@vger.kernel.org, Rob Herring , linux-mediatek@lists.infradead.org, Matthias Brugger , linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Hi, On Wed, 2017-11-29 at 10:52 -0500, Adam Wallis wrote: > The xHCI driver currently has the IMOD set to 160, which > translates to an IMOD interval of 40,000ns (160 * 250)ns > > Commit 0cbd4b34cda9 ("xhci: mediatek: support MTK xHCI host controller") > introduced a QUIRK for the MTK platform to adjust this interval to 20, > which translates to an IMOD interval of 5,000ns (20 * 250)ns. This is > due to the fact that the MTK controller IMOD interval is 8 times > as much as defined in xHCI spec. > > Instead of adding more quirk bits for additional platforms, this patch > introduces the ability for vendors to set the IMOD_INTERVAL as is > optimal for their platform. By using device_property_read_u32() on > "imod-interval", the IMOD INTERVAL can be specified in nano seconds. If > no interval is specified, the default of 40,000ns (IMOD=160) will be > used. > > No bounds checking has been implemented due to the fact that a vendor > may have violated the spec and would need to specify a value outside of > the max 8,000 IRQs/second limit specified in the xHCI spec. > > Backwards compatibility is maintained for MTK_HOSTS through the quirk > bit, however, imod_interval should be pushed into device tree at a > future point and this quirk should be removed from xhci_plat_probe > > Signed-off-by: Adam Wallis > --- > changes from v1: > * Removed device_property_read_u32() per suggestion from greg k-h > * Used ER_IRQ_INTERVAL_MASK in place of (u16) cast > > Documentation/devicetree/bindings/usb/usb-xhci.txt | 1 + > drivers/usb/host/xhci-plat.c | 13 +++++++++++++ > drivers/usb/host/xhci.c | 7 ++----- > drivers/usb/host/xhci.h | 2 ++ > 4 files changed, 18 insertions(+), 5 deletions(-) > > diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt b/Documentation/devicetree/bindings/usb/usb-xhci.txt > index ae6e484..3998459 100644 > --- a/Documentation/devicetree/bindings/usb/usb-xhci.txt > +++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt > @@ -29,6 +29,7 @@ Optional properties: > - usb2-lpm-disable: indicate if we don't want to enable USB2 HW LPM > - usb3-lpm-capable: determines if platform is USB3 LPM capable > - quirk-broken-port-ped: set if the controller has broken port disable mechanism > + - imod-interval: IMOD_INTERVAL in nano-seconds. Default is 40000 > > Example: > usb@f0931000 { > diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c > index 09f164f..3c63de1 100644 > --- a/drivers/usb/host/xhci-plat.c > +++ b/drivers/usb/host/xhci-plat.c > @@ -23,6 +23,7 @@ > #include "xhci-plat.h" > #include "xhci-mvebu.h" > #include "xhci-rcar.h" > +#include "xhci-mtk.h" Needn't it, MTK makes use of xhci-mtk.c but not xhci-plat.c > > static struct hc_driver __read_mostly xhci_plat_hc_driver; > > @@ -269,6 +270,18 @@ static int xhci_plat_probe(struct platform_device *pdev) > if (device_property_read_bool(&pdev->dev, "quirk-broken-port-ped")) > xhci->quirks |= XHCI_BROKEN_PORT_PED; > > + /* > + * imod_interval is the interrupt modulation value in nanoseconds. > + * The increment interval is 8 times as much as that defined in > + * the xHCI spec on MTK's controller. This quirk check exists to provide > + * backwards compatibility, however, this should be pushed into > + * the device tree files at some point in the future and > + * checking the quirk should be removed from xhci_plat_probe. > + */ > + xhci->imod_interval = xhci->quirks & XHCI_MTK_HOST ? 5000 : 40000; Can be moved into xhci-mtk.c for MTK quirk, like as following: Thanks > + > + device_property_read_u32(sysdev, "imod-interval", &xhci->imod_interval); > + > hcd->usb_phy = devm_usb_get_phy_by_phandle(sysdev, "usb-phy", 0); > if (IS_ERR(hcd->usb_phy)) { > ret = PTR_ERR(hcd->usb_phy); > diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c > index 2424d30..0b7755b 100644 > --- a/drivers/usb/host/xhci.c > +++ b/drivers/usb/host/xhci.c > @@ -586,11 +586,8 @@ int xhci_run(struct usb_hcd *hcd) > "// Set the interrupt modulation register"); > temp = readl(&xhci->ir_set->irq_control); > temp &= ~ER_IRQ_INTERVAL_MASK; > - /* > - * the increment interval is 8 times as much as that defined > - * in xHCI spec on MTK's controller > - */ > - temp |= (u32) ((xhci->quirks & XHCI_MTK_HOST) ? 20 : 160); > + temp |= (xhci->imod_interval / 250) & ER_IRQ_INTERVAL_MASK; > + > writel(temp, &xhci->ir_set->irq_control); > > /* Set the HCD state before we enable the irqs */ > diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h > index 99a014a..2a4177b 100644 > --- a/drivers/usb/host/xhci.h > +++ b/drivers/usb/host/xhci.h > @@ -1717,6 +1717,8 @@ struct xhci_hcd { > u8 max_interrupters; > u8 max_ports; > u8 isoc_threshold; > + /* imod_interval in ns (I * 250ns) */ > + u32 imod_interval; > int event_ring_max; > /* 4KB min, 128MB max */ > int page_size; diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c index 2d473e0..a03451b 100644 --- a/drivers/usb/host/xhci-mtk.c +++ b/drivers/usb/host/xhci-mtk.c @@ -699,6 +699,13 @@ static int xhci_mtk_probe(struct platform_device *pdev) goto power_off_phys; } + /* + * the increment interval is 8 times as much as that defined + * in xHCI spec on MTK's controller + */ + xhci->imod_interval = 5000; + device_property_read_u32(dev, "imod-interval", &xhci->imod_interval); + ret = usb_add_hcd(hcd, irq, IRQF_SHARED); if (ret) goto put_usb3_hcd;