Skip to content

Commit e522a78

Browse files
jgunthorpegregkh
authored andcommitted
RDMA/siw,rxe: Make emulated devices virtual in the device tree
[ Upstream commit a9d2e9a ] This moves siw and rxe to be virtual devices in the device tree: lrwxrwxrwx 1 root root 0 Nov 6 13:55 /sys/class/infiniband/rxe0 -> ../../devices/virtual/infiniband/rxe0/ Previously they were trying to parent themselves to the physical device of their attached netdev, which doesn't make alot of sense. My hope is this will solve some weird syzkaller hits related to sysfs as it could be possible that the parent of a netdev is another netdev, eg under bonding or some other syzkaller found netdev configuration. Nesting a ib_device under anything but a physical device is going to cause inconsistencies in sysfs during destructions. Link: https://lore.kernel.org/r/0-v1-dcbfc68c4b4a+d6-virtual_dev_jgg@nvidia.com Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 404fa09 commit e522a78

3 files changed

Lines changed: 1 addition & 31 deletions

File tree

‎drivers/infiniband/sw/rxe/rxe_net.c‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,6 @@
2020

2121
static struct rxe_recv_sockets recv_sockets;
2222

23-
struct device *rxe_dma_device(struct rxe_dev *rxe)
24-
{
25-
struct net_device *ndev;
26-
27-
ndev = rxe->ndev;
28-
29-
if (is_vlan_dev(ndev))
30-
ndev = vlan_dev_real_dev(ndev);
31-
32-
return ndev->dev.parent;
33-
}
34-
3523
int rxe_mcast_add(struct rxe_dev *rxe, union ib_gid *mgid)
3624
{
3725
int err;

‎drivers/infiniband/sw/rxe/rxe_verbs.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,6 @@ int rxe_register_device(struct rxe_dev *rxe, const char *ibdev_name)
11241124
dev->node_type = RDMA_NODE_IB_CA;
11251125
dev->phys_port_cnt = 1;
11261126
dev->num_comp_vectors = num_possible_cpus();
1127-
dev->dev.parent = rxe_dma_device(rxe);
11281127
dev->local_dma_lkey = 0;
11291128
addrconf_addr_eui48((unsigned char *)&dev->node_guid,
11301129
rxe->ndev->dev_addr);

‎drivers/infiniband/sw/siw/siw_main.c‎

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -305,24 +305,8 @@ static struct siw_device *siw_device_create(struct net_device *netdev)
305305
{
306306
struct siw_device *sdev = NULL;
307307
struct ib_device *base_dev;
308-
struct device *parent = netdev->dev.parent;
309308
int rv;
310309

311-
if (!parent) {
312-
/*
313-
* The loopback device has no parent device,
314-
* so it appears as a top-level device. To support
315-
* loopback device connectivity, take this device
316-
* as the parent device. Skip all other devices
317-
* w/o parent device.
318-
*/
319-
if (netdev->type != ARPHRD_LOOPBACK) {
320-
pr_warn("siw: device %s error: no parent device\n",
321-
netdev->name);
322-
return NULL;
323-
}
324-
parent = &netdev->dev;
325-
}
326310
sdev = ib_alloc_device(siw_device, base_dev);
327311
if (!sdev)
328312
return NULL;
@@ -381,7 +365,6 @@ static struct siw_device *siw_device_create(struct net_device *netdev)
381365
* per physical port.
382366
*/
383367
base_dev->phys_port_cnt = 1;
384-
base_dev->dev.parent = parent;
385368
base_dev->num_comp_vectors = num_possible_cpus();
386369

387370
xa_init_flags(&sdev->qp_xa, XA_FLAGS_ALLOC1);
@@ -423,7 +406,7 @@ static struct siw_device *siw_device_create(struct net_device *netdev)
423406
atomic_set(&sdev->num_mr, 0);
424407
atomic_set(&sdev->num_pd, 0);
425408

426-
sdev->numa_node = dev_to_node(parent);
409+
sdev->numa_node = dev_to_node(&netdev->dev);
427410
spin_lock_init(&sdev->lock);
428411

429412
return sdev;

0 commit comments

Comments
 (0)