Skip to contentSkip to conversation

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

PATCH In review Christian König 4 participants 4 messages Sep 21 – Sep 22 DMA buffer sharing framework

lore
Share & tools
lore
#0 lore raw

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

That is unecessary here and creates an unwanted dependency to the PCI subsystem.

Use forward declare in dma-buf-mapping.h instead.

v2: switch to forward declare

---
 include/linux/dma-buf-mapping.h | 2 ++
 include/linux/dma-buf.h         | 1 -
 2 files changed, 2 insertions(+), 1 deletion(-)
include/linux/dma-buf-mapping.h +2 -0
index 09bde3f748e4..64c03608cce7 100644
@@ -7,6 +7,8 @@
 #define __DMA_BUF_MAPPING_H__
 #include <linux/dma-buf.h>
 
+struct p2pdma_provider;
+
 struct sg_table *dma_buf_phys_vec_to_sgt(struct dma_buf_attachment *attach,
 					 struct p2pdma_provider *provider,
 					 struct phys_vec *phys_vec,
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
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Christian König

That is unecessary here and creates an unwanted dependency to the PCI subsystem.

Use forward declare in dma-buf-mapping.h instead.

Quoted 7 lines

v2: switch to forward declare

---
 include/linux/dma-buf-mapping.h | 2 ++
 include/linux/dma-buf.h         | 1 -
 2 files changed, 2 insertions(+), 1 deletion(-)

Jason

#2 lore raw
In reply to Christian König
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] dma-buf: build failure in dma-buf-mapping.c due to missing pci-p2pdma include --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] dma-buf: build failure in dma-buf-mapping.c due to missing pci-p2pdma include --

commit 8de2b0ebefc837cd0e3d5d4be72922d840602ba3
Author: Christian König <[email protected]>
dma-buf: remove pci-p2pdma include from dma-buf.h v2

This commit removes the <linux/pci-p2pdma.h> include from <linux/dma-buf.h> to eliminate an unwanted dependency on the PCI subsystem. It uses a forward declaration in <linux/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 build for
drivers/dma-buf/dma-buf-mapping.c?

That file unconditionally uses functions and enum values from the pci-p2pdma header without explicitly including it, relying on this transitive inclusion. For example:

drivers/dma-buf/dma-buf-mapping.c:dma_buf_phys_vec_to_sgt() {
...

	switch (pci_p2pdma_map_type(provider, attach->dev)) {
	case PCI_P2PDMA_MAP_BUS_ADDR:

...
}

Will this lead to a compile-time failure for drivers/dma-buf/dma-buf-mapping.c due to undeclared identifiers?

Quoted 3 lines
include/linux/dma-buf.h +0 -0
 struct device;
 struct dma_buf;
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#3 lore raw
In reply to Christian König
Quoted 9 lines · Christian König

That is unecessary here and creates an unwanted dependency to the PCI subsystem.

Use forward declare in dma-buf-mapping.h instead.

v2: switch to forward declare

---

It is better to put the changelog below the --- line, as this information does not add anything useful for readers of the Git log.

Quoted 3 lines
 include/linux/dma-buf-mapping.h | 2 ++
 include/linux/dma-buf.h         | 1 -
 2 files changed, 2 insertions(+), 1 deletion(-)

I would expect #include <linux/pci-p2pdma.h> to be in drivers/dma-buf/dma-buf-mapping.c instead.

Thanks

Quoted 29 lines
include/linux/dma-buf-mapping.h +2 -0
index 09bde3f748e4..64c03608cce7 100644
@@ -7,6 +7,8 @@
 #define __DMA_BUF_MAPPING_H__
 #include <linux/dma-buf.h>
 
+struct p2pdma_provider;
+
 struct sg_table *dma_buf_phys_vec_to_sgt(struct dma_buf_attachment *attach,
 					 struct p2pdma_provider *provider,
 					 struct phys_vec *phys_vec,
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