Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754764AbdCGDWo (ORCPT ); Mon, 6 Mar 2017 22:22:44 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:32112 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754614AbdCGDVv (ORCPT ); Mon, 6 Mar 2017 22:21:51 -0500 X-IronPort-AV: E=Sophos;i="5.35,256,1483977600"; d="scan'208";a="1126757" Authentication-Results: spf=pass (sender IP is 63.163.107.21) smtp.mailfrom=sandisk.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=sandisk.com; X-AuditID: 0ac94369-1c3ff7000000728b-2b-58be00693a7e From: Bart Van Assche To: Doug Ledford CC: Greg Kroah-Hartman , Sebastian Ott , Parav Pandit , , , Bart Van Assche , Bjorn Helgaas , "Benjamin Herrenschmidt" , David Woodhouse , "H . Peter Anvin" , Ingo Molnar , Russell King Subject: [PATCH 1/2] device: Stop requiring that struct device is embedded in struct pci_dev Date: Mon, 6 Mar 2017 16:35:48 -0800 Message-ID: <20170307003549.3872-2-bart.vanassche@sandisk.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170307003549.3872-1-bart.vanassche@sandisk.com> References: <20170307003549.3872-1-bart.vanassche@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprJIsWRmVeSWpSXmKPExsXCddJ5kW42w74Ig9Ov+C0+NLUyWyxpyrB4 ef4Dq8XElZOZLZoXr2ezmLZR3OLyrjlsFs8O9bJYHJq6l9Hi0oEFTBbNV/+yWJzqOszowONx +dpFZo8Fm0o9Nq/Q8uh508Lq8eDQZhaP/XPXsHs8m36YyeP9vqtsHp83yXmcaPnCGsAVxWWT kpqTWZZapG+XwJVxcMVOpoKtkhX71rxgb2BsF+1i5OSQEDCROLzxNCuILSSwlEni0VTrLkYu IHsro8TEv79ZYYpuNkxkhEhsZpRYcH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mz2f7x+ULnhyYvXZ2hSbByWHf0kc0sy9ZP2wTffZ7u8/mWumFBS/CZVI/XxxCWeEdUnA cfWD/oK2B915fd+YfayKUy39mbHDtvb2M8HmzkMbj1S3FodwMHO8NwxffjB5cpH4ybblbb/8 dy77srbUsWbPpx4TxeVKLMUZiYZazEXFiQAj64mA/AEAAA== MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:63.163.107.21;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(7916002)(39840400002)(39850400002)(39450400003)(39860400002)(39410400002)(2980300002)(438002)(9170700003)(8676002)(86362001)(81166006)(92566002)(36756003)(626004)(50226002)(38730400002)(53936002)(77096006)(2906002)(54906002)(189998001)(110136004)(356003)(305945005)(7416002)(6666003)(4326008)(50986999)(33646002)(1076002)(2950100002)(50466002)(48376002)(76176999)(5660300001)(5003940100001)(6916009)(2270400002)(47776003)(106466001);DIR:OUT;SFP:1102;SCL:1;SRVR:BLUPR04MB516;H:milsmgep15.sandisk.com;FPR:;SPF:Pass;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BN3NAM04FT052;1:e3I0fQMSMmUb8P+lT5OTEIYE0ED+Ny5DqItwIR3+fwqrt+i8scW1jNI48ip8VZgzyBoCSHgwoVLQ12wRKtlL1mjVG+4LGOKruKQlmHRRyMGB0R3beLhIm6m5YVWDxLiiyOTygQZU6IE38atueVFa8h1Mcipsv+m2Tg5mQp+BY+fsvVIbmBNu2Hf67zmUg+hI3XL+GMTiE6Il9qvneQJaE7CD6wKnxtcJnPH8tVfJtcSPO+zuFZZYma/2095l9WjEZz3vkS+/V4XSS86UpJLTf6g/vnNHXqQXRhQqEu8uMXm0W1G9ab06HgIRzHkP3sWsiUmqvkBZeVr19RN6mHkbDTuW3kRcci3KEN3nDZTfNlzrX2DYJXw6KOcjXjRxLSk33RMjTsOje54Qx+TTdRXG9eDS7vsreljCvGjDx7JXkDLR7wLtB17nk3CIwlqopa4Ph5daT6o45ut8pG5TUXuNI6uZLu/bIEUf725Ecmko0gVcKOXgen5mN/P3i/cTNN+k+XFVslN6AIha7edGzq25Egyrfk+bn/xOnXb1IEWRgEk= X-MS-Office365-Filtering-Correlation-Id: a2d9cd0b-b62d-4b47-a7a8-08d464f1ebb9 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(8251501002);SRVR:BLUPR04MB516; X-Microsoft-Exchange-Diagnostics: 1;BLUPR04MB516;3:fD4jFeCCgK7uiRGLUcQ1cQHYewiMJi/tN9WpFLbKAXxGKleK1Dzsrto5AhLJircA7cnk76letNfZpoIrrRuFnvJ1brEDKzYShD1DN9bgYPl4SkbTM0O5M+jnHGfgmgDBHNRl/83Yj83BFjgBwwxFOd4IbjXMxrIROAVHdjOl+uGIrvA7IMroTnCLkKOKktKJ8Ld9AqmoYAWsnDOnzDdVWTmecembungO43AZu3hbpGtX39bQcd1NXbfb4tyGE3FFVPFxxOe2DtfUhMDme4/CN19xERgxfK7O0ht/73yLTiaJTT2VD+zGQRkThTh+b0rebqZ0GKRGp9f5LZjOhI6pggzieaZ8i21sXYGP+dnv0HF/jxSpT0qCqqmSCD/xrNjfrpOqO6U/H4C9fTp8btHppQ==;25:BQEhgG5SThw+cTqx9bqA5qgvEbfsSmEj985NWXu5KrC52VBTzufw70/gzAYNbo/xJ9RHe4ybXYuqm4ix1rCUvGKDI8hoLuoBhVoKjgajVQRr5WvtYFnP6Ft7a1eV7iDFXJ0plOLXVN0fxMcF37HgYIUMiwYrVUlkQ0sQkkH7NeTsL4HfVpEN2EQeBsGU9AEv6srf42lb+qyyebxEuacjnqCtbwhVHbGJoab13UWQ65kCY16b+uqjJxOCe1+kqSiDoyRHsjnNDHfKWPaWAa6Gpqsq3wgttckSpFEP3aOoz8S5UsdtgF8+yZ5+rNFm1d/FL/XHRNqwRzIMWG3jMMNdfZYQanUz4hsmLibb1j99+C1QY9fiJjBc+dSczOsz++UPdkOo0nPvkJyQFUjEItZCtCAt00X8OiVodwbJIga1FTj0OUQRUIIFRfV6672ntqOOlZGQcR9gMw7B/ZntumRFTQ== X-Microsoft-Exchange-Diagnostics: 1;BLUPR04MB516;31:X4u0AF69G/0HwjdE7bsMg7UHKUlE1Oy3RCDNfxhSYrbcVghT1d/hS/WnQs8WIJ5EC2xVcefIzSus1+sNDPMt227GFMoj4SCGZwHAHVkAY9h+2vuVco6WHXaHBbb0dqTLjc3ETfThPY2jXGh6HAE2zkGPZX0k+s0dAPKG4Q3R26HHjBYEhdLYrsEUCGR7KWwjFtyx++UKNOeg13shETZxWw9fBLfgXKtSQYr7vpPuken3S8SsCeYPOrfV+YP0fQ1M9zn9n4s+XrJBlGrTlCIwNQ==;20:mCHtk2ID3JJWRxXDVV2QFlQ+aPkUTiYMRCUL4l4N3U/LbPxTsV47MRI3WEfABsLEUUPsi02d+JpboJZ8hWcXtg8xGYsHbw7EMdXwTBio/P80ClN1GXsSuBGP3pnIP41SAIPt4jal9rkhMEKv7wAqOoYfy/Jcy57tysoJexlDFcsPu7nTPgehWI2qRNsSlRz+2oN8l2TmFYk8qs2043/79peRFbzkAhbjGlhf7+7R4he2QPbm6vTfKQgEJVOG59GCh5MtIscq7u20B277AC/82QWfA9c73eZj8s52/OL0u1LqVqDZ53Mo2HKX3WLcS6/WM8KGaoyjkeOpVpSb86pABB9HmOlbHyoA3FTcdf/FbSYDLaAp8VFxXdDwu4o8InUUdy4s4YwzuGDO1dtOMm/IPC160s9nwpwEeydrtov6pL6xTNa9hBlV/NQglv9AXC0h2ENtiZQQafxIuBm6OpcGz4pfvc6v8XLzL7KDZ3rfu07mPQHdLOTtDYtYgvb7z2un X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(211936372134217)(42932892334569); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(13016025)(13018025)(10201501046)(3002001)(6055026)(6041248)(20161123558025)(20161123562025)(20161123564025)(20161123560025)(20161123555025)(6072148);SRVR:BLUPR04MB516;BCL:0;PCL:0;RULEID:;SRVR:BLUPR04MB516; X-Microsoft-Exchange-Diagnostics: 1;BLUPR04MB516;4:Hynbrm3/ohhTJ6qNk7XP4z75OMbIAVBdT896n1ycF/LUI3pX4E9qeftrRpuaJQ4Q6KGEGsEC0Erft5AHcmO+whTM/J+RARdu8NlNJg5vCvC300nJUEo//s5vkyk56dC/phhHEqa0eZLJANec5PTSAMcYbCHX/fDQYDg+Sqr2R7KdotrjuDowW8BY84T8fRADGyQs1r2fiNQ60miFty+bepB7I5DTlImq6P6KlpACE3+WaarW8UZtmUuIzLfYPdEW6pW0D8U5BpSCyY2IfffMEmfaJvP2mVdNNl6jgY4jaRPdrTRYmx0UvDD6XbZH3qkj/8uGHNg2JAAJS7E3V6c0Ash5l9AauC5jRFtRv2/HJTahB0ATpRJJ8SEZFI7tHZlRsOP8fKVoOqFALbIOKsY6Tvnq+hUnZe8/H6RAckmQ2/trm7+1a337Uv2Fga/6zZ4YwrH8nSAWcf+VD8zaLh4xVIRDWVpkrGSxjTH8c3PMviKaksYpo+jFoNk+tf5ujISRut8Jx0opSO5lQlvb4JIZHc4vWglFqCiXLTRhYb2AX4zCGI7/3GrnF5Mes7OHKc+4O0+OJfe076+C96TPW3d2HPEJKxAewCmGAUNzocssOG7mBPvleVXWzUvYeI/c1W7R5GONt/gkeGPa6wahFZ0Zd+GfzYRaSnF9BgFjnUdg3cZdBuPAMNRvXtXcZNhCjAwH+Oh+W2AjWao/30xK/SIxWTCmDsOxR/eOdL0eQhGBQcmoOa93W3lGwoJIu1540kqr X-Forefront-PRVS: 0239D46DB6 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BLUPR04MB516;23:Nw9mpIFaP8EjKTeurrqz3bEaheDPP/aWWo5+hoTHEx?= =?us-ascii?Q?QHWHClEJAzNqCaeCyqAoiln7ylprTGBQSP/l0Vr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E9J47iO8AXMOBTOUPLH52f8D9k94VpycmeGWw191Jb6V0hg?= =?us-ascii?Q?uvxZeQ6h5dw82ZoanLXYCe3WhH1+Am7YgwNPkeoXzNeDc0j8RbugJa2GZby0?= =?us-ascii?Q?evGas=3D?= X-Microsoft-Exchange-Diagnostics: 1;BLUPR04MB516;6:iNAfyBh7sv4oJdoIffYF+MsUS84NPujvgmQiIFk+c+WVJQomhBdSKpamnvq4vZRAEMav3vDvIwORB0XSCzYjrIY/PUW0K/mgWPxmnkydfhnsHgNErvdsUpwPjL9yL2Oa/8AOWI/qQAuA9W0poNHVTwJi6zCQsBo/XYAPc5ChiBoztJRBmvKK/YTWfAte/4QU+UIPaNXV/72kL5AMcRxXUSDJaKliBujKWqS3B48nivnzDxsO73kcLyx7RZvc1Ec7hpYe3/zIa/SnnIXRfZdVsMSSjTFyvjOuqNEvhgH+iXByba7614aZPIiccLp3A1FUoLv0YYfx+oG8mwl0aEPLxmranF1LTwXBBaYEnIMo6osIYpRuLCQQIVLmq36odu0pW90NrGcJ20ZPajcqYxyZW7GBvm6Q1L/Tfb6/qGLkFog=;5:HWH/tA8z/XCukcCt7F5lAj8TJ6e1qNEssMqQ2RPxVdvHWMOdB58Yt2dF8QShMLeFiA2dTzjjjYsb2YdncTMmAmUqqhyQakdHjGQCA/ZR9ACFlCRVBobz5FnUaxzT2MfxROazA2m3A+ZnSp/eL8pVBQ==;24:00DBSZXzz17OX0hnQuQ/pT7Dqjdifum7/HeyjmDXTL8o/1oExBTpzztsuo6dDbCCCgiovKJjRrMuei0iUnKClQsEfIUw2gn96I+5Rs9GPY4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BLUPR04MB516;7:QXeKenKG/hQh3iFyFibO9sigsF1snNqIeUwN5hnaV216Hi23frqa5A5UGA33DmBbFASiq0L04n7ZL/kD7i9Dw2SBL5vjtbI9GUVuJTxG/vwlVqlnpayNLEZeVR7+iMQh+ADQfvZHX0Njjvp3d0T4vjI4k2M8WtXwPw0XEEoOuSmQOggOljCQ3jrPuGh1hrMVnxBpiOBDf470ryGSM1oIecSjyHtcXR78KgTQAxQf416uTZTZR+KnR6CLlR4r+hzsYvSncIQ86VQCR6421AHFPb1jd3aozyLl6L3j5ArrvCDSMu6HWoU3GzDOJen+lNA+LJkR2+96Xmf+1ay/uJ9O1Q==;20:5xYNH2CQC9BDkk+A2GjLjk+a4x4hv66Z3c0FiGJjxGc+3J1NeYli+CPZBVdQfJFwPozO2HKQJ6nk8VS9OSbgglSHUygqWANq6tKyya9Ry6I3rnrkTXueQcHbi1D1JAWK5V6nDfOn3ZIheLMEMmZUkhR7rlVSN4/KgHuhw4GRy2A= X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Mar 2017 00:35:56.0166 (UTC) X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=b61c8803-16f3-4c35-9b17-6f65f441df86;Ip=[63.163.107.21];Helo=[milsmgep15.sandisk.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR04MB516 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3167 Lines: 84 The dma mapping operations of several architectures and also of several I/O MMU implementations need to translate a struct device pointer into a struct pci_dev pointer. This translation is performed by to_pci_dev(). That macro assumes that struct device is embedded in struct pci_dev. However, that is not the case for the device structure in struct ib_device. Since that device structure is passed to DMA mapping operations since kernel v4.11-rc1, introduce a pointer in struct device to make the translation from struct device into struct pci_dev more flexible. Signed-off-by: Bart Van Assche Cc: Greg Kroah-Hartman Cc: Bjorn Helgaas Cc: Benjamin Herrenschmidt Cc: David Woodhouse Cc: H. Peter Anvin Cc: Ingo Molnar Cc: Russell King --- drivers/pci/probe.c | 1 + include/linux/device.h | 5 +++++ include/linux/pci.h | 5 ++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index dfc9a2794141..60d739b59520 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1736,6 +1736,7 @@ struct pci_dev *pci_alloc_dev(struct pci_bus *bus) INIT_LIST_HEAD(&dev->bus_list); dev->dev.type = &pci_dev_type; + dev->dev.pci_dev = dev; dev->bus = pci_bus_get(bus); return dev; diff --git a/include/linux/device.h b/include/linux/device.h index 30c4570e928d..c18afd376d2a 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -42,6 +42,7 @@ struct fwnode_handle; struct iommu_ops; struct iommu_group; struct iommu_fwspec; +struct pci_dev; struct bus_attribute { struct attribute attr; @@ -860,6 +861,9 @@ struct dev_links_info { * segment limitations. * @dma_pools: Dma pools (if dma'ble device). * @dma_mem: Internal for coherent mem override. + * @pci_dev: PCI device associated with this device. Used by DMA mapping + * operations on architectures that need access to PCI device + * members that are not in struct device. * @cma_area: Contiguous memory area for dma allocations * @archdata: For arch-specific additions. * @of_node: Associated device tree node. @@ -940,6 +944,7 @@ struct device { struct dma_coherent_mem *dma_mem; /* internal for coherent mem override */ + struct pci_dev *pci_dev; /* for DMA mapping operations */ #ifdef CONFIG_DMA_CMA struct cma *cma_area; /* contiguous memory area for dma allocations */ diff --git a/include/linux/pci.h b/include/linux/pci.h index eb3da1a04e6c..eca790eaae20 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -409,7 +409,10 @@ static inline struct pci_dev *pci_physfn(struct pci_dev *dev) struct pci_dev *pci_alloc_dev(struct pci_bus *bus); -#define to_pci_dev(n) container_of(n, struct pci_dev, dev) +static inline struct pci_dev *to_pci_dev(const struct device *dev) +{ + return dev->pci_dev; +} #define for_each_pci_dev(d) while ((d = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, d)) != NULL) static inline int pci_channel_offline(struct pci_dev *pdev) -- 2.12.0