rdma: fix INFINIBAND_USER_ACCESS dependency
authorArnd Bergmann <arnd@arndb.de>
Mon, 3 Jul 2023 11:30:06 +0000 (13:30 +0200)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 3 Jul 2023 23:55:04 +0000 (16:55 -0700)
commitb39aeb338a6f3854fe52c7e669438731ec2138c9
tree465c1afe09cbf71bf4d8a5821d693c8023537826
parenta8d70602b186f3c347e62c59a418be802b71886d
rdma: fix INFINIBAND_USER_ACCESS dependency

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 <arnd@arndb.de>
Acked-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/rdma/uverbs_ioctl.h