2023-07-03 12:16:27

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH] RDMA: fix INFINIBAND_USER_ACCESS dependency

From: Arnd Bergmann <[email protected]>

After a change to the bnxt_re driver, it fails to link when
CONFIG_INFINIBAND_USER_ACCESS is disabled:

aarch64-linux-ld: drivers/infiniband/hw/bnxt_re/ib_verbs.o: in function `bnxt_re_handler_BNXT_RE_METHOD_ALLOC_PAGE':
ib_verbs.c:(.text+0xd64): undefined reference to `ib_uverbs_get_ucontext_file'
aarch64-linux-ld: drivers/infiniband/hw/bnxt_re/ib_verbs.o:(.rodata+0x168): undefined reference to `uverbs_idr_class'
aarch64-linux-ld: drivers/infiniband/hw/bnxt_re/ib_verbs.o:(.rodata+0x1a8): undefined reference to `uverbs_destroy_def_handler'

The problem is that the 'bnxt_re_uapi_defs' structure is built
unconditionally and references a couple of functions that are never
really called in this configuration but instead require other functions
that are left out.

Adding an #ifdef around the new code, or a Kconfig dependency would
address this problem, but adding the compile-time check inside of the
UAPI_DEF_CHAIN_OBJ_TREE_NAMED() macro seems best because that also
addresses the problem in other drivers that may run into the same
dependency.

Fixes: 360da60d6c6ed ("RDMA/bnxt_re: Enable low latency push")
Signed-off-by: Arnd Bergmann <[email protected]>
---
include/rdma/uverbs_ioctl.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/rdma/uverbs_ioctl.h b/include/rdma/uverbs_ioctl.h
index 9d45a5b203169..06287de69cd29 100644
--- a/include/rdma/uverbs_ioctl.h
+++ b/include/rdma/uverbs_ioctl.h
@@ -436,8 +436,10 @@ struct uapi_definition {
}, \
##__VA_ARGS__
#define UAPI_DEF_CHAIN_OBJ_TREE_NAMED(_object_enum, ...) \
- UAPI_DEF_CHAIN_OBJ_TREE(_object_enum, &UVERBS_OBJECT(_object_enum), \
- ##__VA_ARGS__)
+ UAPI_DEF_CHAIN_OBJ_TREE(_object_enum, \
+ PTR_IF(IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS), \
+ &UVERBS_OBJECT(_object_enum)), \
+ ##__VA_ARGS__)

/*
* =======================================
--
2.39.2



2023-07-03 13:44:36

by Leon Romanovsky

[permalink] [raw]
Subject: Re: [PATCH] RDMA: fix INFINIBAND_USER_ACCESS dependency

On Mon, Jul 03, 2023 at 01:30:06PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <[email protected]>
>
> After a change to the bnxt_re driver, it fails to link when
> CONFIG_INFINIBAND_USER_ACCESS is disabled:
>
> aarch64-linux-ld: drivers/infiniband/hw/bnxt_re/ib_verbs.o: in function `bnxt_re_handler_BNXT_RE_METHOD_ALLOC_PAGE':
> ib_verbs.c:(.text+0xd64): undefined reference to `ib_uverbs_get_ucontext_file'
> aarch64-linux-ld: drivers/infiniband/hw/bnxt_re/ib_verbs.o:(.rodata+0x168): undefined reference to `uverbs_idr_class'
> aarch64-linux-ld: drivers/infiniband/hw/bnxt_re/ib_verbs.o:(.rodata+0x1a8): undefined reference to `uverbs_destroy_def_handler'
>
> The problem is that the 'bnxt_re_uapi_defs' structure is built
> unconditionally and references a couple of functions that are never
> really called in this configuration but instead require other functions
> that are left out.
>
> Adding an #ifdef around the new code, or a Kconfig dependency would
> address this problem, but adding the compile-time check inside of the
> UAPI_DEF_CHAIN_OBJ_TREE_NAMED() macro seems best because that also
> addresses the problem in other drivers that may run into the same
> dependency.
>
> Fixes: 360da60d6c6ed ("RDMA/bnxt_re: Enable low latency push")
> Signed-off-by: Arnd Bergmann <[email protected]>
> ---
> include/rdma/uverbs_ioctl.h | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>

Thanks,
Acked-by: Leon Romanovsky <[email protected]>

Linus, can you please apply this patch directly as it is overkill to
send PR for one patch?

https://lore.kernel.org/all/[email protected]

Thanks

2023-07-04 00:16:28

by Linus Torvalds

[permalink] [raw]
Subject: Re: [PATCH] RDMA: fix INFINIBAND_USER_ACCESS dependency

On Mon, 3 Jul 2023 at 06:32, Leon Romanovsky <[email protected]> wrote:
>
> Linus, can you please apply this patch directly as it is overkill to
> send PR for one patch?

Done.

Linus