From patchwork Mon Mar 13 02:18:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 9619695 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 1701D604CC for ; Mon, 13 Mar 2017 02:31:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 087DD2843D for ; Mon, 13 Mar 2017 02:31:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F0A2F28445; Mon, 13 Mar 2017 02:31:21 +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=-1.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID 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 2A2262843D for ; Mon, 13 Mar 2017 02:31:21 +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: 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: List-Owner; bh=Tpw8mawgNMfegce2Zk/DrpW//YrGwNMGXF9xddsI/7c=; b=BzibGfuz/02+nR Vi6X9Dg9urEE57KV7eiFr+KlrgBj+HoC7wcn34gmtH8BE9n26EL4HGDz55tjWPqurPwLb6KcnnYfo akBAq2AwzANArkY+tLa+UsH3v9ebHdmOK1e4VPM52s7BTLe1r2okYtWgc9bjwIDMlP5WcKAGCU193 d03eJjnxVco0BIEOW+ebJqsaGAFhFtxIpOeAAeaE/pm1uhlIogg/k3fGKMF/qtNFjUyJ2LtWeuB2a v6BG/N5C94p1XrCQXd53VnmWRv2JeUy90fUR4/r8qPjl8TitEv/YdCE5G/dLMd5HLmVfZih3O2p6k BEae4pxRVhTGP9/p8gyQ==; 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 1cnFlW-0006Z7-Tc; Mon, 13 Mar 2017 02:31:18 +0000 Received: from mail-by2nam01on0043.outbound.protection.outlook.com ([104.47.34.43] helo=NAM01-BY2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cnFaB-0008NP-KE for linux-arm-kernel@lists.infradead.org; Mon, 13 Mar 2017 02:19:42 +0000 Received: from DM2PR03CA0028.namprd03.prod.outlook.com (10.141.96.27) by BLUPR03MB184.namprd03.prod.outlook.com (10.255.212.156) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.961.17; Mon, 13 Mar 2017 02:19:14 +0000 Received: from BL2FFO11FD023.protection.gbl (2a01:111:f400:7c09::195) by DM2PR03CA0028.outlook.office365.com (2a01:111:e400:2428::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.961.17 via Frontend Transport; Mon, 13 Mar 2017 02:19:13 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11FD023.mail.protection.outlook.com (10.173.161.102) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.961.10 via Frontend Transport; Mon, 13 Mar 2017 02:19:13 +0000 Received: from b29397-desktop.ap.freescale.net (b29397-desktop.ap.freescale.net [10.192.242.114]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v2D2IsBc028817; Sun, 12 Mar 2017 19:19:10 -0700 From: Peter Chen To: Subject: [PATCH 4/5] usb: xhci: use bus->sysdev for DMA configuration Date: Mon, 13 Mar 2017 10:18:44 +0800 Message-ID: <1489371525-18928-5-git-send-email-peter.chen@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1489371525-18928-1-git-send-email-peter.chen@nxp.com> References: <1489371525-18928-1-git-send-email-peter.chen@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131338451536776986; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(336005)(39410400002)(39400400002)(39450400003)(39840400002)(39380400002)(39850400002)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(9170700003)(8656002)(53936002)(36756003)(33646002)(106466001)(2351001)(5003940100001)(5660300001)(105606002)(4326008)(54906002)(86362001)(47776003)(38730400002)(110136004)(8936002)(8676002)(50226002)(76176999)(77096006)(50986999)(2950100002)(6916009)(6666003)(305945005)(356003)(81166006)(85426001)(2906002)(48376002)(189998001)(50466002)(104016004)(68736007); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR03MB184; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; MX:1; A:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD023; 1:fTZgp1FQ+81hJ+AdrXjrXro0N4HOQE8CWwMfcafes5Cnjcno4x40oh5silL0xI5Ya0BmNLtPQvK30AQJQLFZJpYN1Ws+75vMHXVKPPVFM9MTr63J66h4vl9LHA+W9kUuwLlt97Dj0EkftdMzfNef0r48dqkb8icfmHTDBRK1ToPyiIxwfaRN7DnmJHAY3d/OXu+HGxP3VWAhPv94Uo3f6j5ID0obeYWE2ufgd28M+OBnYQbZWbueJk1HPc4mgwRgItxULjArSlDB0KbpZkhIvY7i94/6WDaVJ+qUramdi479Q6l2FNZ2+zFqJ8K7reVUzbpX+4FbkwaY+hFEV4KLjveD+TpDICX5ho1GrXY9tc/NIgLIyk4QGajEjiI8TO8r8hyvuh+DUXVIvVGu4K6Qn03Sailby6V5N6DbfcHiz0s8V/jHTqb4uu33hQZOFWWXrwo0RuNywxDWO5PLgkzt/9K03WfAAZoDbZz6P04gXuEz1T+VjWT2l26M62MA0NpQRwACmj4fJMJzNEP9NLeZxEU9V7CRjk66JPHZ8qg2g+0/RwJ3Fdtvfuek9JbZyvdEtozt99aTD+x5Wdi/CWJa3DutM6cuxZWp5cLVbaZd3L4+xacWpdHBW4mtvI5n48cTFUiVPh338h0FYeJhfDuuWKVfrJ3HGQxr+PKNCWuU6is+Ycde5nFc83bnmnWoUMMkWshnogzZCqpYFFmQUUz7VqYbs/cQUuLv2e6Guif+EOd53dKQuGVzEYlhtQFlpT0Y MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 5410df86-db72-414f-adb9-08d469b757a7 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:BLUPR03MB184; X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB184; 3:Y2Iux8nng+7J6UFG04spsl948Jh0a6SIOohGKvoVtj+6iXT3anq50/KyrP6OT9ESOySNe5WJ+i1PHCzVuxBk5yWJJ65OR1PClaUjC/RCsUVx6Pwf+5MRt36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l2ISV84= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(82608151540597)(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095060)(601004)(2401047)(13015025)(5005006)(8121501046)(13017025)(13018025)(13023025)(13024025)(10201501046)(3002001)(6055026)(6096035)(20161123556025)(20161123563025)(20161123559025)(20161123565025)(20161123561025); SRVR:BLUPR03MB184; BCL:0; PCL:0; RULEID:(400006); SRVR:BLUPR03MB184; X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB184; 4:2CerrNk5Dlf7UZjT5uWLequo8UUK/bdp/Ur9xy6fD8ZRgTdTuHjXS7qrgwJNUR8Dz5CqivHAJxZV3r4PlTmtarI526+WVGbIIjNPGk6R2tiruy70M5UKFYwcuMcXs+wMmMiAyK9lrbhX7mPEahIds7BjMi1talLmp8RN+iLY1ZHQak9aEatFPaUQexF+qbIQTCCy7nuLowcOqUux92OtR4utSN/Kw0oTAR/LKePxH3W2AyDryVLSPIi1pbi/3TLOqhKNU888+SMsFgKs/UXIl+rSFhL9tfO8zv+AAuC9Eg5UIqTY6fOQ2BOjGuMLhxeMBl4+Gcn0K7fstrgSIonudSpPFsFJjh9xjirTtSxbEp/odZ5VJpzExajuIozzt29GK0sRpSRFuDAieOHypyMXtQdFUYL19afT2KwXM8/FZMnKZnTiH7AxQi0i2HZ5BBkQNXLrPFFJ0zgcAVOC5siU6pYsxYW+Pec0/5jkwH8kE6joSKQLwtASprjVBmfcWQI/pMuFS8aQpiX/+gf3H2+emGsDVFn1wSbC4qIEGqcguzeHX/Y4MOcAWEAY0rS4abki5LrrBJH5T8/FGgDL7FN73dRjROb0VfQpbrvfN5xxTIQbv/pbJ284oxortxmvuCo878CkZoA+MpygK1QiU6hfbqNOARYnOw2CvCXoqGxlQgCRAV3LHEfQgXpz9bLywP6eyRXGP8gFK08DpU0FRjMLvUR3cYhhlD3CyJWjlk7LWVzgeo7bIHZXm0+Qywmm4e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K8WH2L75YtKvYTAgC0JYspBD02iJOvNWaBtSYJ4DPzwEy4S9KkxbrMh4Z+6I1Ryo91+DXJEF+UBUXTcA1fMEsVGWEz+NcuVtrXDbrKlYXPSBpq2wtYfJMVt4E4x4y7SBsYaIEWzKLB4ikjeVRXxG3qgoeGyiX; 24:gNN9G7nRO0UkLbwTcvfrI3G6kN0rUa1XsVW1s8+EaPXSIDMQcibRkcjyycpFb8ag1XqCstWcNc3TbKQdH2wXuJqDOnzWIsprQdRNyc5w5NE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB184; 7:NHnXKMpTwHRw9AZ6EGBa84PTEpmL1HX9p0ByQ+mlYizSnllb8kboTpTp/CTXx3najxDxaRS7jzNuSICcjVhBBnGQc9+sI1fh/CbjBqcRdvP2yXfaJ1Uc2EgTTYlV9jB+/7dZFfdgUV6KEJIZQ1q0wZjPtvS2eJnEjHbCZq0KbJDw4VUkhM9/MRw7VXCdqiln+tf6ViPpqn5svNf+ly2OcXP5UCOVabpxsBSIW8QTEZ1D1+FiwdCS5xQTY34pmz9Z72+sGR11vGLfbL+xp0wC/GGpsNErYdktJS0dxFOxCZTAmvD6AlqHjPZxnxFmNntivlkxOf/amMlnux8QwjBcMw== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Mar 2017 02:19:13.4904 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB184 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170312_191936_210315_50C2B94D X-CRM114-Status: GOOD ( 18.99 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Chen , Mathias Nyman , Arnd Bergmann , Baolin Wang , linux-usb@vger.kernel.org, Sriram Dash , 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 X-Virus-Scanned: ClamAV using ClamSMTP From: Arnd Bergmann For xhci-hcd platform device, all the DMA parameters are not configured properly, notably dma ops for dwc3 devices. So, set the dma for xhci from sysdev. sysdev is pointing to device that is known to the system firmware or hardware. Cc: Baolin Wang Tested-by: Alexander Sverdlin Tested-by: Vivek Gautam Signed-off-by: Arnd Bergmann Signed-off-by: Sriram Dash Signed-off-by: Mathias Nyman Signed-off-by: Peter Chen --- drivers/usb/host/xhci-mem.c | 12 ++++++------ drivers/usb/host/xhci-plat.c | 35 +++++++++++++++++++++++++++-------- drivers/usb/host/xhci.c | 15 +++++++++++---- 3 files changed, 44 insertions(+), 18 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index ba1853f4..032a702 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -586,7 +586,7 @@ static void xhci_free_stream_ctx(struct xhci_hcd *xhci, unsigned int num_stream_ctxs, struct xhci_stream_ctx *stream_ctx, dma_addr_t dma) { - struct device *dev = xhci_to_hcd(xhci)->self.controller; + struct device *dev = xhci_to_hcd(xhci)->self.sysdev; size_t size = sizeof(struct xhci_stream_ctx) * num_stream_ctxs; if (size > MEDIUM_STREAM_ARRAY_SIZE) @@ -614,7 +614,7 @@ static struct xhci_stream_ctx *xhci_alloc_stream_ctx(struct xhci_hcd *xhci, unsigned int num_stream_ctxs, dma_addr_t *dma, gfp_t mem_flags) { - struct device *dev = xhci_to_hcd(xhci)->self.controller; + struct device *dev = xhci_to_hcd(xhci)->self.sysdev; size_t size = sizeof(struct xhci_stream_ctx) * num_stream_ctxs; if (size > MEDIUM_STREAM_ARRAY_SIZE) @@ -1686,7 +1686,7 @@ void xhci_slot_copy(struct xhci_hcd *xhci, static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags) { int i; - struct device *dev = xhci_to_hcd(xhci)->self.controller; + struct device *dev = xhci_to_hcd(xhci)->self.sysdev; int num_sp = HCS_MAX_SCRATCHPAD(xhci->hcs_params2); xhci_dbg_trace(xhci, trace_xhci_dbg_init, @@ -1758,7 +1758,7 @@ static void scratchpad_free(struct xhci_hcd *xhci) { int num_sp; int i; - struct device *dev = xhci_to_hcd(xhci)->self.controller; + struct device *dev = xhci_to_hcd(xhci)->self.sysdev; if (!xhci->scratchpad) return; @@ -1831,7 +1831,7 @@ void xhci_free_command(struct xhci_hcd *xhci, void xhci_mem_cleanup(struct xhci_hcd *xhci) { - struct device *dev = xhci_to_hcd(xhci)->self.controller; + struct device *dev = xhci_to_hcd(xhci)->self.sysdev; int size; int i, j, num_ports; @@ -2373,7 +2373,7 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags) int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) { dma_addr_t dma; - struct device *dev = xhci_to_hcd(xhci)->self.controller; + struct device *dev = xhci_to_hcd(xhci)->self.sysdev; unsigned int val, val2; u64 val_64; struct xhci_segment *seg; diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index bd02a6c..fa97826 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -148,6 +149,7 @@ static int xhci_plat_probe(struct platform_device *pdev) { const struct of_device_id *match; const struct hc_driver *driver; + struct device *sysdev; struct xhci_hcd *xhci; struct resource *res; struct usb_hcd *hcd; @@ -164,22 +166,39 @@ static int xhci_plat_probe(struct platform_device *pdev) if (irq < 0) return -ENODEV; + /* + * sysdev must point to a device that is known to the system firmware + * or PCI hardware. We handle these three cases here: + * 1. xhci_plat comes from firmware + * 2. xhci_plat is child of a device from firmware (dwc3-plat) + * 3. xhci_plat is grandchild of a pci device (dwc3-pci) + */ + sysdev = &pdev->dev; + if (sysdev->parent && !sysdev->of_node && sysdev->parent->of_node) + sysdev = sysdev->parent; +#ifdef CONFIG_PCI + else if (sysdev->parent && sysdev->parent->parent && + sysdev->parent->parent->bus == &pci_bus_type) + sysdev = sysdev->parent->parent; +#endif + /* Try to set 64-bit DMA first */ - if (!pdev->dev.dma_mask) + if (WARN_ON(!sysdev->dma_mask)) /* Platform did not initialize dma_mask */ - ret = dma_coerce_mask_and_coherent(&pdev->dev, + ret = dma_coerce_mask_and_coherent(sysdev, DMA_BIT_MASK(64)); else - ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); + ret = dma_set_mask_and_coherent(sysdev, DMA_BIT_MASK(64)); /* If seting 64-bit DMA mask fails, fall back to 32-bit DMA mask */ if (ret) { - ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); + ret = dma_set_mask_and_coherent(sysdev, DMA_BIT_MASK(32)); if (ret) return ret; } - hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev)); + hcd = __usb_create_hcd(driver, sysdev, &pdev->dev, + dev_name(&pdev->dev), NULL); if (!hcd) return -ENOMEM; @@ -222,20 +241,20 @@ static int xhci_plat_probe(struct platform_device *pdev) xhci->clk = clk; xhci->main_hcd = hcd; - xhci->shared_hcd = usb_create_shared_hcd(driver, &pdev->dev, + xhci->shared_hcd = __usb_create_hcd(driver, sysdev, &pdev->dev, dev_name(&pdev->dev), hcd); if (!xhci->shared_hcd) { ret = -ENOMEM; goto disable_clk; } - if (device_property_read_bool(&pdev->dev, "usb3-lpm-capable")) + if (device_property_read_bool(sysdev, "usb3-lpm-capable")) xhci->quirks |= XHCI_LPM_SUPPORT; if (device_property_read_bool(&pdev->dev, "quirk-broken-port-ped")) xhci->quirks |= XHCI_BROKEN_PORT_PED; - hcd->usb_phy = devm_usb_get_phy_by_phandle(&pdev->dev, "usb-phy", 0); + 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); if (ret == -EPROBE_DEFER) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 50aee8b..4296db9 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -237,6 +237,9 @@ static int xhci_free_msi(struct xhci_hcd *xhci) static int xhci_setup_msi(struct xhci_hcd *xhci) { int ret; + /* + * TODO:Check with MSI Soc for sysdev + */ struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); ret = pci_enable_msi(pdev); @@ -263,7 +266,7 @@ static int xhci_setup_msi(struct xhci_hcd *xhci) */ static void xhci_free_irq(struct xhci_hcd *xhci) { - struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); + struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.sysdev); int ret; /* return if using legacy interrupt */ @@ -748,7 +751,7 @@ void xhci_shutdown(struct usb_hcd *hcd) struct xhci_hcd *xhci = hcd_to_xhci(hcd); if (xhci->quirks & XHCI_SPURIOUS_REBOOT) - usb_disable_xhci_ports(to_pci_dev(hcd->self.controller)); + usb_disable_xhci_ports(to_pci_dev(hcd->self.sysdev)); spin_lock_irq(&xhci->lock); xhci_halt(xhci); @@ -765,7 +768,7 @@ void xhci_shutdown(struct usb_hcd *hcd) /* Yet another workaround for spurious wakeups at shutdown with HSW */ if (xhci->quirks & XHCI_SPURIOUS_WAKEUP) - pci_set_power_state(to_pci_dev(hcd->self.controller), PCI_D3hot); + pci_set_power_state(to_pci_dev(hcd->self.sysdev), PCI_D3hot); } #ifdef CONFIG_PM @@ -4801,7 +4804,11 @@ int xhci_get_frame(struct usb_hcd *hcd) int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) { struct xhci_hcd *xhci; - struct device *dev = hcd->self.controller; + /* + * TODO: Check with DWC3 clients for sysdev according to + * quirks + */ + struct device *dev = hcd->self.sysdev; int retval; /* Accept arbitrarily long scatter-gather lists */