Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: "yanjun.zhu" <yanjun.zhu@linux.dev>
To: Leon Romanovsky <leon@kernel.org>, Jason Gunthorpe <jgg@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>,
	kernel test robot <lkp@intel.com>,
	linux-rdma@vger.kernel.org, Parav Pandit <parav@nvidia.com>
Subject: Re: [PATCH rdma-next] RDMA/uverbs: Add empty rdma_uattrs_has_raw_cap() declaration
Date: Tue, 8 Jul 2025 16:57:55 -0700	[thread overview]
Message-ID: <b202d1f7-7d73-430a-b725-58ca91a21b3f@linux.dev> (raw)
In-Reply-To: <72dee6b379bd709255a5d8e8010b576d50e47170.1751967071.git.leon@kernel.org>

On 7/8/25 2:31 AM, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@nvidia.com>
> 
> The call to rdma_uattrs_has_raw_cap() is placed in mlx5 fs.c file,
> which is compiled without relation to CONFIG_INFINIBAND_USER_ACCESS.
> 
> Despite the check is used only in flows with CONFIG_INFINIBAND_USER_ACCESS=y|m,
> the compilers generate the following error for CONFIG_INFINIBAND_USER_ACCESS=n
> builds.
> 
>>> ERROR: modpost: "rdma_uattrs_has_raw_cap" [drivers/infiniband/hw/mlx5/mlx5_ib.ko] undefined!
> 
> Fixes: f458ccd2aa2c ("RDMA/uverbs: Check CAP_NET_RAW in user namespace for flow create")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202507080725.bh7xrhpg-lkp@intel.com/
> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> ---
>   include/rdma/ib_verbs.h | 8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index c263327a0205..ce4180c4db14 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -4841,15 +4841,19 @@ struct ib_ucontext *ib_uverbs_get_ucontext_file(struct ib_uverbs_file *ufile);
>   
>   #if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS)
>   int uverbs_destroy_def_handler(struct uverbs_attr_bundle *attrs);
> +bool rdma_uattrs_has_raw_cap(const struct uverbs_attr_bundle *attrs);
>   #else
>   static inline int uverbs_destroy_def_handler(struct uverbs_attr_bundle *attrs)
>   {
>   	return 0;
>   }
> +static inline bool
> +rdma_uattrs_has_raw_cap(const struct uverbs_attr_bundle *attrs)
> +{
> +	return false;
> +}
>   #endif

The function rdma_uattrs_has_raw_cap is implemented in the file 
rdma_core.c. This file is included in the build via the Makefile:

"
...
ib_uverbs-y := uverbs_main.o uverbs_cmd.o uverbs_marshall.o \
                rdma_core.o uverbs_std_types.o uverbs_ioctl.o \
                ...
"
As a result, rdma_core.o is compiled only when 
CONFIG_INFINIBAND_USER_ACCESS is enabled.

In other words, the implementation of the rdma_uattrs_has_raw_cap 
function is guarded by CONFIG_INFINIBAND_USER_ACCESS.

Given this, it is reasonable to move the declaration of 
rdma_uattrs_has_raw_cap into the scope of CONFIG_INFINIBAND_USER_ACCESS 
in ib_verbs.h.

Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev>

Zhu Yanjun

>   
> -bool rdma_uattrs_has_raw_cap(const struct uverbs_attr_bundle *attrs);
> -
>   struct net_device *rdma_alloc_netdev(struct ib_device *device, u32 port_num,
>   				     enum rdma_netdev_t type, const char *name,
>   				     unsigned char name_assign_type,


  parent reply	other threads:[~2025-07-08 23:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-08  9:31 [PATCH rdma-next] RDMA/uverbs: Add empty rdma_uattrs_has_raw_cap() declaration Leon Romanovsky
2025-07-08  9:40 ` Parav Pandit
2025-07-08 23:57 ` yanjun.zhu [this message]
2025-07-09  7:41 ` Leon Romanovsky

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=b202d1f7-7d73-430a-b725-58ca91a21b3f@linux.dev \
    --to=yanjun.zhu@linux.dev \
    --cc=jgg@nvidia.com \
    --cc=leon@kernel.org \
    --cc=leonro@nvidia.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=parav@nvidia.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