mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH -mm 00/12] adds include/asm-generic/pci-dma-common.h
@ 2010-02-09 13:35 e
  2010-02-09 13:35 ` [PATCH -mm 01/12] " e
                   ` (12 more replies)
  0 siblings, 13 replies; 16+ messages in thread
From: e @ 2010-02-09 13:35 UTC (permalink / raw)
  To: linux-kernel
  Cc: akpm, fujita.tomonori, x86, Richard Henderson, Ivan Kokshaysky,
	Matt Turner, Russell King, David Howells, Tony Luck,
	Ralf Baechle, Kyle McMartin, Helge Deller, James Bottomley,
	Benjamin Herrenschmidt, Paul Mundt, David S. Miller,
	Chris Zankel

This patchset adds include/asm-generic/pci-dma-common.h that defines
the pci_unmap state API:

DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
DECLARE_PCI_UNMAP_LEN(LEN_NAME)
pci_unmap_addr(PTR, ADDR_NAME)
pci_unmap_addr_set(PTR, ADDR_NAME, VAL)
pci_unmap_len(PTR, LEN_NAME)
pci_unmap_len_set(PTR, LEN_NAME, VAL)

This enables us to remove lots of the duplication in architecture
implementations since there are only two ways to define the API.

If architectures define HAVE_ARCH_PCI_UNMAP, they get the real
definition of pci_unmap state API. If not, they get the noop
definition.

In the long term, it's better to replace the API with the generic
device model API such as DECLARE_DMA_UNMAP_ADDR. We can map the API to
the generic one (like dma-mapping-compat.h does). This patch also
makes the migration process easier.

=
 arch/alpha/include/asm/pci.h         |   14 ++------------
 arch/arm/include/asm/pci.h           |    8 ++------
 arch/frv/include/asm/pci.h           |    7 +------
 arch/ia64/include/asm/pci.h          |   14 ++------------
 arch/mips/include/asm/pci.h          |   23 +++--------------------
 arch/parisc/include/asm/pci.h        |   14 ++------------
 arch/powerpc/include/asm/pci.h       |   33 +++------------------------------
 arch/sh/include/asm/pci.h            |   15 ++-------------
 arch/sparc/include/asm/pci.h         |    3 +++
 arch/sparc/include/asm/pci_32.h      |   14 --------------
 arch/sparc/include/asm/pci_64.h      |   14 --------------
 arch/x86/include/asm/pci.h           |   27 ++-------------------------
 arch/xtensa/include/asm/pci.h        |    7 +------
 include/asm-generic/pci-dma-common.h |   20 ++++++++++++++++++++
 14 files changed, 43 insertions(+), 170 deletions(-)




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

* [PATCH -mm 01/12] adds include/asm-generic/pci-dma-common.h
  2010-02-09 13:35 [PATCH -mm 00/12] adds include/asm-generic/pci-dma-common.h e
@ 2010-02-09 13:35 ` e
  2010-02-09 13:35 ` [PATCH -mm 02/12] x86: use asm-generic/pci-dma-common.h e
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: e @ 2010-02-09 13:35 UTC (permalink / raw)
  To: linux-kernel
  Cc: akpm, fujita.tomonori, x86, Richard Henderson, Ivan Kokshaysky,
	Matt Turner, Russell King, David Howells, Tony Luck,
	Ralf Baechle, Kyle McMartin, Helge Deller, James Bottomley,
	Benjamin Herrenschmidt, Paul Mundt, David S. Miller,
	Chris Zankel

From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>

This patch adds include/asm-generic/pci-dma-common.h that defines the
pci_unmap state API:

DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
DECLARE_PCI_UNMAP_LEN(LEN_NAME)
pci_unmap_addr(PTR, ADDR_NAME)
pci_unmap_addr_set(PTR, ADDR_NAME, VAL)
pci_unmap_len(PTR, LEN_NAME)
pci_unmap_len_set(PTR, LEN_NAME, VAL)

This enables us to remove lots of the duplication in architecture
implementations since there are only two ways to define the API.

If architectures define HAVE_ARCH_PCI_UNMAP, they get the real
definition of pci_unmap state API. If not, they get the noop
definition.

In the long term, it's better to replace the API with the generic
device model API such as DECLARE_DMA_UNMAP_ADDR. We can map the API to
the generic one (like dma-mapping-compat.h does). This patch also
makes the migration process easier.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: x86@kernel.org
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: David Howells <dhowells@redhat.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Kyle McMartin <kyle@mcmartin.ca>
Cc: Helge Deller <deller@gmx.de>
Cc: James Bottomley <James.Bottomley@suse.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: David S. Miller <davem@davemloft.net>
Cc: Chris Zankel <chris@zankel.net>
---
 include/asm-generic/pci-dma-common.h |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
 create mode 100644 include/asm-generic/pci-dma-common.h

