Re: [PATCH v2 02/13] RDMA/core: Add rdma_udata_to_dev()

Jason Gunthorpe
2026-03-02T19:36:33Z

On Mon, Mar 02, 2026 at 09:30:56PM +0200, Leon Romanovsky wrote:

> > +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.

I thought about that, and looked at it, but the entire flow to build
the dbg prints goes through alot of common infrastructure and it
rapidly became a big pain to put the udata through like that.

All drivers should be able to get the dev from their own information
so shouldn't be using the udata version at all.

Thus I'd prefer this since it probably won't be more than these couple
callers from the core code.

Arguably discouraging drivers from using it is a positive.

Jason