From patchwork Mon Feb 6 09:13:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 9557289 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 2DB8460413 for ; Mon, 6 Feb 2017 09:16:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 182212624A for ; Mon, 6 Feb 2017 09:16:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C2F027F85; Mon, 6 Feb 2017 09:16:38 +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 130002624A for ; Mon, 6 Feb 2017 09:16:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751799AbdBFJPL (ORCPT ); Mon, 6 Feb 2017 04:15:11 -0500 Received: from mail-by2nam01on0082.outbound.protection.outlook.com ([104.47.34.82]:41120 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751748AbdBFJOs (ORCPT ); Mon, 6 Feb 2017 04:14:48 -0500 Received: from BN6PR03CA0035.namprd03.prod.outlook.com (10.175.124.21) by CY1PR0301MB0731.namprd03.prod.outlook.com (10.160.159.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.874.12; Mon, 6 Feb 2017 09:14:35 +0000 Received: from BY2FFO11FD038.protection.gbl (2a01:111:f400:7c0c::182) by BN6PR03CA0035.outlook.office365.com (2603:10b6:404:10c::21) 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; Mon, 6 Feb 2017 09:14:35 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; gmail.com; dkim=none (message not signed) header.d=none; gmail.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 BY2FFO11FD038.mail.protection.outlook.com (10.1.14.223) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.888.7 via Frontend Transport; Mon, 6 Feb 2017 09:14:34 +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 v169Dq2O005959; Mon, 6 Feb 2017 02:14:21 -0700 From: Peter Chen To: , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , Sriram Dash , Mathias Nyman , Felipe Balbi , Grygorii Strashko , Sinjan Kumar , David Fisher , "Catalin Marinas" , "Thang Q. Nguyen" , Yoshihiro Shimoda , Stephen Boyd , Bjorn Andersson , "Ming Lei" , Jon Masters , Dann Frazier , Peter Chen , Leo Li Subject: [PATCH v12 3/9] usb: separate out sysdev pointer from usb_bus Date: Mon, 6 Feb 2017 17:13:35 +0800 Message-ID: <1486372421-29073-4-git-send-email-peter.chen@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1486372421-29073-1-git-send-email-peter.chen@nxp.com> References: <1486372421-29073-1-git-send-email-peter.chen@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131308460753328087; (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)(7916002)(336005)(39410400002)(39400400002)(39840400002)(39380400002)(39860400002)(39850400002)(39450400003)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(5890100001)(4326007)(305945005)(105606002)(189998001)(2950100002)(8656002)(106466001)(76176999)(53936002)(50986999)(104016004)(8936002)(5660300001)(6666003)(5001770100001)(85426001)(2171002)(97736004)(36756003)(33646002)(81156014)(2201001)(47776003)(7416002)(7406005)(48376002)(81166006)(8676002)(50466002)(38730400001)(77096006)(2906002)(68736007)(5003940100001)(575784001)(86362001)(54906002)(92566002)(356003)(626004)(50226002)(39060400001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0301MB0731; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD038; 1:Z54VkYWr7K1B+/Pdn19+OTBPzw9VWP8UzHryP0yB3NsEhhjzsmmP+MIUJAdhhwAXJn9Yq43Wzm+Ieqv7Jz0ENfcWbkwNv18IcZWTMvaXABXZQaIuYGCh2VRUz+LMTy2oQVmjGHpDTzwQxeg6QfZJwEB7vqNamG/ga1GbdQ3KXk9+7gJaQ+mtuBDtX6l4PqgE4G0sO93z0VVLHvbnNHGsSoEs7tWozUruDb8v5UE+CmDjvElUv9ABRFgchUtPiBuwkuh4YYInk1n+HUqt4/Qt4Vxuse8RjKrUmQxUnsekHNo3QzmzqmcmwS7CPwIbW6Lb7loW4sGn2ypuzfe+AsxU8hYDffKHuX6TkPx60Bz5dapIHYNP9md1SUeQRQ5GvjsoocV6qr7Bm/tVnlJdtRK+57peIEaTlzoVgfGynUrRGe5JPOPbF/Dtab6gsW97y6nNl8SqzV9EMFuBydRA5irpgbj4Wvbm+LRxc1jeOdoumxs4VYcjhrNwdTNVP/WDb14RxoCxsaRu11cfosSfkDho37hm4wnYn0quIeC+t8BxsGr+A89AXwB2s9Fr68idovrc5LqVXe8X4iIbs/V9Lr3I+Up61Jzs/r6KXAKqma8WC7eqyh20+i0mKG3Ll2CQXKZ2HgdDHDeiji/l1f3+hsF9bszgeDkmWc9k2rnMtmgviH0= MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 0c638647-cd05-4714-97d7-08d44e7091ab X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:CY1PR0301MB0731; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0731; 3:2KbXFN9X2ZUspV7HDYfNsGZc5lTJVNg8vLoqSd1L1LP5MmM9prNTlG5SKazHOXt9hgesX2x6D+2zJ2kfyFDt1zVaHh69zaIGJZEVNk9YCx7Zk7SpZ8OjwXlhD/r9AnYXem5wbL2voAeaWrxyK7OmbDhUAmL0xWVGNN/6SvLSIDhDM8sDdebGWsiStR+toVLH5tLRh2cF5MkYZ040eROYmbdloDb8FMhE7ULVyQHPx6nH1p/zP9Ksa9viO63wI9vxcwrkSPCIJ87CqZ1sX7L5AGao/HYjN2vzsz2fDUsRaXvilWoVBVnFF7alCfPn60KXA7AyqT6VrWaR8Dlpzz/XXSDI5FJcUFi/wokKDz+VD0xPthS3vSDZC5TKDas8VRgN; 25:WlG2Ld2KwJTkXtBcfP6NTSte2DgBafzi2kLqiS55ZL+aUSF7/AqS3zK85fIz/e94Wsjs8huvLuJ+G6bpvQ+mjUTtHAZfHu42J1DaR/cNFndmfG0dpfHqRIURKePi96kneid4g2lUL36NlN7Q50rR/BwHQ9tBi4QR3D+TDvLdk7FRxIW7Z2Y24l/hiDJ8n2JjFzpHzlh1FQimxFwCe0fiKE/r7woAFRRs2YBRvDzW13AFoZXKhrEA8JhehUGD0s1cSUBBHbRmDFl1jsxV6ZOUIaPOi0BHiezH0rNexxSAKXz9MptfZgAy55ThQlBMGJMdqTN6DHlE3rDT0BI5qVtNNnb6SMCtRaewD7Urxnk4fcKUYRk+/tnmypvP8Q0xht9Q0b6Stzo+SNZ/Ith2tje7XHyVqrHIOdrzUhHUGY11OM6IvB8iB0f3DyZ3pCmOqWCL0uARZGCs3rdoRIjBkt/PDQ== X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0731; 31:GmNKhMmz7whUAUNESnVTIrm+ZP6yIL1oMl7YvF1RhStfMjp1JrBD/O13AKjweQdydPr3Ob205dfcFR1bw16JpRrkBNsKaOAXrmK+ePp8/GgzcWvzQWa/2gPqL1FzJnp3he5izBbqjVB1l1s7UrgVWnJLAoey1QttmDUlzvXHrFIHl9ADecTsDqfDbuIPpYakjzesc/XC4tpI4keQ0SY1QbY5E8Xn5OiVVfHCCz9vfSdNhRBswKfwBnHdbxL6M0TdBaPlsshuzWkNeFaApp919Am0S2ZnhOthCnWP/95reQg= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917)(31051911155226)(185117386973197)(82608151540597)(198206253151910)(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095060)(601004)(2401047)(13023025)(13024025)(13018025)(13017025)(5005006)(8121501046)(20170203043)(13015025)(3002001)(10201501046)(6055026)(6096035)(20161123563025)(20161123556025)(20161123565025)(20161123559025)(20161123561025); SRVR:CY1PR0301MB0731; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR0301MB0731; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0731; 4:oR1TyCCbU+fLKXPxAJGWyt7KDF5akiBU9JIS3t2W7Dn32WuO7sVEd+RGrOVUF7hrgwGdNzvXO2yAOtm+XxKcaYdCuT70K510IH/K64BdiZsGwgF0qLhijRaJHk0cur9jSAKaiNd14HReX7i1e8tuM7VVFc/tKUndgr4y3M5jTMloqEYbsevLONcydt2hb+nQ8qQLhloWuQnrVzO7lHHKoPV0ylyoFUUtev18YLZBgqPgGwu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zSSyvea3eSoqdpr; 24:2l8+9JtqI/Bta2YWSHxhxbMVmrDaimpgH2MLhzuzYxELlKBsZ/v2tkMCAG0aWgyL1hibVuRcKbIsEdK52t/1EH22HGhqnrLIxK+SB8vKhys= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0731; 7:qKrvOXyD+z600tP9UB7+H12Pm+DC9OF+ATu+edekglbFd+s+Bz61dAJDLUc9e/oiHOkjISWOBG9BxixffjVvDGHSvl1kOKT9zPZBQ2rb4EuT4FAWG3txwKg0MzVkeAqoDi5cQdPEaRFi6IXtk5kboGVdEoZ+yOs4YXDf5D4gA+aN3T9e8icyuHDCCl4ugbIm+jxMNTzCWNq7atRwDFHq3avtinL3wXXSbExNgbxo6iLtYP9e+08qDcd1FO3sBICQynvv+GithZomQp0W4PU3g1xJnShOi8G+Vl5wY8SjGTVhts9x1nlJYNN4eAEy88Cg2gg+uHpynlGXmng+xCfnuNjU/BQs/2KMp5lQAzLcu203X775JRAcgR+FBccSTznNJkqsgtumO5uwmm9Hiw3UF53w6TZuyRYGD4r33c53npc8jSvctGuAaIPhpWsvaPwUXYtxuCmyuB2w6LGa3AStgU9IvN0I8CDZpTEoC4599eq8vKyxa4n8H9YoPk6HJOFsb+lhRiQBHOPvgZaRRc48yQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2017 09:14:34.8960 (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: CY1PR0301MB0731 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. The idea here is that you pass in the parent of_node along with the child device pointer, so it would behave exactly like the parent already does. The difference is that it also handles all the other attributes besides the mask. sysdev will represent the physical device, as seen from firmware or bus.Splitting the usb_bus->controller field into the Linux-internal device (used for the sysfs hierarchy, for printks and for power management) and a new pointer (used for DMA, DT enumeration and phy lookup) probably covers all that we really need. Signed-off-by: Arnd Bergmann Signed-off-by: Sriram Dash Tested-by: Baolin Wang Tested-by: Brian Norris Tested-by: Alexander Sverdlin Tested-by: Vivek Gautam Signed-off-by: Mathias Nyman Cc: Felipe Balbi Cc: Grygorii Strashko Cc: Sinjan Kumar Cc: David Fisher Cc: Catalin Marinas Cc: "Thang Q. Nguyen" Cc: Yoshihiro Shimoda Cc: Stephen Boyd Cc: Bjorn Andersson Cc: Ming Lei Cc: Jon Masters Cc: Dann Frazier Cc: Peter Chen Cc: Leo Li --- drivers/usb/core/buffer.c | 12 ++++++------ drivers/usb/core/hcd.c | 48 ++++++++++++++++++++++++++++------------------- drivers/usb/core/usb.c | 18 +++++++++--------- include/linux/usb.h | 1 + include/linux/usb/hcd.h | 3 +++ 5 files changed, 48 insertions(+), 34 deletions(-) diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c index b9bf6e2..b64568c 100644 --- a/drivers/usb/core/buffer.c +++ b/drivers/usb/core/buffer.c @@ -66,7 +66,7 @@ int hcd_buffer_create(struct usb_hcd *hcd) int i, size; if (!IS_ENABLED(CONFIG_HAS_DMA) || - (!hcd->self.controller->dma_mask && + (!is_device_dma_capable(hcd->self.sysdev) && !(hcd->driver->flags & HCD_LOCAL_MEM))) return 0; @@ -75,7 +75,7 @@ int hcd_buffer_create(struct usb_hcd *hcd) if (!size) continue; snprintf(name, sizeof(name), "buffer-%d", size); - hcd->pool[i] = dma_pool_create(name, hcd->self.controller, + hcd->pool[i] = dma_pool_create(name, hcd->self.sysdev, size, size, 0); if (!hcd->pool[i]) { hcd_buffer_destroy(hcd); @@ -130,7 +130,7 @@ void *hcd_buffer_alloc( /* some USB hosts just use PIO */ if (!IS_ENABLED(CONFIG_HAS_DMA) || - (!bus->controller->dma_mask && + (!is_device_dma_capable(bus->sysdev) && !(hcd->driver->flags & HCD_LOCAL_MEM))) { *dma = ~(dma_addr_t) 0; return kmalloc(size, mem_flags); @@ -140,7 +140,7 @@ void *hcd_buffer_alloc( if (size <= pool_max[i]) return dma_pool_alloc(hcd->pool[i], mem_flags, dma); } - return dma_alloc_coherent(hcd->self.controller, size, dma, mem_flags); + return dma_alloc_coherent(hcd->self.sysdev, size, dma, mem_flags); } void hcd_buffer_free( @@ -157,7 +157,7 @@ void hcd_buffer_free( return; if (!IS_ENABLED(CONFIG_HAS_DMA) || - (!bus->controller->dma_mask && + (!is_device_dma_capable(bus->sysdev) && !(hcd->driver->flags & HCD_LOCAL_MEM))) { kfree(addr); return; @@ -169,5 +169,5 @@ void hcd_buffer_free( return; } } - dma_free_coherent(hcd->self.controller, size, addr, dma); + dma_free_coherent(hcd->self.sysdev, size, addr, dma); } diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 612fab6..46cb20f 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -1073,6 +1073,7 @@ static void usb_deregister_bus (struct usb_bus *bus) static int register_root_hub(struct usb_hcd *hcd) { struct device *parent_dev = hcd->self.controller; + struct device *sysdev = hcd->self.sysdev; struct usb_device *usb_dev = hcd->self.root_hub; const int devnum = 1; int retval; @@ -1119,7 +1120,7 @@ static int register_root_hub(struct usb_hcd *hcd) /* Did the HC die before the root hub was registered? */ if (HCD_DEAD(hcd)) usb_hc_died (hcd); /* This time clean up */ - usb_dev->dev.of_node = parent_dev->of_node; + usb_dev->dev.of_node = sysdev->of_node; } mutex_unlock(&usb_bus_idr_lock); @@ -1465,19 +1466,19 @@ void usb_hcd_unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb) dir = usb_urb_dir_in(urb) ? DMA_FROM_DEVICE : DMA_TO_DEVICE; if (IS_ENABLED(CONFIG_HAS_DMA) && (urb->transfer_flags & URB_DMA_MAP_SG)) - dma_unmap_sg(hcd->self.controller, + dma_unmap_sg(hcd->self.sysdev, urb->sg, urb->num_sgs, dir); else if (IS_ENABLED(CONFIG_HAS_DMA) && (urb->transfer_flags & URB_DMA_MAP_PAGE)) - dma_unmap_page(hcd->self.controller, + dma_unmap_page(hcd->self.sysdev, urb->transfer_dma, urb->transfer_buffer_length, dir); else if (IS_ENABLED(CONFIG_HAS_DMA) && (urb->transfer_flags & URB_DMA_MAP_SINGLE)) - dma_unmap_single(hcd->self.controller, + dma_unmap_single(hcd->self.sysdev, urb->transfer_dma, urb->transfer_buffer_length, dir); @@ -1520,11 +1521,11 @@ int usb_hcd_map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb, return ret; if (IS_ENABLED(CONFIG_HAS_DMA) && hcd->self.uses_dma) { urb->setup_dma = dma_map_single( - hcd->self.controller, + hcd->self.sysdev, urb->setup_packet, sizeof(struct usb_ctrlrequest), DMA_TO_DEVICE); - if (dma_mapping_error(hcd->self.controller, + if (dma_mapping_error(hcd->self.sysdev, urb->setup_dma)) return -EAGAIN; urb->transfer_flags |= URB_SETUP_MAP_SINGLE; @@ -1555,7 +1556,7 @@ int usb_hcd_map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb, } n = dma_map_sg( - hcd->self.controller, + hcd->self.sysdev, urb->sg, urb->num_sgs, dir); @@ -1570,12 +1571,12 @@ int usb_hcd_map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb, } else if (urb->sg) { struct scatterlist *sg = urb->sg; urb->transfer_dma = dma_map_page( - hcd->self.controller, + hcd->self.sysdev, sg_page(sg), sg->offset, urb->transfer_buffer_length, dir); - if (dma_mapping_error(hcd->self.controller, + if (dma_mapping_error(hcd->self.sysdev, urb->transfer_dma)) ret = -EAGAIN; else @@ -1585,11 +1586,11 @@ int usb_hcd_map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb, ret = -EAGAIN; } else { urb->transfer_dma = dma_map_single( - hcd->self.controller, + hcd->self.sysdev, urb->transfer_buffer, urb->transfer_buffer_length, dir); - if (dma_mapping_error(hcd->self.controller, + if (dma_mapping_error(hcd->self.sysdev, urb->transfer_dma)) ret = -EAGAIN; else @@ -2511,8 +2512,8 @@ static void init_giveback_urb_bh(struct giveback_urb_bh *bh) * Return: On success, a pointer to the created and initialized HCD structure. * On failure (e.g. if memory is unavailable), %NULL. */ -struct usb_hcd *usb_create_shared_hcd(const struct hc_driver *driver, - struct device *dev, const char *bus_name, +struct usb_hcd *__usb_create_hcd(const struct hc_driver *driver, + struct device *sysdev, struct device *dev, const char *bus_name, struct usb_hcd *primary_hcd) { struct usb_hcd *hcd; @@ -2553,8 +2554,9 @@ struct usb_hcd *usb_create_shared_hcd(const struct hc_driver *driver, usb_bus_init(&hcd->self); hcd->self.controller = dev; + hcd->self.sysdev = sysdev; hcd->self.bus_name = bus_name; - hcd->self.uses_dma = (dev->dma_mask != NULL); + hcd->self.uses_dma = (sysdev->dma_mask != NULL); init_timer(&hcd->rh_timer); hcd->rh_timer.function = rh_timer_func; @@ -2569,6 +2571,14 @@ struct usb_hcd *usb_create_shared_hcd(const struct hc_driver *driver, "USB Host Controller"; return hcd; } +EXPORT_SYMBOL_GPL(__usb_create_hcd); + +struct usb_hcd *usb_create_shared_hcd(const struct hc_driver *driver, + struct device *dev, const char *bus_name, + struct usb_hcd *primary_hcd) +{ + return __usb_create_hcd(driver, dev, dev, bus_name, primary_hcd); +} EXPORT_SYMBOL_GPL(usb_create_shared_hcd); /** @@ -2588,7 +2598,7 @@ EXPORT_SYMBOL_GPL(usb_create_shared_hcd); struct usb_hcd *usb_create_hcd(const struct hc_driver *driver, struct device *dev, const char *bus_name) { - return usb_create_shared_hcd(driver, dev, bus_name, NULL); + return __usb_create_hcd(driver, dev, dev, bus_name, NULL); } EXPORT_SYMBOL_GPL(usb_create_hcd); @@ -2715,7 +2725,7 @@ int usb_add_hcd(struct usb_hcd *hcd, struct usb_device *rhdev; if (IS_ENABLED(CONFIG_USB_PHY) && !hcd->usb_phy) { - struct usb_phy *phy = usb_get_phy_dev(hcd->self.controller, 0); + struct usb_phy *phy = usb_get_phy_dev(hcd->self.sysdev, 0); if (IS_ERR(phy)) { retval = PTR_ERR(phy); @@ -2733,7 +2743,7 @@ int usb_add_hcd(struct usb_hcd *hcd, } if (IS_ENABLED(CONFIG_GENERIC_PHY) && !hcd->phy) { - struct phy *phy = phy_get(hcd->self.controller, "usb"); + struct phy *phy = phy_get(hcd->self.sysdev, "usb"); if (IS_ERR(phy)) { retval = PTR_ERR(phy); @@ -2781,7 +2791,7 @@ int usb_add_hcd(struct usb_hcd *hcd, */ retval = hcd_buffer_create(hcd); if (retval != 0) { - dev_dbg(hcd->self.controller, "pool alloc failed\n"); + dev_dbg(hcd->self.sysdev, "pool alloc failed\n"); goto err_create_buf; } @@ -2791,7 +2801,7 @@ int usb_add_hcd(struct usb_hcd *hcd, rhdev = usb_alloc_dev(NULL, &hcd->self, 0); if (rhdev == NULL) { - dev_err(hcd->self.controller, "unable to allocate root hub\n"); + dev_err(hcd->self.sysdev, "unable to allocate root hub\n"); retval = -ENOMEM; goto err_allocate_root_hub; } diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index a2ccc69f..4cd6e0e 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -453,9 +453,9 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent, * Note: calling dma_set_mask() on a USB device would set the * mask for the entire HCD, so don't do that. */ - dev->dev.dma_mask = bus->controller->dma_mask; - dev->dev.dma_pfn_offset = bus->controller->dma_pfn_offset; - set_dev_node(&dev->dev, dev_to_node(bus->controller)); + dev->dev.dma_mask = bus->sysdev->dma_mask; + dev->dev.dma_pfn_offset = bus->sysdev->dma_pfn_offset; + set_dev_node(&dev->dev, dev_to_node(bus->sysdev)); dev->state = USB_STATE_ATTACHED; dev->lpm_disable_count = 1; atomic_set(&dev->urbnum, 0); @@ -803,7 +803,7 @@ struct urb *usb_buffer_map(struct urb *urb) if (!urb || !urb->dev || !(bus = urb->dev->bus) - || !(controller = bus->controller)) + || !(controller = bus->sysdev)) return NULL; if (controller->dma_mask) { @@ -841,7 +841,7 @@ void usb_buffer_dmasync(struct urb *urb) || !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP) || !urb->dev || !(bus = urb->dev->bus) - || !(controller = bus->controller)) + || !(controller = bus->sysdev)) return; if (controller->dma_mask) { @@ -875,7 +875,7 @@ void usb_buffer_unmap(struct urb *urb) || !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP) || !urb->dev || !(bus = urb->dev->bus) - || !(controller = bus->controller)) + || !(controller = bus->sysdev)) return; if (controller->dma_mask) { @@ -925,7 +925,7 @@ int usb_buffer_map_sg(const struct usb_device *dev, int is_in, if (!dev || !(bus = dev->bus) - || !(controller = bus->controller) + || !(controller = bus->sysdev) || !controller->dma_mask) return -EINVAL; @@ -961,7 +961,7 @@ void usb_buffer_dmasync_sg(const struct usb_device *dev, int is_in, if (!dev || !(bus = dev->bus) - || !(controller = bus->controller) + || !(controller = bus->sysdev) || !controller->dma_mask) return; @@ -989,7 +989,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in, if (!dev || !(bus = dev->bus) - || !(controller = bus->controller) + || !(controller = bus->sysdev) || !controller->dma_mask) return; diff --git a/include/linux/usb.h b/include/linux/usb.h index 7e68259..1487526 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -354,6 +354,7 @@ struct usb_devmap { */ struct usb_bus { struct device *controller; /* host/master side hardware */ + struct device *sysdev; /* as seen from firmware or bus */ int busnum; /* Bus number (in order of reg) */ const char *bus_name; /* stable id (PCI slot_name etc) */ u8 uses_dma; /* Does the host controller use DMA? */ diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h index 40edf6a..4e8590a 100644 --- a/include/linux/usb/hcd.h +++ b/include/linux/usb/hcd.h @@ -437,6 +437,9 @@ extern int usb_hcd_alloc_bandwidth(struct usb_device *udev, struct usb_host_interface *new_alt); extern int usb_hcd_get_frame_number(struct usb_device *udev); +struct usb_hcd *__usb_create_hcd(const struct hc_driver *driver, + struct device *sysdev, struct device *dev, const char *bus_name, + struct usb_hcd *primary_hcd); extern struct usb_hcd *usb_create_hcd(const struct hc_driver *driver, struct device *dev, const char *bus_name); extern struct usb_hcd *usb_create_shared_hcd(const struct hc_driver *driver,