From: Leon Romanovsky <leon@kernel.org>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>,
linux-rdma@vger.kernel.org,
Selvin Xavier <selvin.xavier@broadcom.com>,
Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>,
patches@lists.linux.dev
Subject: Re: [PATCH v2 02/13] RDMA/core: Add rdma_udata_to_dev()
Date: Mon, 2 Mar 2026 21:30:56 +0200 [thread overview]
Message-ID: <20260302193056.GT12611@unreal> (raw)
In-Reply-To: <2-v2-13af4a900857+4f13-bnxt_re_uapi_jgg@nvidia.com>
On Thu, Feb 26, 2026 at 09:11:05PM -0400, Jason Gunthorpe wrote:
> Get an ib_device out of a udata so it can be used for debug prints.
>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
> drivers/infiniband/core/ib_core_uverbs.c | 27 ++++++++++++++++++++++++
> include/rdma/uverbs_ioctl.h | 2 ++
> 2 files changed, 29 insertions(+)
>
> diff --git a/drivers/infiniband/core/ib_core_uverbs.c b/drivers/infiniband/core/ib_core_uverbs.c
> index d3836a62a00495..bfe37a9c8a72bf 100644
> --- a/drivers/infiniband/core/ib_core_uverbs.c
> +++ b/drivers/infiniband/core/ib_core_uverbs.c
> @@ -389,3 +389,30 @@ int rdma_user_mmap_entry_insert(struct ib_ucontext *ucontext,
> U32_MAX);
> }
> EXPORT_SYMBOL(rdma_user_mmap_entry_insert);
> +
> +/**
> + * rdma_udata_to_dev - Get a ib_device from a udata
> + * @udata: The system calls ib_udata struct
> + *
> + * The struct ib_device that is handling the uverbs call. Must not be called if
> + * udata is NULL. The result can be NULL.
> + */
> +struct ib_device *rdma_udata_to_dev(struct ib_udata *udata)
> +{
> + struct uverbs_attr_bundle *bundle =
> + rdma_udata_to_uverbs_attr_bundle(udata);
> +
> + lockdep_assert_held(&bundle->ufile->device->disassociate_srcu);
> +
> + if (bundle->context)
> + return bundle->context->device;
> +
> + /*
> + * If the context hasn't been created yet use the ufile's dev, but it
> + * might be NULL if we are racing with disassociate.
> + */
> + return srcu_dereference(bundle->ufile->device->ib_dev,
> + &bundle->ufile->device->disassociate_srcu);
> +}
> +EXPORT_SYMBOL(rdma_udata_to_dev);
Thanks for this function, looks great, however I wonder about use of it
in debug prints. What about changing:
+ ibdev_dbg(
+ rdma_udata_to_dev(udata),
...
to be something
+ udata_dbg(
+ udata,
....
Together with keeping this rdma_udata_to_dev() function.
Thanks
next prev parent reply other threads:[~2026-03-02 19:31 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-27 1:11 [PATCH v2 00/13] Provide udata helpers and use them in bnxt_re Jason Gunthorpe
2026-02-27 1:11 ` [PATCH v2 01/13] RDMA: Use copy_struct_from_user() instead of open coding Jason Gunthorpe
2026-02-27 1:11 ` [PATCH v2 02/13] RDMA/core: Add rdma_udata_to_dev() Jason Gunthorpe
2026-03-02 19:30 ` Leon Romanovsky [this message]
2026-03-02 19:36 ` Jason Gunthorpe
2026-02-27 1:11 ` [PATCH v2 03/13] RDMA: Add ib_copy_validate_udata_in() Jason Gunthorpe
2026-02-27 7:50 ` kernel test robot
2026-02-28 10:24 ` kernel test robot
2026-02-27 1:11 ` [PATCH v2 04/13] RDMA: Add ib_copy_validate_udata_in_cm() Jason Gunthorpe
2026-02-27 1:11 ` [PATCH v2 05/13] RDMA: Add ib_respond_udata() Jason Gunthorpe
2026-02-27 1:11 ` [PATCH v2 06/13] RDMA: Add ib_is_udata_in_empty() Jason Gunthorpe
2026-02-27 1:11 ` [PATCH v2 07/13] RDMA: Provide documentation about the uABI compatibility rules Jason Gunthorpe
2026-02-27 1:11 ` [PATCH v2 08/13] RDMA/bnxt_re: Add compatibility checks to the uapi path Jason Gunthorpe
2026-02-27 1:11 ` [PATCH v2 09/13] RDMA/bnxt_re: Add compatibility checks to the uapi path for no data Jason Gunthorpe
2026-02-27 1:11 ` [PATCH v2 10/13] RDMA/bnxt_re: Add missing comp_mask validation Jason Gunthorpe
2026-02-27 1:11 ` [PATCH v2 11/13] RDMA/bnxt_re: Use ib_respond_udata() Jason Gunthorpe
2026-02-27 1:11 ` [PATCH v2 12/13] RDMA/bnxt_re: Use ib_respond_empty_udata() Jason Gunthorpe
2026-02-27 1:11 ` [PATCH v2 13/13] RDMA/bnxt_re: Add BNXT_RE_UCNTX_CMASK_UAPI_COMPAT_SUPPORTED Jason Gunthorpe
2026-03-02 19:24 ` [PATCH v2 00/13] Provide udata helpers and use them in bnxt_re Leon Romanovsky
2026-03-02 19:33 ` Jason Gunthorpe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260302193056.GT12611@unreal \
--to=leon@kernel.org \
--cc=jgg@nvidia.com \
--cc=kalesh-anakkur.purayil@broadcom.com \
--cc=linux-rdma@vger.kernel.org \
--cc=patches@lists.linux.dev \
--cc=selvin.xavier@broadcom.com \
--cc=sriharsha.basavapatna@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox