[PATCH for-next] RDMA/core: Fix ib_core building error when CONFIG_MMU=n

From: Junxian Huang
Date: Thu Aug 08 2024 - 03:46:18 EST


zap_vma_ptes() depends on CONFIG_MMU. When CONFIG_MMU=n,
a building error occurs due to the zap_vma_ptes() call in
uverbs_user_mmap_disassociate():

ERROR: modpost: "zap_vma_ptes" [drivers/infiniband/core/ib_core.ko] undefined!

Add "#ifdef CONFIG_MMU" to fix this error.

Fixes: 577b3696166a ("RDMA/core: Provide rdma_user_mmap_disassociate() to disassociate mmap pages")
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Closes: https://lore.kernel.org/oe-kbuild-all/202408072142.mVX227UI-lkp@xxxxxxxxx/
Signed-off-by: Junxian Huang <huangjunxian6@xxxxxxxxxxxxx>
---
drivers/infiniband/core/ib_core_uverbs.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/core/ib_core_uverbs.c b/drivers/infiniband/core/ib_core_uverbs.c
index 4e27389a75ad..911aec0573cb 100644
--- a/drivers/infiniband/core/ib_core_uverbs.c
+++ b/drivers/infiniband/core/ib_core_uverbs.c
@@ -367,6 +367,7 @@ int rdma_user_mmap_entry_insert(struct ib_ucontext *ucontext,
}
EXPORT_SYMBOL(rdma_user_mmap_entry_insert);

+#ifdef CONFIG_MMU
void uverbs_user_mmap_disassociate(struct ib_uverbs_file *ufile)
{
struct rdma_umap_priv *priv, *next_priv;
@@ -428,7 +429,6 @@ void uverbs_user_mmap_disassociate(struct ib_uverbs_file *ufile)
mmput(mm);
}
}
-EXPORT_SYMBOL(uverbs_user_mmap_disassociate);

/**
* rdma_user_mmap_disassociate() - disassociate the mmap from the ucontext.
@@ -449,4 +449,14 @@ void rdma_user_mmap_disassociate(struct ib_ucontext *ucontext)
uverbs_user_mmap_disassociate(ufile);
up_read(&ufile->hw_destroy_rwsem);
}
+#else
+void uverbs_user_mmap_disassociate(struct ib_uverbs_file *ufile)
+{
+}
+
+void rdma_user_mmap_disassociate(struct ib_ucontext *ucontext)
+{
+}
+#endif
+EXPORT_SYMBOL(uverbs_user_mmap_disassociate);
EXPORT_SYMBOL(rdma_user_mmap_disassociate);
--
2.33.0