diff --git a/include/asm-generic/pci-dma-common.h b/include/asm-generic/pci-dma-common.h
new file mode 100644
index 0000000..f688bff
--- /dev/null
+++ b/include/asm-generic/pci-dma-common.h
@@ -0,0 +1,20 @@
+#ifndef _ASM_GENERIC_PCI_DMA_COMMON_H
+#define _ASM_GENERIC_PCI_DMA_COMMON_H
+
+#ifdef HAVE_ARCH_PCI_UNMAP
+#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)        dma_addr_t ADDR_NAME;
+#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)          __u32 LEN_NAME;
+#define pci_unmap_addr(PTR, ADDR_NAME)           ((PTR)->ADDR_NAME)
+#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL)  (((PTR)->ADDR_NAME) = (VAL))
+#define pci_unmap_len(PTR, LEN_NAME)             ((PTR)->LEN_NAME)
+#define pci_unmap_len_set(PTR, LEN_NAME, VAL)    (((PTR)->LEN_NAME) = (VAL))
+#else
+#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
+#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
+#define pci_unmap_addr(PTR, ADDR_NAME)           (0)
+#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL)  do { } while (0)
+#define pci_unmap_len(PTR, LEN_NAME)             (0)
+#define pci_unmap_len_set(PTR, LEN_NAME, VAL)    do { } while (0)
+#endif
+
+#endif
-- 
1.5.6.5


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

