IB/core fixes for kernel v4.11-rc
Subsystems (3)
cover IB/core fixes for kernel v4.11-rc
Hello Doug,
The following bugs have been reported against kernel v4.11-rc1:
* I/O MMU support for PCIe RDMA drivers is broken.
* s390 support for RDMA drivers is broken.
The two patches in this series address this. Please consider these patches for kernel v4.11-rc.
Thanks,
Bart.
Bart Van Assche (2):
device: Stop requiring that struct device is embedded in struct
pci_dev
IB/core: Restore I/O MMU, s390 and powerpc support
drivers/infiniband/core/device.c | 10 +++++++++- drivers/pci/probe.c | 1 + include/linux/device.h | 5 +++++ include/linux/pci.h | 5 ++++- 4 files changed, 19 insertions(+), 2 deletions(-)
Signature · 1 line
2.12.0
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 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.
--- drivers/pci/probe.c | 1 + include/linux/device.h | 5 +++++ include/linux/pci.h | 5 ++++- 3 files changed, 10 insertions(+), 1 deletion(-)
drivers/pci/probe.c +1 -0
@@ -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;
include/linux/device.h +5 -0
@@ -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 */
include/linux/pci.h +4 -1
@@ -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)
Signature · 6 lines
2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/2 IB/core: Restore I/O MMU, s390 and powerpc support
In reply to Bart Van AsscheAvoid that the following error message is reported on the console while loading an RDMA driver with I/O MMU support enabled:
DMAR: Allocating domain for mlx5_0 failed
Ensure that DMA mapping operations that use to_pci_dev() to access to struct pci_dev see the correct PCI device. E.g. the s390 and powerpc DMA mapping operations use to_pci_dev() even with I/O MMU support disabled.
--- drivers/infiniband/core/device.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/infiniband/core/device.c +9 -1
@@ -39,6 +39,7 @@#include <linux/init.h> #include <linux/mutex.h> #include <linux/netdevice.h> +#include <linux/pci.h> #include <rdma/rdma_netlink.h> #include <rdma/ib_addr.h> #include <rdma/ib_cache.h>
@@ -325,6 +326,10 @@ EXPORT_SYMBOL(ib_get_device_fw_str);* devices with the IB core. All registered clients will receive a * callback for each device that is added. @device must be allocated * with ib_alloc_device(). +* +* Unless requested otherwise by the caller, this function makes sure that DMA +* mapping operations on &device->dev behave identical to DMA mapping +* operations on the parent device (device->dev.parent). */ int ib_register_device(struct ib_device *device, int (*port_callback)(struct ib_device *,
@@ -336,8 +341,11 @@ int ib_register_device(struct ib_device *device,struct device *parent = device->dev.parent;WARN_ON_ONCE (!parent); -if (!device->dev.dma_ops) +if (!device->dev.dma_ops) { device->dev.dma_ops = parent->dma_ops; + device->dev.pci_dev =to_pci_dev (parent); + device->dev.archdata = parent->archdata; + }if (!device->dev.dma_mask) device->dev.dma_mask = parent->dma_mask;if (!device->dev.coherent_dma_mask)
Signature · 1 line
2.12.0
RE: [PATCH 1/2] device: Stop requiring that struct device is embedded in struct pci_dev
In reply to Bart Van AsscheHi Bart,
Quoted 65 lines
-----Original Message-----
From: [email protected] [mailto:linux-rdma- [email protected]] On Behalf Of Bart Van Assche
Sent: Monday, March 6, 2017 6:36 PM
To: Doug Ledford <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>; Sebastian Ott <[email protected]>; Parav Pandit <parav-VPRAkNaXOzVWk0Htik3J/[email protected]>; linux- [email protected]; [email protected]; Bart Van Assche <[email protected]>; Bjorn Helgaas <[email protected]>; Benjamin Herrenschmidt <[email protected]>; David Woodhouse <[email protected]>; H . Peter Anvin <[email protected]>; Ingo Molnar <[email protected]>; Russell King <[email protected]>
Subject: [PATCH 1/2] device: Stop requiring that struct device is embedded in
structpci_devThe 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_devpointer. This translation is performed byto_pci_dev(). That macro assumes that struct device is embedded in structpci_dev. However, that is not the case for the device structure in structib_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 structpci_devmore flexible.Signed-off-by Bart Van Assche <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Bjorn Helgaas <[email protected]>Cc Benjamin Herrenschmidt <[email protected]>Cc David Woodhouse <[email protected]>Cc H. Peter Anvin <[email protected]>Cc Ingo Molnar <[email protected]>Cc Russell King <[email protected]>--- drivers/pci/probe.c | 1 + include/linux/device.h | 5 +++++ include/linux/pci.h | 5 ++++- 3 files changed, 10 insertions(+), 1 deletion(-)include/linux/device.h index renamed from include/linux/device.h +0
-0
30c4570e928d..c18afd376d2a100644include/linux/device.h +2
-0@@ -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.include/linux/device.h +0
-0@@ -940,6 +944,7 @@ struct device {struct dma_coherent_mem *dma_mem;/* internal for coherent mem
include/linux/device.h struct device { · line 947
Quoted 2 lines
include/linux/device.h +1
-0override */ +struct pci_dev *pci_dev;/* for DMA mapping operations */
Compilation would break when CONFIG_PCI is not defined for some embedded platforms.
More than that, including specific pci_dev structure pointer in generic structure such as device just doesn't sound right. I tested equivalent patch that you sent, but I don't think this is right direction to fix this bug.
Quoted 23 lines
#ifdef
CONFIG_DMA_CMAinclude/linux/device.h +0
-0struct cma *cma_area;/* contiguous memory area for dma allocations */ include/linux/pci.h index renamed from include/linux/pci.h +0
-0
eb3da1a04e6c..eca790eaae20100644include/linux/pci.h +3
-2@@ -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
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/2] device: Stop requiring that struct device is embedded in struct pci_dev
Quoted 3 lines · Parav Pandit
Compilation would break when
CONFIG_PCIis not defined for some embedded platforms.
More than that, including specificpci_devstructure pointer in generic structure such as device just doesn't sound right. I tested equivalent patch that you sent, but I don't think this is right direction to fix this bug.
You are welcome to voice your opinion. But unless anyone proposes a better alternative I propose to proceed with this approach.
Bart.
RE: [PATCH 1/2] device: Stop requiring that struct device is embedded in struct pci_dev
In reply to Bart Van AsscheHi Bart,
Quoted 15 lines
-----Original Message-----
From: [email protected] [mailto:linux-rdma- [email protected]] On Behalf Of Bart Van Assche
Sent: Monday, March 6, 2017 6:36 PM
To: Doug Ledford <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>; Sebastian Ott <[email protected]>; Parav Pandit <parav-VPRAkNaXOzVWk0Htik3J/[email protected]>; linux- [email protected]; [email protected]; Bart Van Assche <[email protected]>; Bjorn Helgaas <[email protected]>; Benjamin Herrenschmidt <[email protected]>; David Woodhouse <[email protected]>; H . Peter Anvin <[email protected]>; Ingo Molnar <[email protected]>; Russell King <[email protected]>
Subject: [PATCH 1/2] device: Stop requiring that struct device is embedded in
structpci_dev
Quoted 5 lines
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_devpointer. This translation is performed byto_pci_dev(). That macro assumes that struct device is embedded in structpci_dev. However, that is not the case for the device structure in structib_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.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
[email protected]
maintainerRe: [PATCH 1/2] device: Stop requiring that struct device is embedded in struct pci_dev
In reply to Bart Van AsscheQuoted 7 lines · Bart Van Assche
Quoted 3 lines · Parav Pandit
Compilation would break when
CONFIG_PCIis not defined for some embedded platforms.
More than that, including specificpci_devstructure pointer in generic structure such as device just doesn't sound right. I tested equivalent patch that you sent, but I don't think this is right direction to fix this bug.You are welcome to voice your opinion. But unless anyone proposes a better alternative I propose to proceed with this approach.
That's not how development happens. You don't just do "here's a something I came up with, if you don't like it, tough!" If people object, you need to resolve those objections, not ignore them.
Especially when you are breaking the build!!!
come on now, you know better than this.
greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Greg Kroah-Hartman
maintainerRe: [PATCH 1/2] device: Stop requiring that struct device is embedded in struct pci_dev
In reply to Bart Van AsscheQuoted 6 lines · Bart Van Assche
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_devpointer. This translation is performed byto_pci_dev(). That macro assumes that struct device is embedded in structpci_dev. However, that is not the case for the device structure in structib_device.
Then don't blindly cast it backwards! Fix that up, an ib device should have access to the dma structures that the PCI device it depends on has. If not, you need to set that up properly in the IB core, don't mess with the driver core for this at all.
Somehow all other subsystems work just fine, don't instantly think that the driver core needs to bend to the will of the IB code, because you are somehow "special". Hint, you aren't :)
greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH 1/2] device: Stop requiring that struct device is embedded in struct pci_dev
Hi Greg,
Quoted 22 lines
-----Original Message-----
From: Greg Kroah-Hartman [mailto:[email protected]]
Sent: Monday, March 6, 2017 10:53 PM
To: Bart Van Assche <[email protected]>
Cc: Doug Ledford <[email protected]>; Sebastian Ott <[email protected]>; Parav Pandit <parav-VPRAkNaXOzVWk0Htik3J/[email protected]>; linux- [email protected]; [email protected]; Bjorn Helgaas <[email protected]>; Benjamin Herrenschmidt <[email protected]>; David Woodhouse <[email protected]>; H . Peter Anvin <[email protected]>; Ingo Molnar <[email protected]>; Russell King <[email protected]>
Subject: Re: [PATCH 1/2] device: Stop requiring that struct device is
embedded in structpci_devQuoted 6 lines · Bart Van Assche
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_devpointer. This translation is performed byto_pci_dev(). That macro assumes that struct device is embedded in structpci_dev. However, that is not the case for the device structure in structib_device.
Quoted 5 lines
Then don't blindly cast it backwards! Fix that up, an ib device should have access to the dma structures that the PCI device it depends on has. If not, you need to set that up properly in the IB core, don't mess with the driver core for this at all.
I replied with pseudo code in previous reply to Bart to bring back dma_device member in the ib_device. dma_device member was already present in near past of few weeks.
It should be able to work using it without performance impact and without touching driver core layer like in this patch.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/2] device: Stop requiring that struct device is embedded in struct pci_dev
T24gVHVlLCAyMDE3LTAzLTA3IGF0IDA1OjA4ICswMDAwLCBQYXJhdiBQYW5kaXQgd3JvdGU6DQo+ IEkgcmVwbGllZCB3aXRoIHBzZXVkbyBjb2RlIGluIHByZXZpb3VzIHJlcGx5IHRvIEJhcnQgdG8g YnJpbmcgYmFjayBkbWFfZGV2aWNlIG1lbWJlciBpbiB0aGUgaWJfZGV2aWNlLg0KPiBkbWFfZGV2 aWNlIG1lbWJlciB3YXMgYWxyZWFkeSBwcmVzZW50IGluIG5lYXIgcGFzdCBvZiBmZXcgd2Vla3Mu DQo+IEl0IHNob3VsZCBiZSBhYmxlIHRvIHdvcmsgdXNpbmcgaXQgd2l0aG91dCBwZXJmb3JtYW5j ZSBpbXBhY3QgYW5kIHdpdGhvdXQgdG91Y2hpbmcgZHJpdmVyIGNvcmUgbGF5ZXIgbGlrZSBpbiB0 aGlzIHBhdGNoLg0KDQpUaGF0J3MgY29uZnVzaW5nIGFuZCB3YXMgYSBzb3VyY2Ugb2YgYnVncyBh bmQgaW5jb25zaXN0ZW5jaWVzLiBXZSBkbyBub3QNCndhbnQgdHdvIGRldmljZSBzdHJ1Y3R1cmVz IGluIHN0cnVjdCBpYl9kZXZpY2UgKHN0cnVjdCBkZXZpY2UgZGV2IGFuZCBzdHJ1Y3QNCmRldmlj ZSAqZG1hX2RldmljZSkuDQoNCkJhcnQu
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH 1/2] device: Stop requiring that struct device is embedded in struct pci_dev
SGkgQmFydCwNCg0KPiAtLS0tLU9yaWdpbmFsIE1lc3NhZ2UtLS0tLQ0KPiBGcm9tOiBsaW51eC1y ZG1hLW93bmVyQHZnZXIua2VybmVsLm9yZyBbbWFpbHRvOmxpbnV4LXJkbWEtDQo+IG93bmVyQHZn ZXIua2VybmVsLm9yZ10gT24gQmVoYWxmIE9mIEJhcnQgVmFuIEFzc2NoZQ0KPiBTZW50OiBNb25k YXksIE1hcmNoIDYsIDIwMTcgMTE6MTMgUE0NCj4gVG86IFBhcmF2IFBhbmRpdCA8cGFyYXZAbWVs bGFub3guY29tPjsgZ3JlZ2toQGxpbnV4Zm91bmRhdGlvbi5vcmcNCj4gQ2M6IGxpbnV4LWtlcm5l bEB2Z2VyLmtlcm5lbC5vcmc7IGxpbnV4LXJkbWFAdmdlci5rZXJuZWwub3JnOw0KPiBzZWJvdHRA bGludXgudm5ldC5pYm0uY29tOyBsaW51eEBhcm1saW51eC5vcmcudWs7IGhwYUB6eXRvci5jb207 DQo+IG1pbmdvQHJlZGhhdC5jb207IGR3bXcyQGluZnJhZGVhZC5vcmc7IGJoZWxnYWFzQGdvb2ds ZS5jb207DQo+IGRsZWRmb3JkQHJlZGhhdC5jb207IGJlbmhAa2VybmVsLmNyYXNoaW5nLm9yZw0K PiBTdWJqZWN0OiBSZTogW1BBVENIIDEvMl0gZGV2aWNlOiBTdG9wIHJlcXVpcmluZyB0aGF0IHN0 cnVjdCBkZXZpY2UgaXMNCj4gZW1iZWRkZWQgaW4gc3RydWN0IHBjaV9kZXYNCj4gDQo+IE9uIFR1 ZSwgMjAxNy0wMy0wNyBhdCAwNTowOCArMDAwMCwgUGFyYXYgUGFuZGl0IHdyb3RlOg0KPiA+IEkg cmVwbGllZCB3aXRoIHBzZXVkbyBjb2RlIGluIHByZXZpb3VzIHJlcGx5IHRvIEJhcnQgdG8gYnJp bmcgYmFjaw0KPiBkbWFfZGV2aWNlIG1lbWJlciBpbiB0aGUgaWJfZGV2aWNlLg0KPiA+IGRtYV9k ZXZpY2UgbWVtYmVyIHdhcyBhbHJlYWR5IHByZXNlbnQgaW4gbmVhciBwYXN0IG9mIGZldyB3ZWVr cy4NCj4gPiBJdCBzaG91bGQgYmUgYWJsZSB0byB3b3JrIHVzaW5nIGl0IHdpdGhvdXQgcGVyZm9y bWFuY2UgaW1wYWN0IGFuZCB3aXRob3V0DQo+IHRvdWNoaW5nIGRyaXZlciBjb3JlIGxheWVyIGxp a2UgaW4gdGhpcyBwYXRjaC4NCj4gDQo+IFRoYXQncyBjb25mdXNpbmcgYW5kIHdhcyBhIHNvdXJj ZSBvZiBidWdzIGFuZCBpbmNvbnNpc3RlbmNpZXMuIFdlIGRvIG5vdA0KPiB3YW50IHR3byBkZXZp Y2Ugc3RydWN0dXJlcyBpbiBzdHJ1Y3QgaWJfZGV2aWNlIChzdHJ1Y3QgZGV2aWNlIGRldiBhbmQg c3RydWN0DQo+IGRldmljZSAqZG1hX2RldmljZSkuDQoNCmRldmljZSBkZXYgcmVwcmVzZW50cywg ZGV2IHN0cnVjdHVyZSBvZiB0aGUgaWJfZGV2aWNlLg0KV2hpbGUgZG1hX2RldmljZSBpcyBmb3Ig dGhlIGFjdHVhbCBkZXZpY2UgYXMgeW91IGtub3cuDQoNCklmIHlvdSBsb29rIGF0IG5ldF9kZXZp Y2UsIA0KSXQgaGFzIGRldmljZSBkZXYuDQp2ZW5kb3IgZHJpdmVycyBzdG9yZSBwY2lfZGV2IHBv aW50ZXIgYW5kIGFjY2VzcyBkZXZpY2Ugb2YgcGNpX2RldiBldGMuDQpFdmVyeSBuZXRfZGV2aWNl IGRyaXZlciBoYXMgdG8gZG8gdGhhdC4NCg0KSWJfZGV2aWNlIHNpbXBsaWZpZXMgdGhhdCB3b3Jr IGZvciBpYiBzdGFjayBieSBzdG9yaW5nIGRtYV9kZXZpY2UuDQpJIHRoaW5rIHRoaXMgaXMgbGVz cyBjb25mdXNpbmcuDQoNCj4gDQo+IEJhcnQuTiAgICAgciAgeSAgIGIgWCAgx6d2IF4gKd66ey5u ICsgICAgeyAg2Zoge2F5IB3Kh9qZICxqICAgZiAgIGggICB6IB4gdyAgICAgICBqOit2ICAgdyBq IG0gICAgICAgICB6WisNCj4g3aJqIiAgISBpDQo=
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/2] device: Stop requiring that struct device is embedded in struct pci_dev
In reply to Greg Kroah-HartmanQuoted 3 lines · Greg Kroah-Hartman
Somehow all other subsystems work just fine, don't instantly think that the driver core needs to bend to the will of the IB code, because you are somehow "special". Hint, you aren't :)
Hi Greg,
In another e-mail Parav compared IB drivers with networking drivers. But I think that's a bad comparison: in the networking stack it's the network driver itself that sets up and triggers DMA while in the IB stack it's the upper layer protocol (ULP) driver that calls the functions defined in struct dma_ops. For some IB HW drivers (hfi1, qib and rdma_rxe) the ULP driver must use the DMA mapping operations from lib/dma-virt.c while for all other IB HW drivers the ULP driver must use the PCI DMA mapping functions. The ib_dma_*() functions select the right DMA mapping operations - either the PCI DMA mapping operations or those from lib/dma-virt.c. My question to you is how we should organize struct ib_device such that we can get rid of the ib_dma_*() helper functions. How to make sure that the to_pci_dev() translation works correctly for the device structure that is embedded in struct ib_device? Should a pointer to struct pci_dev be embedded in struct device (as done in patch 1/2 in this series) or should the struct device in ib_device be changed into a struct pci_dev and should the pci_dev information from /sys/devices/pci*/*/* be duplicated into the pci_dev information in struct ib_device (/sys/devices/pci*/*/*/infiniband/*)? For the latter approach, would there be a risk that the duplicated information becomes inconsistent?
Thanks,
Bart.
[email protected]
maintainerRe: [PATCH 1/2] device: Stop requiring that struct device is embedded in struct pci_dev
Quoted 8 lines · Bart Van Assche
Quoted 3 lines · Greg Kroah-Hartman
Somehow all other subsystems work just fine, don't instantly think that the driver core needs to bend to the will of the IB code, because you are somehow "special". Hint, you aren't :)
Hi Greg,
In another e-mail Parav compared IB drivers with networking drivers.
Great, then notice that networking drivers don't need to do this type of crud :)
Quoted 6 lines
But I think that's a bad comparison: in the networking stack it's the network driver itself that sets up and triggers DMA while in the IB stack it's the upper layer protocol (ULP) driver that calls the functions defined in struct
dma_ops. For some IB HW drivers (hfi1, qib andrdma_rxe) the ULP driver must
use the DMA mapping operations fromlib/dma-virt.cwhile for all other IB HW
Quoted 8 lines
drivers the ULP driver must use the PCI DMA mapping functions. The ib_dma_*() functions select the right DMA mapping operations - either the PCI DMA mapping operations or those from
lib/dma-virt.c. My question to you is how we should organize structib_devicesuch that we can get rid of the ib_dma_*() helper functions. How to make sure that theto_pci_dev()translation works correctly for the device structure that is embedded in structib_device? Should a pointer to structpci_devbe embedded in struct device (as done in patch 1/2 in this series)
I already said no to this, why do you think that it is still ok?
Quoted 2 lines
or should the struct device in
ib_devicebe changed into a structpci_dev
Ick, no.
Quoted 3 lines
and should the
pci_devinformation from/sys/devices/pci*/*/*be duplicated into thepci_devinformation in structib_device(/sys/devices/pci*/*/*/infiniband/*)?
I don't think you really thought that one through :)
Quoted 2 lines
For the latter approach, would
there be a risk that the duplicated information becomes inconsistent?
No, it just wouldn't work :)
Why not just save off a pointer to your pci_dev in your ib_device structure? That way you know what the type is, and you have access to everything you need.
But hey, I know nothing about IB and I really want to keep it that way. You do what you want to, as long as you don't abuse the driver model, like your patch 1/2 did. Remember, not all the world is IB.
thanks,
greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH 1/2] device: Stop requiring that struct device is embedded in struct pci_dev
Quoted 20 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Tuesday, March 7, 2017 11:14 AM
To: Bart Van Assche <[email protected]>
Cc: [email protected]; [email protected]; Parav Pandit <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 1/2] device: Stop requiring that struct device is embedded in structpci_devQuoted 5 lines · Bart Van Assche
Quoted 3 lines · Greg Kroah-Hartman
Somehow all other subsystems work just fine, don't instantly think that the driver core needs to bend to the will of the IB code, because you are somehow "special". Hint, you aren't :)
Quoted 7 lines
Quoted 3 lines
Hi Greg,
In another e-mail Parav compared IB drivers with networking drivers.
Great, then notice that networking drivers don't need to do this type of crud :)
Well what I compared is:
netdev has struct device and it also has underlying pci_dev based device.
ibdev has struct device and it also has underlying pci_dev based device.
So let us try to treat them in same way wherever possible and keep setup needed in ib drivers.
Quoted 5 lines
Quoted 5 lines
But I think that's a bad comparison: in the networking stack it's the network driver itself that sets up and triggers DMA while in the IB stack it's the upper layer protocol (ULP) driver that calls the functions defined in struct
dma_ops. For some IB HW drivers (hfi1, qib andrdma_rxe) the ULP driver must use the DMA mapping operations from
DMA mapping and allocation is done in different layer for its own reason unrelated to this change. If rxe, qib, hfi1 point to right dma_device, can't we remove the ib_dma_*()?
Re: [PATCH 1/2] device: Stop requiring that struct device is embedded in struct pci_dev
In reply to Greg Kroah-HartmanQuoted 8 lines · Greg Kroah-Hartman
Quoted 6 lines · Bart Van Assche
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_devpointer. This translation is performed byto_pci_dev(). That macro assumes that struct device is embedded in structpci_dev. However, that is not the case for the device structure in structib_device.
Quoted 8 lines
Then don't blindly cast it backwards! Fix that up, an ib device should have access to the dma structures that the PCI device it depends on has. If not, you need to set that up properly in the IB core, don't mess with the driver core for this at all.
Somehow all other subsystems work just fine, don't instantly think that the driver core needs to bend to the will of the IB code, because you are somehow "special". Hint, you aren't :)
Right, in his case, Bart, you can either pass the the struct device for use for DMA to the ib devices, which is easy but a bit gross, or have the ib core provide a set of dma_ops for the ib_device that are "wrappers" calling back to the "parent" device.
Any struct device whose dma_ops haven't been setup by the architecture core cannot be used for DMA as-is without such "reflector" dma_ops provided by the creator of that struct device.
The architecture core only knows about some "directly" attached things like PCI, some cases of platform devices etc... and has no way of setting things up for subsystem specific thigns like ib_device.
Thus the subsystem must take care of it and provide its own dma_ops that "reflect" the calls to the original parent device that was setup by the architecture.
Cheers,
Ben.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html