Batch of unrelated cleanups in IB
Subsystems (4)
cover Batch of unrelated cleanups in IB
A collection of independent, self-contained cleanup patches in IB.
Thanks
---
Leon Romanovsky (4):
RDMA/umem: Remove redundant DMABUF ops check RDMA/mlx5: Avoid direct access to DMA device pointer RDMA/qedr: Remove unused defines RDMA/ocrdma: Remove unused OCRDMA_UVERBS definition
Maher Sanalla (1):
RDMA/mlx5: Fix ucaps init error flow
Parav Pandit (1):
RDMA/core: Avoid exporting module local functions and remove not-used ones
drivers/infiniband/core/device.c | 30 ------------------------------ drivers/infiniband/core/umem_dmabuf.c | 3 --- drivers/infiniband/hw/mlx5/main.c | 6 +++++- drivers/infiniband/hw/mlx5/mr.c | 11 ++++++----- drivers/infiniband/hw/ocrdma/ocrdma.h | 2 -- drivers/infiniband/hw/qedr/qedr.h | 20 -------------------- include/rdma/ib_verbs.h | 2 -- 7 files changed, 11 insertions(+), 63 deletions(-)
---
base-commit: a3572bdc3a028ca47f77d7166ac95b719cf77d50
change-id: 20251224-ib-core-misc-0081798ba040
Best regards,
Signature · 1 line
Leon Romanovsky <[email protected]>
PATCH 1/6 RDMA/umem: Remove redundant DMABUF ops check
From: Leon Romanovsky <[email protected]>
ib_umem_dmabuf_get_with_dma_device() is an in-kernel function and does not require a defensive check for the .move_notify callback. All current callers guarantee that this callback is always present.
--- drivers/infiniband/core/umem_dmabuf.c | 3 --- 1 file changed, 3 deletions(-)
drivers/infiniband/core/umem_dmabuf.c +0 -3
@@ -129,9 +129,6 @@ ib_umem_dmabuf_get_with_dma_device(struct ib_device *device,if (check_add_overflow (offset, (unsigned long )size, &end))return ret; -if (unlikely (!ops || !ops->move_notify)) -return ret; - dmabuf =dma_buf_get (fd);if (IS_ERR (dmabuf))return ERR_CAST (dmabuf);
Signature · 1 line
2.52.0
PATCH 3/6 RDMA/mlx5: Fix ucaps init error flow
In reply to Leon RomanovskyFrom: Maher Sanalla <[email protected]>
In mlx5_ib_stage_caps_init(), if mlx5_ib_init_ucaps() fails after mlx5_ib_init_var_table() succeeds, the VAR bitmap is leaked since the function returns without cleanup.
Thus, cleanup the var table bitmap in case of error of initializing ucaps before exiting, preventing the leak above.
--- drivers/infiniband/hw/mlx5/main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/main.c +5 -1
@@ -4466,12 +4466,16 @@ static int mlx5_ib_stage_caps_init(struct mlx5_ib_dev *dev) MLX5_HCA_CAP_2_GENERAL_OBJECT_TYPES_RDMA_CTRL) { err =mlx5_ib_init_ucaps (dev);if (err) -return err; + goto err_ucaps; } dev->ib_dev.use_cq_dim = true;return 0 ; + +err_ucaps: +bitmap_free (dev->var_table.bitmap); +return err; } static const struct ib_device_ops mlx5_ib_dev_port_ops = {
Signature · 1 line
2.52.0
PATCH 4/6 RDMA/mlx5: Avoid direct access to DMA device pointer
In reply to Leon RomanovskyFrom: Leon Romanovsky <[email protected]>
The dma_device field is marked as internal and must not be accessed by drivers or ULPs. Remove all direct mlx5 references to this field.
--- drivers/infiniband/hw/mlx5/mr.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/infiniband/hw/mlx5/mr.c +6 -5
@@ -1646,10 +1646,13 @@ reg_user_mr_dmabuf(struct ib_pd *pd, struct device *dma_device, offset, length, fd, access_flags, &mlx5_ib_dmabuf_attach_ops); - else + else if (dma_device) umem_dmabuf =ib_umem_dmabuf_get_pinned_with_dma_device (&dev->ib_dev, dma_device, offset, length, fd, access_flags); + else + umem_dmabuf =ib_umem_dmabuf_get_pinned ( + &dev->ib_dev, offset, length, fd, access_flags);if (IS_ERR (umem_dmabuf)) {mlx5_ib_dbg (dev,"umem_dmabuf get failed (%pe)\n" , umem_dmabuf);
@@ -1782,10 +1785,8 @@ struct ib_mr *mlx5_ib_reg_user_mr_dmabuf(struct ib_pd *pd, u64 offset,return reg_user_mr_dmabuf_by_data_direct (pd, offset, length, virt_addr, fd, access_flags); -return reg_user_mr_dmabuf (pd, pd->device->dma_device, - offset, length, virt_addr, - fd, access_flags,MLX5_MKC_ACCESS_MODE_MTT , - dmah); +return reg_user_mr_dmabuf (pd,NULL , offset, length, virt_addr, fd, + access_flags,MLX5_MKC_ACCESS_MODE_MTT , dmah); }/*
Signature · 1 line
2.52.0
PATCH 2/6 RDMA/core: Avoid exporting module local functions and remove not-used ones
In reply to Leon RomanovskyFrom: Parav Pandit <[email protected]>
Some of the functions are local to the module and some are not used starting from commit 36783dec8d79 ("RDMA/rxe: Delete deprecated module parameters interface"). Delete and avoid exporting them.
--- drivers/infiniband/core/device.c | 30 ------------------------------ include/rdma/ib_verbs.h | 2 -- 2 files changed, 32 deletions(-)
drivers/infiniband/core/device.c +0 -30
@@ -361,34 +361,6 @@ static struct ib_device *__ib_device_get_by_name(const char *name)return NULL ; } -/** -* ib_device_get_by_name - Find an IB device by name -* @name: The name to look for -* @driver_id: The driver ID that must match (RDMA_DRIVER_UNKNOWN matches all) -* -* Find and hold an ib_device by its name. The caller must call -* ib_device_put() on the returned pointer. -*/ -struct ib_device *ib_device_get_by_name (const char *name, -enum rdma_driver_id driver_id) -{ -struct ib_device *device; - -down_read (&devices_rwsem); - device =__ib_device_get_by_name (name); -if (device && driver_id !=RDMA_DRIVER_UNKNOWN && - device->ops.driver_id != driver_id) - device =NULL ; - -if (device) { -if (!ib_device_try_get (device)) - device =NULL ; - } -up_read (&devices_rwsem); -return device; -} -EXPORT_SYMBOL (ib_device_get_by_name); -static int rename_compat_devs (struct ib_device *device) {struct ib_core_device *cdev;
@@ -2875,7 +2847,6 @@ int ib_add_sub_device(struct ib_device *parent,return ret; } -EXPORT_SYMBOL (ib_add_sub_device);int ib_del_sub_device_and_put (struct ib_device *sub) {
@@ -2894,7 +2865,6 @@ int ib_del_sub_device_and_put(struct ib_device *sub)return 0 ; } -EXPORT_SYMBOL (ib_del_sub_device_and_put);#ifdef CONFIG_INFINIBAND_VIRT_DMA int ib_dma_virt_map_sg (struct ib_device *dev,struct scatterlist *sg,int nents)
include/rdma/ib_verbs.h +0 -2
@@ -4545,8 +4545,6 @@ static inline bool ib_device_try_get(struct ib_device *dev)void ib_device_put (struct ib_device *device);struct ib_device *ib_device_get_by_netdev (struct net_device *ndev,enum rdma_driver_id driver_id); -struct ib_device *ib_device_get_by_name (const char *name, -enum rdma_driver_id driver_id);struct net_device *ib_get_net_dev_by_params (struct ib_device *dev,u32 port,u16 pkey,const union ib_gid *gid,const struct sockaddr *addr);
Signature · 1 line
2.52.0
PATCH 6/6 RDMA/ocrdma: Remove unused OCRDMA_UVERBS definition
In reply to Leon RomanovskyFrom: Leon Romanovsky <[email protected]>
The OCRDMA_UVERBS() macro is unused, so remove it to clean up the code.
--- drivers/infiniband/hw/ocrdma/ocrdma.h | 2 -- 1 file changed, 2 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma.h +0 -2
@@ -67,8 +67,6 @@#define OC_SKH_DEVICE_VF 0x728#define OCRDMA_MAX_AH 512 -#define OCRDMA_UVERBS (CMD_NAME ) (1ull << IB_USER_VERBS_CMD_##CMD_NAME) -#define convert_to_64bit (lo, hi) ((u64)hi << 32 | (u64)lo)#define EQ_INTR_PER_SEC_THRSH_HI 150000#define EQ_INTR_PER_SEC_THRSH_LOW 100000
Signature · 1 line
2.52.0
PATCH 5/6 RDMA/qedr: Remove unused defines
In reply to Leon RomanovskyFrom: Leon Romanovsky <[email protected]>
Perform basic cleanup by removing unused defines from qedr.h.
--- drivers/infiniband/hw/qedr/qedr.h | 20 -------------------- 1 file changed, 20 deletions(-)
drivers/infiniband/hw/qedr/qedr.h +0 -20
@@ -53,11 +53,8 @@ DP_NAME(dev) ? DP_NAME(dev) : "", ## __VA_ARGS__)#define QEDR_MSG_INIT "INIT" -#define QEDR_MSG_MISC "MISC"#define QEDR_MSG_CQ " CQ"#define QEDR_MSG_MR " MR" -#define QEDR_MSG_RQ " RQ" -#define QEDR_MSG_SQ " SQ"#define QEDR_MSG_QP " QP"#define QEDR_MSG_SRQ " SRQ"#define QEDR_MSG_GSI " GSI"
@@ -65,7 +62,6 @@#define QEDR_CQ_MAGIC_NUMBER (0x11223344) -#define FW_PAGE_SIZE (RDMA_RING_PAGE_SIZE)#define FW_PAGE_SHIFT (12)struct qedr_dev ;
@@ -178,24 +174,18 @@ struct qedr_dev {u8 user_dpm_enabled; }; -#define QEDR_MAX_SQ_PBL (0x8000)#define QEDR_MAX_SQ_PBL_ENTRIES (0x10000 / sizeof(void *))#define QEDR_SQE_ELEMENT_SIZE (sizeof(struct rdma_sq_sge))#define QEDR_MAX_SQE_ELEMENTS_PER_SQE (ROCE_REQ_MAX_SINGLE_SQ_WQE_SIZE / \ QEDR_SQE_ELEMENT_SIZE) -#define QEDR_MAX_SQE_ELEMENTS_PER_PAGE ((RDMA_RING_PAGE_SIZE) / \ - QEDR_SQE_ELEMENT_SIZE)#define QEDR_MAX_SQE ((QEDR_MAX_SQ_PBL_ENTRIES) *\ (RDMA_RING_PAGE_SIZE) / \ (QEDR_SQE_ELEMENT_SIZE) /\ (QEDR_MAX_SQE_ELEMENTS_PER_SQE))/* RQ */ -#define QEDR_MAX_RQ_PBL (0x2000)#define QEDR_MAX_RQ_PBL_ENTRIES (0x10000 / sizeof(void *))#define QEDR_RQE_ELEMENT_SIZE (sizeof(struct rdma_rq_sge))#define QEDR_MAX_RQE_ELEMENTS_PER_RQE (RDMA_MAX_SGE_PER_RQ_WQE) -#define QEDR_MAX_RQE_ELEMENTS_PER_PAGE ((RDMA_RING_PAGE_SIZE) / \ - QEDR_RQE_ELEMENT_SIZE)#define QEDR_MAX_RQE ((QEDR_MAX_RQ_PBL_ENTRIES) *\ (RDMA_RING_PAGE_SIZE) / \ (QEDR_RQE_ELEMENT_SIZE) /\
@@ -210,12 +200,8 @@ struct qedr_dev {#define QEDR_ROCE_MAX_CNQ_SIZE (0x4000) -#define QEDR_MAX_PORT (1)#define QEDR_PORT (1) -#define QEDR_UVERBS (CMD_NAME ) (1ull << IB_USER_VERBS_CMD_##CMD_NAME) - -#define QEDR_ROCE_PKEY_MAX 1#define QEDR_ROCE_PKEY_TABLE_LEN 1#define QEDR_ROCE_PKEY_DEFAULT 0xffff
@@ -336,12 +322,6 @@ struct qedr_qp_hwq_info {union db_prod32 iwarp_db2_data; }; -#define QEDR_INC_SW_IDX (p_info, index) \ - do { \ - p_info->index = (p_info->index + 1) & \ - qed_chain_get_capacity(p_info->pbl) \ - } while (0) -struct qedr_srq_hwq_info {u32 max_sges;u32 max_wr;
Signature · 1 line
2.52.0
Re: [PATCH rdma-next 1/6] RDMA/umem: Remove redundant DMABUF ops check
In reply to Leon RomanovskyQuoted 8 lines · Leon Romanovsky
From: Leon Romanovsky <[email protected]>
ib_umem_dmabuf_get_with_dma_device()is an in-kernel function and does not require a defensive check for the .move_notify callback. All current callers guarantee that this callback is always present.Signed-off-by Leon Romanovsky <[email protected]>
Signature · 2 lines
Regards, Kalesh AP
Re: [PATCH rdma-next 5/6] RDMA/qedr: Remove unused defines
In reply to Leon RomanovskyQuoted 6 lines · Leon Romanovsky
From: Leon Romanovsky <[email protected]>
Perform basic cleanup by removing unused defines from
qedr.h.Signed-off-by Leon Romanovsky <[email protected]>
Signature · 2 lines
Regards, Kalesh AP
Re: [PATCH rdma-next 3/6] RDMA/mlx5: Fix ucaps init error flow
In reply to Leon RomanovskyQuoted 7 lines · Leon Romanovsky
From: Maher Sanalla <[email protected]>
In
mlx5_ib_stage_caps_init(), ifmlx5_ib_init_ucaps()fails aftermlx5_ib_init_var_table()succeeds, the VAR bitmap is leaked since the function returns without cleanup.
Quoted 7 lines
Thus, cleanup the var table bitmap in case of error of initializing ucaps before exiting, preventing the leak above.
Fixes cf7174e8982f ("RDMA/mlx5: Create UCAP char devices for supported device capabilities")Signed-off-by Maher Sanalla <[email protected]>Reviewed-by Yishai Hadas <[email protected]>Signed-off-by Leon Romanovsky <[email protected]>
Signature · 2 lines
Regards, Kalesh AP
Re: [PATCH rdma-next 6/6] RDMA/ocrdma: Remove unused OCRDMA_UVERBS definition
In reply to Leon RomanovskyQuoted 6 lines · Leon Romanovsky
From: Leon Romanovsky <[email protected]>
The
OCRDMA_UVERBS()macro is unused, so remove it to clean up the code.Signed-off-by Leon Romanovsky <[email protected]>
Signature · 2 lines
Regards, Kalesh AP
Re: [PATCH rdma-next 4/6] RDMA/mlx5: Avoid direct access to DMA device pointer
In reply to Leon RomanovskyQuoted 7 lines · Leon Romanovsky
From: Leon Romanovsky <[email protected]>
The
dma_devicefield is marked as internal and must not be accessed by drivers or ULPs. Remove all direct mlx5 references to this field.Signed-off-by Leon Romanovsky <[email protected]>
Signature · 2 lines
Regards, Kalesh AP
Re: [PATCH rdma-next 2/6] RDMA/core: Avoid exporting module local functions and remove not-used ones
In reply to Leon RomanovskyQuoted 9 lines · Leon Romanovsky
From: Parav Pandit <[email protected]>
Some of the functions are local to the module and some are not used starting from commit
36783dec8d79("RDMA/rxe: Delete deprecated module parameters interface"). Delete and avoid exporting them.Signed-off-by Parav Pandit <[email protected]>Signed-off-by Leon Romanovsky <[email protected]>
Signature · 2 lines
Regards, Kalesh AP
Re: [PATCH rdma-next 2/6] RDMA/core: Avoid exporting module local functions and remove not-used ones
In reply to Leon RomanovskyQuoted 8 lines · Leon Romanovsky
From: Parav Pandit <[email protected]>
Some of the functions are local to the module and some are not used starting from commit
36783dec8d79("RDMA/rxe: Delete deprecated module parameters interface"). Delete and avoid exporting them.Signed-off-by Parav Pandit <[email protected]>Signed-off-by Leon Romanovsky <[email protected]>
Zhu Yanjun
Quoted 74 lines
--- drivers/infiniband/core/device.c | 30 ------------------------------ include/rdma/ib_verbs.h | 2 -- 2 files changed, 32 deletions(-)drivers/infiniband/core/device.c +0
-30@@ -361,34 +361,6 @@ static struct ib_device *__ib_device_get_by_name(const char *name)return NULL ; } -/** -* ib_device_get_by_name - Find an IB device by name -* @name: The name to look for -* @driver_id: The driver ID that must match (RDMA_DRIVER_UNKNOWN matches all) -* -* Find and hold an ib_device by its name. The caller must call -* ib_device_put() on the returned pointer. -*/ -struct ib_device *ib_device_get_by_name (const char *name, -enum rdma_driver_id driver_id) -{ -struct ib_device *device; - -down_read (&devices_rwsem); - device =__ib_device_get_by_name (name); -if (device && driver_id !=RDMA_DRIVER_UNKNOWN && - device->ops.driver_id != driver_id) - device =NULL ; - -if (device) { -if (!ib_device_try_get (device)) - device =NULL ; - } -up_read (&devices_rwsem); -return device; -} -EXPORT_SYMBOL (ib_device_get_by_name); -static int rename_compat_devs (struct ib_device *device) {struct ib_core_device *cdev;@@ -2875,7 +2847,6 @@ int ib_add_sub_device(struct ib_device *parent,return ret; } -EXPORT_SYMBOL (ib_add_sub_device);int ib_del_sub_device_and_put (struct ib_device *sub) {@@ -2894,7 +2865,6 @@ int ib_del_sub_device_and_put(struct ib_device *sub)return 0 ; } -EXPORT_SYMBOL (ib_del_sub_device_and_put);#ifdef CONFIG_INFINIBAND_VIRT_DMA int ib_dma_virt_map_sg (struct ib_device *dev,struct scatterlist *sg,int nents)include/rdma/ib_verbs.h +0
-2@@ -4545,8 +4545,6 @@ static inline bool ib_device_try_get(struct ib_device *dev)void ib_device_put (struct ib_device *device);struct ib_device *ib_device_get_by_netdev (struct net_device *ndev,enum rdma_driver_id driver_id); -struct ib_device *ib_device_get_by_name (const char *name, -enum rdma_driver_id driver_id);struct net_device *ib_get_net_dev_by_params (struct ib_device *dev,u32 port,u16 pkey,const union ib_gid *gid,const struct sockaddr *addr);
Leon Romanovsky
AppliedQuoted 4 lines · Leon Romanovsky
A collection of independent, self-contained cleanup patches in IB.
Thanks
Applied, thanks!
[1/6] RDMA/umem: Remove redundant DMABUF ops check
https://git.kernel.org/rdma/rdma/c/ac7dea328ab52a [2/6] RDMA/core: Avoid exporting module local functions and remove not-used ones https://git.kernel.org/rdma/rdma/c/8d466b155f8389 [3/6] RDMA/mlx5: Fix ucaps init error flow https://git.kernel.org/rdma/rdma/c/6dc78c53de99e4 [4/6] RDMA/mlx5: Avoid direct access to DMA device pointer https://git.kernel.org/rdma/rdma/c/522a5c1c56fbf7 [5/6] RDMA/qedr: Remove unused defines https://git.kernel.org/rdma/rdma/c/cc016ebeb146d0 [6/6] RDMA/ocrdma: Remove unused OCRDMA_UVERBS definition https://git.kernel.org/rdma/rdma/c/325e3b5431ddd2
Best regards,
Signature · 1 line
Leon Romanovsky <[email protected]>