]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
RDMA/uverbs: Remove legacy umem field from struct ib_cq
authorJiri Pirko <jiri@nvidia.com>
Fri, 29 May 2026 13:43:07 +0000 (15:43 +0200)
committerJason Gunthorpe <jgg@nvidia.com>
Fri, 29 May 2026 23:19:59 +0000 (20:19 -0300)
Now that all drivers use helper to get umem and manage the lifetime,
legacy umem field in struct ib_cq is no longer needed. Remove it
along with ib_umem_get_cq_tmp() helper that populated it and both
error and destroy paths.

Link: https://patch.msgid.link/r/20260529134312.2836341-12-jiri@resnulli.us
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/core/umem.c
drivers/infiniband/core/uverbs_cmd.c
drivers/infiniband/core/uverbs_std_types_cq.c
drivers/infiniband/core/verbs.c
include/rdma/ib_umem.h
include/rdma/ib_verbs.h

index b3261b924a718d6381daa2ca88122bbcec2c8760..89311fe656197f2e587ed3d422ab60bbb78b10ee 100644 (file)
@@ -602,35 +602,6 @@ struct ib_umem *ib_umem_get_cq_buf_or_va(struct ib_device *device,
 }
 EXPORT_SYMBOL(ib_umem_get_cq_buf_or_va);
 
-/**
- * ib_umem_get_cq_tmp - Temporary CQ buffer umem getter.
- * @device: IB device.
- * @attrs:  uverbs attribute bundle.
- *
- * Pins a CQ buffer described by the legacy CQ buffer attributes.
- * Returns NULL when none are supplied.
- *
- * Will be removed once all CQ drivers have switched to get
- * their buffer directly.
- *
- * Return: caller-owned umem on success; NULL when no legacy attribute
- * is supplied; ERR_PTR(...) on error.
- */
-struct ib_umem *ib_umem_get_cq_tmp(struct ib_device *device,
-                                  struct uverbs_attr_bundle *attrs)
-{
-       struct ib_uverbs_buffer_desc desc = {};
-       int ret;
-
-       ret = uverbs_create_cq_get_buffer_desc(attrs, &desc);
-       if (ret == -ENODATA)
-               return NULL;
-       if (ret)
-               return ERR_PTR(ret);
-       return ib_umem_get_desc(device, &desc, IB_ACCESS_LOCAL_WRITE);
-}
-EXPORT_SYMBOL(ib_umem_get_cq_tmp);
-
 /**
  * ib_umem_release - release pinned memory
  * @umem: umem struct to release
index 32914007bae66f33d262741b9362ab46f95de657..86df7ec83b3a7beca4feea1444f3b84e6bb718d5 100644 (file)
@@ -1084,7 +1084,6 @@ static int create_cq(struct uverbs_attr_bundle *attrs,
        return uverbs_response(attrs, &resp, sizeof(resp));
 
 err_free:
-       ib_umem_release(cq->umem);
        rdma_restrack_put(&cq->res);
        kfree(cq);
 err_file:
index 05d1294762c0be3c33635d9552bcfe30c1672b9b..148cdd180dab53b6c0fa90725a76f46c74a71372 100644 (file)
@@ -68,7 +68,6 @@ static int UVERBS_HANDLER(UVERBS_METHOD_CQ_CREATE)(
        struct ib_device *ib_dev = attrs->context->device;
        struct ib_cq_init_attr attr = {};
        struct ib_uobject *ev_file_uobj;
-       struct ib_umem *umem = NULL;
        struct ib_cq *cq;
        u64 user_handle;
        int ret;
@@ -117,16 +116,9 @@ static int UVERBS_HANDLER(UVERBS_METHOD_CQ_CREATE)(
        INIT_LIST_HEAD(&obj->comp_list);
        INIT_LIST_HEAD(&obj->uevent.event_list);
 
-       umem = ib_umem_get_cq_tmp(ib_dev, attrs);
-       if (IS_ERR(umem)) {
-               ret = PTR_ERR(umem);
-               goto err_event_file;
-       }
-
        cq = rdma_zalloc_drv_obj(ib_dev, ib_cq);
        if (!cq) {
                ret = -ENOMEM;
-               ib_umem_release(umem);
                goto err_event_file;
        }
 
@@ -135,11 +127,6 @@ static int UVERBS_HANDLER(UVERBS_METHOD_CQ_CREATE)(
        cq->comp_handler  = ib_uverbs_comp_handler;
        cq->event_handler = ib_uverbs_cq_event_handler;
        cq->cq_context    = ev_file ? &ev_file->ev_queue : NULL;
-       /*
-        * If UMEM is not provided here, legacy drivers will set it during
-        * CQ creation based on their internal udata.
-        */
-       cq->umem = umem;
        atomic_set(&cq->usecnt, 0);
 
        rdma_restrack_new(&cq->res, RDMA_RESTRACK_CQ);
