RDMA: Move owner into struct ib_device_ops
authorJason Gunthorpe <jgg@mellanox.com>
Wed, 5 Jun 2019 17:39:26 +0000 (14:39 -0300)
committerJason Gunthorpe <jgg@mellanox.com>
Mon, 10 Jun 2019 19:56:03 +0000 (16:56 -0300)
This more closely follows how other subsytems work, with owner being a
member of the structure containing the function pointers.

Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
20 files changed:
drivers/infiniband/core/device.c
drivers/infiniband/core/uverbs_main.c
drivers/infiniband/hw/bnxt_re/main.c
drivers/infiniband/hw/cxgb3/iwch_provider.c
drivers/infiniband/hw/cxgb4/provider.c
drivers/infiniband/hw/efa/efa_main.c
drivers/infiniband/hw/hfi1/verbs.c
drivers/infiniband/hw/hns/hns_roce_main.c
drivers/infiniband/hw/i40iw/i40iw_verbs.c
drivers/infiniband/hw/mlx4/main.c
drivers/infiniband/hw/mlx5/main.c
drivers/infiniband/hw/mthca/mthca_provider.c
drivers/infiniband/hw/nes/nes_verbs.c
drivers/infiniband/hw/ocrdma/ocrdma_main.c
drivers/infiniband/hw/qedr/main.c
drivers/infiniband/hw/qib/qib_verbs.c
drivers/infiniband/hw/usnic/usnic_ib_main.c
drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c
drivers/infiniband/sw/rxe/rxe_verbs.c
include/rdma/ib_verbs.h

index a00b7fc360bfa5c0871f854e90c9c1796fc342f3..357d74c8df2b2d097718b1c3747f7dbe771e5483 100644 (file)
@@ -2323,6 +2323,10 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops)
                        dev_ops->driver_id != ops->driver_id);
                dev_ops->driver_id = ops->driver_id;
        }
+       if (ops->owner) {
+               WARN_ON(dev_ops->owner && dev_ops->owner != ops->owner);
+               dev_ops->owner = ops->owner;
+       }
        if (ops->uverbs_abi_ver)
                dev_ops->uverbs_abi_ver = ops->uverbs_abi_ver;
 
index 0f8a286a92d3debfe6cc40bc4318ba023a65e645..870b3dd35aac631ab8ed0c01b66adafe624803e1 100644 (file)
@@ -198,7 +198,7 @@ void ib_uverbs_release_file(struct kref *ref)
        ib_dev = srcu_dereference(file->device->ib_dev,
                                  &file->device->disassociate_srcu);
        if (ib_dev && !ib_dev->ops.disassociate_ucontext)
-               module_put(ib_dev->owner);
+               module_put(ib_dev->ops.owner);
        srcu_read_unlock(&file->device->disassociate_srcu, srcu_key);
 
        if (atomic_dec_and_test(&file->device->refcount))
@@ -1065,7 +1065,7 @@ static int ib_uverbs_open(struct inode *inode, struct file *filp)
        module_dependent = !(ib_dev->ops.disassociate_ucontext);
 
        if (module_dependent) {
-               if (!try_module_get(ib_dev->owner)) {
+               if (!try_module_get(ib_dev->ops.owner)) {
                        ret = -ENODEV;
                        goto err;
                }
@@ -1100,7 +1100,7 @@ static int ib_uverbs_open(struct inode *inode, struct file *filp)
        return stream_open(inode, filp);
 
 err_module:
-       module_put(ib_dev->owner);
+       module_put(ib_dev->ops.owner);
 
 err:
        mutex_unlock(&dev->lists_mutex);
index a45cb9ee51abf90842859b095cb5fe42cddc48fc..351c420248a0cc8bf4fdadb3116d7769ea4522c5 100644 (file)
@@ -596,6 +596,7 @@ static void bnxt_re_unregister_ib(struct bnxt_re_dev *rdev)
 }
 
 static const struct ib_device_ops bnxt_re_dev_ops = {
+       .owner = THIS_MODULE,
        .driver_id = RDMA_DRIVER_BNXT_RE,
        .uverbs_abi_ver = BNXT_RE_ABI_VERSION,
 
@@ -651,7 +652,6 @@ static int bnxt_re_register_ib(struct bnxt_re_dev *rdev)
        int ret;
 
        /* ib device init */
-       ibdev->owner = THIS_MODULE;
        ibdev->node_type = RDMA_NODE_IB_CA;
        strlcpy(ibdev->node_desc, BNXT_RE_DESC " HCA",
                strlen(BNXT_RE_DESC) + 5);
index 5b410605a3a1f9730e7f600a977fe4382d65ee3d..1b35941eee74c74591a19ff2a2861bf69f8d63dc 100644 (file)
@@ -1236,6 +1236,7 @@ static void get_dev_fw_ver_str(struct ib_device *ibdev, char *str)
 }
 
 static const struct ib_device_ops iwch_dev_ops = {
+       .owner = THIS_MODULE,
        .driver_id = RDMA_DRIVER_CXGB3,
        .uverbs_abi_ver = IWCH_UVERBS_ABI_VERSION,
 
@@ -1285,7 +1286,6 @@ int iwch_register_device(struct iwch_dev *dev)
        pr_debug("%s iwch_dev %p\n", __func__, dev);
        memset(&dev->ibdev.node_guid, 0, sizeof(dev->ibdev.node_guid));
        memcpy(&dev->ibdev.node_guid, dev->rdev.t3cdev_p->lldev->dev_addr, 6);
-       dev->ibdev.owner = THIS_MODULE;
        dev->device_cap_flags = IB_DEVICE_LOCAL_DMA_LKEY |
                                IB_DEVICE_MEM_WINDOW |
                                IB_DEVICE_MEM_MGT_EXTENSIONS;
index c56cdfbd8a8848889ef742515f3f0c09bef66311..2b1f2443b7daac3f88f992a3ce376442680348cf 100644 (file)
@@ -489,6 +489,7 @@ static int fill_res_entry(struct sk_buff *msg, struct rdma_restrack_entry *res)
 }
 
 static const struct ib_device_ops c4iw_dev_ops = {
+       .owner = THIS_MODULE,
        .driver_id = RDMA_DRIVER_CXGB4,
        .uverbs_abi_ver = C4IW_UVERBS_ABI_VERSION,
 
@@ -563,7 +564,6 @@ void c4iw_register_device(struct work_struct *work)
        pr_debug("c4iw_dev %p\n", dev);
        memset(&dev->ibdev.node_guid, 0, sizeof(dev->ibdev.node_guid));
        memcpy(&dev->ibdev.node_guid, dev->rdev.lldi.ports[0]->dev_addr, 6);
-       dev->ibdev.owner = THIS_MODULE;
        dev->device_cap_flags = IB_DEVICE_LOCAL_DMA_LKEY | IB_DEVICE_MEM_WINDOW;
        if (fastreg_support)
                dev->device_cap_flags |= IB_DEVICE_MEM_MGT_EXTENSIONS;
index b05c5a0b9bc0bed8d29c6b2150fc0ca8c343f1f8..b891ee239a675525e5efa83adab29e7bd4bb915c 100644 (file)
@@ -197,6 +197,7 @@ static void efa_stats_init(struct efa_dev *dev)
 }
 
 static const struct ib_device_ops efa_dev_ops = {
+       .owner = THIS_MODULE,
        .driver_id = RDMA_DRIVER_EFA,
        .uverbs_abi_ver = EFA_UVERBS_ABI_VERSION,
 
@@ -262,7 +263,6 @@ static int efa_ib_device_add(struct efa_dev *dev)
        if (err)
                goto err_release_doorbell_bar;
 
-       dev->ibdev.owner = THIS_MODULE;
        dev->ibdev.node_type = RDMA_NODE_UNSPECIFIED;
        dev->ibdev.phys_port_cnt = 1;
        dev->ibdev.num_comp_vectors = 1;
index a97f4f9e5c6a8ad1d605e50024f7406c00d22370..1f36db98240fd6fdb373dd3a97f3fda3933ac7a2 100644 (file)
@@ -1779,6 +1779,7 @@ static int get_hw_stats(struct ib_device *ibdev, struct rdma_hw_stats *stats,
 }
 
 static const struct ib_device_ops hfi1_dev_ops = {
+       .owner = THIS_MODULE,
        .driver_id = RDMA_DRIVER_HFI1,
 
        .alloc_hw_stats = alloc_hw_stats,
@@ -1831,7 +1832,6 @@ int hfi1_register_ib_device(struct hfi1_devdata *dd)
         */
        if (!ib_hfi1_sys_image_guid)
                ib_hfi1_sys_image_guid = ibdev->node_guid;
-       ibdev->owner = THIS_MODULE;
        ibdev->phys_port_cnt = dd->num_pports;
        ibdev->dev.parent = &dd->pcidev->dev;
 
index e496b0628e252b1d71e5285df932e9c3e5a19209..f07b2ec86ec2c2368b0b90c4d926a2ddc618beb2 100644 (file)
@@ -414,6 +414,7 @@ static void hns_roce_unregister_device(struct hns_roce_dev *hr_dev)
 }
 
 static const struct ib_device_ops hns_roce_dev_ops = {
+       .owner = THIS_MODULE,
        .driver_id = RDMA_DRIVER_HNS,
        .uverbs_abi_ver = 1,
 
@@ -483,7 +484,6 @@ static int hns_roce_register_device(struct hns_roce_dev *hr_dev)
 
        ib_dev = &hr_dev->ib_dev;
 
-       ib_dev->owner                   = THIS_MODULE;
        ib_dev->node_type               = RDMA_NODE_IB_CA;
        ib_dev->dev.parent              = dev;
 
index 4dc647c8556b98feca8c610352b66eafb58c7edd..bfe16e6f04f43e3aa5d74c850461151978242aad 100644 (file)
@@ -2650,6 +2650,7 @@ static int i40iw_query_pkey(struct ib_device *ibdev,
 }
 
 static const struct ib_device_ops i40iw_dev_ops = {
+       .owner = THIS_MODULE,
        .driver_id = RDMA_DRIVER_I40IW,
        /* NOTE: Older kernels wrongly use 0 for the uverbs_abi_ver */
        .uverbs_abi_ver = I40IW_ABI_VER,
@@ -2711,7 +2712,6 @@ static struct i40iw_ib_device *i40iw_init_rdma_device(struct i40iw_device *iwdev
                i40iw_pr_err("iwdev == NULL\n");
                return NULL;
        }
-       iwibdev->ibdev.owner = THIS_MODULE;
        iwdev->iwibdev = iwibdev;
        iwibdev->iwdev = iwdev;
 
index 1f87221acbb05651d3b40a259fa13daa70bf993c..5d7a87842291d58d57fcad50f8366236c21c8df9 100644 (file)
@@ -2510,6 +2510,7 @@ static void get_fw_ver_str(struct ib_device *device, char *str)
 }
 
 static const struct ib_device_ops mlx4_ib_dev_ops = {
+       .owner = THIS_MODULE,
        .driver_id = RDMA_DRIVER_MLX4,
        .uverbs_abi_ver = MLX4_IB_UVERBS_ABI_VERSION,
 
@@ -2646,7 +2647,6 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
        ibdev->dev = dev;
        ibdev->bond_next_port   = 0;
 
-       ibdev->ib_dev.owner             = THIS_MODULE;
        ibdev->ib_dev.node_type         = RDMA_NODE_IB_CA;
        ibdev->ib_dev.local_dma_lkey    = dev->caps.reserved_lkey;
        ibdev->num_ports                = num_ports;
index 0c23eccb88558b65f0fc078c7d79be958c882e10..1e3d936ed80980c7f0a557ce32063a0eda9818c0 100644 (file)
@@ -6044,7 +6044,6 @@ static int mlx5_ib_stage_init_init(struct mlx5_ib_dev *dev)
        if (mlx5_use_mad_ifc(dev))
                get_ext_port_caps(dev);
 
-       dev->ib_dev.owner               = THIS_MODULE;
        dev->ib_dev.node_type           = RDMA_NODE_IB_CA;
        dev->ib_dev.local_dma_lkey      = 0 /* not supported for now */;
        dev->ib_dev.phys_port_cnt       = dev->num_ports;
@@ -6124,6 +6123,7 @@ static void mlx5_ib_stage_flow_db_cleanup(struct mlx5_ib_dev *dev)
 }
 
 static const struct ib_device_ops mlx5_ib_dev_ops = {
+       .owner = THIS_MODULE,
        .driver_id = RDMA_DRIVER_MLX5,
        .uverbs_abi_ver = MLX5_IB_UVERBS_ABI_VERSION,
 
index 690c65accea4a95b5fd626022a1c41a5c01b490e..b128ff76f7096646b5e94d2c996fd276c77879ac 100644 (file)
@@ -1153,6 +1153,7 @@ static void get_dev_fw_str(struct ib_device *device, char *str)
 }
 
 static const struct ib_device_ops mthca_dev_ops = {
+       .owner = THIS_MODULE,
        .driver_id = RDMA_DRIVER_MTHCA,
        .uverbs_abi_ver = MTHCA_UVERBS_ABI_VERSION,
 
@@ -1246,8 +1247,6 @@ int mthca_register_device(struct mthca_dev *dev)
        if (ret)
                return ret;
 
-       dev->ib_dev.owner                = THIS_MODULE;
-
        dev->ib_dev.uverbs_cmd_mask      =
                (1ull << IB_USER_VERBS_CMD_GET_CONTEXT)         |
                (1ull << IB_USER_VERBS_CMD_QUERY_DEVICE)        |
index f1fdd6829a4035092682dcd97d7ccf2244fee976..db044b2eaeadbfc0bb5624f7febfcc1e85d6079a 100644 (file)
@@ -3558,6 +3558,7 @@ static void get_dev_fw_str(struct ib_device *dev, char *str)
 }
 
 static const struct ib_device_ops nes_dev_ops = {
+       .owner = THIS_MODULE,
        .driver_id = RDMA_DRIVER_NES,
        /* NOTE: Older kernels wrongly use 0 for the uverbs_abi_ver */
        .uverbs_abi_ver = NES_ABI_USERSPACE_VER,
@@ -3617,7 +3618,6 @@ struct nes_ib_device *nes_init_ofa_device(struct net_device *netdev)
        if (nesibdev == NULL) {
                return NULL;
        }
-       nesibdev->ibdev.owner = THIS_MODULE;
 
        nesibdev->ibdev.node_type = RDMA_NODE_RNIC;
        memset(&nesibdev->ibdev.node_guid, 0, sizeof(nesibdev->ibdev.node_guid));
index ef823f1144b5223e5bf801e9409aab28168b38f4..b326313d413f7518daf2c86f2fd13d1fb9c5044f 100644 (file)
@@ -144,6 +144,7 @@ static const struct attribute_group ocrdma_attr_group = {
 };
 
 static const struct ib_device_ops ocrdma_dev_ops = {
+       .owner = THIS_MODULE,
        .driver_id = RDMA_DRIVER_OCRDMA,
        .uverbs_abi_ver = OCRDMA_ABI_VERSION,
 
@@ -203,7 +204,6 @@ static int ocrdma_register_device(struct ocrdma_dev *dev)
        BUILD_BUG_ON(sizeof(OCRDMA_NODE_DESC) > IB_DEVICE_NODE_DESC_MAX);
        memcpy(dev->ibdev.node_desc, OCRDMA_NODE_DESC,
               sizeof(OCRDMA_NODE_DESC));
-       dev->ibdev.owner = THIS_MODULE;
        dev->ibdev.uverbs_cmd_mask =
            OCRDMA_UVERBS(GET_CONTEXT) |
            OCRDMA_UVERBS(QUERY_DEVICE) |
index 793e25776a7e241ddccdef350ebf7b9678b09309..a0bb07ba0f3c0a652730b59918549b4812ec6da1 100644 (file)
@@ -183,6 +183,7 @@ static void qedr_roce_register_device(struct qedr_dev *dev)
 }
 
 static const struct ib_device_ops qedr_dev_ops = {
+       .owner = THIS_MODULE,
        .driver_id = RDMA_DRIVER_QEDR,
        .uverbs_abi_ver = QEDR_ABI_VERSION,
 
@@ -234,7 +235,6 @@ static int qedr_register_device(struct qedr_dev *dev)
 
        dev->ibdev.node_guid = dev->attr.node_guid;
        memcpy(dev->ibdev.node_desc, QEDR_NODE_DESC, sizeof(QEDR_NODE_DESC));
-       dev->ibdev.owner = THIS_MODULE;
 
        dev->ibdev.uverbs_cmd_mask = QEDR_UVERBS(GET_CONTEXT) |
                                     QEDR_UVERBS(QUERY_DEVICE) |
index bbc331d7f49bd8c010e44b051227119f8fe287e5..54310fd6c7b6892bb64618846159594d96c28148 100644 (file)
@@ -1482,6 +1482,7 @@ static void qib_fill_device_attr(struct qib_devdata *dd)
 }
 
 static const struct ib_device_ops qib_dev_ops = {
+       .owner = THIS_MODULE,
        .driver_id = RDMA_DRIVER_QIB,
 
        .init_port = qib_create_port_files,
@@ -1547,7 +1548,6 @@ int qib_register_ib_device(struct qib_devdata *dd)
        if (!ib_qib_sys_image_guid)
                ib_qib_sys_image_guid = ppd->guid;
 
-       ibdev->owner = THIS_MODULE;
        ibdev->node_guid = ppd->guid;
        ibdev->phys_port_cnt = dd->num_pports;
        ibdev->dev.parent = &dd->pcidev->dev;
index f6169081609580277bc8dbefd455d76be508b3ae..e701322dc7401b8457e656ce45814c10082eb4bb 100644 (file)
@@ -329,6 +329,7 @@ static void usnic_get_dev_fw_str(struct ib_device *device, char *str)
 }
 
 static const struct ib_device_ops usnic_dev_ops = {
+       .owner = THIS_MODULE,
        .driver_id = RDMA_DRIVER_USNIC,
        .uverbs_abi_ver = USNIC_UVERBS_ABI_VERSION,
 
@@ -387,7 +388,6 @@ static void *usnic_ib_device_add(struct pci_dev *dev)
 
        us_ibdev->pdev = dev;
        us_ibdev->netdev = pci_get_drvdata(dev);
-       us_ibdev->ib_dev.owner = THIS_MODULE;
        us_ibdev->ib_dev.node_type = RDMA_NODE_USNIC_UDP;
        us_ibdev->ib_dev.phys_port_cnt = USNIC_IB_PORT_CNT;
        us_ibdev->ib_dev.num_comp_vectors = USNIC_IB_NUM_COMP_VECTORS;
index 2a7eb2838453d40b0521a2f437cadd58cadafbd1..0c48464ffff1b7a49258e05560da2801acb6a10f 100644 (file)
@@ -144,6 +144,7 @@ static int pvrdma_port_immutable(struct ib_device *ibdev, u8 port_num,
 }
 
 static const struct ib_device_ops pvrdma_dev_ops = {
+       .owner = THIS_MODULE,
        .driver_id = RDMA_DRIVER_VMW_PVRDMA,
        .uverbs_abi_ver = PVRDMA_UVERBS_ABI_VERSION,
 
@@ -201,7 +202,6 @@ static int pvrdma_register_device(struct pvrdma_dev *dev)
        dev->ib_dev.node_guid = dev->dsr->caps.node_guid;
        dev->sys_image_guid = dev->dsr->caps.sys_image_guid;
        dev->flags = 0;
-       dev->ib_dev.owner = THIS_MODULE;
        dev->ib_dev.num_comp_vectors = 1;
        dev->ib_dev.dev.parent = &dev->pdev->dev;
        dev->ib_dev.uverbs_cmd_mask =
index 9e87cdb82becaa880227f585ee6c936e4aa43d13..046129393215dad96874bc24cda2a7108bf2f3b4 100644 (file)
@@ -1111,6 +1111,7 @@ static int rxe_enable_driver(struct ib_device *ib_dev)
 }
 
 static const struct ib_device_ops rxe_dev_ops = {
+       .owner = THIS_MODULE,
        .driver_id = RDMA_DRIVER_RXE,
        .uverbs_abi_ver = RXE_UVERBS_ABI_VERSION,
 
@@ -1173,7 +1174,6 @@ int rxe_register_device(struct rxe_dev *rxe, const char *ibdev_name)
 
        strlcpy(dev->node_desc, "rxe", sizeof(dev->node_desc));
 
-       dev->owner = THIS_MODULE;
        dev->node_type = RDMA_NODE_IB_CA;
        dev->phys_port_cnt = 1;
        dev->num_comp_vectors = num_possible_cpus();
index 16405b9bca137b69f108d1d643f305c210eb5d89..d1f16a6c4810ff62ea2b9144bd3ef990a967805b 100644 (file)
@@ -2329,6 +2329,7 @@ struct iw_cm_conn_param;
  * need to define the supported operations, otherwise they will be set to null.
  */
 struct ib_device_ops {
+       struct module *owner;
        enum rdma_driver_id driver_id;
        u32 uverbs_abi_ver;
 
@@ -2639,7 +2640,6 @@ struct ib_device {
 
        int                           num_comp_vectors;
 
-       struct module               *owner;
        union {
                struct device           dev;
                struct ib_core_device   coredev;