From patchwork Sat Feb 11 01:27:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 9567779 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 269AA601C3 for ; Sat, 11 Feb 2017 02:03:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 130C5285CF for ; Sat, 11 Feb 2017 02:03:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 06978285F0; Sat, 11 Feb 2017 02:03:11 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E45C5285EE for ; Sat, 11 Feb 2017 02:03:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752593AbdBKCCw (ORCPT ); Fri, 10 Feb 2017 21:02:52 -0500 Received: from mail-cys01nam02on0072.outbound.protection.outlook.com ([104.47.37.72]:6592 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751880AbdBKCCs (ORCPT ); Fri, 10 Feb 2017 21:02:48 -0500 Received: from BN6PR03CA0020.namprd03.prod.outlook.com (10.168.230.158) by BY2PR0301MB0726.namprd03.prod.outlook.com (10.160.63.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.888.16; Sat, 11 Feb 2017 01:47:44 +0000 Received: from BL2FFO11FD024.protection.gbl (2a01:111:f400:7c09::155) by BN6PR03CA0020.outlook.office365.com (2603:10b6:404:23::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.888.16 via Frontend Transport; Sat, 11 Feb 2017 01:47:43 +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; nxp.com; dkim=none (message not signed) header.d=none; 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 BL2FFO11FD024.mail.protection.outlook.com (10.173.161.103) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.904.16 via Frontend Transport; Sat, 11 Feb 2017 01:47:43 +0000 Received: from shlinux2.ap.freescale.net (shlinux2.ap.freescale.net [10.192.224.44]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v1B1kZwP001095; Fri, 10 Feb 2017 18:47:34 -0700 From: Peter Chen To: , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , Baolin Wang , Vivek Gautam , Alexander Sverdlin , Mathias Nyman , Sriram Dash Subject: [PATCH v13 06/12] usb: xhci: use bus->sysdev for DMA configuration Date: Sat, 11 Feb 2017 09:27:17 +0800 Message-ID: <1486776443-2280-7-git-send-email-peter.chen@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1486776443-2280-1-git-send-email-peter.chen@nxp.com> References: <1486776443-2280-1-git-send-email-peter.chen@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131312512639793128; (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)(7916002)(39380400002)(39410400002)(39450400003)(39850400002)(39860400002)(39840400002)(39400400002)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(5660300001)(54906002)(38730400002)(2201001)(53936002)(8656002)(36756003)(47776003)(2171002)(7406005)(86362001)(305945005)(2950100002)(6666003)(356003)(189998001)(106466001)(76176999)(50986999)(33646002)(4326007)(7416002)(2906002)(48376002)(626004)(92566002)(77096006)(50466002)(97736004)(5003940100001)(39060400001)(68736007)(105606002)(85426001)(81166006)(104016004)(81156014)(50226002)(8936002)(8676002); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR0301MB0726; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD024; 1:O9rfN9W3YgEgSqRQjUHe9zlB9bDGo+h4VlRES0mpARHGmOZnUEGPDqmCmoRQkBdA40LkDYkkGXfPx/3Xb8mH/QFgmnnQP51F7Mu3hxNoBFKmAty+yMVJWH7Nky7EE7cOKos+ibxgX8XQaEKfGa97culxP/Wtf3aUYj2JcGwaAmv5m0m/pRGN9lMWrkPX8tHtzZIDc62ufqvgQATsz7NJAj7qNBX2n+CGDJywB0P2zyVETs6APMwHoXyw2VabPfsNran1mahOyDBqK7vHnlCzVXcfMuqWKgHLaAlcQbzqjzEa9j8+fZbV3hha9FOekYIXIhj3OMyGn1+J3PcBwuwmtlWnd1m6PD6fQF82cSDSPeG+Bi8xHaVFxazzYIovzZWxJ7cGVFsp/tTO6Cp7R+aTzraFmQDkqNUYDpjiRIauegq8cVi5CNikx1Tl1Ttf/XdnNW4Rs0NswdIMOQ83sXkOj9moUmG+P5FBDDvKF+LnH5BZcCFe//OFZcrhcdCfthqJeYUvq6afqDOBDmM0aJJCYhesTPq6jxJBE7HDDk1aL578lPOcHPXiULnQp6TckY0iregZOPlh3oIuqUvUHXZSC3I1PoRTUoI1p/rWJpbpwQLDj+QkexbVG4oLKDBLvLd4gvbDzBBzNAoE07XBfAXJLDcSGv5QvuMgic2laNlcAThuKlKa1A4sQK1/3WyvRmS06Gyoz5sjPbeuNPDeS5aVNjsE5b5+I7Tz62EM//7FSkPBPU7uTFASSMw+cFNKYisH MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 2604e8f8-edd2-45f0-1687-08d4521ff8ea X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:BY2PR0301MB0726; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0726; 3:uW8W4yLwgd2KKGyHKGi7dpkp9pEIvDm1y0klRducxMntk7X0h+G3KIyz9YV8Juq6Cr+Bg1iO2zg2jJQ7VAQVJKAOiK0jAqk77+a5IAY8m6uOAkpzrRqPbDtej9NqIiYDap8zKawwIkdVK9Ff5Omqj7+wejU/mNYgL96YFQaWrMTPgMxZST5faf84VBnSgBs2Jo6OebHOViAvv5o1HDT2yIG8a5OKndhrXNo3jiQsmYkF/yQ0ZpgqZNdF2m41UQT21Ra0ouM3G/pqCUhlhX+jpb6OYKGZyqDZZGlJO2kjqiLEelujml5mz7uR0oBg3heOg5YYE2kRRQmB3mjCmy/OCRSRnKTXAA6LtHP21tW9zoFAPtCDznyIvq58rbIyMsEf; 25:nazHI/56kmbCSs6s4nY18fkZUSXPOZGSBOIJsaxOlYYxetI47UO5RVtTq9/rngW8x5NZwcdeMYp6ejRtQMLZie3+NoOP2XICRV7kcN7kDey1sTo5NBW0+zt0HpYSE8gcJWJlfzWysj3G7OyvWjUKYYf24CNkLLhRxtRhPKISxjAdkIlFl0735W2660txCfDzEHgDwQA95a7PrEObKFj3ygYLM+v7oLAg5Xi48cDHltU+Ar3AnqiqcKICwhLX9fF1EBblGxNSoRBX+h0b3ftGfiwER0dugzNpraE0S7kiIr6T5b5Z9mPPTM3PURKQ2jlnrE6mx4Na9HDbgz+fv5ou2UJBukgVklROdAmLJd2quLgE+SBw7BTkanaVV6kb/lOeevCdQhFcbdTnrsJrdhEEnN/VH9xtY0Ow+JNh1UQ3pEqIBHPNLobsgfGe8+gB1TWtuF+eEH9EKc2UDjFDl7cN3Q== X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0726; 31:dGMyw1Uqh8IphAYDFgFbuHHQHWfvbZtdw3bQpVtKjrQLzn3X9j8CH5+TmeJ5/sv0RR3tTldwA/YO5ys3jLLQkwF70/q1Bulj1QvBjEsiHUfGRleXTWpu3UJliUdzzwPub3pCM1Lke+OwuIIdt/i3Xu6EjNPIYBn6sqgbWbxyuPwXNCB5dqAVDWOdbZFS1tab/z6refV4rPRZtp8sFRcrdJgiMUhCBQA8s5i8OWiUB8y+YzwI8wodiI4cIuRMleN1YyavpkfdA8OTB7Ucaf54Gw== 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)(5005006)(13018025)(8121501046)(13024025)(13023025)(13015025)(13017025)(3002001)(10201501046)(6055026)(6096035)(20161123556025)(20161123565025)(20161123561025)(20161123559025)(20161123563025); SRVR:BY2PR0301MB0726; BCL:0; PCL:0; RULEID:(400006); SRVR:BY2PR0301MB0726; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0726; 4:1GRm6/pyAHHj2BzFtvvv95SBR135DaWPmGDQfZFixMnIluJUSOBbgZEL4gPzFLHmdj8XW3ev3hBarr84O47PX3W12LxRNKXCVRYyz2TKy7z+/B/QzafMxbxc5mCWQFRF/l0wVsnwyiWPuKTyxa0LNemsUFiMJB1o7YRy5V4r0LT8RnGH4/+e+F7VgPVf5XadxDdpPich7JnLM5xeX0+LD303zpumhnNI1PVnmecgfUMf6mZfCo1bKxNyQjlf5M9PImMCaggfC8J5lONAGUqHsSq6v0AAmkUZO1AcYJenMb9pxlJ1Wqr2TO4HIo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yn9lEdCMG5ON1ka?= =?us-ascii?Q?YZk9dGHxpIBjRkSomixcOk+WS8zeVZ3FhWpBwIS5vNCZI5+trTsgV+/lrAfZ?= =?us-ascii?Q?fww0u3A=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0726; 6:CG4L7hXiCRG2dsPqERljOb/Gqb6hA/EEG2Eve9v9lRZLq50QUIj1luGEXvnSRnNEo+k/n/OyHe1t6gRNbu4gArmjwtgoqJs7+srkulLnCoFM7laB8eaELmcfdyLDRyjnNIJD6tslFvLrtHruUVm5KivushYO8x/iCV2/+rMaEf4AJOLfmaCkbQE/k36o/ggXY7rhw9C6pr3NGjdneky6+yGTdmcGABGAWab4r/pEEOuuSPcR0jvwqdVbpD+2asTah0ORjKAPxt0RAKTv7NQq92vcToGlJBNvSL0BBn8apN9naiM+X5t9TzCtZWtN5ZU5d8T4nlBq1vKSTO8vkZPFidWxf1nBrtAAK8ZvG+OuUvXcQu1BnPYmYPGXCscRYD0QOx1aRdSSGU5kQ/HOxfxW2BZAA0TOyi+OrE00kE5nd2A=; 5:+NwcftnYq9V+UvigfbvVwKbed74Roofj8yyhyVvSRc9R7REmKEKDZ3gbofKGIf0ugAd16uHwO6xbiPNZF1TnuC9lI2F7AtDSvmrk9a8MojSdO4tlD0Qe/nFhGNx3LyJSeA+n0FRkxgACeMhcrrSnNI7EqHGEGgKv0cdtq4xR62PMW8+BScoMgKSjbK6N/twR; 24:/vaqA7DjGOEh8yyDZn7f9697I5sKkrzVRLYfvMkML2vVIYtiqmmSVlpl7uGPTIb1GQJqqzqME2jv40ZXjIqUZFxcZpLJY9pCfthqVKTJJRA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0726; 7:dIPCXZJJuIakG8zRJJaZn2acN5kr/FzWjgf+HaC3vLJr9oawYxcPCzcItagJbe/Hk05vx0mHfCreuRQ2rnLEmd4pTm3Q0ojnLK/SMVayXaWUxm8r1zU2tTxGDcG1jtSgOtOS9V3B42HpMZJnzmLVQN8KR1GsRX2SQgSKm2s9QMJTclSeOCVG6J4Vvnxkfe9gZpDJewBblAuHRsZ9c2Iu1g7w+GB6B6JaSv9fmrY+V5OhPzkCPoNi2b5N6fHWzfw2c7kisKKujvIIPyc72bR79kNKYl2TIHr8LV9u8rCu47Ja7b3zIkCrbR61+o2osRdcsIgfbQRkIJ157cAMpBsp10b4GECoB9XeIwaTIqtbW9Um8pIspogSA4ngoRT+KZkEXgt4JagLJJFExChFnJzYpeMgXpKls1hkX2LopolIKlYn9dLW9QpiPhp8b9uKuen5C9ywgo5du+o8al3YKwOiklo6IEw5yptPgEK8xLOgQ4NV1SffY4Qe34LslvXqM17bbR/D7R1hE2KUO7YSdVYLhQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Feb 2017 01:47:43.6049 (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: BY2PR0301MB0726 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.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 Cc: Vivek Gautam Cc: Alexander Sverdlin Cc: Mathias Nyman Signed-off-by: Arnd Bergmann Signed-off-by: Sriram Dash Tested-by: Alexander Sverdlin Tested-by: Vivek Gautam --- Hi, Baolin, Vivek and Alexander, I removed your tested-by tag due to add one change that adding sysdev for shared hcd too, if your test shows this change works for you or has no effect for you, please consider adding tested-by tag again, thanks. 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 6d33b42..4ecb3fd 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 6d6c460..ab0839c 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 */