* [PATCH -mm 02/12] x86: use asm-generic/pci-dma-common.h
  2010-02-09 13:35 [PATCH -mm 00/12] adds include/asm-generic/pci-dma-common.h e
  2010-02-09 13:35 ` [PATCH -mm 01/12] " e
@ 2010-02-09 13:35 ` e
  2010-02-09 13:35 ` [PATCH -mm 03/12] alpha: " e
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: e @ 2010-02-09 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, fujita.tomonori, x86

From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: x86@kernel.org
---
 arch/x86/include/asm/pci.h |   27 ++-------------------------
 1 files changed, 2 insertions(+), 25 deletions(-)

diff --git a/arch/x86/include/asm/pci.h b/arch/x86/include/asm/pci.h
index ada8c20..441e94a 100644
--- a/arch/x86/include/asm/pci.h
+++ b/arch/x86/include/asm/pci.h
@@ -91,32 +91,9 @@ extern void pci_iommu_alloc(void);
 #define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys)
 
 #if defined(CONFIG_X86_64) || defined(CONFIG_DMAR) || defined(CONFIG_DMA_API_DEBUG)
-
-#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)       \
-	        dma_addr_t ADDR_NAME;
-#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)         \
-	        __u32 LEN_NAME;
-#define pci_unmap_addr(PTR, ADDR_NAME)                  \
-	        ((PTR)->ADDR_NAME)
-#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL)         \
-	        (((PTR)->ADDR_NAME) = (VAL))
-#define pci_unmap_len(PTR, LEN_NAME)                    \
-	        ((PTR)->LEN_NAME)
-#define pci_unmap_len_set(PTR, LEN_NAME, VAL)           \
-	        (((PTR)->LEN_NAME) = (VAL))
-
-#else
-
-#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)       dma_addr_t ADDR_NAME[0];
-#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) unsigned LEN_NAME[0];
-#define pci_unmap_addr(PTR, ADDR_NAME)  sizeof((PTR)->ADDR_NAME)
-#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) \
-	        do { break; } while (pci_unmap_addr(PTR, ADDR_NAME))
-#define pci_unmap_len(PTR, LEN_NAME)            sizeof((PTR)->LEN_NAME)
-#define pci_unmap_len_set(PTR, LEN_NAME, VAL) \
-	        do { break; } while (pci_unmap_len(PTR, LEN_NAME))
-
+#define HAVE_ARCH_PCI_UNMAP
 #endif
+#include <asm-generic/pci-dma-common.h>
 
 #endif  /* __KERNEL__ */
 
-- 
1.5.6.5


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

* [PATCH -mm 03/12] alpha: use asm-generic/pci-dma-common.h
  2010-02-09 13:35 [PATCH -mm 00/12] adds include/asm-generic/pci-dma-common.h e
  2010-02-09 13:35 ` [PATCH -mm 01/12] " e
  2010-02-09 13:35 ` [PATCH -mm 02/12] x86: use asm-generic/pci-dma-common.h e
@ 2010-02-09 13:35 ` e
  2010-02-09 13:35 ` [PATCH -mm 04/12] arm: " e
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: e @ 2010-02-09 13:35 UTC (permalink / raw)
  To: linux-kernel
  Cc: akpm, fujita.tomonori, Richard Henderson, Ivan Kokshaysky, Matt Turner

From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
---
 arch/alpha/include/asm/pci.h |   14 ++------------
 1 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/arch/alpha/include/asm/pci.h b/arch/alpha/include/asm/pci.h
index dd8dcab..6d2a8cc 100644
--- a/arch/alpha/include/asm/pci.h
+++ b/arch/alpha/include/asm/pci.h
@@ -120,18 +120,8 @@ extern void pci_unmap_single(struct pci_dev *, dma_addr_t, size_t, int);
 extern void pci_unmap_page(struct pci_dev *, dma_addr_t, size_t, int);
 
 /* pci_unmap_{single,page} is not a nop, thus... */
-#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)	\
-	dma_addr_t ADDR_NAME;
-#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)		\
-	__u32 LEN_NAME;
-#define pci_unmap_addr(PTR, ADDR_NAME)			\
-	((PTR)->ADDR_NAME)
-#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL)		\
-	(((PTR)->ADDR_NAME) = (VAL))
-#define pci_unmap_len(PTR, LEN_NAME)			\
-	((PTR)->LEN_NAME)
-#define pci_unmap_len_set(PTR, LEN_NAME, VAL)		\
-	(((PTR)->LEN_NAME) = (VAL))
+#define HAVE_ARCH_PCI_UNMAP
+#include <asm-generic/pci-dma-common.h>
 
 /* Map a set of buffers described by scatterlist in streaming mode for
    PCI DMA.  This is the scatter-gather version of the above
-- 
1.5.6.5


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

* [PATCH -mm 04/12] arm: use asm-generic/pci-dma-common.h
  2010-02-09 13:35 [PATCH -mm 00/12] adds include/asm-generic/pci-dma-common.h e
                   ` (2 preceding siblings ...)
  2010-02-09 13:35 ` [PATCH -mm 03/12] alpha: " e
@ 2010-02-09 13:35 ` e
  2010-02-09 13:35 ` [PATCH -mm 05/12] frv: " e
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: e @ 2010-02-09 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, fujita.tomonori, Russell King

From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Russell King <linux@arm.linux.org.uk>
---
 arch/arm/include/asm/pci.h |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/arm/include/asm/pci.h b/arch/arm/include/asm/pci.h
index 226cddd..27f4103 100644
--- a/arch/arm/include/asm/pci.h
+++ b/arch/arm/include/asm/pci.h
@@ -34,12 +34,8 @@ static inline void pcibios_penalize_isa_irq(int irq, int active)
  * Whether pci_unmap_{single,page} is a nop depends upon the
  * configuration.
  */
-#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)	dma_addr_t ADDR_NAME;
-#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)		__u32 LEN_NAME;
-#define pci_unmap_addr(PTR, ADDR_NAME)		((PTR)->ADDR_NAME)
-#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL)	(((PTR)->ADDR_NAME) = (VAL))
-#define pci_unmap_len(PTR, LEN_NAME)		((PTR)->LEN_NAME)
-#define pci_unmap_len_set(PTR, LEN_NAME, VAL)	(((PTR)->LEN_NAME) = (VAL))
+#define HAVE_ARCH_PCI_UNMAP
+#include <asm-generic/pci-dma-common.h>
 
 #ifdef CONFIG_PCI
 static inline void pci_dma_burst_advice(struct pci_dev *pdev,
-- 
1.5.6.5


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

* [PATCH -mm 05/12] frv: use asm-generic/pci-dma-common.h
  2010-02-09 13:35 [PATCH -mm 00/12] adds include/asm-generic/pci-dma-common.h e
                   ` (3 preceding siblings ...)
  2010-02-09 13:35 ` [PATCH -mm 04/12] arm: " e
@ 2010-02-09 13:35 ` e
  2010-02-09 13:35 ` [PATCH -mm 06/12] ia64: " e
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: e @ 2010-02-09 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, fujita.tomonori, David Howells

From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: David Howells <dhowells@redhat.com>
---
 arch/frv/include/asm/pci.h |    7 +------
 1 files changed, 1 insertions(+), 6 deletions(-)

diff --git a/arch/frv/include/asm/pci.h b/arch/frv/include/asm/pci.h
index 8c7260a..030a190 100644
--- a/arch/frv/include/asm/pci.h
+++ b/arch/frv/include/asm/pci.h
@@ -44,12 +44,7 @@ extern void pci_free_consistent(struct pci_dev *hwdev, size_t size,
 #define pci_controller_num(PDEV)	(0)
 
 /* pci_unmap_{page,single} is a nop so... */
-#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
-#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
-#define pci_unmap_addr(PTR, ADDR_NAME)		(0)
-#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL)	do { } while (0)
-#define pci_unmap_len(PTR, LEN_NAME)		(0)
-#define pci_unmap_len_set(PTR, LEN_NAME, VAL)	do { } while (0)
+#include <asm-generic/pci-dma-common.h>
 
 #ifdef CONFIG_PCI
 static inline void pci_dma_burst_advice(struct pci_dev *pdev,
-- 
1.5.6.5


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

* [PATCH -mm 06/12] ia64: use asm-generic/pci-dma-common.h
  2010-02-09 13:35 [PATCH -mm 00/12] adds include/asm-generic/pci-dma-common.h e
                   ` (4 preceding siblings ...)
  2010-02-09 13:35 ` [PATCH -mm 05/12] frv: " e
@ 2010-02-09 13:35 ` e
  2010-02-09 13:35 ` [PATCH -mm 07/12] mips: " e
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: e @ 2010-02-09 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, fujita.tomonori, Tony Luck

From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Tony Luck <tony.luck@intel.com>
---
 arch/ia64/include/asm/pci.h |   14 ++------------
 1 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/arch/ia64/include/asm/pci.h b/arch/ia64/include/asm/pci.h
index 55281aa..56df0b5 100644
--- a/arch/ia64/include/asm/pci.h
+++ b/arch/ia64/include/asm/pci.h
@@ -57,18 +57,8 @@ pcibios_penalize_isa_irq (int irq, int active)
 #include <asm-generic/pci-dma-compat.h>
 
 /* pci_unmap_{single,page} is not a nop, thus... */
-#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)	\
-	dma_addr_t ADDR_NAME;
-#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)		\
-	__u32 LEN_NAME;
-#define pci_unmap_addr(PTR, ADDR_NAME)			\
-	((PTR)->ADDR_NAME)
-#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL)		\
-	(((PTR)->ADDR_NAME) = (VAL))
-#define pci_unmap_len(PTR, LEN_NAME)			\
-	((PTR)->LEN_NAME)
-#define pci_unmap_len_set(PTR, LEN_NAME, VAL)		\
-	(((PTR)->LEN_NAME) = (VAL))
+#define HAVE_ARCH_PCI_UNMAP
+#include <asm-generic/pci-dma-common.h>
 
 #ifdef CONFIG_PCI
 static inline void pci_dma_burst_advice(struct pci_dev *pdev,
-- 
1.5.6.5


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

* [PATCH -mm 07/12] mips: use asm-generic/pci-dma-common.h
  2010-02-09 13:35 [PATCH -mm 00/12] adds include/asm-generic/pci-dma-common.h e
                   ` (5 preceding siblings ...)
  2010-02-09 13:35 ` [PATCH -mm 06/12] ia64: " e
@ 2010-02-09 13:35 ` e
  2010-02-09 13:35 ` [PATCH -mm 08/12] parisc: " e
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: e @ 2010-02-09 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, fujita.tomonori, Ralf Baechle

From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Ralf Baechle <ralf@linux-mips.org>
---
 arch/mips/include/asm/pci.h |   23 +++--------------------
 1 files changed, 3 insertions(+), 20 deletions(-)

diff --git a/arch/mips/include/asm/pci.h b/arch/mips/include/asm/pci.h
index 5ebf825..76c6e98 100644
--- a/arch/mips/include/asm/pci.h
+++ b/arch/mips/include/asm/pci.h
@@ -103,26 +103,9 @@ struct pci_dev;
 extern unsigned int PCI_DMA_BUS_IS_PHYS;
 
 #ifdef CONFIG_DMA_NEED_PCI_MAP_STATE
-
-/* pci_unmap_{single,page} is not a nop, thus... */
-#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)	dma_addr_t ADDR_NAME;
-#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)		__u32 LEN_NAME;
-#define pci_unmap_addr(PTR, ADDR_NAME)		((PTR)->ADDR_NAME)
-#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL)	(((PTR)->ADDR_NAME) = (VAL))
-#define pci_unmap_len(PTR, LEN_NAME)		((PTR)->LEN_NAME)
-#define pci_unmap_len_set(PTR, LEN_NAME, VAL)	(((PTR)->LEN_NAME) = (VAL))
-
-#else /* CONFIG_DMA_NEED_PCI_MAP_STATE  */
-
-/* pci_unmap_{page,single} is a nop so... */
-#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
-#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
-#define pci_unmap_addr(PTR, ADDR_NAME)		(0)
-#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL)	do { } while (0)
-#define pci_unmap_len(PTR, LEN_NAME)		(0)
-#define pci_unmap_len_set(PTR, LEN_NAME, VAL)	do { } while (0)
-
-#endif /* CONFIG_DMA_NEED_PCI_MAP_STATE  */
+#define HAVE_ARCH_PCI_UNMAP
+#endif
+#include <asm-generic/pci-dma-common.h>
 
 #ifdef CONFIG_PCI
 static inline void pci_dma_burst_advice(struct pci_dev *pdev,
-- 
1.5.6.5


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

* [PATCH -mm 08/12] parisc: use asm-generic/pci-dma-common.h
  2010-02-09 13:35 [PATCH -mm 00/12] adds include/asm-generic/pci-dma-common.h e
                   ` (6 preceding siblings ...)
  2010-02-09 13:35 ` [PATCH -mm 07/12] mips: " e
@ 2010-02-09 13:35 ` e
  2010-02-09 13:35 ` [PATCH -mm 09/12] powerpc: " e
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: e @ 2010-02-09 13:35 UTC (permalink / raw)
  To: linux-kernel
  Cc: akpm, fujita.tomonori, Kyle McMartin, Helge Deller, James Bottomley

From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Kyle McMartin <kyle@mcmartin.ca>
Cc: Helge Deller <deller@gmx.de>
Cc: James Bottomley <James.Bottomley@suse.de>
---
 arch/parisc/include/asm/pci.h |   14 ++------------
 1 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/arch/parisc/include/asm/pci.h b/arch/parisc/include/asm/pci.h
index 64c7aa5..e397277 100644
--- a/arch/parisc/include/asm/pci.h
+++ b/arch/parisc/include/asm/pci.h
@@ -184,18 +184,8 @@ struct pci_bios_ops {
 };
 
 /* pci_unmap_{single,page} is not a nop, thus... */
-#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)	\
-	dma_addr_t ADDR_NAME;
-#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)		\
-	__u32 LEN_NAME;
-#define pci_unmap_addr(PTR, ADDR_NAME)			\
-	((PTR)->ADDR_NAME)
-#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL)		\
-	(((PTR)->ADDR_NAME) = (VAL))
-#define pci_unmap_len(PTR, LEN_NAME)			\
-	((PTR)->LEN_NAME)
-#define pci_unmap_len_set(PTR, LEN_NAME, VAL)		\
-	(((PTR)->LEN_NAME) = (VAL))
+#define HAVE_ARCH_PCI_UNMAP
+#include <asm-generic/pci-dma-common.h>
 
 /*
 ** Stuff declared in arch/parisc/kernel/pci.c
-- 
1.5.6.5


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

* [PATCH -mm 09/12] powerpc: use asm-generic/pci-dma-common.h
  2010-02-09 13:35 [PATCH -mm 00/12] adds include/asm-generic/pci-dma-common.h e
                   ` (7 preceding siblings ...)
  2010-02-09 13:35 ` [PATCH -mm 08/12] parisc: " e
@ 2010-02-09 13:35 ` e
  2010-02-09 13:35 ` [PATCH -mm 10/12] sh: " e
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: e @ 2010-02-09 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, fujita.tomonori, Benjamin Herrenschmidt

From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 arch/powerpc/include/asm/pci.h |   33 +++------------------------------
 1 files changed, 3 insertions(+), 30 deletions(-)

diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h
index b5ea626..089c8d3 100644
--- a/arch/powerpc/include/asm/pci.h
+++ b/arch/powerpc/include/asm/pci.h
@@ -142,36 +142,9 @@ extern int pci_mmap_legacy_page_range(struct pci_bus *bus,
 #define HAVE_PCI_LEGACY	1
 
 #if defined(CONFIG_PPC64) || defined(CONFIG_NOT_COHERENT_CACHE)
-/*
- * For 64-bit kernels, pci_unmap_{single,page} is not a nop.
- * For 32-bit non-coherent kernels, pci_dma_sync_single_for_cpu() and
- * so on are not nops.
- * and thus...
- */
-#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)	\
-	dma_addr_t ADDR_NAME;
-#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)		\
-	__u32 LEN_NAME;
-#define pci_unmap_addr(PTR, ADDR_NAME)			\
-	((PTR)->ADDR_NAME)
-#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL)		\
-	(((PTR)->ADDR_NAME) = (VAL))
-#define pci_unmap_len(PTR, LEN_NAME)			\
-	((PTR)->LEN_NAME)
-#define pci_unmap_len_set(PTR, LEN_NAME, VAL)		\
-	(((PTR)->LEN_NAME) = (VAL))
-
-#else /* 32-bit && coherent */
-
-/* pci_unmap_{page,single} is a nop so... */
-#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
-#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
-#define pci_unmap_addr(PTR, ADDR_NAME)		(0)
-#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL)	do { } while (0)
-#define pci_unmap_len(PTR, LEN_NAME)		(0)
-#define pci_unmap_len_set(PTR, LEN_NAME, VAL)	do { } while (0)
-
-#endif /* CONFIG_PPC64 || CONFIG_NOT_COHERENT_CACHE */
+#define HAVE_ARCH_PCI_UNMAP
+#endif
+#include <asm-generic/pci-dma-common.h>
 
 #ifdef CONFIG_PPC64
 
-- 
1.5.6.5


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

* [PATCH -mm 10/12] sh: use asm-generic/pci-dma-common.h
  2010-02-09 13:35 [PATCH -mm 00/12] adds include/asm-generic/pci-dma-common.h e
                   ` (8 preceding siblings ...)
  2010-02-09 13:35 ` [PATCH -mm 09/12] powerpc: " e
@ 2010-02-09 13:35 ` e
  2010-02-09 13:35 ` [PATCH -mm 11/12] sparc: " e
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: e @ 2010-02-09 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, fujita.tomonori, Paul Mundt

From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Paul Mundt <lethal@linux-sh.org>
---
 arch/sh/include/asm/pci.h |   15 ++-------------
 1 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/arch/sh/include/asm/pci.h b/arch/sh/include/asm/pci.h
index 1042f7f..3106018 100644
--- a/arch/sh/include/asm/pci.h
+++ b/arch/sh/include/asm/pci.h
@@ -87,20 +87,9 @@ static inline void pcibios_penalize_isa_irq(int irq, int active)
  * configuration.
  */
 #ifdef CONFIG_DMA_NONCOHERENT
-#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)	dma_addr_t ADDR_NAME;
-#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)		__u32 LEN_NAME;
-#define pci_unmap_addr(PTR, ADDR_NAME)		((PTR)->ADDR_NAME)
-#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL)	(((PTR)->ADDR_NAME) = (VAL))
-#define pci_unmap_len(PTR, LEN_NAME)		((PTR)->LEN_NAME)
-#define pci_unmap_len_set(PTR, LEN_NAME, VAL)	(((PTR)->LEN_NAME) = (VAL))
-#else
-#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
-#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
-#define pci_unmap_addr(PTR, ADDR_NAME)		(0)
-#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL)	do { } while (0)
-#define pci_unmap_len(PTR, LEN_NAME)		(0)
-#define pci_unmap_len_set(PTR, LEN_NAME, VAL)	do { } while (0)
+#define HAVE_ARCH_PCI_UNMAP
 #endif
+#include <asm-generic/pci-dma-common.h>
 
 #ifdef CONFIG_PCI
 /*
-- 
1.5.6.5


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

* [PATCH -mm 11/12] sparc: use asm-generic/pci-dma-common.h
  2010-02-09 13:35 [PATCH -mm 00/12] adds include/asm-generic/pci-dma-common.h e
                   ` (9 preceding siblings ...)
  2010-02-09 13:35 ` [PATCH -mm 10/12] sh: " e
@ 2010-02-09 13:35 ` e
  2010-02-09 19:26   ` David Miller
  2010-02-09 13:35 ` [PATCH -mm 12/12] xtensa: " e
  2010-02-09 15:23 ` [PATCH -mm 00/12] adds include/asm-generic/pci-dma-common.h Arnd Bergmann
  12 siblings, 1 reply; 16+ messages in thread
From: e @ 2010-02-09 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, fujita.tomonori, David S. Miller

From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: David S. Miller <davem@davemloft.net>
---
 arch/sparc/include/asm/pci.h    |    3 +++
 arch/sparc/include/asm/pci_32.h |   14 --------------
 arch/sparc/include/asm/pci_64.h |   14 --------------
 3 files changed, 3 insertions(+), 28 deletions(-)

diff --git a/arch/sparc/include/asm/pci.h b/arch/sparc/include/asm/pci.h
index d9c031f..4fd2d17 100644
--- a/arch/sparc/include/asm/pci.h
+++ b/arch/sparc/include/asm/pci.h
@@ -6,6 +6,9 @@
 #include <asm/pci_32.h>
 #endif
 
+#define HAVE_ARCH_PCI_UNMAP
+#include <asm-generic/pci-dma-common.h>
+
 #include <asm-generic/pci-dma-compat.h>
 
 #endif
diff --git a/arch/sparc/include/asm/pci_32.h b/arch/sparc/include/asm/pci_32.h
index e769f66..332ac9a 100644
--- a/arch/sparc/include/asm/pci_32.h
+++ b/arch/sparc/include/asm/pci_32.h
@@ -32,20 +32,6 @@ static inline void pcibios_penalize_isa_irq(int irq, int active)
 
 struct pci_dev;
 
-/* pci_unmap_{single,page} is not a nop, thus... */
-#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)	\
-	dma_addr_t ADDR_NAME;
-#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)		\
-	__u32 LEN_NAME;
-#define pci_unmap_addr(PTR, ADDR_NAME)			\
-	((PTR)->ADDR_NAME)
-#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL)		\
-	(((PTR)->ADDR_NAME) = (VAL))
-#define pci_unmap_len(PTR, LEN_NAME)			\
-	((PTR)->LEN_NAME)
-#define pci_unmap_len_set(PTR, LEN_NAME, VAL)		\
-	(((PTR)->LEN_NAME) = (VAL))
-
 #ifdef CONFIG_PCI
 static inline void pci_dma_burst_advice(struct pci_dev *pdev,
 					enum pci_dma_burst_strategy *strat,
diff --git a/arch/sparc/include/asm/pci_64.h b/arch/sparc/include/asm/pci_64.h
index b0576df..5312782 100644
--- a/arch/sparc/include/asm/pci_64.h
+++ b/arch/sparc/include/asm/pci_64.h
@@ -32,20 +32,6 @@ static inline void pcibios_penalize_isa_irq(int irq, int active)
  */
 #define PCI_DMA_BUS_IS_PHYS	(0)
 
-/* pci_unmap_{single,page} is not a nop, thus... */
-#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)	\
-	dma_addr_t ADDR_NAME;
-#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)		\
-	__u32 LEN_NAME;
-#define pci_unmap_addr(PTR, ADDR_NAME)			\
-	((PTR)->ADDR_NAME)
-#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL)		\
-	(((PTR)->ADDR_NAME) = (VAL))
-#define pci_unmap_len(PTR, LEN_NAME)			\
-	((PTR)->LEN_NAME)
-#define pci_unmap_len_set(PTR, LEN_NAME, VAL)		\
-	(((PTR)->LEN_NAME) = (VAL))
-
 /* PCI IOMMU mapping bypass support. */
 
 /* PCI 64-bit addressing works for all slots on all controller
-- 
1.5.6.5


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

* [PATCH -mm 12/12] xtensa: use asm-generic/pci-dma-common.h
  2010-02-09 13:35 [PATCH -mm 00/12] adds include/asm-generic/pci-dma-common.h e
                   ` (10 preceding siblings ...)
  2010-02-09 13:35 ` [PATCH -mm 11/12] sparc: " e
@ 2010-02-09 13:35 ` e
  2010-02-09 15:23 ` [PATCH -mm 00/12] adds include/asm-generic/pci-dma-common.h Arnd Bergmann
  12 siblings, 0 replies; 16+ messages in thread
From: e @ 2010-02-09 13:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, fujita.tomonori, Chris Zankel

From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Chris Zankel <chris@zankel.net>
---
 arch/xtensa/include/asm/pci.h |    7 +------
 1 files changed, 1 insertions(+), 6 deletions(-)

diff --git a/arch/xtensa/include/asm/pci.h b/arch/xtensa/include/asm/pci.h
index 66410ac..32828f8 100644
--- a/arch/xtensa/include/asm/pci.h
+++ b/arch/xtensa/include/asm/pci.h
@@ -57,12 +57,7 @@ struct pci_dev;
 #define PCI_DMA_BUS_IS_PHYS	(1)
 
 /* pci_unmap_{page,single} is a no-op, so */
-#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
-#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
-#define pci_unmap_addr(PTR, ADDR_NAME)		(0)
-#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL)	do { } while (0)
-#define pci_ubnmap_len(PTR, LEN_NAME)		(0)
-#define pci_unmap_len_set(PTR, LEN_NAME, VAL)	do { } while (0)
+#include <asm-generic/pci-dma-common.h>
 
 /* Map a range of PCI memory or I/O space for a device into user space */
 int pci_mmap_page_range(struct pci_dev *pdev, struct vm_area_struct *vma,
-- 
1.5.6.5


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

* Re: [PATCH -mm 00/12] adds include/asm-generic/pci-dma-common.h
  2010-02-09 13:35 [PATCH -mm 00/12] adds include/asm-generic/pci-dma-common.h e
                   ` (11 preceding siblings ...)
  2010-02-09 13:35 ` [PATCH -mm 12/12] xtensa: " e
@ 2010-02-09 15:23 ` Arnd Bergmann
  2010-02-10  0:06   ` FUJITA Tomonori
  12 siblings, 1 reply; 16+ messages in thread
From: Arnd Bergmann @ 2010-02-09 15:23 UTC (permalink / raw)
  To: e
  Cc: linux-kernel, akpm, fujita.tomonori, x86, Richard Henderson,
	Ivan Kokshaysky, Matt Turner, Russell King, David Howells,
	Tony Luck, Ralf Baechle, Kyle McMartin, Helge Deller,
	James Bottomley, Benjamin Herrenschmidt, Paul Mundt,
	David S. Miller, Chris Zankel

On Tuesday 09 February 2010, e@lab.ntt.co.jp wrote:
> This patchset adds include/asm-generic/pci-dma-common.h that defines
> the pci_unmap state API:
> 
> DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
> DECLARE_PCI_UNMAP_LEN(LEN_NAME)
> pci_unmap_addr(PTR, ADDR_NAME)
> pci_unmap_addr_set(PTR, ADDR_NAME, VAL)
> pci_unmap_len(PTR, LEN_NAME)
> pci_unmap_len_set(PTR, LEN_NAME, VAL)
> 
> This enables us to remove lots of the duplication in architecture
> implementations since there are only two ways to define the API.

Good stuff, moving this code to a common location is certainly
a step in the right direction.

A few general comments though:

* It seems you left out arch/cris for no good reason.
* The general tendency nowadays is to avoid new HAVE_ARCH_*
  macros and instead using either a Kconfig symbol or
  checking the presence of the macros themselves. In this case,
  the macro would always be present, so CONFIG_PCI_UNMAP
  would be reasonable.
* AFAICT, there are no architectures left doing the
  non-generic version, so the code could be moved to
  a global file in include/linux instead of include/asm-generic.
  While include/linux/pci.h is already a bit overloaded, it's
  probably the right place for this. Alternatively,
  include/linux/pci-dma.h, included from include/linux/pci.h.

> In the long term, it's better to replace the API with the generic
> device model API such as DECLARE_DMA_UNMAP_ADDR. We can map the API to
> the generic one (like dma-mapping-compat.h does). This patch also
> makes the migration process easier.

Agreed.
 
	Arnd

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

* Re: [PATCH -mm 11/12] sparc: use asm-generic/pci-dma-common.h
  2010-02-09 13:35 ` [PATCH -mm 11/12] sparc: " e
@ 2010-02-09 19:26   ` David Miller
  0 siblings, 0 replies; 16+ messages in thread
From: David Miller @ 2010-02-09 19:26 UTC (permalink / raw)
  To: e; +Cc: linux-kernel, akpm, fujita.tomonori

From: e@lab.ntt.co.jp
Date: Tue,  9 Feb 2010 22:35:23 +0900

> From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
> 
> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>

Acked-by: David S. Miller <davem@davemloft.net>

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

* Re: [PATCH -mm 00/12] adds include/asm-generic/pci-dma-common.h
  2010-02-09 15:23 ` [PATCH -mm 00/12] adds include/asm-generic/pci-dma-common.h Arnd Bergmann
@ 2010-02-10  0:06   ` FUJITA Tomonori
  0 siblings, 0 replies; 16+ messages in thread
From: FUJITA Tomonori @ 2010-02-10  0:06 UTC (permalink / raw)
  To: arnd
  Cc: linux-kernel, akpm, fujita.tomonori, x86, rth, ink, mattst88,
	linux, dhowells, tony.luck, ralf, kyle, deller, James.Bottomley,
	benh, lethal, davem, chris

On Tue, 9 Feb 2010 16:23:35 +0100
Arnd Bergmann <arnd@arndb.de> wrote:

> On Tuesday 09 February 2010, e@lab.ntt.co.jp wrote:
> > This patchset adds include/asm-generic/pci-dma-common.h that defines
> > the pci_unmap state API:
> > 
> > DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
> > DECLARE_PCI_UNMAP_LEN(LEN_NAME)
> > pci_unmap_addr(PTR, ADDR_NAME)
> > pci_unmap_addr_set(PTR, ADDR_NAME, VAL)
> > pci_unmap_len(PTR, LEN_NAME)
> > pci_unmap_len_set(PTR, LEN_NAME, VAL)
> > 
> > This enables us to remove lots of the duplication in architecture
> > implementations since there are only two ways to define the API.
> 
> Good stuff, moving this code to a common location is certainly
> a step in the right direction.
> 
> A few general comments though:
> 
> * It seems you left out arch/cris for no good reason.

Yeah, somehow I missed it. I'll do next time.


> * The general tendency nowadays is to avoid new HAVE_ARCH_*
>   macros and instead using either a Kconfig symbol or
>   checking the presence of the macros themselves. In this case,
>   the macro would always be present, so CONFIG_PCI_UNMAP
>   would be reasonable.

I see. I go with CONFIG_NEED_DMA_MAP_STATE (it's a bit explanatory and
mips already uses CONFIG_DMA_NEED_PCI_MAP_STATE for the same purpose).


> * AFAICT, there are no architectures left doing the
>   non-generic version, so the code could be moved to
>   a global file in include/linux instead of include/asm-generic.
>   While include/linux/pci.h is already a bit overloaded, it's
>   probably the right place for this. Alternatively,
>   include/linux/pci-dma.h, included from include/linux/pci.h.

Ok, I go with linux/pci-dma.h. I prefer linux/pci.h but as you said,
looks like already too big. We'll remove this file after moving to the
generic device model. So the name shouldn't matter much.


Thanks!

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

end of thread, other threads:[~2010-02-10  0:09 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-09 13:35 [PATCH -mm 00/12] adds include/asm-generic/pci-dma-common.h e
2010-02-09 13:35 ` [PATCH -mm 01/12] " e
2010-02-09 13:35 ` [PATCH -mm 02/12] x86: use asm-generic/pci-dma-common.h e
2010-02-09 13:35 ` [PATCH -mm 03/12] alpha: " e
2010-02-09 13:35 ` [PATCH -mm 04/12] arm: " e
2010-02-09 13:35 ` [PATCH -mm 05/12] frv: " e
2010-02-09 13:35 ` [PATCH -mm 06/12] ia64: " e
2010-02-09 13:35 ` [PATCH -mm 07/12] mips: " e
2010-02-09 13:35 ` [PATCH -mm 08/12] parisc: " e
2010-02-09 13:35 ` [PATCH -mm 09/12] powerpc: " e
2010-02-09 13:35 ` [PATCH -mm 10/12] sh: " e
2010-02-09 13:35 ` [PATCH -mm 11/12] sparc: " e
2010-02-09 19:26   ` David Miller
2010-02-09 13:35 ` [PATCH -mm 12/12] xtensa: " e
2010-02-09 15:23 ` [PATCH -mm 00/12] adds include/asm-generic/pci-dma-common.h Arnd Bergmann
2010-02-10  0:06   ` FUJITA Tomonori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome