From: Jiri Pirko Date: Fri, 29 May 2026 13:43:07 +0000 (+0200) Subject: RDMA/uverbs: Remove legacy umem field from struct ib_cq X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c5bbaaf4441558a5b7ab0e4db3f153b18a4ec19;p=thirdparty%2Fkernel%2Flinux.git RDMA/uverbs: Remove legacy umem field from struct ib_cq 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 Signed-off-by: Jason Gunthorpe --- diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c index b3261b924a718..89311fe656197 100644 --- a/drivers/infiniband/core/umem.c +++ b/drivers/infiniband/core/umem.c @@ -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 diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 32914007bae66..86df7ec83b3a7 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -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: diff --git a/drivers/infiniband/core/uverbs_std_types_cq.c b/drivers/infiniband/core/uverbs_std_types_cq.c index 05d1294762c0b..148cdd180dab5 100644 --- a/drivers/infiniband/core/uverbs_std_types_cq.c +++ b/drivers/infiniband/core/uverbs_std_types_cq.c @@ -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: diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c index bac87de9cc673..de7d19fabd759 100644 --- a/drivers/infiniband/core/verbs.c +++ b/drivers/infiniband/core/verbs.c @@ -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; diff --git a/include/rdma/ib_umem.h b/include/rdma/ib_umem.h index 492c8d3657303..370d802f0e632 100644 --- a/include/rdma/ib_umem.h +++ b/include/rdma/ib_umem.h @@ -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) { diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 01e0eea0703f9..893cb5b73951a 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -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: