linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* two small PCI header cleanups
@ 2016-03-06 15:17 Christoph Hellwig
  2016-03-06 15:17 ` [PATCH 1/3] frv: remove stray pci_{alloc,free}_consistent declaration Christoph Hellwig
                   ` (3 more replies)
  0 siblings, 4 replies; 20+ messages in thread
From: Christoph Hellwig @ 2016-03-06 15:17 UTC (permalink / raw)
  To: bhelgaas; +Cc: linux-pci, linux-arch, linux-kernel

Move a header from asm-generic to Linux because it isn't a generic arch
implementation, and also implement the pci_dma_* helpers in common code.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 1/3] frv: remove stray pci_{alloc,free}_consistent declaration
  2016-03-06 15:17 two small PCI header cleanups Christoph Hellwig
@ 2016-03-06 15:17 ` Christoph Hellwig
  2016-03-07 17:57   ` Bjorn Helgaas
  2016-03-06 15:17 ` [PATCH 2/3] pci: move pci-bridge.h out of asm-generic Christoph Hellwig
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 20+ messages in thread
From: Christoph Hellwig @ 2016-03-06 15:17 UTC (permalink / raw)
  To: bhelgaas; +Cc: linux-pci, linux-arch, linux-kernel

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 arch/frv/include/asm/pci.h | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/arch/frv/include/asm/pci.h b/arch/frv/include/asm/pci.h
index e43d22c..7e96b57 100644
--- a/arch/frv/include/asm/pci.h
+++ b/arch/frv/include/asm/pci.h
@@ -32,12 +32,6 @@ extern void consistent_sync_page(struct page *page, unsigned long offset,
 				 size_t size, int direction);
 #endif
 
-extern void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
-				  dma_addr_t *dma_handle);
-
-extern void pci_free_consistent(struct pci_dev *hwdev, size_t size,
-				void *vaddr, dma_addr_t dma_handle);
-
 /* Return the index of the PCI controller for device PDEV. */
 #define pci_controller_num(PDEV)	(0)
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 2/3] pci: move pci-bridge.h out of asm-generic
  2016-03-06 15:17 two small PCI header cleanups Christoph Hellwig
  2016-03-06 15:17 ` [PATCH 1/3] frv: remove stray pci_{alloc,free}_consistent declaration Christoph Hellwig
@ 2016-03-06 15:17 ` Christoph Hellwig
  2016-03-07 16:35   ` Bjorn Helgaas
  2016-03-06 15:17 ` [PATCH 3/3] pci: move pci_dma_* helpers to common code Christoph Hellwig
  2016-03-06 20:47 ` two small PCI header cleanups Arnd Bergmann
  3 siblings, 1 reply; 20+ messages in thread
From: Christoph Hellwig @ 2016-03-06 15:17 UTC (permalink / raw)
  To: bhelgaas; +Cc: linux-pci, linux-arch, linux-kernel

This isn't an asm-generic header, but something used both by common code
and architectures.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 arch/alpha/include/asm/pci.h          |  2 +-
 arch/arm/include/asm/pci.h            |  2 +-
 arch/arm64/include/asm/pci.h          |  2 +-
 arch/mips/include/asm/pci.h           |  2 +-
 arch/powerpc/include/asm/pci-bridge.h |  2 +-
 arch/unicore32/include/asm/pci.h      |  2 +-
 arch/x86/pci/common.c                 |  2 +-
 drivers/of/of_pci.c                   |  2 +-
 drivers/pci/pci.c                     |  2 +-
 drivers/pci/probe.c                   |  2 +-
 drivers/pci/setup-bus.c               |  2 +-
 include/asm-generic/pci-bridge.h      | 74 -----------------------------------
 include/linux/pci-bridge.h            | 74 +++++++++++++++++++++++++++++++++++
 13 files changed, 85 insertions(+), 85 deletions(-)
 delete mode 100644 include/asm-generic/pci-bridge.h
 create mode 100644 include/linux/pci-bridge.h

diff --git a/arch/alpha/include/asm/pci.h b/arch/alpha/include/asm/pci.h
index 98f2eee..a742497 100644
--- a/arch/alpha/include/asm/pci.h
+++ b/arch/alpha/include/asm/pci.h
@@ -7,7 +7,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/scatterlist.h>
 #include <asm/machvec.h>
-#include <asm-generic/pci-bridge.h>
+#include <linux/pci-bridge.h>
 
 /*
  * The following structure is used to manage multiple PCI busses.
diff --git a/arch/arm/include/asm/pci.h b/arch/arm/include/asm/pci.h
index a563544..f869627 100644
--- a/arch/arm/include/asm/pci.h
+++ b/arch/arm/include/asm/pci.h
@@ -3,7 +3,7 @@
 
 #ifdef __KERNEL__
 #include <asm-generic/pci-dma-compat.h>
-#include <asm-generic/pci-bridge.h>
+#include <linux/pci-bridge.h>
 
 #include <asm/mach/pci.h> /* for pci_sys_data */
 
diff --git a/arch/arm64/include/asm/pci.h b/arch/arm64/include/asm/pci.h
index b008a72..a44f008 100644
--- a/arch/arm64/include/asm/pci.h
+++ b/arch/arm64/include/asm/pci.h
@@ -7,7 +7,7 @@
 #include <linux/dma-mapping.h>
 
 #include <asm/io.h>
-#include <asm-generic/pci-bridge.h>
+#include <linux/pci-bridge.h>
 #include <asm-generic/pci-dma-compat.h>
 
 #define PCIBIOS_MIN_IO		0x1000
diff --git a/arch/mips/include/asm/pci.h b/arch/mips/include/asm/pci.h
index 98c31e5..bb94de4 100644
--- a/arch/mips/include/asm/pci.h
+++ b/arch/mips/include/asm/pci.h
@@ -102,7 +102,7 @@ static inline void pci_resource_to_user(const struct pci_dev *dev, int bar,
 #include <linux/scatterlist.h>
 #include <linux/string.h>
 #include <asm/io.h>
-#include <asm-generic/pci-bridge.h>
+#include <linux/pci-bridge.h>
 
 struct pci_dev;
 
diff --git a/arch/powerpc/include/asm/pci-bridge.h b/arch/powerpc/include/asm/pci-bridge.h
index 54843ca..fd0363d 100644
--- a/arch/powerpc/include/asm/pci-bridge.h
+++ b/arch/powerpc/include/asm/pci-bridge.h
@@ -10,7 +10,7 @@
 #include <linux/pci.h>
 #include <linux/list.h>
 #include <linux/ioport.h>
-#include <asm-generic/pci-bridge.h>
+#include <linux/pci-bridge.h>
 
 struct device_node;
 
diff --git a/arch/unicore32/include/asm/pci.h b/arch/unicore32/include/asm/pci.h
index 38b3f37..e36ca77 100644
--- a/arch/unicore32/include/asm/pci.h
+++ b/arch/unicore32/include/asm/pci.h
@@ -14,7 +14,7 @@
 
 #ifdef __KERNEL__
 #include <asm-generic/pci-dma-compat.h>
-#include <asm-generic/pci-bridge.h>
+#include <linux/pci-bridge.h>
 #include <asm-generic/pci.h>
 #include <mach/hardware.h> /* for PCIBIOS_MIN_* */
 
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index d34b511..edd0022 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -12,7 +12,7 @@
 #include <linux/dmi.h>
 #include <linux/slab.h>
 
-#include <asm-generic/pci-bridge.h>
+#include <linux/pci-bridge.h>
 #include <asm/acpi.h>
 #include <asm/segment.h>
 #include <asm/io.h>
diff --git a/drivers/of/of_pci.c b/drivers/of/of_pci.c
index b1449f7..64705ef 100644
--- a/drivers/of/of_pci.c
+++ b/drivers/of/of_pci.c
@@ -5,7 +5,7 @@
 #include <linux/of_device.h>
 #include <linux/of_pci.h>
 #include <linux/slab.h>
-#include <asm-generic/pci-bridge.h>
+#include <linux/pci-bridge.h>
 
 static inline int __of_pci_pci_compare(struct device_node *node,
 				       unsigned int data)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 602eb42..5e5a196 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -25,7 +25,7 @@
 #include <linux/device.h>
 #include <linux/pm_runtime.h>
 #include <linux/pci_hotplug.h>
-#include <asm-generic/pci-bridge.h>
+#include <linux/pci-bridge.h>
 #include <asm/setup.h>
 #include <linux/aer.h>
 #include "pci.h"
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 6d7ab9b..af4dad3 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -15,7 +15,7 @@
 #include <linux/pci-aspm.h>
 #include <linux/aer.h>
 #include <linux/acpi.h>
-#include <asm-generic/pci-bridge.h>
+#include <linux/pci-bridge.h>
 #include "pci.h"
 
 #define CARDBUS_LATENCY_TIMER	176	/* secondary latency timer */
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 7796d0a..03c047c 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -25,7 +25,7 @@
 #include <linux/ioport.h>
 #include <linux/cache.h>
 #include <linux/slab.h>
-#include <asm-generic/pci-bridge.h>
+#include <linux/pci-bridge.h>
 #include "pci.h"
 
 unsigned int pci_flags;
diff --git a/include/asm-generic/pci-bridge.h b/include/asm-generic/pci-bridge.h
deleted file mode 100644
index 20db2e5..0000000
--- a/include/asm-generic/pci-bridge.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-#ifndef _ASM_GENERIC_PCI_BRIDGE_H
-#define _ASM_GENERIC_PCI_BRIDGE_H
-
-#ifdef __KERNEL__
-
-enum {
-	/* Force re-assigning all resources (ignore firmware
-	 * setup completely)
-	 */
-	PCI_REASSIGN_ALL_RSRC	= 0x00000001,
-
-	/* Re-assign all bus numbers */
-	PCI_REASSIGN_ALL_BUS	= 0x00000002,
-
-	/* Do not try to assign, just use existing setup */
-	PCI_PROBE_ONLY		= 0x00000004,
-
-	/* Don't bother with ISA alignment unless the bridge has
-	 * ISA forwarding enabled
-	 */
-	PCI_CAN_SKIP_ISA_ALIGN	= 0x00000008,
-
-	/* Enable domain numbers in /proc */
-	PCI_ENABLE_PROC_DOMAINS	= 0x00000010,
-	/* ... except for domain 0 */
-	PCI_COMPAT_DOMAIN_0	= 0x00000020,
-
-	/* PCIe downstream ports are bridges that normally lead to only a
-	 * device 0, but if this is set, we scan all possible devices, not
-	 * just device 0.
-	 */
-	PCI_SCAN_ALL_PCIE_DEVS	= 0x00000040,
-};
-
-#ifdef CONFIG_PCI
-extern unsigned int pci_flags;
-
-static inline void pci_set_flags(int flags)
-{
-	pci_flags = flags;
-}
-
-static inline void pci_add_flags(int flags)
-{
-	pci_flags |= flags;
-}
-
-static inline void pci_clear_flags(int flags)
-{
-	pci_flags &= ~flags;
-}
-
-static inline int pci_has_flag(int flag)
-{
-	return pci_flags & flag;
-}
-#else
-static inline void pci_set_flags(int flags) { }
-static inline void pci_add_flags(int flags) { }
-static inline void pci_clear_flags(int flags) { }
-static inline int pci_has_flag(int flag)
-{
-	return 0;
-}
-#endif	/* CONFIG_PCI */
-
-#endif	/* __KERNEL__ */
-#endif	/* _ASM_GENERIC_PCI_BRIDGE_H */
diff --git a/include/linux/pci-bridge.h b/include/linux/pci-bridge.h
new file mode 100644
index 0000000..25416e0
--- /dev/null
+++ b/include/linux/pci-bridge.h
@@ -0,0 +1,74 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+#ifndef _LINUX_PCI_BRIDGE_H
+#define _LINUX_PCI_BRIDGE_H
+
+#ifdef __KERNEL__
+
+enum {
+	/* Force re-assigning all resources (ignore firmware
+	 * setup completely)
+	 */
+	PCI_REASSIGN_ALL_RSRC	= 0x00000001,
+
+	/* Re-assign all bus numbers */
+	PCI_REASSIGN_ALL_BUS	= 0x00000002,
+
+	/* Do not try to assign, just use existing setup */
+	PCI_PROBE_ONLY		= 0x00000004,
+
+	/* Don't bother with ISA alignment unless the bridge has
+	 * ISA forwarding enabled
+	 */
+	PCI_CAN_SKIP_ISA_ALIGN	= 0x00000008,
+
+	/* Enable domain numbers in /proc */
+	PCI_ENABLE_PROC_DOMAINS	= 0x00000010,
+	/* ... except for domain 0 */
+	PCI_COMPAT_DOMAIN_0	= 0x00000020,
+
+	/* PCIe downstream ports are bridges that normally lead to only a
+	 * device 0, but if this is set, we scan all possible devices, not
+	 * just device 0.
+	 */
+	PCI_SCAN_ALL_PCIE_DEVS	= 0x00000040,
+};
+
+#ifdef CONFIG_PCI
+extern unsigned int pci_flags;
+
+static inline void pci_set_flags(int flags)
+{
+	pci_flags = flags;
+}
+
+static inline void pci_add_flags(int flags)
+{
+	pci_flags |= flags;
+}
+
+static inline void pci_clear_flags(int flags)
+{
+	pci_flags &= ~flags;
+}
+
+static inline int pci_has_flag(int flag)
+{
+	return pci_flags & flag;
+}
+#else
+static inline void pci_set_flags(int flags) { }
+static inline void pci_add_flags(int flags) { }
+static inline void pci_clear_flags(int flags) { }
+static inline int pci_has_flag(int flag)
+{
+	return 0;
+}
+#endif	/* CONFIG_PCI */
+
+#endif	/* __KERNEL__ */
+#endif	/* _LINUX_PCI_BRIDGE_H */
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 3/3] pci: move pci_dma_* helpers to common code
  2016-03-06 15:17 two small PCI header cleanups Christoph Hellwig
  2016-03-06 15:17 ` [PATCH 1/3] frv: remove stray pci_{alloc,free}_consistent declaration Christoph Hellwig
  2016-03-06 15:17 ` [PATCH 2/3] pci: move pci-bridge.h out of asm-generic Christoph Hellwig
@ 2016-03-06 15:17 ` Christoph Hellwig
  2016-03-06 15:17   ` Christoph Hellwig
  2016-03-07 18:28   ` Bjorn Helgaas
  2016-03-06 20:47 ` two small PCI header cleanups Arnd Bergmann
  3 siblings, 2 replies; 20+ messages in thread
From: Christoph Hellwig @ 2016-03-06 15:17 UTC (permalink / raw)
  To: bhelgaas; +Cc: linux-pci, linux-arch, linux-kernel

For a long time all architectures implement the pci_dma_* functions
using the generic DMA API, and they all use the same header to do
so.  This patch moves this header, pci-dma-compat.h, to include/linux
and includes it from the generic pci.h instead of having each arch
duplicate this include.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 arch/alpha/include/asm/pci.h         |   7 ---
 arch/arm/include/asm/pci.h           |   1 -
 arch/arm64/include/asm/pci.h         |   1 -
 arch/avr32/include/asm/pci.h         |   2 -
 arch/blackfin/include/asm/pci.h      |   1 -
 arch/cris/include/asm/pci.h          |   3 -
 arch/frv/include/asm/pci.h           |   1 -
 arch/ia64/include/asm/pci.h          |   2 -
 arch/m68k/include/asm/pci.h          |   1 -
 arch/microblaze/include/asm/pci.h    |   2 -
 arch/mips/include/asm/pci.h          |   3 -
 arch/mn10300/include/asm/pci.h       |   3 -
 arch/parisc/include/asm/pci.h        |   3 -
 arch/powerpc/include/asm/pci.h       |   2 -
 arch/s390/include/asm/pci.h          |   1 -
 arch/sh/include/asm/pci.h            |   3 -
 arch/sparc/include/asm/pci.h         |   3 -
 arch/tile/include/asm/pci.h          |   3 -
 arch/unicore32/include/asm/pci.h     |   1 -
 arch/x86/include/asm/pci.h           |   3 -
 arch/xtensa/include/asm/pci.h        |   3 -
 include/asm-generic/pci-dma-compat.h | 118 -----------------------------------
 include/linux/pci-dma-compat.h       | 118 +++++++++++++++++++++++++++++++++++
 include/linux/pci.h                  |   4 ++
 24 files changed, 122 insertions(+), 167 deletions(-)
 delete mode 100644 include/asm-generic/pci-dma-compat.h
 create mode 100644 include/linux/pci-dma-compat.h

diff --git a/arch/alpha/include/asm/pci.h b/arch/alpha/include/asm/pci.h
index a742497..c4f0884 100644
--- a/arch/alpha/include/asm/pci.h
+++ b/arch/alpha/include/asm/pci.h
@@ -66,13 +66,6 @@ extern void pcibios_set_master(struct pci_dev *dev);
    decisions.  */
 #define PCI_DMA_BUS_IS_PHYS  0
 
-#ifdef CONFIG_PCI
-
-/* implement the pci_ DMA API in terms of the generic device dma_ one */
-#include <asm-generic/pci-dma-compat.h>
-
-#endif
-
 /* TODO: integrate with include/asm-generic/pci.h ? */
 static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
 {
diff --git a/arch/arm/include/asm/pci.h b/arch/arm/include/asm/pci.h
index f869627..0860d1c 100644
--- a/arch/arm/include/asm/pci.h
+++ b/arch/arm/include/asm/pci.h
@@ -2,7 +2,6 @@
 #define ASMARM_PCI_H
 
 #ifdef __KERNEL__
-#include <asm-generic/pci-dma-compat.h>
 #include <linux/pci-bridge.h>
 
 #include <asm/mach/pci.h> /* for pci_sys_data */
diff --git a/arch/arm64/include/asm/pci.h b/arch/arm64/include/asm/pci.h
index a44f008..349b927 100644
--- a/arch/arm64/include/asm/pci.h
+++ b/arch/arm64/include/asm/pci.h
@@ -8,7 +8,6 @@
 
 #include <asm/io.h>
 #include <linux/pci-bridge.h>
-#include <asm-generic/pci-dma-compat.h>
 
 #define PCIBIOS_MIN_IO		0x1000
 #define PCIBIOS_MIN_MEM		0
diff --git a/arch/avr32/include/asm/pci.h b/arch/avr32/include/asm/pci.h
index a32a023..0f5f134 100644
--- a/arch/avr32/include/asm/pci.h
+++ b/arch/avr32/include/asm/pci.h
@@ -5,6 +5,4 @@
 
 #define PCI_DMA_BUS_IS_PHYS	(1)
 
-#include <asm-generic/pci-dma-compat.h>
-
 #endif /* __ASM_AVR32_PCI_H__ */
diff --git a/arch/blackfin/include/asm/pci.h b/arch/blackfin/include/asm/pci.h
index 14efc0d..11ea1cb 100644
--- a/arch/blackfin/include/asm/pci.h
+++ b/arch/blackfin/include/asm/pci.h
@@ -4,7 +4,6 @@
 #define _ASM_BFIN_PCI_H
 
 #include <linux/scatterlist.h>
-#include <asm-generic/pci-dma-compat.h>
 #include <asm-generic/pci.h>
 
 #define PCIBIOS_MIN_IO 0x00001000
diff --git a/arch/cris/include/asm/pci.h b/arch/cris/include/asm/pci.h
index c15b4b4..b1b289d 100644
--- a/arch/cris/include/asm/pci.h
+++ b/arch/cris/include/asm/pci.h
@@ -48,9 +48,6 @@ extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
 
 #endif /* __KERNEL__ */
 
-/* implement the pci_ DMA API in terms of the generic device dma_ one */
-#include <asm-generic/pci-dma-compat.h>
-
 /* generic pci stuff */
 #include <asm-generic/pci.h>
 
diff --git a/arch/frv/include/asm/pci.h b/arch/frv/include/asm/pci.h
index 7e96b57..809cfc6 100644
--- a/arch/frv/include/asm/pci.h
+++ b/arch/frv/include/asm/pci.h
@@ -15,7 +15,6 @@
 
 #include <linux/mm.h>
 #include <linux/scatterlist.h>
-#include <asm-generic/pci-dma-compat.h>
 #include <asm-generic/pci.h>
 
 struct pci_dev;
diff --git a/arch/ia64/include/asm/pci.h b/arch/ia64/include/asm/pci.h
index 07039d1..c0835b0 100644
--- a/arch/ia64/include/asm/pci.h
+++ b/arch/ia64/include/asm/pci.h
@@ -50,8 +50,6 @@ struct pci_dev;
 extern unsigned long ia64_max_iommu_merge_mask;
 #define PCI_DMA_BUS_IS_PHYS	(ia64_max_iommu_merge_mask == ~0UL)
 
-#include <asm-generic/pci-dma-compat.h>
-
 #define HAVE_PCI_MMAP
 extern int pci_mmap_page_range (struct pci_dev *dev, struct vm_area_struct *vma,
 				enum pci_mmap_state mmap_state, int write_combine);
diff --git a/arch/m68k/include/asm/pci.h b/arch/m68k/include/asm/pci.h
index 848c3df..3a3dbcf4 100644
--- a/arch/m68k/include/asm/pci.h
+++ b/arch/m68k/include/asm/pci.h
@@ -1,7 +1,6 @@
 #ifndef _ASM_M68K_PCI_H
 #define _ASM_M68K_PCI_H
 
-#include <asm-generic/pci-dma-compat.h>
 #include <asm-generic/pci.h>
 
 /* The PCI address space does equal the physical memory
diff --git a/arch/microblaze/include/asm/pci.h b/arch/microblaze/include/asm/pci.h
index dc9eb66..fc3ecb5 100644
--- a/arch/microblaze/include/asm/pci.h
+++ b/arch/microblaze/include/asm/pci.h
@@ -22,8 +22,6 @@
 #include <asm/prom.h>
 #include <asm/pci-bridge.h>
 
-#include <asm-generic/pci-dma-compat.h>
-
 #define PCIBIOS_MIN_IO		0x1000
 #define PCIBIOS_MIN_MEM		0x10000000
 
diff --git a/arch/mips/include/asm/pci.h b/arch/mips/include/asm/pci.h
index bb94de4..731ada1 100644
--- a/arch/mips/include/asm/pci.h
+++ b/arch/mips/include/asm/pci.h
@@ -125,9 +125,6 @@ static inline int pci_proc_domain(struct pci_bus *bus)
 
 #endif /* __KERNEL__ */
 
-/* implement the pci_ DMA API in terms of the generic device dma_ one */
-#include <asm-generic/pci-dma-compat.h>
-
 /* Do platform specific device initialization at pci_enable_device() time */
 extern int pcibios_plat_dev_init(struct pci_dev *dev);
 
diff --git a/arch/mn10300/include/asm/pci.h b/arch/mn10300/include/asm/pci.h
index be3debb..51159ff 100644
--- a/arch/mn10300/include/asm/pci.h
+++ b/arch/mn10300/include/asm/pci.h
@@ -80,9 +80,6 @@ extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
 
 #endif /* __KERNEL__ */
 
-/* implement the pci_ DMA API in terms of the generic device dma_ one */
-#include <asm-generic/pci-dma-compat.h>
-
 static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
 {
 	return channel ? 15 : 14;
diff --git a/arch/parisc/include/asm/pci.h b/arch/parisc/include/asm/pci.h
index 89c53bf..defebd9 100644
--- a/arch/parisc/include/asm/pci.h
+++ b/arch/parisc/include/asm/pci.h
@@ -194,9 +194,6 @@ extern void pcibios_init_bridge(struct pci_dev *);
 #define PCIBIOS_MIN_IO          0x10
 #define PCIBIOS_MIN_MEM         0x1000 /* NBPG - but pci/setup-res.c dies */
 
-/* export the pci_ DMA API in terms of the dma_ one */
-#include <asm-generic/pci-dma-compat.h>
-
 static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
 {
 	return channel ? 15 : 14;
diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h
index 6f8065a..a6f3ac0 100644
--- a/arch/powerpc/include/asm/pci.h
+++ b/arch/powerpc/include/asm/pci.h
@@ -20,8 +20,6 @@
 #include <asm/prom.h>
 #include <asm/pci-bridge.h>
 
-#include <asm-generic/pci-dma-compat.h>
-
 /* Return values for pci_controller_ops.probe_mode function */
 #define PCI_PROBE_NONE		-1	/* Don't look at this bus at all */
 #define PCI_PROBE_NORMAL	0	/* Do normal PCI probing */
diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h
index c873e68..fdba308 100644
--- a/arch/s390/include/asm/pci.h
+++ b/arch/s390/include/asm/pci.h
@@ -9,7 +9,6 @@
 #include <linux/pci.h>
 #include <linux/mutex.h>
 #include <asm-generic/pci.h>
-#include <asm-generic/pci-dma-compat.h>
 #include <asm/pci_clp.h>
 #include <asm/pci_debug.h>
 
diff --git a/arch/sh/include/asm/pci.h b/arch/sh/include/asm/pci.h
index e343dbd0..644314f 100644
--- a/arch/sh/include/asm/pci.h
+++ b/arch/sh/include/asm/pci.h
@@ -105,9 +105,6 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
 	return channel ? 15 : 14;
 }
 
-/* generic DMA-mapping stuff */
-#include <asm-generic/pci-dma-compat.h>
-
 #endif /* __KERNEL__ */
 #endif /* __ASM_SH_PCI_H */
 
diff --git a/arch/sparc/include/asm/pci.h b/arch/sparc/include/asm/pci.h
index d9c031f..6e14fd1 100644
--- a/arch/sparc/include/asm/pci.h
+++ b/arch/sparc/include/asm/pci.h
@@ -5,7 +5,4 @@
 #else
 #include <asm/pci_32.h>
 #endif
-
-#include <asm-generic/pci-dma-compat.h>
-
 #endif
diff --git a/arch/tile/include/asm/pci.h b/arch/tile/include/asm/pci.h
index dfedd7a..fe3de50 100644
--- a/arch/tile/include/asm/pci.h
+++ b/arch/tile/include/asm/pci.h
@@ -226,7 +226,4 @@ static inline int pcibios_assign_all_busses(void)
 /* Use any cpu for PCI. */
 #define cpumask_of_pcibus(bus) cpu_online_mask
 
-/* implement the pci_ DMA API in terms of the generic device dma_ one */
-#include <asm-generic/pci-dma-compat.h>
-
 #endif /* _ASM_TILE_PCI_H */
diff --git a/arch/unicore32/include/asm/pci.h b/arch/unicore32/include/asm/pci.h
index e36ca77..2f03304 100644
--- a/arch/unicore32/include/asm/pci.h
+++ b/arch/unicore32/include/asm/pci.h
@@ -13,7 +13,6 @@
 #define __UNICORE_PCI_H__
 
 #ifdef __KERNEL__
-#include <asm-generic/pci-dma-compat.h>
 #include <linux/pci-bridge.h>
 #include <asm-generic/pci.h>
 #include <mach/hardware.h> /* for PCIBIOS_MIN_* */
diff --git a/arch/x86/include/asm/pci.h b/arch/x86/include/asm/pci.h
index 4625943..7fd8eaa 100644
--- a/arch/x86/include/asm/pci.h
+++ b/arch/x86/include/asm/pci.h
@@ -105,9 +105,6 @@ void native_restore_msi_irqs(struct pci_dev *dev);
 #include <asm/pci_64.h>
 #endif
 
-/* implement the pci_ DMA API in terms of the generic device dma_ one */
-#include <asm-generic/pci-dma-compat.h>
-
 /* generic pci stuff */
 #include <asm-generic/pci.h>
 
diff --git a/arch/xtensa/include/asm/pci.h b/arch/xtensa/include/asm/pci.h
index e438a00..5d6bd93 100644
--- a/arch/xtensa/include/asm/pci.h
+++ b/arch/xtensa/include/asm/pci.h
@@ -55,9 +55,6 @@ int pci_mmap_page_range(struct pci_dev *pdev, struct vm_area_struct *vma,
 
 #endif /* __KERNEL__ */
 
-/* Implement the pci_ DMA API in terms of the generic device dma_ one */
-#include <asm-generic/pci-dma-compat.h>
-
 /* Generic PCI */
 #include <asm-generic/pci.h>
 
diff --git a/include/asm-generic/pci-dma-compat.h b/include/asm-generic/pci-dma-compat.h
deleted file mode 100644
index eafce7b..0000000
--- a/include/asm-generic/pci-dma-compat.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/* include this file if the platform implements the dma_ DMA Mapping API
- * and wants to provide the pci_ DMA Mapping API in terms of it */
-
-#ifndef _ASM_GENERIC_PCI_DMA_COMPAT_H
-#define _ASM_GENERIC_PCI_DMA_COMPAT_H
-
-#include <linux/dma-mapping.h>
-
-static inline void *
-pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
-		     dma_addr_t *dma_handle)
-{
-	return dma_alloc_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, dma_handle, GFP_ATOMIC);
-}
-
-static inline void *
-pci_zalloc_consistent(struct pci_dev *hwdev, size_t size,
-		      dma_addr_t *dma_handle)
-{
-	return dma_zalloc_coherent(hwdev == NULL ? NULL : &hwdev->dev,
-				   size, dma_handle, GFP_ATOMIC);
-}
-
-static inline void
-pci_free_consistent(struct pci_dev *hwdev, size_t size,
-		    void *vaddr, dma_addr_t dma_handle)
-{
-	dma_free_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, vaddr, dma_handle);
-}
-
-static inline dma_addr_t
-pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int direction)
-{
-	return dma_map_single(hwdev == NULL ? NULL : &hwdev->dev, ptr, size, (enum dma_data_direction)direction);
-}
-
-static inline void
-pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr,
-		 size_t size, int direction)
-{
-	dma_unmap_single(hwdev == NULL ? NULL : &hwdev->dev, dma_addr, size, (enum dma_data_direction)direction);
-}
-
-static inline dma_addr_t
-pci_map_page(struct pci_dev *hwdev, struct page *page,
-	     unsigned long offset, size_t size, int direction)
-{
-	return dma_map_page(hwdev == NULL ? NULL : &hwdev->dev, page, offset, size, (enum dma_data_direction)direction);
-}
-
-static inline void
-pci_unmap_page(struct pci_dev *hwdev, dma_addr_t dma_address,
-	       size_t size, int direction)
-{
-	dma_unmap_page(hwdev == NULL ? NULL : &hwdev->dev, dma_address, size, (enum dma_data_direction)direction);
-}
-
-static inline int
-pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg,
-	   int nents, int direction)
-{
-	return dma_map_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nents, (enum dma_data_direction)direction);
-}
-
-static inline void
-pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg,
-	     int nents, int direction)
-{
-	dma_unmap_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nents, (enum dma_data_direction)direction);
-}
-
-static inline void
-pci_dma_sync_single_for_cpu(struct pci_dev *hwdev, dma_addr_t dma_handle,
-		    size_t size, int direction)
-{
-	dma_sync_single_for_cpu(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction);
-}
-
-static inline void
-pci_dma_sync_single_for_device(struct pci_dev *hwdev, dma_addr_t dma_handle,
-		    size_t size, int direction)
-{
-	dma_sync_single_for_device(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction);
-}
-
-static inline void
-pci_dma_sync_sg_for_cpu(struct pci_dev *hwdev, struct scatterlist *sg,
-		int nelems, int direction)
-{
-	dma_sync_sg_for_cpu(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction);
-}
-
-static inline void
-pci_dma_sync_sg_for_device(struct pci_dev *hwdev, struct scatterlist *sg,
-		int nelems, int direction)
-{
-	dma_sync_sg_for_device(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction);
-}
-
-static inline int
-pci_dma_mapping_error(struct pci_dev *pdev, dma_addr_t dma_addr)
-{
-	return dma_mapping_error(&pdev->dev, dma_addr);
-}
-
-#ifdef CONFIG_PCI
-static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask)
-{
-	return dma_set_mask(&dev->dev, mask);
-}
-
-static inline int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
-{
-	return dma_set_coherent_mask(&dev->dev, mask);
-}
-#endif
-
-#endif
diff --git a/include/linux/pci-dma-compat.h b/include/linux/pci-dma-compat.h
new file mode 100644
index 0000000..eafce7b
--- /dev/null
+++ b/include/linux/pci-dma-compat.h
@@ -0,0 +1,118 @@
+/* include this file if the platform implements the dma_ DMA Mapping API
+ * and wants to provide the pci_ DMA Mapping API in terms of it */
+
+#ifndef _ASM_GENERIC_PCI_DMA_COMPAT_H
+#define _ASM_GENERIC_PCI_DMA_COMPAT_H
+
+#include <linux/dma-mapping.h>
+
+static inline void *
+pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
+		     dma_addr_t *dma_handle)
+{
+	return dma_alloc_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, dma_handle, GFP_ATOMIC);
+}
+
+static inline void *
+pci_zalloc_consistent(struct pci_dev *hwdev, size_t size,
+		      dma_addr_t *dma_handle)
+{
+	return dma_zalloc_coherent(hwdev == NULL ? NULL : &hwdev->dev,
+				   size, dma_handle, GFP_ATOMIC);
+}
+
+static inline void
+pci_free_consistent(struct pci_dev *hwdev, size_t size,
+		    void *vaddr, dma_addr_t dma_handle)
+{
+	dma_free_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, vaddr, dma_handle);
+}
+
+static inline dma_addr_t
+pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int direction)
+{
+	return dma_map_single(hwdev == NULL ? NULL : &hwdev->dev, ptr, size, (enum dma_data_direction)direction);
+}
+
+static inline void
+pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr,
+		 size_t size, int direction)
+{
+	dma_unmap_single(hwdev == NULL ? NULL : &hwdev->dev, dma_addr, size, (enum dma_data_direction)direction);
+}
+
+static inline dma_addr_t
+pci_map_page(struct pci_dev *hwdev, struct page *page,
+	     unsigned long offset, size_t size, int direction)
+{
+	return dma_map_page(hwdev == NULL ? NULL : &hwdev->dev, page, offset, size, (enum dma_data_direction)direction);
+}
+
+static inline void
+pci_unmap_page(struct pci_dev *hwdev, dma_addr_t dma_address,
+	       size_t size, int direction)
+{
+	dma_unmap_page(hwdev == NULL ? NULL : &hwdev->dev, dma_address, size, (enum dma_data_direction)direction);
+}
+
+static inline int
+pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg,
+	   int nents, int direction)
+{
+	return dma_map_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nents, (enum dma_data_direction)direction);
+}
+
+static inline void
+pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg,
+	     int nents, int direction)
+{
+	dma_unmap_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nents, (enum dma_data_direction)direction);
+}
+
+static inline void
+pci_dma_sync_single_for_cpu(struct pci_dev *hwdev, dma_addr_t dma_handle,
+		    size_t size, int direction)
+{
+	dma_sync_single_for_cpu(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction);
+}
+
+static inline void
+pci_dma_sync_single_for_device(struct pci_dev *hwdev, dma_addr_t dma_handle,
+		    size_t size, int direction)
+{
+	dma_sync_single_for_device(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction);
+}
+
+static inline void
+pci_dma_sync_sg_for_cpu(struct pci_dev *hwdev, struct scatterlist *sg,
+		int nelems, int direction)
+{
+	dma_sync_sg_for_cpu(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction);
+}
+
+static inline void
+pci_dma_sync_sg_for_device(struct pci_dev *hwdev, struct scatterlist *sg,
+		int nelems, int direction)
+{
+	dma_sync_sg_for_device(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction);
+}
+
+static inline int
+pci_dma_mapping_error(struct pci_dev *pdev, dma_addr_t dma_addr)
+{
+	return dma_mapping_error(&pdev->dev, dma_addr);
+}
+
+#ifdef CONFIG_PCI
+static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask)
+{
+	return dma_set_mask(&dev->dev, mask);
+}
+
+static inline int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
+{
+	return dma_set_coherent_mask(&dev->dev, mask);
+}
+#endif
+
+#endif
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 2771625..a3d22a5d 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1972,4 +1972,8 @@ static inline bool pci_ari_enabled(struct pci_bus *bus)
 {
 	return bus->self && bus->self->ari_enabled;
 }
+
+/* provide the legacy pci_dma_* API */
+#include <linux/pci-dma-compat.h>
+
 #endif /* LINUX_PCI_H */
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 3/3] pci: move pci_dma_* helpers to common code
  2016-03-06 15:17 ` [PATCH 3/3] pci: move pci_dma_* helpers to common code Christoph Hellwig
@ 2016-03-06 15:17   ` Christoph Hellwig
  2016-03-07 18:28   ` Bjorn Helgaas
  1 sibling, 0 replies; 20+ messages in thread
From: Christoph Hellwig @ 2016-03-06 15:17 UTC (permalink / raw)
  To: bhelgaas; +Cc: linux-pci, linux-arch, linux-kernel

For a long time all architectures implement the pci_dma_* functions
using the generic DMA API, and they all use the same header to do
so.  This patch moves this header, pci-dma-compat.h, to include/linux
and includes it from the generic pci.h instead of having each arch
duplicate this include.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 arch/alpha/include/asm/pci.h         |   7 ---
 arch/arm/include/asm/pci.h           |   1 -
 arch/arm64/include/asm/pci.h         |   1 -
 arch/avr32/include/asm/pci.h         |   2 -
 arch/blackfin/include/asm/pci.h      |   1 -
 arch/cris/include/asm/pci.h          |   3 -
 arch/frv/include/asm/pci.h           |   1 -
 arch/ia64/include/asm/pci.h          |   2 -
 arch/m68k/include/asm/pci.h          |   1 -
 arch/microblaze/include/asm/pci.h    |   2 -
 arch/mips/include/asm/pci.h          |   3 -
 arch/mn10300/include/asm/pci.h       |   3 -
 arch/parisc/include/asm/pci.h        |   3 -
 arch/powerpc/include/asm/pci.h       |   2 -
 arch/s390/include/asm/pci.h          |   1 -
 arch/sh/include/asm/pci.h            |   3 -
 arch/sparc/include/asm/pci.h         |   3 -
 arch/tile/include/asm/pci.h          |   3 -
 arch/unicore32/include/asm/pci.h     |   1 -
 arch/x86/include/asm/pci.h           |   3 -
 arch/xtensa/include/asm/pci.h        |   3 -
 include/asm-generic/pci-dma-compat.h | 118 -----------------------------------
 include/linux/pci-dma-compat.h       | 118 +++++++++++++++++++++++++++++++++++
 include/linux/pci.h                  |   4 ++
 24 files changed, 122 insertions(+), 167 deletions(-)
 delete mode 100644 include/asm-generic/pci-dma-compat.h
 create mode 100644 include/linux/pci-dma-compat.h

diff --git a/arch/alpha/include/asm/pci.h b/arch/alpha/include/asm/pci.h
index a742497..c4f0884 100644
--- a/arch/alpha/include/asm/pci.h
+++ b/arch/alpha/include/asm/pci.h
@@ -66,13 +66,6 @@ extern void pcibios_set_master(struct pci_dev *dev);
    decisions.  */
 #define PCI_DMA_BUS_IS_PHYS  0
 
-#ifdef CONFIG_PCI
-
-/* implement the pci_ DMA API in terms of the generic device dma_ one */
-#include <asm-generic/pci-dma-compat.h>
-
-#endif
-
 /* TODO: integrate with include/asm-generic/pci.h ? */
 static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
 {
diff --git a/arch/arm/include/asm/pci.h b/arch/arm/include/asm/pci.h
index f869627..0860d1c 100644
--- a/arch/arm/include/asm/pci.h
+++ b/arch/arm/include/asm/pci.h
@@ -2,7 +2,6 @@
 #define ASMARM_PCI_H
 
 #ifdef __KERNEL__
-#include <asm-generic/pci-dma-compat.h>
 #include <linux/pci-bridge.h>
 
 #include <asm/mach/pci.h> /* for pci_sys_data */
diff --git a/arch/arm64/include/asm/pci.h b/arch/arm64/include/asm/pci.h
index a44f008..349b927 100644
--- a/arch/arm64/include/asm/pci.h
+++ b/arch/arm64/include/asm/pci.h
@@ -8,7 +8,6 @@
 
 #include <asm/io.h>
 #include <linux/pci-bridge.h>
-#include <asm-generic/pci-dma-compat.h>
 
 #define PCIBIOS_MIN_IO		0x1000
 #define PCIBIOS_MIN_MEM		0
diff --git a/arch/avr32/include/asm/pci.h b/arch/avr32/include/asm/pci.h
index a32a023..0f5f134 100644
--- a/arch/avr32/include/asm/pci.h
+++ b/arch/avr32/include/asm/pci.h
@@ -5,6 +5,4 @@
 
 #define PCI_DMA_BUS_IS_PHYS	(1)
 
-#include <asm-generic/pci-dma-compat.h>
-
 #endif /* __ASM_AVR32_PCI_H__ */
diff --git a/arch/blackfin/include/asm/pci.h b/arch/blackfin/include/asm/pci.h
index 14efc0d..11ea1cb 100644
--- a/arch/blackfin/include/asm/pci.h
+++ b/arch/blackfin/include/asm/pci.h
@@ -4,7 +4,6 @@
 #define _ASM_BFIN_PCI_H
 
 #include <linux/scatterlist.h>
-#include <asm-generic/pci-dma-compat.h>
 #include <asm-generic/pci.h>
 
 #define PCIBIOS_MIN_IO 0x00001000
diff --git a/arch/cris/include/asm/pci.h b/arch/cris/include/asm/pci.h
index c15b4b4..b1b289d 100644
--- a/arch/cris/include/asm/pci.h
+++ b/arch/cris/include/asm/pci.h
@@ -48,9 +48,6 @@ extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
 
 #endif /* __KERNEL__ */
 
-/* implement the pci_ DMA API in terms of the generic device dma_ one */
-#include <asm-generic/pci-dma-compat.h>
-
 /* generic pci stuff */
 #include <asm-generic/pci.h>
 
diff --git a/arch/frv/include/asm/pci.h b/arch/frv/include/asm/pci.h
index 7e96b57..809cfc6 100644
--- a/arch/frv/include/asm/pci.h
+++ b/arch/frv/include/asm/pci.h
@@ -15,7 +15,6 @@
 
 #include <linux/mm.h>
 #include <linux/scatterlist.h>
-#include <asm-generic/pci-dma-compat.h>
 #include <asm-generic/pci.h>
 
 struct pci_dev;
diff --git a/arch/ia64/include/asm/pci.h b/arch/ia64/include/asm/pci.h
index 07039d1..c0835b0 100644
--- a/arch/ia64/include/asm/pci.h
+++ b/arch/ia64/include/asm/pci.h
@@ -50,8 +50,6 @@ struct pci_dev;
 extern unsigned long ia64_max_iommu_merge_mask;
 #define PCI_DMA_BUS_IS_PHYS	(ia64_max_iommu_merge_mask == ~0UL)
 
-#include <asm-generic/pci-dma-compat.h>
-
 #define HAVE_PCI_MMAP
 extern int pci_mmap_page_range (struct pci_dev *dev, struct vm_area_struct *vma,
 				enum pci_mmap_state mmap_state, int write_combine);
diff --git a/arch/m68k/include/asm/pci.h b/arch/m68k/include/asm/pci.h
index 848c3df..3a3dbcf4 100644
--- a/arch/m68k/include/asm/pci.h
+++ b/arch/m68k/include/asm/pci.h
@@ -1,7 +1,6 @@
 #ifndef _ASM_M68K_PCI_H
 #define _ASM_M68K_PCI_H
 
-#include <asm-generic/pci-dma-compat.h>
 #include <asm-generic/pci.h>
 
 /* The PCI address space does equal the physical memory
diff --git a/arch/microblaze/include/asm/pci.h b/arch/microblaze/include/asm/pci.h
index dc9eb66..fc3ecb5 100644
--- a/arch/microblaze/include/asm/pci.h
+++ b/arch/microblaze/include/asm/pci.h
@@ -22,8 +22,6 @@
 #include <asm/prom.h>
 #include <asm/pci-bridge.h>
 
-#include <asm-generic/pci-dma-compat.h>
-
 #define PCIBIOS_MIN_IO		0x1000
 #define PCIBIOS_MIN_MEM		0x10000000
 
diff --git a/arch/mips/include/asm/pci.h b/arch/mips/include/asm/pci.h
index bb94de4..731ada1 100644
--- a/arch/mips/include/asm/pci.h
+++ b/arch/mips/include/asm/pci.h
@@ -125,9 +125,6 @@ static inline int pci_proc_domain(struct pci_bus *bus)
 
 #endif /* __KERNEL__ */
 
-/* implement the pci_ DMA API in terms of the generic device dma_ one */
-#include <asm-generic/pci-dma-compat.h>
-
 /* Do platform specific device initialization at pci_enable_device() time */
 extern int pcibios_plat_dev_init(struct pci_dev *dev);
 
diff --git a/arch/mn10300/include/asm/pci.h b/arch/mn10300/include/asm/pci.h
index be3debb..51159ff 100644
--- a/arch/mn10300/include/asm/pci.h
+++ b/arch/mn10300/include/asm/pci.h
@@ -80,9 +80,6 @@ extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
 
 #endif /* __KERNEL__ */
 
-/* implement the pci_ DMA API in terms of the generic device dma_ one */
-#include <asm-generic/pci-dma-compat.h>
-
 static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
 {
 	return channel ? 15 : 14;
diff --git a/arch/parisc/include/asm/pci.h b/arch/parisc/include/asm/pci.h
index 89c53bf..defebd9 100644
--- a/arch/parisc/include/asm/pci.h
+++ b/arch/parisc/include/asm/pci.h
@@ -194,9 +194,6 @@ extern void pcibios_init_bridge(struct pci_dev *);
 #define PCIBIOS_MIN_IO          0x10
 #define PCIBIOS_MIN_MEM         0x1000 /* NBPG - but pci/setup-res.c dies */
 
-/* export the pci_ DMA API in terms of the dma_ one */
-#include <asm-generic/pci-dma-compat.h>
-
 static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
 {
 	return channel ? 15 : 14;
diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h
index 6f8065a..a6f3ac0 100644
--- a/arch/powerpc/include/asm/pci.h
+++ b/arch/powerpc/include/asm/pci.h
@@ -20,8 +20,6 @@
 #include <asm/prom.h>
 #include <asm/pci-bridge.h>
 
-#include <asm-generic/pci-dma-compat.h>
-
 /* Return values for pci_controller_ops.probe_mode function */
 #define PCI_PROBE_NONE		-1	/* Don't look at this bus at all */
 #define PCI_PROBE_NORMAL	0	/* Do normal PCI probing */
diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h
index c873e68..fdba308 100644
--- a/arch/s390/include/asm/pci.h
+++ b/arch/s390/include/asm/pci.h
@@ -9,7 +9,6 @@
 #include <linux/pci.h>
 #include <linux/mutex.h>
 #include <asm-generic/pci.h>
-#include <asm-generic/pci-dma-compat.h>
 #include <asm/pci_clp.h>
 #include <asm/pci_debug.h>
 
diff --git a/arch/sh/include/asm/pci.h b/arch/sh/include/asm/pci.h
index e343dbd0..644314f 100644
--- a/arch/sh/include/asm/pci.h
+++ b/arch/sh/include/asm/pci.h
@@ -105,9 +105,6 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
 	return channel ? 15 : 14;
 }
 
-/* generic DMA-mapping stuff */
-#include <asm-generic/pci-dma-compat.h>
-
 #endif /* __KERNEL__ */
 #endif /* __ASM_SH_PCI_H */
 
diff --git a/arch/sparc/include/asm/pci.h b/arch/sparc/include/asm/pci.h
index d9c031f..6e14fd1 100644
--- a/arch/sparc/include/asm/pci.h
+++ b/arch/sparc/include/asm/pci.h
@@ -5,7 +5,4 @@
 #else
 #include <asm/pci_32.h>
 #endif
-
-#include <asm-generic/pci-dma-compat.h>
-
 #endif
diff --git a/arch/tile/include/asm/pci.h b/arch/tile/include/asm/pci.h
index dfedd7a..fe3de50 100644
--- a/arch/tile/include/asm/pci.h
+++ b/arch/tile/include/asm/pci.h
@@ -226,7 +226,4 @@ static inline int pcibios_assign_all_busses(void)
 /* Use any cpu for PCI. */
 #define cpumask_of_pcibus(bus) cpu_online_mask
 
-/* implement the pci_ DMA API in terms of the generic device dma_ one */
-#include <asm-generic/pci-dma-compat.h>
-
 #endif /* _ASM_TILE_PCI_H */
diff --git a/arch/unicore32/include/asm/pci.h b/arch/unicore32/include/asm/pci.h
index e36ca77..2f03304 100644
--- a/arch/unicore32/include/asm/pci.h
+++ b/arch/unicore32/include/asm/pci.h
@@ -13,7 +13,6 @@
 #define __UNICORE_PCI_H__
 
 #ifdef __KERNEL__
-#include <asm-generic/pci-dma-compat.h>
 #include <linux/pci-bridge.h>
 #include <asm-generic/pci.h>
 #include <mach/hardware.h> /* for PCIBIOS_MIN_* */
diff --git a/arch/x86/include/asm/pci.h b/arch/x86/include/asm/pci.h
index 4625943..7fd8eaa 100644
--- a/arch/x86/include/asm/pci.h
+++ b/arch/x86/include/asm/pci.h
@@ -105,9 +105,6 @@ void native_restore_msi_irqs(struct pci_dev *dev);
 #include <asm/pci_64.h>
 #endif
 
-/* implement the pci_ DMA API in terms of the generic device dma_ one */
-#include <asm-generic/pci-dma-compat.h>
-
 /* generic pci stuff */
 #include <asm-generic/pci.h>
 
diff --git a/arch/xtensa/include/asm/pci.h b/arch/xtensa/include/asm/pci.h
index e438a00..5d6bd93 100644
--- a/arch/xtensa/include/asm/pci.h
+++ b/arch/xtensa/include/asm/pci.h
@@ -55,9 +55,6 @@ int pci_mmap_page_range(struct pci_dev *pdev, struct vm_area_struct *vma,
 
 #endif /* __KERNEL__ */
 
-/* Implement the pci_ DMA API in terms of the generic device dma_ one */
-#include <asm-generic/pci-dma-compat.h>
-
 /* Generic PCI */
 #include <asm-generic/pci.h>
 
diff --git a/include/asm-generic/pci-dma-compat.h b/include/asm-generic/pci-dma-compat.h
deleted file mode 100644
index eafce7b..0000000
--- a/include/asm-generic/pci-dma-compat.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/* include this file if the platform implements the dma_ DMA Mapping API
- * and wants to provide the pci_ DMA Mapping API in terms of it */
-
-#ifndef _ASM_GENERIC_PCI_DMA_COMPAT_H
-#define _ASM_GENERIC_PCI_DMA_COMPAT_H
-
-#include <linux/dma-mapping.h>
-
-static inline void *
-pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
-		     dma_addr_t *dma_handle)
-{
-	return dma_alloc_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, dma_handle, GFP_ATOMIC);
-}
-
-static inline void *
-pci_zalloc_consistent(struct pci_dev *hwdev, size_t size,
-		      dma_addr_t *dma_handle)
-{
-	return dma_zalloc_coherent(hwdev == NULL ? NULL : &hwdev->dev,
-				   size, dma_handle, GFP_ATOMIC);
-}
-
-static inline void
-pci_free_consistent(struct pci_dev *hwdev, size_t size,
-		    void *vaddr, dma_addr_t dma_handle)
-{
-	dma_free_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, vaddr, dma_handle);
-}
-
-static inline dma_addr_t
-pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int direction)
-{
-	return dma_map_single(hwdev == NULL ? NULL : &hwdev->dev, ptr, size, (enum dma_data_direction)direction);
-}
-
-static inline void
-pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr,
-		 size_t size, int direction)
-{
-	dma_unmap_single(hwdev == NULL ? NULL : &hwdev->dev, dma_addr, size, (enum dma_data_direction)direction);
-}
-
-static inline dma_addr_t
-pci_map_page(struct pci_dev *hwdev, struct page *page,
-	     unsigned long offset, size_t size, int direction)
-{
-	return dma_map_page(hwdev == NULL ? NULL : &hwdev->dev, page, offset, size, (enum dma_data_direction)direction);
-}
-
-static inline void
-pci_unmap_page(struct pci_dev *hwdev, dma_addr_t dma_address,
-	       size_t size, int direction)
-{
-	dma_unmap_page(hwdev == NULL ? NULL : &hwdev->dev, dma_address, size, (enum dma_data_direction)direction);
-}
-
-static inline int
-pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg,
-	   int nents, int direction)
-{
-	return dma_map_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nents, (enum dma_data_direction)direction);
-}
-
-static inline void
-pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg,
-	     int nents, int direction)
-{
-	dma_unmap_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nents, (enum dma_data_direction)direction);
-}
-
-static inline void
-pci_dma_sync_single_for_cpu(struct pci_dev *hwdev, dma_addr_t dma_handle,
-		    size_t size, int direction)
-{
-	dma_sync_single_for_cpu(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction);
-}
-
-static inline void
-pci_dma_sync_single_for_device(struct pci_dev *hwdev, dma_addr_t dma_handle,
-		    size_t size, int direction)
-{
-	dma_sync_single_for_device(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction);
-}
-
-static inline void
-pci_dma_sync_sg_for_cpu(struct pci_dev *hwdev, struct scatterlist *sg,
-		int nelems, int direction)
-{
-	dma_sync_sg_for_cpu(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction);
-}
-
-static inline void
-pci_dma_sync_sg_for_device(struct pci_dev *hwdev, struct scatterlist *sg,
-		int nelems, int direction)
-{
-	dma_sync_sg_for_device(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction);
-}
-
-static inline int
-pci_dma_mapping_error(struct pci_dev *pdev, dma_addr_t dma_addr)
-{
-	return dma_mapping_error(&pdev->dev, dma_addr);
-}
-
-#ifdef CONFIG_PCI
-static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask)
-{
-	return dma_set_mask(&dev->dev, mask);
-}
-
-static inline int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
-{
-	return dma_set_coherent_mask(&dev->dev, mask);
-}
-#endif
-
-#endif
diff --git a/include/linux/pci-dma-compat.h b/include/linux/pci-dma-compat.h
new file mode 100644
index 0000000..eafce7b
--- /dev/null
+++ b/include/linux/pci-dma-compat.h
@@ -0,0 +1,118 @@
+/* include this file if the platform implements the dma_ DMA Mapping API
+ * and wants to provide the pci_ DMA Mapping API in terms of it */
+
+#ifndef _ASM_GENERIC_PCI_DMA_COMPAT_H
+#define _ASM_GENERIC_PCI_DMA_COMPAT_H
+
+#include <linux/dma-mapping.h>
+
+static inline void *
+pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
+		     dma_addr_t *dma_handle)
+{
+	return dma_alloc_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, dma_handle, GFP_ATOMIC);
+}
+
+static inline void *
+pci_zalloc_consistent(struct pci_dev *hwdev, size_t size,
+		      dma_addr_t *dma_handle)
+{
+	return dma_zalloc_coherent(hwdev == NULL ? NULL : &hwdev->dev,
+				   size, dma_handle, GFP_ATOMIC);
+}
+
+static inline void
+pci_free_consistent(struct pci_dev *hwdev, size_t size,
+		    void *vaddr, dma_addr_t dma_handle)
+{
+	dma_free_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, vaddr, dma_handle);
+}
+
+static inline dma_addr_t
+pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int direction)
+{
+	return dma_map_single(hwdev == NULL ? NULL : &hwdev->dev, ptr, size, (enum dma_data_direction)direction);
+}
+
+static inline void
+pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr,
+		 size_t size, int direction)
+{
+	dma_unmap_single(hwdev == NULL ? NULL : &hwdev->dev, dma_addr, size, (enum dma_data_direction)direction);
+}
+
+static inline dma_addr_t
+pci_map_page(struct pci_dev *hwdev, struct page *page,
+	     unsigned long offset, size_t size, int direction)
+{
+	return dma_map_page(hwdev == NULL ? NULL : &hwdev->dev, page, offset, size, (enum dma_data_direction)direction);
+}
+
+static inline void
+pci_unmap_page(struct pci_dev *hwdev, dma_addr_t dma_address,
+	       size_t size, int direction)
+{
+	dma_unmap_page(hwdev == NULL ? NULL : &hwdev->dev, dma_address, size, (enum dma_data_direction)direction);
+}
+
+static inline int
+pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg,
+	   int nents, int direction)
+{
+	return dma_map_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nents, (enum dma_data_direction)direction);
+}
+
+static inline void
+pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg,
+	     int nents, int direction)
+{
+	dma_unmap_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nents, (enum dma_data_direction)direction);
+}
+
+static inline void
+pci_dma_sync_single_for_cpu(struct pci_dev *hwdev, dma_addr_t dma_handle,
+		    size_t size, int direction)
+{
+	dma_sync_single_for_cpu(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction);
+}
+
+static inline void
+pci_dma_sync_single_for_device(struct pci_dev *hwdev, dma_addr_t dma_handle,
+		    size_t size, int direction)
+{
+	dma_sync_single_for_device(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction);
+}
+
+static inline void
+pci_dma_sync_sg_for_cpu(struct pci_dev *hwdev, struct scatterlist *sg,
+		int nelems, int direction)
+{
+	dma_sync_sg_for_cpu(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction);
+}
+
+static inline void
+pci_dma_sync_sg_for_device(struct pci_dev *hwdev, struct scatterlist *sg,
+		int nelems, int direction)
+{
+	dma_sync_sg_for_device(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction);
+}
+
+static inline int
+pci_dma_mapping_error(struct pci_dev *pdev, dma_addr_t dma_addr)
+{
+	return dma_mapping_error(&pdev->dev, dma_addr);
+}
+
+#ifdef CONFIG_PCI
+static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask)
+{
+	return dma_set_mask(&dev->dev, mask);
+}
+
+static inline int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
+{
+	return dma_set_coherent_mask(&dev->dev, mask);
+}
+#endif
+
+#endif
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 2771625..a3d22a5d 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1972,4 +1972,8 @@ static inline bool pci_ari_enabled(struct pci_bus *bus)
 {
 	return bus->self && bus->self->ari_enabled;
 }
+
+/* provide the legacy pci_dma_* API */
+#include <linux/pci-dma-compat.h>
+
 #endif /* LINUX_PCI_H */
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: two small PCI header cleanups
  2016-03-06 15:17 two small PCI header cleanups Christoph Hellwig
                   ` (2 preceding siblings ...)
  2016-03-06 15:17 ` [PATCH 3/3] pci: move pci_dma_* helpers to common code Christoph Hellwig
@ 2016-03-06 20:47 ` Arnd Bergmann
  2016-03-06 20:52   ` Christoph Hellwig
  3 siblings, 1 reply; 20+ messages in thread
From: Arnd Bergmann @ 2016-03-06 20:47 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: bhelgaas, linux-pci, linux-arch, linux-kernel

On Sunday 06 March 2016, Christoph Hellwig wrote:
> Move a header from asm-generic to Linux because it isn't a generic arch
> implementation, and also implement the pci_dma_* helpers in common code.
> 

Nice cleanup!

Should I take these through the asm-generic tree?

	Arnd

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: two small PCI header cleanups
  2016-03-06 20:47 ` two small PCI header cleanups Arnd Bergmann
@ 2016-03-06 20:52   ` Christoph Hellwig
  2016-03-06 20:52     ` Christoph Hellwig
  0 siblings, 1 reply; 20+ messages in thread
From: Christoph Hellwig @ 2016-03-06 20:52 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Christoph Hellwig, bhelgaas, linux-pci, linux-arch, linux-kernel

On Sun, Mar 06, 2016 at 09:47:03PM +0100, Arnd Bergmann wrote:
> > Move a header from asm-generic to Linux because it isn't a generic arch
> > implementation, and also implement the pci_dma_* helpers in common code.
> > 
> 
> Nice cleanup!
> 
> Should I take these through the asm-generic tree?

I expected Bjoern to takes this throught the PCI tree, but as far
as I'm concerned your tree is fine as well.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: two small PCI header cleanups
  2016-03-06 20:52   ` Christoph Hellwig
@ 2016-03-06 20:52     ` Christoph Hellwig
  0 siblings, 0 replies; 20+ messages in thread
From: Christoph Hellwig @ 2016-03-06 20:52 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Christoph Hellwig, bhelgaas, linux-pci, linux-arch, linux-kernel

On Sun, Mar 06, 2016 at 09:47:03PM +0100, Arnd Bergmann wrote:
> > Move a header from asm-generic to Linux because it isn't a generic arch
> > implementation, and also implement the pci_dma_* helpers in common code.
> > 
> 
> Nice cleanup!
> 
> Should I take these through the asm-generic tree?

I expected Bjoern to takes this throught the PCI tree, but as far
as I'm concerned your tree is fine as well.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/3] pci: move pci-bridge.h out of asm-generic
  2016-03-06 15:17 ` [PATCH 2/3] pci: move pci-bridge.h out of asm-generic Christoph Hellwig
@ 2016-03-07 16:35   ` Bjorn Helgaas
  2016-03-07 16:37     ` Christoph Hellwig
  0 siblings, 1 reply; 20+ messages in thread
From: Bjorn Helgaas @ 2016-03-07 16:35 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: bhelgaas, linux-pci, linux-arch, linux-kernel, Arnd Bergmann

[+cc Arnd]

On Sun, Mar 06, 2016 at 04:17:54PM +0100, Christoph Hellwig wrote:
> This isn't an asm-generic header, but something used both by common code
> and architectures.

I did something similar with
http://lkml.kernel.org/r/20160202193026.9258.7573.stgit@bhelgaas-glaptop2.roam.corp.google.com

The generic things in include/asm-generic/pci-bridge.h weren't really
bridge-related, so I moved them to include/linux/pci.h instead of creating
include/linux/pci-bridge.h.

Then include/asm-generic/pci-bridge.h was empty, so I removed it and the
includes of it.

There were a few arch-specific asm/pci-bridge.h files, but they do contain
arch-specific things, and they're only included by arch code, so I left
them alone.

My changes are in linux-next, and I plan to merge them during the v4.6
merge window.

Bjorn

> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  arch/alpha/include/asm/pci.h          |  2 +-
>  arch/arm/include/asm/pci.h            |  2 +-
>  arch/arm64/include/asm/pci.h          |  2 +-
>  arch/mips/include/asm/pci.h           |  2 +-
>  arch/powerpc/include/asm/pci-bridge.h |  2 +-
>  arch/unicore32/include/asm/pci.h      |  2 +-
>  arch/x86/pci/common.c                 |  2 +-
>  drivers/of/of_pci.c                   |  2 +-
>  drivers/pci/pci.c                     |  2 +-
>  drivers/pci/probe.c                   |  2 +-
>  drivers/pci/setup-bus.c               |  2 +-
>  include/asm-generic/pci-bridge.h      | 74 -----------------------------------
>  include/linux/pci-bridge.h            | 74 +++++++++++++++++++++++++++++++++++
>  13 files changed, 85 insertions(+), 85 deletions(-)
>  delete mode 100644 include/asm-generic/pci-bridge.h
>  create mode 100644 include/linux/pci-bridge.h
> 
> diff --git a/arch/alpha/include/asm/pci.h b/arch/alpha/include/asm/pci.h
> index 98f2eee..a742497 100644
> --- a/arch/alpha/include/asm/pci.h
> +++ b/arch/alpha/include/asm/pci.h
> @@ -7,7 +7,7 @@
>  #include <linux/dma-mapping.h>
>  #include <linux/scatterlist.h>
>  #include <asm/machvec.h>
> -#include <asm-generic/pci-bridge.h>
> +#include <linux/pci-bridge.h>
>  
>  /*
>   * The following structure is used to manage multiple PCI busses.
> diff --git a/arch/arm/include/asm/pci.h b/arch/arm/include/asm/pci.h
> index a563544..f869627 100644
> --- a/arch/arm/include/asm/pci.h
> +++ b/arch/arm/include/asm/pci.h
> @@ -3,7 +3,7 @@
>  
>  #ifdef __KERNEL__
>  #include <asm-generic/pci-dma-compat.h>
> -#include <asm-generic/pci-bridge.h>
> +#include <linux/pci-bridge.h>
>  
>  #include <asm/mach/pci.h> /* for pci_sys_data */
>  
> diff --git a/arch/arm64/include/asm/pci.h b/arch/arm64/include/asm/pci.h
> index b008a72..a44f008 100644
> --- a/arch/arm64/include/asm/pci.h
> +++ b/arch/arm64/include/asm/pci.h
> @@ -7,7 +7,7 @@
>  #include <linux/dma-mapping.h>
>  
>  #include <asm/io.h>
> -#include <asm-generic/pci-bridge.h>
> +#include <linux/pci-bridge.h>
>  #include <asm-generic/pci-dma-compat.h>
>  
>  #define PCIBIOS_MIN_IO		0x1000
> diff --git a/arch/mips/include/asm/pci.h b/arch/mips/include/asm/pci.h
> index 98c31e5..bb94de4 100644
> --- a/arch/mips/include/asm/pci.h
> +++ b/arch/mips/include/asm/pci.h
> @@ -102,7 +102,7 @@ static inline void pci_resource_to_user(const struct pci_dev *dev, int bar,
>  #include <linux/scatterlist.h>
>  #include <linux/string.h>
>  #include <asm/io.h>
> -#include <asm-generic/pci-bridge.h>
> +#include <linux/pci-bridge.h>
>  
>  struct pci_dev;
>  
> diff --git a/arch/powerpc/include/asm/pci-bridge.h b/arch/powerpc/include/asm/pci-bridge.h
> index 54843ca..fd0363d 100644
> --- a/arch/powerpc/include/asm/pci-bridge.h
> +++ b/arch/powerpc/include/asm/pci-bridge.h
> @@ -10,7 +10,7 @@
>  #include <linux/pci.h>
>  #include <linux/list.h>
>  #include <linux/ioport.h>
> -#include <asm-generic/pci-bridge.h>
> +#include <linux/pci-bridge.h>
>  
>  struct device_node;
>  
> diff --git a/arch/unicore32/include/asm/pci.h b/arch/unicore32/include/asm/pci.h
> index 38b3f37..e36ca77 100644
> --- a/arch/unicore32/include/asm/pci.h
> +++ b/arch/unicore32/include/asm/pci.h
> @@ -14,7 +14,7 @@
>  
>  #ifdef __KERNEL__
>  #include <asm-generic/pci-dma-compat.h>
> -#include <asm-generic/pci-bridge.h>
> +#include <linux/pci-bridge.h>
>  #include <asm-generic/pci.h>
>  #include <mach/hardware.h> /* for PCIBIOS_MIN_* */
>  
> diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
> index d34b511..edd0022 100644
> --- a/arch/x86/pci/common.c
> +++ b/arch/x86/pci/common.c
> @@ -12,7 +12,7 @@
>  #include <linux/dmi.h>
>  #include <linux/slab.h>
>  
> -#include <asm-generic/pci-bridge.h>
> +#include <linux/pci-bridge.h>
>  #include <asm/acpi.h>
>  #include <asm/segment.h>
>  #include <asm/io.h>
> diff --git a/drivers/of/of_pci.c b/drivers/of/of_pci.c
> index b1449f7..64705ef 100644
> --- a/drivers/of/of_pci.c
> +++ b/drivers/of/of_pci.c
> @@ -5,7 +5,7 @@
>  #include <linux/of_device.h>
>  #include <linux/of_pci.h>
>  #include <linux/slab.h>
> -#include <asm-generic/pci-bridge.h>
> +#include <linux/pci-bridge.h>
>  
>  static inline int __of_pci_pci_compare(struct device_node *node,
>  				       unsigned int data)
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 602eb42..5e5a196 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -25,7 +25,7 @@
>  #include <linux/device.h>
>  #include <linux/pm_runtime.h>
>  #include <linux/pci_hotplug.h>
> -#include <asm-generic/pci-bridge.h>
> +#include <linux/pci-bridge.h>
>  #include <asm/setup.h>
>  #include <linux/aer.h>
>  #include "pci.h"
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 6d7ab9b..af4dad3 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -15,7 +15,7 @@
>  #include <linux/pci-aspm.h>
>  #include <linux/aer.h>
>  #include <linux/acpi.h>
> -#include <asm-generic/pci-bridge.h>
> +#include <linux/pci-bridge.h>
>  #include "pci.h"
>  
>  #define CARDBUS_LATENCY_TIMER	176	/* secondary latency timer */
> diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
> index 7796d0a..03c047c 100644
> --- a/drivers/pci/setup-bus.c
> +++ b/drivers/pci/setup-bus.c
> @@ -25,7 +25,7 @@
>  #include <linux/ioport.h>
>  #include <linux/cache.h>
>  #include <linux/slab.h>
> -#include <asm-generic/pci-bridge.h>
> +#include <linux/pci-bridge.h>
>  #include "pci.h"
>  
>  unsigned int pci_flags;
> diff --git a/include/asm-generic/pci-bridge.h b/include/asm-generic/pci-bridge.h
> deleted file mode 100644
> index 20db2e5..0000000
> --- a/include/asm-generic/pci-bridge.h
> +++ /dev/null
> @@ -1,74 +0,0 @@
> -/*
> - * This program is free software; you can redistribute it and/or
> - * modify it under the terms of the GNU General Public License
> - * as published by the Free Software Foundation; either version
> - * 2 of the License, or (at your option) any later version.
> - */
> -#ifndef _ASM_GENERIC_PCI_BRIDGE_H
> -#define _ASM_GENERIC_PCI_BRIDGE_H
> -
> -#ifdef __KERNEL__
> -
> -enum {
> -	/* Force re-assigning all resources (ignore firmware
> -	 * setup completely)
> -	 */
> -	PCI_REASSIGN_ALL_RSRC	= 0x00000001,
> -
> -	/* Re-assign all bus numbers */
> -	PCI_REASSIGN_ALL_BUS	= 0x00000002,
> -
> -	/* Do not try to assign, just use existing setup */
> -	PCI_PROBE_ONLY		= 0x00000004,
> -
> -	/* Don't bother with ISA alignment unless the bridge has
> -	 * ISA forwarding enabled
> -	 */
> -	PCI_CAN_SKIP_ISA_ALIGN	= 0x00000008,
> -
> -	/* Enable domain numbers in /proc */
> -	PCI_ENABLE_PROC_DOMAINS	= 0x00000010,
> -	/* ... except for domain 0 */
> -	PCI_COMPAT_DOMAIN_0	= 0x00000020,
> -
> -	/* PCIe downstream ports are bridges that normally lead to only a
> -	 * device 0, but if this is set, we scan all possible devices, not
> -	 * just device 0.
> -	 */
> -	PCI_SCAN_ALL_PCIE_DEVS	= 0x00000040,
> -};
> -
> -#ifdef CONFIG_PCI
> -extern unsigned int pci_flags;
> -
> -static inline void pci_set_flags(int flags)
> -{
> -	pci_flags = flags;
> -}
> -
> -static inline void pci_add_flags(int flags)
> -{
> -	pci_flags |= flags;
> -}
> -
> -static inline void pci_clear_flags(int flags)
> -{
> -	pci_flags &= ~flags;
> -}
> -
> -static inline int pci_has_flag(int flag)
> -{
> -	return pci_flags & flag;
> -}
> -#else
> -static inline void pci_set_flags(int flags) { }
> -static inline void pci_add_flags(int flags) { }
> -static inline void pci_clear_flags(int flags) { }
> -static inline int pci_has_flag(int flag)
> -{
> -	return 0;
> -}
> -#endif	/* CONFIG_PCI */
> -
> -#endif	/* __KERNEL__ */
> -#endif	/* _ASM_GENERIC_PCI_BRIDGE_H */
> diff --git a/include/linux/pci-bridge.h b/include/linux/pci-bridge.h
> new file mode 100644
> index 0000000..25416e0
> --- /dev/null
> +++ b/include/linux/pci-bridge.h
> @@ -0,0 +1,74 @@
> +/*
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version
> + * 2 of the License, or (at your option) any later version.
> + */
> +#ifndef _LINUX_PCI_BRIDGE_H
> +#define _LINUX_PCI_BRIDGE_H
> +
> +#ifdef __KERNEL__
> +
> +enum {
> +	/* Force re-assigning all resources (ignore firmware
> +	 * setup completely)
> +	 */
> +	PCI_REASSIGN_ALL_RSRC	= 0x00000001,
> +
> +	/* Re-assign all bus numbers */
> +	PCI_REASSIGN_ALL_BUS	= 0x00000002,
> +
> +	/* Do not try to assign, just use existing setup */
> +	PCI_PROBE_ONLY		= 0x00000004,
> +
> +	/* Don't bother with ISA alignment unless the bridge has
> +	 * ISA forwarding enabled
> +	 */
> +	PCI_CAN_SKIP_ISA_ALIGN	= 0x00000008,
> +
> +	/* Enable domain numbers in /proc */
> +	PCI_ENABLE_PROC_DOMAINS	= 0x00000010,
> +	/* ... except for domain 0 */
> +	PCI_COMPAT_DOMAIN_0	= 0x00000020,
> +
> +	/* PCIe downstream ports are bridges that normally lead to only a
> +	 * device 0, but if this is set, we scan all possible devices, not
> +	 * just device 0.
> +	 */
> +	PCI_SCAN_ALL_PCIE_DEVS	= 0x00000040,
> +};
> +
> +#ifdef CONFIG_PCI
> +extern unsigned int pci_flags;
> +
> +static inline void pci_set_flags(int flags)
> +{
> +	pci_flags = flags;
> +}
> +
> +static inline void pci_add_flags(int flags)
> +{
> +	pci_flags |= flags;
> +}
> +
> +static inline void pci_clear_flags(int flags)
> +{
> +	pci_flags &= ~flags;
> +}
> +
> +static inline int pci_has_flag(int flag)
> +{
> +	return pci_flags & flag;
> +}
> +#else
> +static inline void pci_set_flags(int flags) { }
> +static inline void pci_add_flags(int flags) { }
> +static inline void pci_clear_flags(int flags) { }
> +static inline int pci_has_flag(int flag)
> +{
> +	return 0;
> +}
> +#endif	/* CONFIG_PCI */
> +
> +#endif	/* __KERNEL__ */
> +#endif	/* _LINUX_PCI_BRIDGE_H */
> -- 
> 2.1.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-arch" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/3] pci: move pci-bridge.h out of asm-generic
  2016-03-07 16:35   ` Bjorn Helgaas
@ 2016-03-07 16:37     ` Christoph Hellwig
  2016-03-07 16:37       ` Christoph Hellwig
  0 siblings, 1 reply; 20+ messages in thread
From: Christoph Hellwig @ 2016-03-07 16:37 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Christoph Hellwig, bhelgaas, linux-pci, linux-arch, linux-kernel,
	Arnd Bergmann

On Mon, Mar 07, 2016 at 10:35:29AM -0600, Bjorn Helgaas wrote:
> I did something similar with
> http://lkml.kernel.org/r/20160202193026.9258.7573.stgit@bhelgaas-glaptop2.roam.corp.google.com
> 
> The generic things in include/asm-generic/pci-bridge.h weren't really
> bridge-related, so I moved them to include/linux/pci.h instead of creating
> include/linux/pci-bridge.h.
> 
> Then include/asm-generic/pci-bridge.h was empty, so I removed it and the
> includes of it.
> 
> There were a few arch-specific asm/pci-bridge.h files, but they do contain
> arch-specific things, and they're only included by arch code, so I left
> them alone.
> 
> My changes are in linux-next, and I plan to merge them during the v4.6
> merge window.

Even better.  Let's drop this patch, but it would still be good to get
the other two through one of the trees.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/3] pci: move pci-bridge.h out of asm-generic
  2016-03-07 16:37     ` Christoph Hellwig
@ 2016-03-07 16:37       ` Christoph Hellwig
  0 siblings, 0 replies; 20+ messages in thread
From: Christoph Hellwig @ 2016-03-07 16:37 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Christoph Hellwig, bhelgaas, linux-pci, linux-arch, linux-kernel,
	Arnd Bergmann

On Mon, Mar 07, 2016 at 10:35:29AM -0600, Bjorn Helgaas wrote:
> I did something similar with
> http://lkml.kernel.org/r/20160202193026.9258.7573.stgit@bhelgaas-glaptop2.roam.corp.google.com
> 
> The generic things in include/asm-generic/pci-bridge.h weren't really
> bridge-related, so I moved them to include/linux/pci.h instead of creating
> include/linux/pci-bridge.h.
> 
> Then include/asm-generic/pci-bridge.h was empty, so I removed it and the
> includes of it.
> 
> There were a few arch-specific asm/pci-bridge.h files, but they do contain
> arch-specific things, and they're only included by arch code, so I left
> them alone.
> 
> My changes are in linux-next, and I plan to merge them during the v4.6
> merge window.

Even better.  Let's drop this patch, but it would still be good to get
the other two through one of the trees.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/3] frv: remove stray pci_{alloc,free}_consistent declaration
  2016-03-06 15:17 ` [PATCH 1/3] frv: remove stray pci_{alloc,free}_consistent declaration Christoph Hellwig
@ 2016-03-07 17:57   ` Bjorn Helgaas
  0 siblings, 0 replies; 20+ messages in thread
From: Bjorn Helgaas @ 2016-03-07 17:57 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: bhelgaas, linux-pci, linux-arch, linux-kernel, David S. Miller,
	David Howells

[+cc David M, David H]

On Sun, Mar 06, 2016 at 04:17:53PM +0100, Christoph Hellwig wrote:
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Applied with acks from David M & David H to pci/misc for v4.6, thanks!

> ---
>  arch/frv/include/asm/pci.h | 6 ------
>  1 file changed, 6 deletions(-)
> 
> diff --git a/arch/frv/include/asm/pci.h b/arch/frv/include/asm/pci.h
> index e43d22c..7e96b57 100644
> --- a/arch/frv/include/asm/pci.h
> +++ b/arch/frv/include/asm/pci.h
> @@ -32,12 +32,6 @@ extern void consistent_sync_page(struct page *page, unsigned long offset,
>  				 size_t size, int direction);
>  #endif
>  
> -extern void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
> -				  dma_addr_t *dma_handle);
> -
> -extern void pci_free_consistent(struct pci_dev *hwdev, size_t size,
> -				void *vaddr, dma_addr_t dma_handle);
> -
>  /* Return the index of the PCI controller for device PDEV. */
>  #define pci_controller_num(PDEV)	(0)
>  
> -- 
> 2.1.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-arch" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 3/3] pci: move pci_dma_* helpers to common code
  2016-03-06 15:17 ` [PATCH 3/3] pci: move pci_dma_* helpers to common code Christoph Hellwig
  2016-03-06 15:17   ` Christoph Hellwig
@ 2016-03-07 18:28   ` Bjorn Helgaas
  2016-03-07 18:28     ` Bjorn Helgaas
                       ` (2 more replies)
  1 sibling, 3 replies; 20+ messages in thread
From: Bjorn Helgaas @ 2016-03-07 18:28 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: bhelgaas, linux-pci, linux-arch, linux-kernel, Arnd Bergmann

[+cc Arnd]

On Sun, Mar 06, 2016 at 04:17:55PM +0100, Christoph Hellwig wrote:
> For a long time all architectures implement the pci_dma_* functions
> using the generic DMA API, and they all use the same header to do
> so.  This patch moves this header, pci-dma-compat.h, to include/linux
> and includes it from the generic pci.h instead of having each arch
> duplicate this include.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

I applied this to pci/misc for v4.6, thanks!  It could go via another
tree, but it does have minor conflicts with my previous patches that
removed asm-generic/pci-dma-compat.h, so I think it makes sense for me
to take it so I can resolve the conflicts.

I wonder if we can consolidate a little more pci_dma_*-related stuff
in pci-dma-compat.h, e.g.,


commit fe537670eab767157eecc50538bd28e8d9b0ce9f
Author: Bjorn Helgaas <bhelgaas@google.com>
Date:   Mon Mar 7 11:39:16 2016 -0600

    PCI: Consolidate PCI DMA constants and interfaces in linux/pci-dma-compat.h
    
    Christoph added a generic include/linux/pci-dma-compat.h, so now there's
    one place with most of the PCI DMA interfaces.  Move more PCI DMA-related
    things there:
    
      - The PCI_DMA_* direction constants from linux/pci.h
      - The pci_set_dma_max_seg_size() and pci_set_dma_seg_boundary()
        CONFIG_PCI implementations from drivers/pci/pci.c
      - The pci_set_dma_max_seg_size() and pci_set_dma_seg_boundary()
        !CONFIG_PCI stubs from linux/pci.h
      - The pci_set_dma_mask() and pci_set_consistent_dma_mask()
        !CONFIG_PCI stubs from linux/pci.h
    
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 64c0a12..0a9c8db 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -3385,18 +3385,6 @@ bool pci_check_and_unmask_intx(struct pci_dev *dev)
 }
 EXPORT_SYMBOL_GPL(pci_check_and_unmask_intx);
 
-int pci_set_dma_max_seg_size(struct pci_dev *dev, unsigned int size)
-{
-	return dma_set_max_seg_size(&dev->dev, size);
-}
-EXPORT_SYMBOL(pci_set_dma_max_seg_size);
-
-int pci_set_dma_seg_boundary(struct pci_dev *dev, unsigned long mask)
-{
-	return dma_set_seg_boundary(&dev->dev, mask);
-}
-EXPORT_SYMBOL(pci_set_dma_seg_boundary);
-
 /**
  * pci_wait_for_pending_transaction - waits for pending transaction
  * @dev: the PCI device to operate on
diff --git a/include/linux/pci-dma-compat.h b/include/linux/pci-dma-compat.h
index eafce7b..39726ca 100644
--- a/include/linux/pci-dma-compat.h
+++ b/include/linux/pci-dma-compat.h
@@ -6,6 +6,12 @@
 
 #include <linux/dma-mapping.h>
 
+/* This defines the direction arg to the DMA mapping routines. */
+#define PCI_DMA_BIDIRECTIONAL	0
+#define PCI_DMA_TODEVICE	1
+#define PCI_DMA_FROMDEVICE	2
+#define PCI_DMA_NONE		3
+
 static inline void *
 pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
 		     dma_addr_t *dma_handle)
@@ -113,6 +119,29 @@ static inline int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
 {
 	return dma_set_coherent_mask(&dev->dev, mask);
 }
+
+static inline int pci_set_dma_max_seg_size(struct pci_dev *dev,
+					   unsigned int size)
+{
+	return dma_set_max_seg_size(&dev->dev, size);
+}
+
+static inline int pci_set_dma_seg_boundary(struct pci_dev *dev,
+					   unsigned long mask)
+{
+	return dma_set_seg_boundary(&dev->dev, mask);
+}
+#else
+static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask)
+{ return -EIO; }
+static inline int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
+{ return -EIO; }
+static inline int pci_set_dma_max_seg_size(struct pci_dev *dev,
+					   unsigned int size)
+{ return -EIO; }
+static inline int pci_set_dma_seg_boundary(struct pci_dev *dev,
+					   unsigned long mask)
+{ return -EIO; }
 #endif
 
 #endif
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 5db6e0c..5049bd6 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -70,12 +70,6 @@ enum pci_mmap_state {
 	pci_mmap_mem
 };
 
-/* This defines the direction arg to the DMA mapping routines. */
-#define PCI_DMA_BIDIRECTIONAL	0
-#define PCI_DMA_TODEVICE	1
-#define PCI_DMA_FROMDEVICE	2
-#define PCI_DMA_NONE		3
-
 /*
  *  For PCI devices, the region numbers are assigned this way:
  */
@@ -1038,8 +1032,6 @@ void pci_intx(struct pci_dev *dev, int enable);
 bool pci_intx_mask_supported(struct pci_dev *dev);
 bool pci_check_and_mask_intx(struct pci_dev *dev);
 bool pci_check_and_unmask_intx(struct pci_dev *dev);
-int pci_set_dma_max_seg_size(struct pci_dev *dev, unsigned int size);
-int pci_set_dma_seg_boundary(struct pci_dev *dev, unsigned long mask);
 int pci_wait_for_pending(struct pci_dev *dev, int pos, u16 mask);
 int pci_wait_for_pending_transaction(struct pci_dev *dev);
 int pcix_get_max_mmrbc(struct pci_dev *dev);
@@ -1255,6 +1247,7 @@ resource_size_t pcibios_iov_resource_alignment(struct pci_dev *dev, int resno);
 
 int pci_set_vga_state(struct pci_dev *pdev, bool decode,
 		      unsigned int command_bits, u32 flags);
+
 /* kmem_cache style wrapper around pci_alloc_consistent() */
 
 #include <linux/pci-dma.h>
@@ -1466,16 +1459,6 @@ static inline struct pci_dev *pci_get_class(unsigned int class,
 static inline void pci_set_master(struct pci_dev *dev) { }
 static inline int pci_enable_device(struct pci_dev *dev) { return -EIO; }
 static inline void pci_disable_device(struct pci_dev *dev) { }
-static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask)
-{ return -EIO; }
-static inline int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
-{ return -EIO; }
-static inline int pci_set_dma_max_seg_size(struct pci_dev *dev,
-					unsigned int size)
-{ return -EIO; }
-static inline int pci_set_dma_seg_boundary(struct pci_dev *dev,
-					unsigned long mask)
-{ return -EIO; }
 static inline int pci_assign_resource(struct pci_dev *dev, int i)
 { return -EBUSY; }
 static inline int __pci_register_driver(struct pci_driver *drv,

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH 3/3] pci: move pci_dma_* helpers to common code
  2016-03-07 18:28   ` Bjorn Helgaas
@ 2016-03-07 18:28     ` Bjorn Helgaas
  2016-03-08  7:32     ` Christoph Hellwig
  2016-03-08 17:43     ` Bjorn Helgaas
  2 siblings, 0 replies; 20+ messages in thread
From: Bjorn Helgaas @ 2016-03-07 18:28 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: bhelgaas, linux-pci, linux-arch, linux-kernel, Arnd Bergmann

[+cc Arnd]

On Sun, Mar 06, 2016 at 04:17:55PM +0100, Christoph Hellwig wrote:
> For a long time all architectures implement the pci_dma_* functions
> using the generic DMA API, and they all use the same header to do
> so.  This patch moves this header, pci-dma-compat.h, to include/linux
> and includes it from the generic pci.h instead of having each arch
> duplicate this include.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

I applied this to pci/misc for v4.6, thanks!  It could go via another
tree, but it does have minor conflicts with my previous patches that
removed asm-generic/pci-dma-compat.h, so I think it makes sense for me
to take it so I can resolve the conflicts.

I wonder if we can consolidate a little more pci_dma_*-related stuff
in pci-dma-compat.h, e.g.,


commit fe537670eab767157eecc50538bd28e8d9b0ce9f
Author: Bjorn Helgaas <bhelgaas@google.com>
Date:   Mon Mar 7 11:39:16 2016 -0600

    PCI: Consolidate PCI DMA constants and interfaces in linux/pci-dma-compat.h
    
    Christoph added a generic include/linux/pci-dma-compat.h, so now there's
    one place with most of the PCI DMA interfaces.  Move more PCI DMA-related
    things there:
    
      - The PCI_DMA_* direction constants from linux/pci.h
      - The pci_set_dma_max_seg_size() and pci_set_dma_seg_boundary()
        CONFIG_PCI implementations from drivers/pci/pci.c
      - The pci_set_dma_max_seg_size() and pci_set_dma_seg_boundary()
        !CONFIG_PCI stubs from linux/pci.h
      - The pci_set_dma_mask() and pci_set_consistent_dma_mask()
        !CONFIG_PCI stubs from linux/pci.h
    
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 64c0a12..0a9c8db 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -3385,18 +3385,6 @@ bool pci_check_and_unmask_intx(struct pci_dev *dev)
 }
 EXPORT_SYMBOL_GPL(pci_check_and_unmask_intx);
 
-int pci_set_dma_max_seg_size(struct pci_dev *dev, unsigned int size)
-{
-	return dma_set_max_seg_size(&dev->dev, size);
-}
-EXPORT_SYMBOL(pci_set_dma_max_seg_size);
-
-int pci_set_dma_seg_boundary(struct pci_dev *dev, unsigned long mask)
-{
-	return dma_set_seg_boundary(&dev->dev, mask);
-}
-EXPORT_SYMBOL(pci_set_dma_seg_boundary);
-
 /**
  * pci_wait_for_pending_transaction - waits for pending transaction
  * @dev: the PCI device to operate on
diff --git a/include/linux/pci-dma-compat.h b/include/linux/pci-dma-compat.h
index eafce7b..39726ca 100644
--- a/include/linux/pci-dma-compat.h
+++ b/include/linux/pci-dma-compat.h
@@ -6,6 +6,12 @@
 
 #include <linux/dma-mapping.h>
 
+/* This defines the direction arg to the DMA mapping routines. */
+#define PCI_DMA_BIDIRECTIONAL	0
+#define PCI_DMA_TODEVICE	1
+#define PCI_DMA_FROMDEVICE	2
+#define PCI_DMA_NONE		3
+
 static inline void *
 pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
 		     dma_addr_t *dma_handle)
@@ -113,6 +119,29 @@ static inline int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
 {
 	return dma_set_coherent_mask(&dev->dev, mask);
 }
+
+static inline int pci_set_dma_max_seg_size(struct pci_dev *dev,
+					   unsigned int size)
+{
+	return dma_set_max_seg_size(&dev->dev, size);
+}
+
+static inline int pci_set_dma_seg_boundary(struct pci_dev *dev,
+					   unsigned long mask)
+{
+	return dma_set_seg_boundary(&dev->dev, mask);
+}
+#else
+static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask)
+{ return -EIO; }
+static inline int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
+{ return -EIO; }
+static inline int pci_set_dma_max_seg_size(struct pci_dev *dev,
+					   unsigned int size)
+{ return -EIO; }
+static inline int pci_set_dma_seg_boundary(struct pci_dev *dev,
+					   unsigned long mask)
+{ return -EIO; }
 #endif
 
 #endif
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 5db6e0c..5049bd6 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -70,12 +70,6 @@ enum pci_mmap_state {
 	pci_mmap_mem
 };
 
-/* This defines the direction arg to the DMA mapping routines. */
-#define PCI_DMA_BIDIRECTIONAL	0
-#define PCI_DMA_TODEVICE	1
-#define PCI_DMA_FROMDEVICE	2
-#define PCI_DMA_NONE		3
-
 /*
  *  For PCI devices, the region numbers are assigned this way:
  */
@@ -1038,8 +1032,6 @@ void pci_intx(struct pci_dev *dev, int enable);
 bool pci_intx_mask_supported(struct pci_dev *dev);
 bool pci_check_and_mask_intx(struct pci_dev *dev);
 bool pci_check_and_unmask_intx(struct pci_dev *dev);
-int pci_set_dma_max_seg_size(struct pci_dev *dev, unsigned int size);
-int pci_set_dma_seg_boundary(struct pci_dev *dev, unsigned long mask);
 int pci_wait_for_pending(struct pci_dev *dev, int pos, u16 mask);
 int pci_wait_for_pending_transaction(struct pci_dev *dev);
 int pcix_get_max_mmrbc(struct pci_dev *dev);
@@ -1255,6 +1247,7 @@ resource_size_t pcibios_iov_resource_alignment(struct pci_dev *dev, int resno);
 
 int pci_set_vga_state(struct pci_dev *pdev, bool decode,
 		      unsigned int command_bits, u32 flags);
+
 /* kmem_cache style wrapper around pci_alloc_consistent() */
 
 #include <linux/pci-dma.h>
@@ -1466,16 +1459,6 @@ static inline struct pci_dev *pci_get_class(unsigned int class,
 static inline void pci_set_master(struct pci_dev *dev) { }
 static inline int pci_enable_device(struct pci_dev *dev) { return -EIO; }
 static inline void pci_disable_device(struct pci_dev *dev) { }
-static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask)
-{ return -EIO; }
-static inline int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
-{ return -EIO; }
-static inline int pci_set_dma_max_seg_size(struct pci_dev *dev,
-					unsigned int size)
-{ return -EIO; }
-static inline int pci_set_dma_seg_boundary(struct pci_dev *dev,
-					unsigned long mask)
-{ return -EIO; }
 static inline int pci_assign_resource(struct pci_dev *dev, int i)
 { return -EBUSY; }
 static inline int __pci_register_driver(struct pci_driver *drv,

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH 3/3] pci: move pci_dma_* helpers to common code
  2016-03-07 18:28   ` Bjorn Helgaas
  2016-03-07 18:28     ` Bjorn Helgaas
@ 2016-03-08  7:32     ` Christoph Hellwig
  2016-03-08  7:32       ` Christoph Hellwig
  2016-03-08 17:43     ` Bjorn Helgaas
  2 siblings, 1 reply; 20+ messages in thread
From: Christoph Hellwig @ 2016-03-08  7:32 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Christoph Hellwig, bhelgaas, linux-pci, linux-arch, linux-kernel,
	Arnd Bergmann

On Mon, Mar 07, 2016 at 12:28:48PM -0600, Bjorn Helgaas wrote:
> I wonder if we can consolidate a little more pci_dma_*-related stuff
> in pci-dma-compat.h, e.g.,

Looks fine to me.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 3/3] pci: move pci_dma_* helpers to common code
  2016-03-08  7:32     ` Christoph Hellwig
@ 2016-03-08  7:32       ` Christoph Hellwig
  0 siblings, 0 replies; 20+ messages in thread
From: Christoph Hellwig @ 2016-03-08  7:32 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Christoph Hellwig, bhelgaas, linux-pci, linux-arch, linux-kernel,
	Arnd Bergmann

On Mon, Mar 07, 2016 at 12:28:48PM -0600, Bjorn Helgaas wrote:
> I wonder if we can consolidate a little more pci_dma_*-related stuff
> in pci-dma-compat.h, e.g.,

Looks fine to me.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 3/3] pci: move pci_dma_* helpers to common code
  2016-03-07 18:28   ` Bjorn Helgaas
  2016-03-07 18:28     ` Bjorn Helgaas
  2016-03-08  7:32     ` Christoph Hellwig
@ 2016-03-08 17:43     ` Bjorn Helgaas
  2016-03-08 17:49       ` Christoph Hellwig
  2 siblings, 1 reply; 20+ messages in thread
From: Bjorn Helgaas @ 2016-03-08 17:43 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: bhelgaas, linux-pci, linux-arch, linux-kernel, Arnd Bergmann

On Mon, Mar 07, 2016 at 12:28:48PM -0600, Bjorn Helgaas wrote:
> commit fe537670eab767157eecc50538bd28e8d9b0ce9f
> Author: Bjorn Helgaas <bhelgaas@google.com>
> Date:   Mon Mar 7 11:39:16 2016 -0600
> 
>     PCI: Consolidate PCI DMA constants and interfaces in linux/pci-dma-compat.h
>     
>     Christoph added a generic include/linux/pci-dma-compat.h, so now there's
>     one place with most of the PCI DMA interfaces.  Move more PCI DMA-related
>     things there:
>     
>       - The PCI_DMA_* direction constants from linux/pci.h
>       - The pci_set_dma_max_seg_size() and pci_set_dma_seg_boundary()
>         CONFIG_PCI implementations from drivers/pci/pci.c
>       - The pci_set_dma_max_seg_size() and pci_set_dma_seg_boundary()
>         !CONFIG_PCI stubs from linux/pci.h
>       - The pci_set_dma_mask() and pci_set_consistent_dma_mask()
>         !CONFIG_PCI stubs from linux/pci.h
>     
>     Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

I applied the patch below to pci/misc for v4.6.

> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 64c0a12..0a9c8db 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -3385,18 +3385,6 @@ bool pci_check_and_unmask_intx(struct pci_dev *dev)
>  }
>  EXPORT_SYMBOL_GPL(pci_check_and_unmask_intx);
>  
> -int pci_set_dma_max_seg_size(struct pci_dev *dev, unsigned int size)
> -{
> -	return dma_set_max_seg_size(&dev->dev, size);
> -}
> -EXPORT_SYMBOL(pci_set_dma_max_seg_size);
> -
> -int pci_set_dma_seg_boundary(struct pci_dev *dev, unsigned long mask)
> -{
> -	return dma_set_seg_boundary(&dev->dev, mask);
> -}
> -EXPORT_SYMBOL(pci_set_dma_seg_boundary);
> -
>  /**
>   * pci_wait_for_pending_transaction - waits for pending transaction
>   * @dev: the PCI device to operate on
> diff --git a/include/linux/pci-dma-compat.h b/include/linux/pci-dma-compat.h
> index eafce7b..39726ca 100644
> --- a/include/linux/pci-dma-compat.h
> +++ b/include/linux/pci-dma-compat.h
> @@ -6,6 +6,12 @@
>  
>  #include <linux/dma-mapping.h>
>  
> +/* This defines the direction arg to the DMA mapping routines. */
> +#define PCI_DMA_BIDIRECTIONAL	0
> +#define PCI_DMA_TODEVICE	1
> +#define PCI_DMA_FROMDEVICE	2
> +#define PCI_DMA_NONE		3
> +
>  static inline void *
>  pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
>  		     dma_addr_t *dma_handle)
> @@ -113,6 +119,29 @@ static inline int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
>  {
>  	return dma_set_coherent_mask(&dev->dev, mask);
>  }
> +
> +static inline int pci_set_dma_max_seg_size(struct pci_dev *dev,
> +					   unsigned int size)
> +{
> +	return dma_set_max_seg_size(&dev->dev, size);
> +}
> +
> +static inline int pci_set_dma_seg_boundary(struct pci_dev *dev,
> +					   unsigned long mask)
> +{
> +	return dma_set_seg_boundary(&dev->dev, mask);
> +}
> +#else
> +static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask)
> +{ return -EIO; }
> +static inline int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
> +{ return -EIO; }
> +static inline int pci_set_dma_max_seg_size(struct pci_dev *dev,
> +					   unsigned int size)
> +{ return -EIO; }
> +static inline int pci_set_dma_seg_boundary(struct pci_dev *dev,
> +					   unsigned long mask)
> +{ return -EIO; }
>  #endif
>  
>  #endif
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 5db6e0c..5049bd6 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -70,12 +70,6 @@ enum pci_mmap_state {
>  	pci_mmap_mem
>  };
>  
> -/* This defines the direction arg to the DMA mapping routines. */
> -#define PCI_DMA_BIDIRECTIONAL	0
> -#define PCI_DMA_TODEVICE	1
> -#define PCI_DMA_FROMDEVICE	2
> -#define PCI_DMA_NONE		3
> -
>  /*
>   *  For PCI devices, the region numbers are assigned this way:
>   */
> @@ -1038,8 +1032,6 @@ void pci_intx(struct pci_dev *dev, int enable);
>  bool pci_intx_mask_supported(struct pci_dev *dev);
>  bool pci_check_and_mask_intx(struct pci_dev *dev);
>  bool pci_check_and_unmask_intx(struct pci_dev *dev);
> -int pci_set_dma_max_seg_size(struct pci_dev *dev, unsigned int size);
> -int pci_set_dma_seg_boundary(struct pci_dev *dev, unsigned long mask);
>  int pci_wait_for_pending(struct pci_dev *dev, int pos, u16 mask);
>  int pci_wait_for_pending_transaction(struct pci_dev *dev);
>  int pcix_get_max_mmrbc(struct pci_dev *dev);
> @@ -1255,6 +1247,7 @@ resource_size_t pcibios_iov_resource_alignment(struct pci_dev *dev, int resno);
>  
>  int pci_set_vga_state(struct pci_dev *pdev, bool decode,
>  		      unsigned int command_bits, u32 flags);
> +
>  /* kmem_cache style wrapper around pci_alloc_consistent() */
>  
>  #include <linux/pci-dma.h>
> @@ -1466,16 +1459,6 @@ static inline struct pci_dev *pci_get_class(unsigned int class,
>  static inline void pci_set_master(struct pci_dev *dev) { }
>  static inline int pci_enable_device(struct pci_dev *dev) { return -EIO; }
>  static inline void pci_disable_device(struct pci_dev *dev) { }
> -static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask)
> -{ return -EIO; }
> -static inline int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
> -{ return -EIO; }
> -static inline int pci_set_dma_max_seg_size(struct pci_dev *dev,
> -					unsigned int size)
> -{ return -EIO; }
> -static inline int pci_set_dma_seg_boundary(struct pci_dev *dev,
> -					unsigned long mask)
> -{ return -EIO; }
>  static inline int pci_assign_resource(struct pci_dev *dev, int i)
>  { return -EBUSY; }
>  static inline int __pci_register_driver(struct pci_driver *drv,
> --
> To unsubscribe from this list: send the line "unsubscribe linux-arch" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 3/3] pci: move pci_dma_* helpers to common code
  2016-03-08 17:43     ` Bjorn Helgaas
@ 2016-03-08 17:49       ` Christoph Hellwig
  2016-03-08 17:49         ` Christoph Hellwig
  2016-03-08 17:55         ` Bjorn Helgaas
  0 siblings, 2 replies; 20+ messages in thread
From: Christoph Hellwig @ 2016-03-08 17:49 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Christoph Hellwig, bhelgaas, linux-pci, linux-arch, linux-kernel,
	Arnd Bergmann

On Tue, Mar 08, 2016 at 11:43:46AM -0600, Bjorn Helgaas wrote:
> I applied the patch below to pci/misc for v4.6.

Btw, where do you keep your tree?

https://git.kernel.org/cgit/linux/kernel/git/helgaas/pci.git/log/?h=pci/misc

hasn't been updated for a month.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 3/3] pci: move pci_dma_* helpers to common code
  2016-03-08 17:49       ` Christoph Hellwig
@ 2016-03-08 17:49         ` Christoph Hellwig
  2016-03-08 17:55         ` Bjorn Helgaas
  1 sibling, 0 replies; 20+ messages in thread
From: Christoph Hellwig @ 2016-03-08 17:49 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Christoph Hellwig, bhelgaas, linux-pci, linux-arch, linux-kernel,
	Arnd Bergmann

On Tue, Mar 08, 2016 at 11:43:46AM -0600, Bjorn Helgaas wrote:
> I applied the patch below to pci/misc for v4.6.

Btw, where do you keep your tree?

https://git.kernel.org/cgit/linux/kernel/git/helgaas/pci.git/log/?h=pci/misc

hasn't been updated for a month.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 3/3] pci: move pci_dma_* helpers to common code
  2016-03-08 17:49       ` Christoph Hellwig
  2016-03-08 17:49         ` Christoph Hellwig
@ 2016-03-08 17:55         ` Bjorn Helgaas
  1 sibling, 0 replies; 20+ messages in thread
From: Bjorn Helgaas @ 2016-03-08 17:55 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: bhelgaas, linux-pci, linux-arch, linux-kernel, Arnd Bergmann

On Tue, Mar 08, 2016 at 06:49:11PM +0100, Christoph Hellwig wrote:
> On Tue, Mar 08, 2016 at 11:43:46AM -0600, Bjorn Helgaas wrote:
> > I applied the patch below to pci/misc for v4.6.
> 
> Btw, where do you keep your tree?
> 
> https://git.kernel.org/cgit/linux/kernel/git/helgaas/pci.git/log/?h=pci/misc
> 
> hasn't been updated for a month.

Sorry, that's the right place; I just hadn't pushed it yet.
Should be there now.  I'll merge it to my "next" branch after the
robot confirms that I haven't broken the build.

Bjorn

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2016-03-08 17:55 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-06 15:17 two small PCI header cleanups Christoph Hellwig
2016-03-06 15:17 ` [PATCH 1/3] frv: remove stray pci_{alloc,free}_consistent declaration Christoph Hellwig
2016-03-07 17:57   ` Bjorn Helgaas
2016-03-06 15:17 ` [PATCH 2/3] pci: move pci-bridge.h out of asm-generic Christoph Hellwig
2016-03-07 16:35   ` Bjorn Helgaas
2016-03-07 16:37     ` Christoph Hellwig
2016-03-07 16:37       ` Christoph Hellwig
2016-03-06 15:17 ` [PATCH 3/3] pci: move pci_dma_* helpers to common code Christoph Hellwig
2016-03-06 15:17   ` Christoph Hellwig
2016-03-07 18:28   ` Bjorn Helgaas
2016-03-07 18:28     ` Bjorn Helgaas
2016-03-08  7:32     ` Christoph Hellwig
2016-03-08  7:32       ` Christoph Hellwig
2016-03-08 17:43     ` Bjorn Helgaas
2016-03-08 17:49       ` Christoph Hellwig
2016-03-08 17:49         ` Christoph Hellwig
2016-03-08 17:55         ` Bjorn Helgaas
2016-03-06 20:47 ` two small PCI header cleanups Arnd Bergmann
2016-03-06 20:52   ` Christoph Hellwig
2016-03-06 20:52     ` Christoph Hellwig

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).