Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1767514AbcKQLru (ORCPT ); Thu, 17 Nov 2016 06:47:50 -0500 Received: from mail-sn1nam01on0089.outbound.protection.outlook.com ([104.47.32.89]:49940 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754090AbcKQLoR (ORCPT ); Thu, 17 Nov 2016 06:44:17 -0500 Authentication-Results: spf=none (sender IP is 192.88.168.50) smtp.mailfrom=lvd5587.freescale.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=fail action=none header.from=nxp.com; X-IncomingTopHeaderMarker: OriginalChecksum:;UpperCasedChecksum:;SizeAsReceived:1604;Count:11 From: Sriram Dash To: , CC: , , , , , , Arnd Bergmann , Sriram Dash , 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 Subject: [PATCH v5 1/6] usb: separate out sysdev pointer from usb_bus Date: Thu, 17 Nov 2016 17:13:43 +0530 Message-ID: <1479383028-27701-2-git-send-email-sriram.dash@nxp.com> X-Mailer: git-send-email 1.7.7.4 In-Reply-To: <1479383028-27701-1-git-send-email-sriram.dash@nxp.com> References: <1479383028-27701-1-git-send-email-sriram.dash@nxp.com> X-IncomingHeaderCount: 11 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131238566538769674;(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)(6039001)(7916002)(2980300002)(428002)(336004)(199003)(189002)(36756003)(76176999)(50986999)(4326007)(42186005)(33646002)(356003)(86372001)(106466001)(105586002)(87936001)(45336002)(8666005)(626004)(103686003)(46386002)(2950100002)(8676002)(97736004)(960300001)(81166006)(5003940100001)(47776003)(7846002)(42882006)(7416002)(6666003)(101416001)(305945005)(5001770100001)(92566002)(81156014)(90966002)(5890100001)(50466002)(4720700003)(50226002)(5660300001)(68736007)(8936002)(189998001)(52956003)(48376002)(2906002)(7059030);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR03MB2478;H:tx30smr01.am.freescale.net;FPR:;SPF:None;PTR:InfoDomainNonexistent;A:0;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11FD019;1:MX+xi4YoNI8bkndwJQFCmmHxFS1vbXdLWYrpkIMKyDRWgADWaz0mFsIVA88/KpxYeMDSUyDpKGDiQc3UuYl4n3JBBZMgJQ+vmYDZr8a0egDxlKsNu/lv3Ohkn8Ln0cdYXwJETw4m2zrgLnI5cv9lHbXKnNb2taVsW0PuW8j6QOkRPvOxzzlByqsTxcStchVCOBhQWWmAGD79wV538adywWN5JB+4A2erqx2D8CqxS5Trz8GjOssu3Bm0mEKfhUl0kW1uXzsE710Zq7g8cJMGjwRpbUMi2fxDvNWGym5QiCJZ36rVy+0IJ6+dd5m2rSrfXmQHWpSk1W/rAzhFml6WB6T9/po5lyo+DmOoY5AUy+mgeG1i5iegJxzMgCkaA2sZ+opv4RYgJD9LsIeAJUO4IzNCaBif92kQLaTdTJ6f2UEFs8P6uHP9KJN6kB5BGAKKWdAxLkkOfuLyDtzCcdO81pyivjwjv2Sf6k797we0U7C+XC3kS98qacXTyZw8WM5g2XojB65PPtQAbu+eA0AzAWc6VBE7sZ3dp3jeqAJMSoeDqaF1UDAVb4XbvEs3yr1fm+naWgLgmQ0/gWQkBY2zmBjJbA05e/PcUUnWT5i4te+INciE3AGGXAmNB5ICYStuCI+xC9N8shaQcwWP7BR7IQ== MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;MWHPR03MB2478;2:WuiLdxGGzuVHEkrQnOxn1ezLvWBA61NlIQLagZ2HMs/cI6/5uzVX3FT1XHa7f4CRfy2I3iTZ4Av9AVmWCD3q6SdxSE2ltqoIv+klfZtZ8CpmBY0gQPNUdwGg5x34flVyUYi2oPuGGpPID8xqWxT5oqrYIH5QSqZfznQPeqhQW8c=;3:nKR1a4NXQ9xpzj1PWYA3SmWFw+e0YWkfsYx4ogaC7HBPLXU1GARvKaMkOPaffSqtWMBQ6ygkNxZDY8qQW61jp3BQryjQH9yBTkxqq68zoRU2scJSGusOFe37EZ9EA66qdpcj+tJe2cBgIpmrePZNjRX4b/HOT0qNmOW+XbAw+7snLLUzEXBu7KaG26y01ikGRu0twbFBHJb+Y7fWaS2NtTfflyFSjTeh0If1kSbTs6uuEbT7CcwrMP57O6JYKIMv0OvlxTUJiWhJTh+yefbC/w==;25:L/8hob/+3ddJ/SkDe8sUmOghzSbqbvW59+y48h2xXrvi1fpRG9ucGdWfqTM16Uw23c0W3WQHEeRcDiJHkZoDwVPGdKkkP+zvA703E37XxGiJRuV0xHvObE74hRO9Cd3ugRXydWY7WO845dJvUYG5B2fLLBSb+KIaVg+jCoWP38R7v/BlMxYIJ2DCtnMb/N+1wITR0GWZYb6b1TDVbxoNe4YsWc2vCPVLt+W17dBjqn8tTzq+IpScGfLdQz3Kmd+QpkPf3ebIjF8WhaGGmwz2qjQAEHMoXdRaH3mPM+sbeiOgPTkiBfxh42tTdVaI+Zj01UMW44ZNk/MuLBwLWK4ww1ljlapOByT0MxvCj7Swisx78lAfu/FP7gpWdsWDGWbxlGC0TzXMwUItdh91LioaxFNMTpbssLPE5qStCKrZs0jtU5KKFK7VWL7EHe9G5/hB+2vTdoA11qnUPL3/2lMTQw== X-MS-Office365-Filtering-Correlation-Id: c6460997-61e2-4b33-88a1-08d40edf0dc1 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:MWHPR03MB2478; X-Microsoft-Exchange-Diagnostics: 1;MWHPR03MB2478;31:BJhyVzLFgH7nxXQvuPWBjvO9guogDkl3/GGLKpawkJBfzNIIL0RtgnsVELFx6man6/Q3ykPlFmeQUA/shdr4bnMobbBucnQD9QVshbC128lJww2sdFf4g5I4wtGixfSP7i5R9ZWSs0/tGOcsBfO1V05uJaH2Tv7CkeSbPHN+Vk6Nkchls5l5krm5aDQzelIHiUvqkG5YJCWctdEyx0+O4d3qpW4WJ57QqIpleUayQ6z29gjQao9s3DIMXMP296fUW4gezvK3Cy3/gPAj2paI4GIJqbSkqyEQGwZ0Vzfo10c= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917)(31051911155226)(185117386973197)(198206253151910)(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6095035)(601004)(2401047)(13018025)(5005006)(13015025)(13017025)(13023025)(13024025)(8121501046)(3002001)(10201501046)(6055026)(6096035);SRVR:MWHPR03MB2478;BCL:0;PCL:0;RULEID:(400006);SRVR:MWHPR03MB2478; X-Microsoft-Exchange-Diagnostics: 1;MWHPR03MB2478;4:W7TPmEk46hKV9XHiZgFXfqslVDjDKVhQaj1cswAG39GThJjpH8Egnj2bb5IlV4cdo2cgH51yK3SSoSFUJfdH5vqj5Zh762QkmS81jDrk4rSjPzGYhYf/TQVYVysA5GmyZ0r12IXKz8FLbsLHzrGUyuPs+V7iQ8+fiqE2nOjEiFZynTAkGdXpcfQVkJQOOe+LTucI4oa5xT6Bhq01PWKyeRdjhk8uFh+f+lZbdAHTl0/0l//4+/jAIwcoaciG//gkBSRosgQomJEOs8J7q/KZ5c9vZFOwy88HgP3u5JK3Gkw0lTvBOymWvD/ADsIgvR3p26uGyqd2KOy8PXa86w/057iOcrfrIHtn6XLeFQqXd60VS1/ba/EKclj7j4PtmgfkvuHP2+3VIlYQlsnwzkX1R942M23CVWvEs3xVXNReR402gZhv1BcGAuwdKYY0NinrdMLcxEmmjgqgphbNtcGWv20aU6Dplw95tnINhXsxkFZUjdfk+auvhe7NjIFlvspcgoTynGJVi98ukYrm/i+DvSjBAldl6+tt9TnwG2CSVTKOIAxVymv3yqZA6jQUtZLCWsoNTyaulF/K5jtnJwkStIBKvpCGYtLn3Z37aPTzlemCqBCgnuYd/UBxI63/OaiVgxt0uwN7XjQe2gd3l+GxMbtqxPdcxuKaJOza4DNeikAbiw6QyzSUVyLZcdeXHlplBkYgQmVivUIxvw8TbVWUjg== X-Forefront-PRVS: 01294F875B X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;MWHPR03MB2478;23:DeSi0YpMk+GGT5IXu+AVlnc5SjGJc2jPyFSv/eN4f?= =?us-ascii?Q?qePu/NH++GcnZqCmF8ezmH0FIXh927MCQzCJFEIo6WGoHsCrZrskEB2NiZAv?= =?us-ascii?Q?zW/cfuR5YpqqmF+Mh//hwH9lSQLQSXuMmrq+W/v4ZBSL53hwymB0UPvn/Pyl?= =?us-ascii?Q?2hWaHqYreWJwfZ6yfGlW8DhZvFlqijuIz64CZrluew5ArQXyANHi/MlHt8nv?= =?us-ascii?Q?eVqkSv0r23q0Egh1Oy25fQ7ml+ooFnnct40ttdGHqOGYmcifnGwP62haTWM5?= =?us-ascii?Q?UdiTFveK0g5K4HHRYU9YqYkYOR0G6HYUb9qu9fJMarWlM4pYgjmO6hjawZuk?= =?us-ascii?Q?dRG0IP4hsBYBhYoWbadm4q4NuQDvs5HVPjGy3wHwZ2Gw/ma9uLHXulCXqVcf?= =?us-ascii?Q?1rcBHwLHf1ex/s74KQKQ6KjdyRO29AbEICaQT5eNM9WR0V22/hZX/aboF8PJ?= =?us-ascii?Q?Dt4bGXqWS4D6T5L0K7+C8ocUIn8M+0sjC5IKDZ+FheP4+3sx5djxYQskcVaX?= =?us-ascii?Q?G02wakxHcJkaK0cuQvMiLvZu0h6PxhqmD6bQkMswx3iEZMQQ7ppTg896i6aJ?= =?us-ascii?Q?fGRikExeAEo5aioHiIKfZ673BEswjMdsvzE79OYPLSVMS2ll3OJ7VKzbjATe?= =?us-ascii?Q?IsJtKx6Zh8O+Y6i4AdLCt/dqf4vLaqAODZAqdmSslDr6OgEOYaZ28tkl6FZq?= =?us-ascii?Q?GgOwQOpl1OvcXuF5DnMdMr3vYO/HDtQo37bVHngjI8U7tH44UjOhjxwQZidz?= =?us-ascii?Q?XKLVwyueA9p2zsi62fAnrOxvb9ca40XHHaIgVyxyvSR57mNEZTQ1ciqoGIY3?= =?us-ascii?Q?Mds2wV+la6lVrthwTtUmg365Pxs42vwrmPGjTb3/Xj1VRYPh2rJMhgjk2wU1?= =?us-ascii?Q?YTNCYiDpNt5BGEVGUkBliyY1b2ecQYjeOynG+I9d3OObJmxrQ7g7xi/UlTq3?= =?us-ascii?Q?ZmR1Uv9YGufvzvOClR/nDV6yaakJtjBxYjD67YGW8wi+wKLJKj3UVgi3Y3Oh?= =?us-ascii?Q?+gtcT2WhRKcWgBE7X35UDtf0qoKgyIPVyDgHY1mY++17ALeoCZdsD7Q2MJER?= =?us-ascii?Q?lEnSR0EkG0E2z7jaql710DAfCMYEcDuYU7lyTFWB+JjrZRxZPv+zrJ9eJ/tq?= =?us-ascii?Q?liB2tnBbP+k+Y1Jizw5Cvygeaqlq/mb/r/bbUNuvlyusaq/+mIF77P/iDdxl?= =?us-ascii?Q?OEv1Tf+OKmDFu+Uua/TfgC6oAi/rVC5idsRPrbULSAeG1TvfxaA4Fhew8yDf?= =?us-ascii?Q?RfS/qpGTaFGLanaYWTkFCoZH3aPGhAe0VeqMMZF?= X-Microsoft-Exchange-Diagnostics: 1;MWHPR03MB2478;6:mS3E1mcfr3F8Z5B0Dv/xHAGcwliFaQblxnhfDUVEY8Uc4dO+/19ALsXi1hWUVNB9wK6TtIeAzSZOssBdwdZhard0xBWFt7VobWh6wJyGBOyr21M6B2BEocrqGSle7D1H7YgCmqMZf+XMI0lRW5Dr57kfHytGtaoR5nH54hlMxDiKRBRcX1QVQzl1VdBotsLauhT8WeKWgOlvruo4wX1t78wrR8EMDNsPp9aKxITSsIVXbVv+NZdc6WrPGtnlAhJ6pjt4ujpEmQkUR/J81jNeDeHC+6h1CwqTbRlC+YAKNHqAiW0q7xeTABziYLZUFTxh+3VcCBetJYcyUdIEKTQqFg==;5:pYqCDa17T1GvDaNqiUGj2OWCkz7Xa9GaDo3IP76IYhiW3CrrFYP6i4sUxOuTkX2MM+22DIOfyPyuwkBC6bznJwl5FpI057U+8fv6JzBHkk1UGwFUV4fCxfQrfhGq/2ZGvmD7+WBbx5kom2bAhV24rlttwQQ4Asn37rLAGDSvVPWAi2ugTBjK3RDYrHfq0Baw;24:xLG0UzjagD7nJpPB590sQGEgfnRUFLwcKTwXyRyBnQVQkwSVkN6qUF/JHH8S3FjMTl1JfqGdSkZSiDyqP68YZsKNShFvv8Jn4NqN5wGrxmQ= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;MWHPR03MB2478;7:7GFOLTVzA1nT0whrXW0u50tKywGc3lV2XDghuu3m9/o1WkFzlGavSW9t6Z0DvfAPSNUWeRtvtwatT9TJEed7slBSdSW1ennxk31qQhG6DA4SlruRiwYEhJpIiBd3f3Sv+YjZtjFJDfx37xoC8MMp8uWPVf7t503pJJojLr/dGcVLhwZi8z5jYiZHWgI1eA6W5FFM9vYJny1oKfpMMvm38NbJQho45Y/IzHL2dsnQ8btr/5TSpdUA/jwQEYphTQQB4RlHAlWTyw7kXORaAKpPhURiA1awnGibmFdtC5bzRxZk3sZIz92gtOgVvecI5LheN4KT2g+2zIObW2Hrc9XKAcvRkn3hIQWrqcQimNKd/48= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2016 11:44:13.3933 (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: MWHPR03MB2478 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 13466 Lines: 388 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 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 --- Changes in v5: - No update Changes in v4: - No update Changes in v3: - usb is_device_dma_capable instead of directly accessing dma props. Changes in v2: - Split the patch wrt driver 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 98e39f9..a6cd44a 100644 --- a/drivers/usb/core/buffer.c +++ b/drivers/usb/core/buffer.c @@ -63,7 +63,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; @@ -72,7 +72,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); @@ -127,7 +127,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); @@ -137,7 +137,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( @@ -154,7 +154,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; @@ -166,5 +166,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 479e223..f8feb08 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 5921514..3abe83a 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -450,9 +450,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); @@ -800,7 +800,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) { @@ -838,7 +838,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) { @@ -872,7 +872,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) { @@ -922,7 +922,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; @@ -958,7 +958,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; @@ -986,7 +986,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 eba1f10..f3f5d8a 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 66fc137..3860560 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, -- 2.1.0