* [PATCH] iommufd: fix building without dmabuf
@ 2025-12-04 10:03 Arnd Bergmann
2025-12-04 13:12 ` Jason Gunthorpe
2025-12-05 19:50 ` Jason Gunthorpe
0 siblings, 2 replies; 4+ messages in thread
From: Arnd Bergmann @ 2025-12-04 10:03 UTC (permalink / raw)
To: Jason Gunthorpe, Kevin Tian, Joerg Roedel, Will Deacon,
Nicolin Chen
Cc: Arnd Bergmann, Robin Murphy, Lu Baolu, Alex Mastro, iommu,
linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
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")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/iommu/iommufd/io_pagetable.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/iommufd/io_pagetable.c b/drivers/iommu/iommufd/io_pagetable.c
index 54cf4d856179..d22e86de03e9 100644
--- a/drivers/iommu/iommufd/io_pagetable.c
+++ b/drivers/iommu/iommufd/io_pagetable.c
@@ -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_DMABUF_HEAPS))
+ 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,
--
2.39.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] iommufd: fix building without dmabuf
2025-12-04 10:03 [PATCH] iommufd: fix building without dmabuf Arnd Bergmann
@ 2025-12-04 13:12 ` Jason Gunthorpe
2025-12-05 19:50 ` Jason Gunthorpe
1 sibling, 0 replies; 4+ messages in thread
From: Jason Gunthorpe @ 2025-12-04 13:12 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Kevin Tian, Joerg Roedel, Will Deacon, Nicolin Chen,
Arnd Bergmann, Robin Murphy, Lu Baolu, Alex Mastro, iommu,
linux-kernel
On Thu, Dec 04, 2025 at 11:03:29AM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> 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")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/iommu/iommufd/io_pagetable.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/iommufd/io_pagetable.c b/drivers/iommu/iommufd/io_pagetable.c
> index 54cf4d856179..d22e86de03e9 100644
> --- a/drivers/iommu/iommufd/io_pagetable.c
> +++ b/drivers/iommu/iommufd/io_pagetable.c
> @@ -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_DMABUF_HEAPS))
> + dmabuf = dma_buf_get(fd);
> + else
> + dmabuf = ERR_PTR(-ENXIO);
Shouldn't this be fixed in include/linux/dma-buf.h with a stub always
fail inline?
Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iommufd: fix building without dmabuf
2025-12-04 10:03 [PATCH] iommufd: fix building without dmabuf Arnd Bergmann
2025-12-04 13:12 ` Jason Gunthorpe
@ 2025-12-05 19:50 ` Jason Gunthorpe
2025-12-05 20:08 ` Arnd Bergmann
1 sibling, 1 reply; 4+ messages in thread
From: Jason Gunthorpe @ 2025-12-05 19:50 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Kevin Tian, Joerg Roedel, Will Deacon, Nicolin Chen,
Arnd Bergmann, Robin Murphy, Lu Baolu, Alex Mastro, iommu,
linux-kernel
On Thu, Dec 04, 2025 at 11:03:29AM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> 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")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/iommu/iommufd/io_pagetable.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
I picked this up anyhow since it looked like adding #ifdef stubs to
dma_buf.h was going to be a bigger thing
> + if (IS_ENABLED(CONFIG_DMABUF_HEAPS))
> + dmabuf = dma_buf_get(fd);
But this needs to be:
if (IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))
dmabuf = dma_buf_get(fd);
I fixed it
Thanks,
Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iommufd: fix building without dmabuf
2025-12-05 19:50 ` Jason Gunthorpe
@ 2025-12-05 20:08 ` Arnd Bergmann
0 siblings, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2025-12-05 20:08 UTC (permalink / raw)
To: Jason Gunthorpe, Arnd Bergmann
Cc: Kevin Tian, Joerg Roedel, Will Deacon, Nicolin Chen, Robin Murphy,
Baolu Lu, Alex Mastro, iommu, linux-kernel
On Fri, Dec 5, 2025, at 20:50, Jason Gunthorpe wrote:
>
> I picked this up anyhow since it looked like adding #ifdef stubs to
> dma_buf.h was going to be a bigger thing
>
>> + if (IS_ENABLED(CONFIG_DMABUF_HEAPS))
>> + dmabuf = dma_buf_get(fd);
>
> But this needs to be:
>
> if (IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))
> dmabuf = dma_buf_get(fd);
>
> I fixed it
Ok, thanks a lot!
Arnd
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-12-05 20:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-04 10:03 [PATCH] iommufd: fix building without dmabuf Arnd Bergmann
2025-12-04 13:12 ` Jason Gunthorpe
2025-12-05 19:50 ` Jason Gunthorpe
2025-12-05 20:08 ` Arnd Bergmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).