Commit a9d2e9ae authored by Jason Gunthorpe's avatar Jason Gunthorpe

RDMA/siw,rxe: Make emulated devices virtual in the device tree

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.comSigned-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
parent 808b2c92
...@@ -19,15 +19,6 @@ ...@@ -19,15 +19,6 @@
static struct rxe_recv_sockets recv_sockets; static struct rxe_recv_sockets recv_sockets;
struct device *rxe_dma_device(struct rxe_dev *rxe)
{
struct net_device *ndev;
ndev = rxe->ndev;
return ndev->dev.parent;
}
int rxe_mcast_add(struct rxe_dev *rxe, union ib_gid *mgid) int rxe_mcast_add(struct rxe_dev *rxe, union ib_gid *mgid)
{ {
int err; int err;
......
...@@ -1134,7 +1134,6 @@ int rxe_register_device(struct rxe_dev *rxe, const char *ibdev_name) ...@@ -1134,7 +1134,6 @@ int rxe_register_device(struct rxe_dev *rxe, const char *ibdev_name)
dev->node_type = RDMA_NODE_IB_CA; dev->node_type = RDMA_NODE_IB_CA;
dev->phys_port_cnt = 1; dev->phys_port_cnt = 1;
dev->num_comp_vectors = num_possible_cpus(); dev->num_comp_vectors = num_possible_cpus();
dev->dev.parent = rxe_dma_device(rxe);
dev->local_dma_lkey = 0; dev->local_dma_lkey = 0;
addrconf_addr_eui48((unsigned char *)&dev->node_guid, addrconf_addr_eui48((unsigned char *)&dev->node_guid,
rxe->ndev->dev_addr); rxe->ndev->dev_addr);
......
...@@ -305,24 +305,8 @@ static struct siw_device *siw_device_create(struct net_device *netdev) ...@@ -305,24 +305,8 @@ static struct siw_device *siw_device_create(struct net_device *netdev)
{ {
struct siw_device *sdev = NULL; struct siw_device *sdev = NULL;
struct ib_device *base_dev; struct ib_device *base_dev;
struct device *parent = netdev->dev.parent;
int rv; int rv;
if (!parent) {
/*
* The loopback device has no parent device,
* so it appears as a top-level device. To support
* loopback device connectivity, take this device
* as the parent device. Skip all other devices
* w/o parent device.
*/
if (netdev->type != ARPHRD_LOOPBACK) {
pr_warn("siw: device %s error: no parent device\n",
netdev->name);
return NULL;
}
parent = &netdev->dev;
}
sdev = ib_alloc_device(siw_device, base_dev); sdev = ib_alloc_device(siw_device, base_dev);
if (!sdev) if (!sdev)
return NULL; return NULL;
...@@ -359,7 +343,6 @@ static struct siw_device *siw_device_create(struct net_device *netdev) ...@@ -359,7 +343,6 @@ static struct siw_device *siw_device_create(struct net_device *netdev)
* per physical port. * per physical port.
*/ */
base_dev->phys_port_cnt = 1; base_dev->phys_port_cnt = 1;
base_dev->dev.parent = parent;
base_dev->num_comp_vectors = num_possible_cpus(); base_dev->num_comp_vectors = num_possible_cpus();
xa_init_flags(&sdev->qp_xa, XA_FLAGS_ALLOC1); xa_init_flags(&sdev->qp_xa, XA_FLAGS_ALLOC1);
...@@ -401,7 +384,7 @@ static struct siw_device *siw_device_create(struct net_device *netdev) ...@@ -401,7 +384,7 @@ static struct siw_device *siw_device_create(struct net_device *netdev)
atomic_set(&sdev->num_mr, 0); atomic_set(&sdev->num_mr, 0);
atomic_set(&sdev->num_pd, 0); atomic_set(&sdev->num_pd, 0);
sdev->numa_node = dev_to_node(parent); sdev->numa_node = dev_to_node(&netdev->dev);
spin_lock_init(&sdev->lock); spin_lock_init(&sdev->lock);
return sdev; return sdev;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment