RDMA/core: Create "issm*" device nodes only when SMI is supported

JIRA: https://issues.redhat.com/browse/RHEL-56247

commit 50660c5197f52b8137e223dc3ba8d43661179a1d
Author: Mark Zhang <markzhang@nvidia.com>
Date:   Sun Jun 16 19:08:33 2024 +0300

    RDMA/core: Create "issm*" device nodes only when SMI is supported

    For an IB port create it's issm device node only when it has SMI
    capability. In following patches mlx5 is going to support IB devices
    without this cap.

    Signed-off-by: Mark Zhang <markzhang@nvidia.com>
    Link: https://lore.kernel.org/r/359f73c9a388d5e3ae971e40d8507888b1ba6f93.1718553901.git.leon@kernel.org
    Signed-off-by: Leon Romanovsky <leonro@nvidia.com>

Signed-off-by: Kamal Heib <kheib@redhat.com>
This commit is contained in:
Kamal Heib 2024-08-28 11:36:06 -04:00
parent a4f4710699
commit 6c43b862d2
1 changed files with 17 additions and 10 deletions

View File

@ -1321,15 +1321,17 @@ static int ib_umad_init_port(struct ib_device *device, int port_num,
if (ret)
goto err_cdev;
ib_umad_init_port_dev(&port->sm_dev, port, device);
port->sm_dev.devt = base_issm;
dev_set_name(&port->sm_dev, "issm%d", port->dev_num);
cdev_init(&port->sm_cdev, &umad_sm_fops);
port->sm_cdev.owner = THIS_MODULE;
if (rdma_cap_ib_smi(device, port_num)) {
ib_umad_init_port_dev(&port->sm_dev, port, device);
port->sm_dev.devt = base_issm;
dev_set_name(&port->sm_dev, "issm%d", port->dev_num);
cdev_init(&port->sm_cdev, &umad_sm_fops);
port->sm_cdev.owner = THIS_MODULE;
ret = cdev_device_add(&port->sm_cdev, &port->sm_dev);
if (ret)
goto err_dev;
ret = cdev_device_add(&port->sm_cdev, &port->sm_dev);
if (ret)
goto err_dev;
}
return 0;
@ -1345,9 +1347,13 @@ err_cdev:
static void ib_umad_kill_port(struct ib_umad_port *port)
{
struct ib_umad_file *file;
bool has_smi = false;
int id;
cdev_device_del(&port->sm_cdev, &port->sm_dev);
if (rdma_cap_ib_smi(port->ib_dev, port->port_num)) {
cdev_device_del(&port->sm_cdev, &port->sm_dev);
has_smi = true;
}
cdev_device_del(&port->cdev, &port->dev);
mutex_lock(&port->file_mutex);
@ -1373,7 +1379,8 @@ static void ib_umad_kill_port(struct ib_umad_port *port)
ida_free(&umad_ida, port->dev_num);
/* balances device_initialize() */
put_device(&port->sm_dev);
if (has_smi)
put_device(&port->sm_dev);
put_device(&port->dev);
}