ib_core: Add missing device link to class device
PATCH 1/1 ib_core: Add missing device link to class device
Add the missing device link from /sys/class/infiniband/* to the actual device.
---
sysfs.c | 1 + 1 file changed, 1 insertion(+)
drivers/infiniband/core/sysfs.c 2007-04-23 15:38:22.000000000 +0200 renamed from drivers/infiniband/core/sysfs.c.old 2007-04-23 15:37:37.000000000 +0200 +1 -0
@@ -683,6 +683,7 @@ int ib_device_register_sysfs(struct ib_d class_dev->class = &ib_class; class_dev->class_data = device; + class_dev->dev = device->dma_device; strlcpy(class_dev->class_id, device->name, BUS_ID_SIZE); INIT_LIST_HEAD(&device->port_list);
Signature · 4 lines
Joachim Fenkes -- eHCA Linux Driver Developer and Hardware Tamer IBM Deutschland Entwicklung GmbH -- Dept. 3627 (I/O Firmware Dev. 2) Schoenaicher Strasse 220 -- 71032 Boeblingen -- Germany eMail: [email protected] -- Phone: +49 7031 16 1239
Hmm, I have links like this on my system already:
$ ls -l /sys/class/infiniband/mlx4_0/device
lrwxrwxrwx 1 root root 0 2007-04-23 12:14 /sys/class/infiniband/mlx4_0/device -> ../../../devices/pci0000:00/0000:00:06.0/0000:0d:00.0the patch actually looks sane but I don't understand why it's needed. Could you explain?
Roland Dreier <[email protected]> wrote on 23.04.2007 21:17:48:
Quoted 4 lines
Hmm, I have links like this on my system already:
the patch actually looks sane but I don't understand why it's needed. Could you explain?
I had a look at the kernel code -- currently, all device drivers except ehca do this by themselves:
cxgb3:
1110 dev->ibdev.dma_device = &(dev->rdev.rnic_info.pdev->dev);
1111 dev->ibdev.class_dev.dev = &(dev->rdev.rnic_info.pdev->dev);
amso1100:
798 dev->ibdev.dma_device = &dev->pcidev->dev;
799 dev->ibdev.class_dev.dev = &dev->pcidev->dev;
ipath:
1559 dev->dma_device = &dd->pcidev->dev;
1560 dev->class_dev.dev = dev->dma_device;
mthca:
1295 dev->ib_dev.dma_device = &dev->pdev->dev; 1296 dev->ib_dev.class_dev.dev = &dev->pdev->dev;
So I think it makes a lot of sense to put the class_dev.dev assignment into generic ib_core code instead of repeating it in all the drivers. The respective lines could move out of the drivers in the future but won't hurt anyone until then.
What's your take on this?
Cheers,
Joachim
---
Joachim Fenkes -- eHCA Linux Driver Developer and Hardware Tamer IBM Deutschland Entwicklung GmbH -- Dept. 3627 (I/O Firmware Dev. 2)
Schoenaicher Strasse 220 -- 71032 Boeblingen -- Germany eMail: [email protected] -- Phone: +49 7031 16 1239
Quoted 7 lines
I had a look at the kernel code -- currently, all device drivers except ehca do this by themselves:
So I think it makes a lot of sense to put the class_dev.dev assignment into generic
ib_corecode instead of repeating it in all the drivers. The respective lines could move out of the drivers in the future but won't hurt anyone until then.
Actually I think we should delete the duplicate code now while merging this. So I queued this up for 2.6.22:
commit f19c8d7cbe3153d68f0a559afd02f66655310238
Author: Joachim Fenkes <[email protected]> Date: Mon Apr 23 18:20:27 2007 +0200
IB: Set class_dev->dev in core for nice device symlink
All RDMA drivers except ehca set class_dev->dev to their dma_device value (ehca leaves this unset). dma_device is the only value that makes any sense, so move this assignment to core/sysfs.c. This reduce the duplicated code in the rest of the drivers and gives ehca a nice /sys/class/infiniband/ehcaX/device symlink.
drivers/infiniband/core/sysfs.c +1 -0
@@ -683,6 +683,7 @@ int ib_device_register_sysfs(struct ib_device *device) class_dev->class = &ib_class; class_dev->class_data = device; + class_dev->dev = device->dma_device;strlcpy (class_dev->class_id, device->name,BUS_ID_SIZE );INIT_LIST_HEAD (&device->port_list);
drivers/infiniband/hw/amso1100/c2_provider.c +0 -1
@@ -796,7 +796,6 @@ int c2_register_device(struct c2_dev *dev)memcpy (&dev->ibdev.node_guid, dev->pseudo_netdev->dev_addr,6 ); dev->ibdev.phys_port_cnt =1 ; dev->ibdev.dma_device = &dev->pcidev->dev; - dev->ibdev.class_dev.dev = &dev->pcidev->dev; dev->ibdev.query_device = c2_query_device; dev->ibdev.query_port = c2_query_port; dev->ibdev.modify_port = c2_modify_port;
drivers/infiniband/hw/cxgb3/iwch_provider.c +0 -1
@@ -1108,7 +1108,6 @@ int iwch_register_device(struct iwch_dev *dev)memcpy (dev->ibdev.node_desc,IWCH_NODE_DESC ,sizeof (IWCH_NODE_DESC )); dev->ibdev.phys_port_cnt = dev->rdev.port_info.nports; dev->ibdev.dma_device = &(dev->rdev.rnic_info.pdev->dev); - dev->ibdev.class_dev.dev = &(dev->rdev.rnic_info.pdev->dev); dev->ibdev.query_device = iwch_query_device; dev->ibdev.query_port = iwch_query_port; dev->ibdev.modify_port = iwch_modify_port;
drivers/infiniband/hw/ipath/ipath_verbs.c +0 -1
@@ -1559,7 +1559,6 @@ int ipath_register_ib_device(struct ipath_devdata *dd) dev->node_type =RDMA_NODE_IB_CA ; dev->phys_port_cnt =1 ; dev->dma_device = &dd->pcidev->dev; - dev->class_dev.dev = dev->dma_device; dev->query_device = ipath_query_device; dev->modify_device = ipath_modify_device; dev->query_port = ipath_query_port;
drivers/infiniband/hw/mthca/mthca_provider.c +0 -1
@@ -1293,7 +1293,6 @@ int mthca_register_device(struct mthca_dev *dev) dev->ib_dev.node_type =RDMA_NODE_IB_CA ; dev->ib_dev.phys_port_cnt = dev->limits.num_ports; dev->ib_dev.dma_device = &dev->pdev->dev; - dev->ib_dev.class_dev.dev = &dev->pdev->dev; dev->ib_dev.query_device = mthca_query_device; dev->ib_dev.query_port = mthca_query_port; dev->ib_dev.modify_device = mthca_modify_device;