aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2005-06-02 15:55:50 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-06-28 00:52:45 -0400
commite24c2d963a604d9eaa560c90371fa387d3eec8f1 (patch)
tree66be193d59dd22fac0b62980769c4f19e045b5a2 /include
parent2311b1f2bbd36fa5f366a7448c718b2556e0f02c (diff)
[PATCH] PCI: DMA bursting advice
After seeing, at best, "guesses" as to the following kind of information in several drivers, I decided that we really need a way for platforms to specifically give advice in this area for what works best with their PCI controller implementation. Basically, this new interface gives DMA bursting advice on PCI. There are three forms of the advice: 1) Burst as much as possible, it is not necessary to end bursts on some particular boundary for best performance. 2) Burst on some byte count multiple. A DMA burst to some multiple of number of bytes may be done, but it is important to end the burst on an exact multiple for best performance. The best example of this I am aware of are the PPC64 PCI controllers, where if you end a burst mid-cacheline then chip has to refetch the data and the IOMMU translations which hurts performance a lot. 3) Burst on a single byte count multiple. Bursts shall end exactly on the next multiple boundary for best performance. Sparc64 and Alpha's PCI controllers operate this way. They disconnect any device which tries to burst across a cacheline boundary. Actually, newer sparc64 PCI controllers do not have this behavior. That is why the "pdev" is passed into the interface, so I can add code later to check which PCI controller the system is using and give advice accordingly. Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'include')
-rw-r--r--include/asm-alpha/pci.h17
-rw-r--r--include/asm-arm/pci.h8
-rw-r--r--include/asm-frv/pci.h8
-rw-r--r--include/asm-i386/pci.h8
-rw-r--r--include/asm-ia64/pci.h17
-rw-r--r--include/asm-mips/pci.h8
-rw-r--r--include/asm-parisc/pci.h17
-rw-r--r--include/asm-ppc/pci.h8
-rw-r--r--include/asm-ppc64/pci.h17
-rw-r--r--include/asm-sh/pci.h8
-rw-r--r--include/asm-sh64/pci.h8
-rw-r--r--include/asm-sparc/pci.h8
-rw-r--r--include/asm-sparc64/pci.h17
-rw-r--r--include/asm-v850/pci.h8
-rw-r--r--include/asm-x86_64/pci.h8
-rw-r--r--include/linux/pci.h9
16 files changed, 174 insertions, 0 deletions
diff --git a/include/asm-alpha/pci.h b/include/asm-alpha/pci.h
index 0c7b57bc043a..6c71dc1ad4ca 100644
--- a/include/asm-alpha/pci.h
+++ b/include/asm-alpha/pci.h
@@ -223,6 +223,23 @@ pci_dac_dma_sync_single_for_device(struct pci_dev *pdev, dma64_addr_t dma_addr,
223 /* Nothing to do. */ 223 /* Nothing to do. */
224} 224}
225 225
226static inline void pci_dma_burst_advice(struct pci_dev *pdev,
227 enum pci_dma_burst_strategy *strat,
228 unsigned long *strategy_parameter)
229{
230 unsigned long cacheline_size;
231 u8 byte;
232
233 pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &byte);
234 if (byte == 0)
235 cacheline_size = 1024;
236 else
237 cacheline_size = (int) byte * 4;
238
239 *strat = PCI_DMA_BURST_BOUNDARY;
240 *strategy_parameter = cacheline_size;
241}
242
226/* TODO: integrate with include/asm-generic/pci.h ? */ 243/* TODO: integrate with include/asm-generic/pci.h ? */
227static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) 244static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
228{ 245{
diff --git a/include/asm-arm/pci.h b/include/asm-arm/pci.h
index 40ffaefbeb1a..bc2ec425aca5 100644
--- a/include/asm-arm/pci.h
+++ b/include/asm-arm/pci.h
@@ -42,6 +42,14 @@ static inline void pcibios_penalize_isa_irq(int irq)
42#define pci_unmap_len(PTR, LEN_NAME) ((PTR)->LEN_NAME) 42#define pci_unmap_len(PTR, LEN_NAME) ((PTR)->LEN_NAME)
43#define pci_unmap_len_set(PTR, LEN_NAME, VAL) (((PTR)->LEN_NAME) = (VAL)) 43#define pci_unmap_len_set(PTR, LEN_NAME, VAL) (((PTR)->LEN_NAME) = (VAL))
44 44
45static inline void pci_dma_burst_advice(struct pci_dev *pdev,
46 enum pci_dma_burst_strategy *strat,
47 unsigned long *strategy_parameter)
48{
49 *strat = PCI_DMA_BURST_INFINITY;
50 *strategy_parameter = ~0UL;
51}
52
45#define HAVE_PCI_MMAP 53#define HAVE_PCI_MMAP
46extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, 54extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
47 enum pci_mmap_state mmap_state, int write_combine); 55 enum pci_mmap_state mmap_state, int write_combine);
diff --git a/include/asm-frv/pci.h b/include/asm-frv/pci.h
index a6a469231f62..13427240664f 100644
--- a/include/asm-frv/pci.h
+++ b/include/asm-frv/pci.h
@@ -57,6 +57,14 @@ extern void pci_free_consistent(struct pci_dev *hwdev, size_t size,
57 */ 57 */
58#define PCI_DMA_BUS_IS_PHYS (1) 58#define PCI_DMA_BUS_IS_PHYS (1)
59 59
60static inline void pci_dma_burst_advice(struct pci_dev *pdev,
61 enum pci_dma_burst_strategy *strat,
62 unsigned long *strategy_parameter)
63{
64 *strat = PCI_DMA_BURST_INFINITY;
65 *strategy_parameter = ~0UL;
66}
67
60/* 68/*
61 * These are pretty much arbitary with the CoMEM implementation. 69 * These are pretty much arbitary with the CoMEM implementation.
62 * We have the whole address space to ourselves. 70 * We have the whole address space to ourselves.
diff --git a/include/asm-i386/pci.h b/include/asm-i386/pci.h
index fb749b85a739..bf07b3af85e3 100644
--- a/include/asm-i386/pci.h
+++ b/include/asm-i386/pci.h
@@ -99,6 +99,14 @@ static inline void pcibios_add_platform_entries(struct pci_dev *dev)
99{ 99{
100} 100}
101 101
102static inline void pci_dma_burst_advice(struct pci_dev *pdev,
103 enum pci_dma_burst_strategy *strat,
104 unsigned long *strategy_parameter)
105{
106 *strat = PCI_DMA_BURST_INFINITY;
107 *strategy_parameter = ~0UL;
108}
109
102#endif /* __KERNEL__ */ 110#endif /* __KERNEL__ */
103 111
104/* implement the pci_ DMA API in terms of the generic device dma_ one */ 112/* implement the pci_ DMA API in terms of the generic device dma_ one */
diff --git a/include/asm-ia64/pci.h b/include/asm-ia64/pci.h
index a8314ee4e7d2..c9f1ab4e477d 100644
--- a/include/asm-ia64/pci.h
+++ b/include/asm-ia64/pci.h
@@ -82,6 +82,23 @@ extern int pcibios_prep_mwi (struct pci_dev *);
82#define sg_dma_len(sg) ((sg)->dma_length) 82#define sg_dma_len(sg) ((sg)->dma_length)
83#define sg_dma_address(sg) ((sg)->dma_address) 83#define sg_dma_address(sg) ((sg)->dma_address)
84 84
85static inline void pci_dma_burst_advice(struct pci_dev *pdev,
86 enum pci_dma_burst_strategy *strat,
87 unsigned long *strategy_parameter)
88{
89 unsigned long cacheline_size;
90 u8 byte;
91
92 pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &byte);
93 if (byte == 0)
94 cacheline_size = 1024;
95 else
96 cacheline_size = (int) byte * 4;
97
98 *strat = PCI_DMA_BURST_MULTIPLE;
99 *strategy_parameter = cacheline_size;
100}
101
85#define HAVE_PCI_MMAP 102#define HAVE_PCI_MMAP
86extern int pci_mmap_page_range (struct pci_dev *dev, struct vm_area_struct *vma, 103extern int pci_mmap_page_range (struct pci_dev *dev, struct vm_area_struct *vma,
87 enum pci_mmap_state mmap_state, int write_combine); 104 enum pci_mmap_state mmap_state, int write_combine);
diff --git a/include/asm-mips/pci.h b/include/asm-mips/pci.h
index c9c576b48556..20b93bfa4565 100644
--- a/include/asm-mips/pci.h
+++ b/include/asm-mips/pci.h
@@ -130,6 +130,14 @@ extern void pci_dac_dma_sync_single_for_cpu(struct pci_dev *pdev,
130extern void pci_dac_dma_sync_single_for_device(struct pci_dev *pdev, 130extern void pci_dac_dma_sync_single_for_device(struct pci_dev *pdev,
131 dma64_addr_t dma_addr, size_t len, int direction); 131 dma64_addr_t dma_addr, size_t len, int direction);
132 132
133static inline void pci_dma_burst_advice(struct pci_dev *pdev,
134 enum pci_dma_burst_strategy *strat,
135 unsigned long *strategy_parameter)
136{
137 *strat = PCI_DMA_BURST_INFINITY;
138 *strategy_parameter = ~0UL;
139}
140
133extern void pcibios_resource_to_bus(struct pci_dev *dev, 141extern void pcibios_resource_to_bus(struct pci_dev *dev,
134 struct pci_bus_region *region, struct resource *res); 142 struct pci_bus_region *region, struct resource *res);
135 143
diff --git a/include/asm-parisc/pci.h b/include/asm-parisc/pci.h
index 0763c2982fb0..f9f5bf90111d 100644
--- a/include/asm-parisc/pci.h
+++ b/include/asm-parisc/pci.h
@@ -230,6 +230,23 @@ extern inline void pcibios_register_hba(struct pci_hba_data *x)
230/* export the pci_ DMA API in terms of the dma_ one */ 230/* export the pci_ DMA API in terms of the dma_ one */
231#include <asm-generic/pci-dma-compat.h> 231#include <asm-generic/pci-dma-compat.h>
232 232
233static inline void pci_dma_burst_advice(struct pci_dev *pdev,
234 enum pci_dma_burst_strategy *strat,
235 unsigned long *strategy_parameter)
236{
237 unsigned long cacheline_size;
238 u8 byte;
239
240 pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &byte);
241 if (byte == 0)
242 cacheline_size = 1024;
243 else
244 cacheline_size = (int) byte * 4;
245
246 *strat = PCI_DMA_BURST_MULTIPLE;
247 *strategy_parameter = cacheline_size;
248}
249
233extern void 250extern void
234pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, 251pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
235 struct resource *res); 252 struct resource *res);
diff --git a/include/asm-ppc/pci.h b/include/asm-ppc/pci.h
index 002e7b305777..669e9de7a525 100644
--- a/include/asm-ppc/pci.h
+++ b/include/asm-ppc/pci.h
@@ -69,6 +69,14 @@ extern unsigned long pci_bus_to_phys(unsigned int ba, int busnr);
69#define pci_unmap_len(PTR, LEN_NAME) (0) 69#define pci_unmap_len(PTR, LEN_NAME) (0)
70#define pci_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0) 70#define pci_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0)
71 71
72static inline void pci_dma_burst_advice(struct pci_dev *pdev,
73 enum pci_dma_burst_strategy *strat,
74 unsigned long *strategy_parameter)
75{
76 *strat = PCI_DMA_BURST_INFINITY;
77 *strategy_parameter = ~0UL;
78}
79
72/* 80/*
73 * At present there are very few 32-bit PPC machines that can have 81 * At present there are very few 32-bit PPC machines that can have
74 * memory above the 4GB point, and we don't support that. 82 * memory above the 4GB point, and we don't support that.
diff --git a/include/asm-ppc64/pci.h b/include/asm-ppc64/pci.h
index 411bf5dee394..20beb10c0902 100644
--- a/include/asm-ppc64/pci.h
+++ b/include/asm-ppc64/pci.h
@@ -78,6 +78,23 @@ static inline int pci_dac_dma_supported(struct pci_dev *hwdev,u64 mask)
78 return 0; 78 return 0;
79} 79}
80 80
81static inline void pci_dma_burst_advice(struct pci_dev *pdev,
82 enum pci_dma_burst_strategy *strat,
83 unsigned long *strategy_parameter)
84{
85 unsigned long cacheline_size;
86 u8 byte;
87
88 pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &byte);
89 if (byte == 0)
90 cacheline_size = 1024;
91 else
92 cacheline_size = (int) byte * 4;
93
94 *strat = PCI_DMA_BURST_MULTIPLE;
95 *strategy_parameter = cacheline_size;
96}
97
81extern int pci_domain_nr(struct pci_bus *bus); 98extern int pci_domain_nr(struct pci_bus *bus);
82 99
83/* Decide whether to display the domain number in /proc */ 100/* Decide whether to display the domain number in /proc */
diff --git a/include/asm-sh/pci.h b/include/asm-sh/pci.h
index 9c3b63d0105e..7237bc6a7280 100644
--- a/include/asm-sh/pci.h
+++ b/include/asm-sh/pci.h
@@ -96,6 +96,14 @@ static inline void pcibios_penalize_isa_irq(int irq)
96#define sg_dma_address(sg) (virt_to_bus((sg)->dma_address)) 96#define sg_dma_address(sg) (virt_to_bus((sg)->dma_address))
97#define sg_dma_len(sg) ((sg)->length) 97#define sg_dma_len(sg) ((sg)->length)
98 98
99static inline void pci_dma_burst_advice(struct pci_dev *pdev,
100 enum pci_dma_burst_strategy *strat,
101 unsigned long *strategy_parameter)
102{
103 *strat = PCI_DMA_BURST_INFINITY;
104 *strategy_parameter = ~0UL;
105}
106
99/* Board-specific fixup routines. */ 107/* Board-specific fixup routines. */
100extern void pcibios_fixup(void); 108extern void pcibios_fixup(void);
101extern void pcibios_fixup_irqs(void); 109extern void pcibios_fixup_irqs(void);
diff --git a/include/asm-sh64/pci.h b/include/asm-sh64/pci.h
index 8cc14e139750..0ac15ab01cce 100644
--- a/include/asm-sh64/pci.h
+++ b/include/asm-sh64/pci.h
@@ -86,6 +86,14 @@ static inline void pcibios_penalize_isa_irq(int irq)
86#define sg_dma_address(sg) ((sg)->dma_address) 86#define sg_dma_address(sg) ((sg)->dma_address)
87#define sg_dma_len(sg) ((sg)->length) 87#define sg_dma_len(sg) ((sg)->length)
88 88
89static inline void pci_dma_burst_advice(struct pci_dev *pdev,
90 enum pci_dma_burst_strategy *strat,
91 unsigned long *strategy_parameter)
92{
93 *strat = PCI_DMA_BURST_INFINITY;
94 *strategy_parameter = ~0UL;
95}
96
89/* Board-specific fixup routines. */ 97/* Board-specific fixup routines. */
90extern void pcibios_fixup(void); 98extern void pcibios_fixup(void);
91extern void pcibios_fixup_irqs(void); 99extern void pcibios_fixup_irqs(void);
diff --git a/include/asm-sparc/pci.h b/include/asm-sparc/pci.h
index d200a25a7373..2fd65db95e92 100644
--- a/include/asm-sparc/pci.h
+++ b/include/asm-sparc/pci.h
@@ -144,6 +144,14 @@ extern inline int pci_dma_supported(struct pci_dev *hwdev, u64 mask)
144 144
145#define pci_dac_dma_supported(dev, mask) (0) 145#define pci_dac_dma_supported(dev, mask) (0)
146 146
147static inline void pci_dma_burst_advice(struct pci_dev *pdev,
148 enum pci_dma_burst_strategy *strat,
149 unsigned long *strategy_parameter)
150{
151 *strat = PCI_DMA_BURST_INFINITY;
152 *strategy_parameter = ~0UL;
153}
154
147static inline void pcibios_add_platform_entries(struct pci_dev *dev) 155static inline void pcibios_add_platform_entries(struct pci_dev *dev)
148{ 156{
149} 157}
diff --git a/include/asm-sparc64/pci.h b/include/asm-sparc64/pci.h
index 2a0c85cd1c11..402667300d01 100644
--- a/include/asm-sparc64/pci.h
+++ b/include/asm-sparc64/pci.h
@@ -220,6 +220,23 @@ static inline int pci_dma_mapping_error(dma_addr_t dma_addr)
220 return (dma_addr == PCI_DMA_ERROR_CODE); 220 return (dma_addr == PCI_DMA_ERROR_CODE);
221} 221}
222 222
223static inline void pci_dma_burst_advice(struct pci_dev *pdev,
224 enum pci_dma_burst_strategy *strat,
225 unsigned long *strategy_parameter)
226{
227 unsigned long cacheline_size;
228 u8 byte;
229
230 pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &byte);
231 if (byte == 0)
232 cacheline_size = 1024;
233 else
234 cacheline_size = (int) byte * 4;
235
236 *strat = PCI_DMA_BURST_BOUNDARY;
237 *strategy_parameter = cacheline_size;
238}
239
223/* Return the index of the PCI controller for device PDEV. */ 240/* Return the index of the PCI controller for device PDEV. */
224 241
225extern int pci_domain_nr(struct pci_bus *bus); 242extern int pci_domain_nr(struct pci_bus *bus);
diff --git a/include/asm-v850/pci.h b/include/asm-v850/pci.h
index e41941447b49..d26eb8d67311 100644
--- a/include/asm-v850/pci.h
+++ b/include/asm-v850/pci.h
@@ -81,6 +81,14 @@ extern void
81pci_free_consistent (struct pci_dev *pdev, size_t size, void *cpu_addr, 81pci_free_consistent (struct pci_dev *pdev, size_t size, void *cpu_addr,
82 dma_addr_t dma_addr); 82 dma_addr_t dma_addr);
83 83
84static inline void pci_dma_burst_advice(struct pci_dev *pdev,
85 enum pci_dma_burst_strategy *strat,
86 unsigned long *strategy_parameter)
87{
88 *strat = PCI_DMA_BURST_INFINITY;
89 *strategy_parameter = ~0UL;
90}
91
84static inline void pcibios_add_platform_entries(struct pci_dev *dev) 92static inline void pcibios_add_platform_entries(struct pci_dev *dev)
85{ 93{
86} 94}
diff --git a/include/asm-x86_64/pci.h b/include/asm-x86_64/pci.h
index 8712520ca47f..8461d6af102e 100644
--- a/include/asm-x86_64/pci.h
+++ b/include/asm-x86_64/pci.h
@@ -123,6 +123,14 @@ pci_dac_dma_sync_single_for_device(struct pci_dev *pdev, dma64_addr_t dma_addr,
123 flush_write_buffers(); 123 flush_write_buffers();
124} 124}
125 125
126static inline void pci_dma_burst_advice(struct pci_dev *pdev,
127 enum pci_dma_burst_strategy *strat,
128 unsigned long *strategy_parameter)
129{
130 *strat = PCI_DMA_BURST_INFINITY;
131 *strategy_parameter = ~0UL;
132}
133
126#define HAVE_PCI_MMAP 134#define HAVE_PCI_MMAP
127extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, 135extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
128 enum pci_mmap_state mmap_state, int write_combine); 136 enum pci_mmap_state mmap_state, int write_combine);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index cfa1455848f4..9ce4f1be093f 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -874,6 +874,15 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max, int pass
874#define pci_pool_alloc(pool, flags, handle) dma_pool_alloc(pool, flags, handle) 874#define pci_pool_alloc(pool, flags, handle) dma_pool_alloc(pool, flags, handle)
875#define pci_pool_free(pool, vaddr, addr) dma_pool_free(pool, vaddr, addr) 875#define pci_pool_free(pool, vaddr, addr) dma_pool_free(pool, vaddr, addr)
876 876
877enum pci_dma_burst_strategy {
878 PCI_DMA_BURST_INFINITY, /* make bursts as large as possible,
879 strategy_parameter is N/A */
880 PCI_DMA_BURST_BOUNDARY, /* disconnect at every strategy_parameter
881 byte boundaries */
882 PCI_DMA_BURST_MULTIPLE, /* disconnect at some multiple of
883 strategy_parameter byte boundaries */
884};
885
877#if defined(CONFIG_ISA) || defined(CONFIG_EISA) 886#if defined(CONFIG_ISA) || defined(CONFIG_EISA)
878extern struct pci_dev *isa_bridge; 887extern struct pci_dev *isa_bridge;
879#endif 888#endif