From patchwork Sat Feb 11 01:27:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 9567767 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 0DD0D60572 for ; Sat, 11 Feb 2017 01:52:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED41A2853B for ; Sat, 11 Feb 2017 01:52:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E1097285BF; Sat, 11 Feb 2017 01:52:13 +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 63BF32853B for ; Sat, 11 Feb 2017 01:52:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752017AbdBKBut (ORCPT ); Fri, 10 Feb 2017 20:50:49 -0500 Received: from mail-bl2nam02on0040.outbound.protection.outlook.com ([104.47.38.40]:24760 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751802AbdBKBt3 (ORCPT ); Fri, 10 Feb 2017 20:49:29 -0500 Received: from BN6PR03CA0026.namprd03.prod.outlook.com (10.175.124.12) by CH1PR03MB1948.namprd03.prod.outlook.com (10.164.115.164) 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:18 +0000 Received: from BY2FFO11FD048.protection.gbl (2a01:111:f400:7c0c::189) by BN6PR03CA0026.outlook.office365.com (2603:10b6:404:10c::12) 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:18 +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 BY2FFO11FD048.mail.protection.outlook.com (10.1.15.176) 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:16 +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 v1B1kZwM001095; Fri, 10 Feb 2017 18:47:04 -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 v13 03/12] usb: separate out sysdev pointer from usb_bus Date: Sat, 11 Feb 2017 09:27:14 +0800 Message-ID: <1486776443-2280-4-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: 131312512373961371; (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)(39840400002)(39850400002)(39380400002)(39860400002)(39410400002)(39400400002)(39450400003)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(33646002)(2201001)(50986999)(50226002)(76176999)(5003940100001)(5890100001)(305945005)(7416002)(7406005)(86362001)(575784001)(53936002)(2171002)(68736007)(356003)(2950100002)(4326007)(2906002)(6666003)(5660300001)(47776003)(105606002)(38730400002)(106466001)(77096006)(39060400001)(54906002)(8656002)(92566002)(189998001)(36756003)(626004)(85426001)(8676002)(81166006)(8936002)(48376002)(97736004)(81156014)(50466002)(104016004); DIR:OUT; SFP:1101; SCL:1; SRVR:CH1PR03MB1948; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD048; 1:nBtVHIkG1zEuFeAMxIr7yBLmeYJYuN8vuu2Jz/6pzyvogJuivfzsXjfW9Slk+cAjyO6eLgmliooWEmnnHS9qZ7sctEDWOLW2I3pYyj86NiguEQe/DkzQC6HKp4l99ghKA4UpnzSX34hcuAA/FGT5xmb2NWBrly1U9Lo4HDiIeaxz1BMXwu+GAVMJ57/ctTnTvGsUnvAQ2jh7rv7ZfywdY6mk6/SrFOGvee3dc0SUCReJzJC1oty4qKMus5xrgQlf0ckjEIQNFpiQGduqBLILD17o0AH3kMTm5UBDB40tSLVJrHQWZ/ATEXubMAX+bC8phCqfLgw2WzNVVR5/BL30DSmRSV6J/3kV4jOz9ky3V2axLEclaam1zsF1TzaZGyCHNtm3IU4imrW0pBjfFjXwyGLhDtxgTleZODjSo+EuAWJyuFkPhAL4ZKUeG3dcqV5XCsooEaZnG4KVLhEuneXE7tHEorFWNnVZzOzQGlfu00QVidJv84+aBIsH8E7dMGhNDTRmCWh97JSIMJEeR1JVUQ5UQa1p0NYTOd6Z2p9gl7sz6SzVU6i2TjFGDn17rI35rtDKcAj1XDWUvzQAn2uNE35zGu83hh246hzIFyS4neDwmAB7RjKNMODwWKilRGrgn0VRI7/sxN83A4DCOwa4yw== MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 3eab3220-4a44-48b0-27db-08d4521fe901 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:CH1PR03MB1948; X-Microsoft-Exchange-Diagnostics: 1; CH1PR03MB1948; 3:drvYwVT2uJEWVPWG60CIUHdor/OwJPSf86I2hKvdkPknjkiJJNAyvZ/t2Ayy5TxBTzq+WHg3oBHSf1RPG2xiWYTG3pOOPJbCop7VQtMsomrIFLegiiVcCWynjH0RnP85zGK/CvGKEroooqHyP+gI0I886vSePOFnpHUjoUdzKAIFg+nJCE7yEoEUahBtFwI9rXK6ksSlZVyyRh8yQqGRRhxUpabzPhcOwMkoPJYSgBYs8IXSYZidUY8chofiXPU0fbptHlty414avkmDwyAAI4s+1+cALaHQguV0KNdoox8sN4EoRjn5ClSlcc0DRCvkaYGCPWp4b9b1omssj4+DxcSkoltLf5Yaj54MGlVpHJXJ55NeVzGcgsHqjayiGcZS; 25:35gz0QvCnnbMdCoD3RMhUN/yDD6/+MXkvJLj1wtvLbzIGGiYgM1OOyAjp3vxwR+NJwlETRdL16GpMgo6Rx/f0ZO89bS1HVYhTr+YxGlZtK1S9j0PKTVVtbz3lZyd29h5NaWxZABDCBiMmaVFiXwcy1G6+u5wdUekdMcmBj0F7mOWjJr+61lGVkyUUSGXhyk3IE+uLRnszWZoam2jJoikR2Q2GOqaNHNkN8rmmonEh2nfVdfVyVYkfqPAUtJ/EO2+k6ighRF9KpYpZgKf9FRdhj4iSHLslb/Rw9RmoflPmiOTvTSdGq+57gV1uBEhepRLx405IQdgba123Nhp1b8MoVUv8iwxZCZej9aArzC0coneXR8CFmQVLmkxoDZCbL0ILCgNgeQ47HM6goSg1IO+nz1huc+waSwMPpCMuGxupfU5L95uQ4HZik9F2DkHts2j9MfCXDIjQX9uC/k2QMF4AA== X-Microsoft-Exchange-Diagnostics: 1; CH1PR03MB1948; 31:tAqpcHRso24cMUoY9nNvwQjwitbIMqthQQxoKLTfXQEkSiyaxTlr1rU57/s3fsNXw5U6W/oNqyKt6Y3/3oO+8RRZTuvoQwHRjpytnMuItHVZmK4LFawB+e7nAftSoqYuSlFEtevJ0huOBXbJzvaq/8DTNsHZk2O0Lt2Gj83AkbY3PtKo0R2dLYrKzuHPz7G9mr5WUW7j9xQkuheck2ZdmcIH18UDlo1VvlPyXiGJdjvwq8xU2NsQxjfYl8l2i6Vi5l4LcnAfuJdp0MeYhZAlhA== 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)(13017025)(13015025)(13024025)(13018025)(13023025)(8121501046)(5005006)(3002001)(10201501046)(6055026)(6096035)(20161123563025)(20161123565025)(20161123561025)(20161123559025)(20161123556025); SRVR:CH1PR03MB1948; BCL:0; PCL:0; RULEID:(400006); SRVR:CH1PR03MB1948; X-Microsoft-Exchange-Diagnostics: 1; CH1PR03MB1948; 4:U0SdPlFytPwIPhvraFN1SyFHHj3RPx466xPC1M7hH29VAQCkv8lygYHRf8e7fpccMhIX+xmR8+jldW9ABwaW866pwoCeJx+pOMdr7diAKbbAa47W0VS5wEHhNVXVGNQVLLoZeDqvSttv2TuyKltlpJ1aCUC9G7NudyPmXgXfJilQRt1cCXg9TEE4f3rde7IzSMv5lF7yTYYdvFCpDXCcdkv/sh3d2HCyocAGRlV3uqzKBREPL4iZkAttUDiTKVItacKnKje/+BwrkWiw6D8R+mXmJPimxUB8126XgRzYSLxaEbGXTUEAB+/XDNounQiqvjuEgnxvQzAbIUZJnawupEo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w1TzMbZOTHchlVlz9uL?= =?us-ascii?Q?/M/R0EPCAvDbsySPnOnqQL7qLDxllbZxW1P7Z2emZBFwYeqHQd982pJSuCnD?= =?us-ascii?Q?7sfMWA/J1wslvuKoEH63gDPAgrEs8CR7++Cwst8KbD36ng1FtxnxuoU1eIzK?= =?us-ascii?Q?cz0IVVoi2C0aRe8X7o/sNfMujob7q3Am5O7TZr3ahzjJjUb?= X-Microsoft-Exchange-Diagnostics: 1; CH1PR03MB1948; 6:RkoGyK2HKwpkzfp8+VAoDfxrITIgcvjU8qV/+VdhAfgjmZV3fd+6bOXqY53MtG4T3vkj5zRfV9iujbHfOXrw0/7t90ZpbJxtaHZdgC4LLxQdmxtxsGrwyuETEvQdLoZM3nHlfKRpydC3X8VnnVBD9IGwGTJ8Ikk1WJVYSgD6/tjrwdxZDA0X1gCstO3QsmlTVpnKBAeTizx0XyrhUg6E5YUNkS96jgZFMDcHqpC24bx8obcLeJRMmrrW7xVFT9uNanC9LxRpWH0y0pVaXXTuf5D/PGjSTgOqVP0yyem6ly4s+YALA88gI0nb55SV5H7Fr2L1tz5zgg+ZpcaNpm8H02kOqvBETDRMogY6Ks6hqFcAPUpJmH8O4cP0k6PjzGxld20FHSJRp3vkbkc/k+0WpAGfKG5EWiyohoEZDd5fwUk=; 5:Zx5xpzlO866or71z00TewObJ2ESz0I+fyL07wJDE5KnwHYnY3IAMx06RIivbgNneNNIL84+IqUeA4263Z8lDG1SB2460LR9myAmt/3eIr5IzWjAa7lRP8ZMufkMmDIVSc/JqLy85xLLv+dMEVGNb5JJpytkjyhgVZz9cs1sagcaosshUOh8akhjVVIbyN+lp; 24:hbR0u0DvT+9ni+u3dUt1LRFe0JSmWi2xl183LqY6oBOBbzql6z0z+IUPidx/otVrw0MUxzObXWLiJL3I538nIaIga9cCIUZIn+IGB5qBZ7A= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CH1PR03MB1948; 7:emSkPhc/kZRxbEoySV9TxciCBmxNURSdnMP/ufrGKImPj/z2AZ+8fr61hQ8FLX0zqPvyLheicZDo2Fh8y+4hAyy0yiy7Aftg5IJN8xwKGVRW8MtVwQl8JXgCAO7mjgRpBeALT6KXkt9+G+vr+LOhLk70uzGQ+o8t+MCHZNPlkfrjAzAfSycra3auS0fGMtVDQmbnQHppAvqChMjVpcVbePkDhd5d/O0jirMWIfbglhjkaIvaT11umQn+xVzN2DlZdl7vDzfjV4IEr2laSusWdeHDe9euPMs2dHucvlMUanykryd8hj6BaoZv5PjbKCLWvqHz4Gc1KXhYd7l57zTcz90y+DOva3xfuOZbIceosVFjbQyqcvIfA6iG5iZzU1M23YHLj96ucwNNteHZnnOOBD3QoU89e/XRwYJt5TCqLbZJinseE+a8TF4Eq2hAw06QbrSI6wNLaiE2oNpHk1vET1OkrDufbr41TbOKawlyUV/UjyFL97zvVRUvwbxCfgsWQvFeiwW7ZTEyOoRYOauvuQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Feb 2017 01:47:16.7253 (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: CH1PR03MB1948 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 | 80 ++++++++++++++++++++++++++--------------------- drivers/usb/core/usb.c | 18 +++++------ include/linux/usb.h | 1 + include/linux/usb/hcd.h | 3 ++ 5 files changed, 64 insertions(+), 50 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..2342c1f 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 @@ -2495,24 +2496,8 @@ static void init_giveback_urb_bh(struct giveback_urb_bh *bh) tasklet_init(&bh->bh, usb_giveback_urb_bh, (unsigned long)bh); } -/** - * usb_create_shared_hcd - create and initialize an HCD structure - * @driver: HC driver that will use this hcd - * @dev: device for this HC, stored in hcd->self.controller - * @bus_name: value to store in hcd->self.bus_name - * @primary_hcd: a pointer to the usb_hcd structure that is sharing the - * PCI device. Only allocate certain resources for the primary HCD - * Context: !in_interrupt() - * - * Allocate a struct usb_hcd, with extra space at the end for the - * HC driver's private data. Initialize the generic members of the - * hcd structure. - * - * 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 +2538,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 +2555,30 @@ struct usb_hcd *usb_create_shared_hcd(const struct hc_driver *driver, "USB Host Controller"; return hcd; } +EXPORT_SYMBOL_GPL(__usb_create_hcd); + +/** + * usb_create_shared_hcd - create and initialize an HCD structure + * @driver: HC driver that will use this hcd + * @dev: device for this HC, stored in hcd->self.controller + * @bus_name: value to store in hcd->self.bus_name + * @primary_hcd: a pointer to the usb_hcd structure that is sharing the + * PCI device. Only allocate certain resources for the primary HCD + * Context: !in_interrupt() + * + * Allocate a struct usb_hcd, with extra space at the end for the + * HC driver's private data. Initialize the generic members of the + * hcd structure. + * + * 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 *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,