Skip to contentSkip to conversation

dma-buf: remove pci-p2pdma include from dma-buf.h

PATCH In review Christian König 3 participants 3 messages Sep 21 DMA buffer sharing framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dma-buf: remove pci-p2pdma include from dma-buf.h

That is unecessary here and creates an unwanted dependency to the PCI subsystem. Move that into dma-buf-mapping.h instead.

---
 include/linux/dma-buf-mapping.h | 1 +
 include/linux/dma-buf.h         | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)
include/linux/dma-buf-mapping.h +1 -0
index 09bde3f748e4..fb5e52260700 100644
@@ -6,6 +6,7 @@
 #ifndef __DMA_BUF_MAPPING_H__
 #define __DMA_BUF_MAPPING_H__
 #include <linux/dma-buf.h>
+#include <linux/pci-p2pdma.h>
 
 struct sg_table *dma_buf_phys_vec_to_sgt(struct dma_buf_attachment *attach,
 					 struct p2pdma_provider *provider,
include/linux/dma-buf.h +0 -1
index d15b2b31d3c9..159271fcf3d2 100644
@@ -22,7 +22,6 @@
 #include <linux/fs.h>
 #include <linux/dma-fence.h>
 #include <linux/wait.h>
-#include <linux/pci-p2pdma.h>
 
 struct device;
 struct dma_buf;
Signature · 1 line
2.43.0
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] mlx5: compilation failure due to missing pci-p2pdma.h include --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] mlx5: compilation failure due to missing pci-p2pdma.h include
--

commit b5028b6ecc514cd51ffdd0df7d0570f15757e7f7
Author: Christian König <[email protected]>

dma-buf: remove pci-p2pdma include from dma-buf.h

That is unecessary here and creates an unwanted dependency to the PCI subsystem. Move that into dma-buf-mapping.h instead.

include/linux/dma-buf.h line 25

Quoted 9 lines
include/linux/dma-buf.h +0 -1
index d15b2b31d3c91..159271fcf3d2e 100644
@@ -22,7 +22,6 @@
 #include <linux/fs.h>
 #include <linux/dma-fence.h>
 #include <linux/wait.h>
-#include <linux/pci-p2pdma.h>

[Severity: Low]
Does removing this include break the compilation of the RDMA mlx5 driver?

It appears the mlx5 driver and ib_verbs.h implicitly relied on dma-buf.h providing declarations for pcim_p2pdma_provider and pcim_p2pdma_init.

Compiling with CONFIG_MLX5_INFINIBAND enabled results in implicit function declaration errors:

drivers/infiniband/hw/mlx5/main.c:mlx5_ib_mmap_get_pfns() {
    ...
    *provider = pcim_p2pdma_provider(pdev, bar);
    ...
}
drivers/infiniband/hw/mlx5/main.c:mlx5_ib_stage_init_init() {
    ...
    err = pcim_p2pdma_init(mdev->pdev);
    ...
}

It also causes a warning in include/rdma/ib_verbs.h where struct p2pdma_provider is used without a forward declaration in struct ib_device_ops:

include/rdma/ib_verbs.h:struct ib_device_ops {
    ...
    struct p2pdma_provider **provider);
    ...
}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#2 lore raw
In reply to Christian König
Quoted 14 lines · Christian König

That is unecessary here and creates an unwanted dependency to the PCI subsystem. Move that into dma-buf-mapping.h instead.

---
 include/linux/dma-buf-mapping.h | 1 +
 include/linux/dma-buf.h         | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)
include/linux/dma-buf-mapping.h +0 -0
index 09bde3f748e4..fb5e52260700 100644

include/linux/dma-buf-mapping.h line 12

Quoted 7 lines
include/linux/dma-buf-mapping.h +1 -0
@@ -6,6 +6,7 @@
 #ifndef __DMA_BUF_MAPPING_H__
 #define __DMA_BUF_MAPPING_H__
 #include <linux/dma-buf.h>
+#include <linux/pci-p2pdma.h>
 
 struct sg_table *dma_buf_phys_vec_to_sgt(struct dma_buf_attachment *attach,
 					 struct p2pdma_provider *provider,

Let's just use a forward declaration instead of the whole header:

struct p2pdma_provider;

Jason