]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
iommufd: Fix building without dmabuf
authorArnd Bergmann <arnd@arndb.de>
Thu, 4 Dec 2025 10:03:29 +0000 (11:03 +0100)
committerJason Gunthorpe <jgg@nvidia.com>
Tue, 16 Dec 2025 00:34:41 +0000 (20:34 -0400)
When DMABUF is disabled, trying to use it causes a link failure:

x86_64-linux-ld: drivers/iommu/iommufd/io_pagetable.o: in function `iopt_map_file_pages':
io_pagetable.c:(.text+0x1735): undefined reference to `dma_buf_get'
x86_64-linux-ld: io_pagetable.c:(.text+0x1775): undefined reference to `dma_buf_put'

Fixes: 44ebaa1744fd ("iommufd: Accept a DMABUF through IOMMU_IOAS_MAP_FILE")
Link: https://patch.msgid.link/r/20251204100333.1034767-1-arnd@kernel.org
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/iommu/iommufd/io_pagetable.c

index 54cf4d856179b99bb88f8724ddee492b07ce7da7..436992331111c60959841209308753a0645ffdd4 100644 (file)
@@ -495,7 +495,11 @@ int iopt_map_file_pages(struct iommufd_ctx *ictx, struct io_pagetable *iopt,
                return -EOVERFLOW;
 
        start_byte = start - ALIGN_DOWN(start, PAGE_SIZE);
-       dmabuf = dma_buf_get(fd);
+       if (IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))
+               dmabuf = dma_buf_get(fd);
+       else
+               dmabuf = ERR_PTR(-ENXIO);
+
        if (!IS_ERR(dmabuf)) {
                pages = iopt_alloc_dmabuf_pages(ictx, dmabuf, start_byte, start,
                                                length,