@@ -152,9 +139,6 @@ static int UVERBS_HANDLER(UVERBS_METHOD_CQ_CREATE)(
        if (ret)
                goto err_free;
 
-       /* Check that driver didn't overrun existing umem */
-       WARN_ON(umem && cq->umem != umem);
-
        obj->uevent.uobject.object = cq;
        obj->uevent.uobject.user_handle = user_handle;
        rdma_restrack_add(&cq->res);
@@ -165,7 +149,6 @@ static int UVERBS_HANDLER(UVERBS_METHOD_CQ_CREATE)(
        return ret;
 
 err_free:
-       ib_umem_release(cq->umem);
        rdma_restrack_put(&cq->res);
        kfree(cq);
 err_event_file:
index bac87de9cc6735c5d25420a7fac8facdd77d5f09..de7d19fabd75951f0c546accbbb97348e756c235 100644 (file)
@@ -2221,12 +2221,6 @@ struct ib_cq *__ib_create_cq(struct ib_device *device,
                kfree(cq);
                return ERR_PTR(ret);
        }
-       /*
-        * We are in kernel verbs flow and drivers are not allowed
-        * to set umem pointer, it needs to stay NULL.
-        */
-       WARN_ON_ONCE(cq->umem);
-
        rdma_restrack_add(&cq->res);
        return cq;
 }
@@ -2257,7 +2251,6 @@ int ib_destroy_cq_user(struct ib_cq *cq, struct ib_udata *udata)
        if (ret)
                return ret;
 
-       ib_umem_release(cq->umem);
        rdma_restrack_del(&cq->res);
        kfree(cq);
        return ret;
index 492c8d36573030f42c84054b2a52153ffa05117f..370d802f0e632f7cdf35ecd3722b216cba6e2e8d 100644 (file)
@@ -96,8 +96,6 @@ struct ib_umem *ib_umem_get_cq_buf(struct ib_device *device,
 struct ib_umem *ib_umem_get_cq_buf_or_va(struct ib_device *device,
                                         const struct uverbs_attr_bundle *attrs,
                                         u64 addr, size_t size, int access);
-struct ib_umem *ib_umem_get_cq_tmp(struct ib_device *device,
-                                  struct uverbs_attr_bundle *attrs);
 
 static inline struct ib_umem *ib_umem_get_va(struct ib_device *device,
                                             unsigned long addr, size_t size,
@@ -229,11 +227,6 @@ ib_umem_get_cq_buf_or_va(struct ib_device *device,
 {
        return ERR_PTR(-EOPNOTSUPP);
 }
-static inline struct ib_umem *
-ib_umem_get_cq_tmp(struct ib_device *device, struct uverbs_attr_bundle *attrs)
-{
-       return ERR_PTR(-EOPNOTSUPP);
-}
 static inline void ib_umem_release(struct ib_umem *umem) { }
 static inline int ib_umem_copy_from(void *dst, struct ib_umem *umem, size_t offset,
                                    size_t length) {
index 01e0eea0703f9d60eaf5bc77da08bd5e57743b9c..893cb5b73951a53b1ebc3e42f3186c84ddf5afc3 100644 (file)
@@ -1738,7 +1738,6 @@ struct ib_cq {
        u8 interrupt:1;
        u8 shared:1;
        unsigned int comp_vector;
-       struct ib_umem *umem;
 
        /*
         * Implementation details of the RDMA core, don't use in drivers: