adds include/asm-generic/pci-dma-common.h
Subsystems (11)
cover adds include/asm-generic/pci-dma-common.h
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(-)
PATCH 1/12 adds include/asm-generic/pci-dma-common.h
From: FUJITA Tomonori <[email protected]>
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.
--- 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
include/asm-generic/pci-dma-common.h new file +20 -0
@@ -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
Signature · 1 line
1.5.6.5
PATCH 2/12 x86: use asm-generic/pci-dma-common.h
In reply to [email protected]From: FUJITA Tomonori <[email protected]>
--- arch/x86/include/asm/pci.h | 27 ++------------------------- 1 files changed, 2 insertions(+), 25 deletions(-)
arch/x86/include/asm/pci.h +2 -25
@@ -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__ */
Signature · 1 line
1.5.6.5
PATCH 3/12 alpha: use asm-generic/pci-dma-common.h
In reply to [email protected]From: FUJITA Tomonori <[email protected]>
--- arch/alpha/include/asm/pci.h | 14 ++------------ 1 files changed, 2 insertions(+), 12 deletions(-)
arch/alpha/include/asm/pci.h +2 -12
@@ -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
Signature · 1 line
1.5.6.5
PATCH 4/12 arm: use asm-generic/pci-dma-common.h
In reply to [email protected]From: FUJITA Tomonori <[email protected]>
--- arch/arm/include/asm/pci.h | 8 ++------ 1 files changed, 2 insertions(+), 6 deletions(-)
arch/arm/include/asm/pci.h +2 -6
@@ -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,
Signature · 1 line
1.5.6.5
PATCH 5/12 frv: use asm-generic/pci-dma-common.h
In reply to [email protected]From: FUJITA Tomonori <[email protected]>
--- arch/frv/include/asm/pci.h | 7 +------ 1 files changed, 1 insertions(+), 6 deletions(-)
arch/frv/include/asm/pci.h +1 -6
@@ -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,
Signature · 1 line
1.5.6.5
PATCH 6/12 ia64: use asm-generic/pci-dma-common.h
In reply to [email protected]From: FUJITA Tomonori <[email protected]>
--- arch/ia64/include/asm/pci.h | 14 ++------------ 1 files changed, 2 insertions(+), 12 deletions(-)
arch/ia64/include/asm/pci.h +2 -12
@@ -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,
Signature · 1 line
1.5.6.5
PATCH 7/12 mips: use asm-generic/pci-dma-common.h
In reply to [email protected]From: FUJITA Tomonori <[email protected]>
--- arch/mips/include/asm/pci.h | 23 +++-------------------- 1 files changed, 3 insertions(+), 20 deletions(-)
arch/mips/include/asm/pci.h +3 -20
@@ -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,
Signature · 1 line
1.5.6.5
PATCH 8/12 parisc: use asm-generic/pci-dma-common.h
In reply to [email protected]From: FUJITA Tomonori <[email protected]>
--- arch/parisc/include/asm/pci.h | 14 ++------------ 1 files changed, 2 insertions(+), 12 deletions(-)
arch/parisc/include/asm/pci.h +2 -12
@@ -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
Signature · 1 line
1.5.6.5
PATCH 9/12 powerpc: use asm-generic/pci-dma-common.h
In reply to [email protected]From: FUJITA Tomonori <[email protected]>
--- arch/powerpc/include/asm/pci.h | 33 +++------------------------------ 1 files changed, 3 insertions(+), 30 deletions(-)
arch/powerpc/include/asm/pci.h +3 -30
@@ -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
Signature · 1 line
1.5.6.5
PATCH 10/12 sh: use asm-generic/pci-dma-common.h
In reply to [email protected]From: FUJITA Tomonori <[email protected]>
--- arch/sh/include/asm/pci.h | 15 ++------------- 1 files changed, 2 insertions(+), 13 deletions(-)
arch/sh/include/asm/pci.h +2 -13
@@ -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 /*
Signature · 1 line
1.5.6.5
PATCH 11/12 sparc: use asm-generic/pci-dma-common.h
In reply to [email protected]From: FUJITA Tomonori <[email protected]>
--- 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(-)
arch/sparc/include/asm/pci.h +3 -0
@@ -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
arch/sparc/include/asm/pci_32.h +0 -14
@@ -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,
arch/sparc/include/asm/pci_64.h +0 -14
@@ -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
Signature · 1 line
1.5.6.5
Re: [PATCH -mm 11/12] sparc: use asm-generic/pci-dma-common.h
From: [email protected]
Date: Tue, 9 Feb 2010 22:35:23 +0900
Quoted 3 lines
From: FUJITA Tomonori <[email protected]>
Signed-off-by FUJITA Tomonori <[email protected]>
PATCH 12/12 xtensa: use asm-generic/pci-dma-common.h
In reply to [email protected]From: FUJITA Tomonori <[email protected]>
--- arch/xtensa/include/asm/pci.h | 7 +------ 1 files changed, 1 insertions(+), 6 deletions(-)
arch/xtensa/include/asm/pci.h +1 -6
@@ -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,
Signature · 1 line
1.5.6.5
Arnd Bergmann
maintainerQuoted 10 lines · On Tuesday 09 February 2010, [email protected] wrote:
This patchset adds
include/asm-generic/pci-dma-common.hthat defines thepci_unmapstate 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)
Quoted 2 lines
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.
Quoted 4 lines
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 (likedma-mapping-compat.hdoes). This patch also makes the migration process easier.
Agreed.
Arnd
Quoted 14 lines · On Tue, 9 Feb 2010 16:23:35 +0100 Arnd Bergmann <[email protected]> wrote:
Quoted 10 lines · On Tuesday 09 February 2010, [email protected] wrote:
This patchset adds
include/asm-generic/pci-dma-common.hthat defines thepci_unmapstate 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)Quoted 2 lines
This enables us to remove lots of the duplication in architecture implementations since there are only two ways to define the API.
Quoted 6 lines
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/crisfor no good reason.
Yeah, somehow I missed it. I'll do next time.
Quoted 5 lines
* The general tendency nowadays is to avoid new HAVE_ARCH_* macros and instead using either a
Kconfigsymbol or checking the presence of the macros themselves. In this case, the macro would always be present, soCONFIG_PCI_UNMAPwould 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).
Quoted 6 lines
* AFAICT, there are no architectures left doing the non-generic version, so the code could be moved to
a global file ininclude/linuxinstead ofinclude/asm-generic. Whileinclude/linux/pci.his already a bit overloaded, it's probably the right place for this. Alternatively,include/linux/pci-dma.h, included frominclude/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!