Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754819AbdCGDXJ (ORCPT ); Mon, 6 Mar 2017 22:23:09 -0500 Received: from mail-eopbgr00070.outbound.protection.outlook.com ([40.107.0.70]:45752 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754611AbdCGDVf (ORCPT ); Mon, 6 Mar 2017 22:21:35 -0500 From: Parav Pandit To: Bart Van Assche , Doug Ledford CC: Greg Kroah-Hartman , Sebastian Ott , "linux-rdma@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Bjorn Helgaas , "Benjamin Herrenschmidt" , David Woodhouse , "H . Peter Anvin" , Ingo Molnar , Russell King Subject: RE: [PATCH 1/2] device: Stop requiring that struct device is embedded in struct pci_dev Thread-Topic: [PATCH 1/2] device: Stop requiring that struct device is embedded in struct pci_dev Thread-Index: AQHSltr7A9hsfT8RwUyV7gxEsYQ73qGIsFvg Date: Tue, 7 Mar 2017 03:21:24 +0000 Message-ID: References: <20170307003549.3872-1-bart.vanassche@sandisk.com> <20170307003549.3872-2-bart.vanassche@sandisk.com> In-Reply-To: <20170307003549.3872-2-bart.vanassche@sandisk.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: sandisk.com; dkim=none (message not signed) header.d=none;sandisk.com; dmarc=none action=none header.from=mellanox.com; x-originating-ip: [2605:6000:ec80:6500:bd58:953a:15b7:a751] x-ms-office365-filtering-correlation-id: 5319fe61-47ed-429b-65ef-08d4650908d7 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(48565401081);SRVR:VI1PR0502MB3006; x-microsoft-exchange-diagnostics: 1;VI1PR0502MB3006;7:GZ62CPrQjchap+iQF8sNAEz78FRb0eCjmf8DaVFLZyh5dP4vDXHYX3NnNWIjeDDzWy1l8lYnOS8182McI72MWZEGSKHl665q9QcJWPB2mH4jx0/ZGejRQ+i62s7LlCE4G3i6ENM5T82rkuVgcfn7XIoh74SqBGdPvMc/BD8qQEnEymyiIdsb/Zq8yo1GOyfDoJVLsAOuVtPEqQM5/TYWjGtlD2U+bAgQC8XNPLW3+IGkrhYJu38TQDdM71DDwVXaiOovVduvTr+hh99mQwsPY+W6UbBVdtbBTJXkFEQftFSasMTWxcEfOyH2bMubbi25HDD9SgahOkYcO4mFAXptZA== x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(9452136761055)(211936372134217)(104084551191319)(42932892334569); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026)(6041248)(20161123560025)(20161123564025)(20161123558025)(20161123562025)(20161123555025)(6072148);SRVR:VI1PR0502MB3006;BCL:0;PCL:0;RULEID:;SRVR:VI1PR0502MB3006; x-forefront-prvs: 0239D46DB6 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(7916002)(39840400002)(39860400002)(39450400003)(39850400002)(39410400002)(13464003)(377454003)(6506006)(229853002)(2906002)(50986999)(106116001)(7736002)(4326008)(74316002)(77096006)(92566002)(305945005)(189998001)(38730400002)(6246003)(53936002)(122556002)(3660700001)(53546006)(76176999)(54356999)(3280700002)(2900100001)(8656002)(2950100002)(7696004)(7416002)(33656002)(6116002)(102836003)(81166006)(99286003)(8676002)(55016002)(9686003)(54906002)(8936002)(86362001)(25786008)(5660300001)(6436002);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0502MB3006;H:VI1PR0502MB3008.eurprd05.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Mar 2017 03:21:24.1345 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0502MB3006 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id v273NCrQ021513 Content-Length: 2608 Lines: 57 Hi Bart, > -----Original Message----- > From: linux-rdma-owner@vger.kernel.org [mailto:linux-rdma- > owner@vger.kernel.org] On Behalf Of Bart Van Assche > Sent: Monday, March 6, 2017 6:36 PM > To: Doug Ledford > Cc: Greg Kroah-Hartman ; Sebastian Ott > ; Parav Pandit ; linux- > rdma@vger.kernel.org; linux-kernel@vger.kernel.org; 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 > > 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 Why can't ib subsystem pass device structure that is embedded in pci_dev when it makes calls to dma_map APIs? The whole point of clean up was to avoid an if() condition in hot datapath. If we invoke dma_map_ and friend functions with right device, shouldn't it work? That avoids the if() condition as well and avoids changing core of Linux like done in this bug fix. I think ib_device should store the right struct device pointer that needs to go to dma_apis, rather than including pci_dev structure pointer in device core layer. Pseudo example code: struct ib_device { struct device *dma_device; }; ib_dma_unmap_single() which had if(), that got removed with dma_unmap_single() with cleanup patch. Instead of, static inline void ib_dma_unmap_single(struct ib_device *dev, u64 addr, size_t size, enum dma_data_direction direction) { dma_unmap_single(&dev->dev, addr, size, direction); } Why can't we do this? static inline void ib_dma_unmap_single(struct ib_device *dev, u64 addr, size_t size, enum dma_data_direction direction) { dma_unmap_single(dev->dma_device, addr, size, direction); } This avoids increasing all device size by 8 bytes in system. It also clean approach where core device structure doesn't have to bother for pci_dev.