diff options
author | Myron Stowe <mstowe@redhat.com> | 2011-10-28 17:48:38 -0400 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2012-01-06 15:10:42 -0500 |
commit | 96c5590058d7fded14f43af2ab521436cecf3125 (patch) | |
tree | 673577f86b1ee8886c27cc86333fdfdc6cc783ac | |
parent | 9cdce18d6f0baae53f012fb3f50e66e7ff24c509 (diff) |
PCI: Pull PCI 'latency timer' setup up into the core
The 'latency timer' of PCI devices, both Type 0 and Type 1,
is setup in architecture-specific code [see: 'pcibios_set_master()'].
There are two approaches being taken by all the architectures - check
if the 'latency timer' is currently set between 16 and 255 and if not
bring it within bounds, or, do nothing (and then there is the
gratuitously different PA-RISC implementation).
There is nothing architecture-specific about PCI's 'latency timer' so
this patch pulls its setup functionality up into the PCI core by
creating a generic 'pcibios_set_master()' function using the '__weak'
attribute which can be used by all architectures as a default which,
if necessary, can then be over-ridden by architecture-specific code.
No functional change.
Signed-off-by: Myron Stowe <myron.stowe@redhat.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
-rw-r--r-- | arch/blackfin/include/asm/pci.h | 4 | ||||
-rw-r--r-- | arch/frv/mb93090-mb00/pci-frv.c | 6 | ||||
-rw-r--r-- | arch/frv/mb93090-mb00/pci-frv.h | 2 | ||||
-rw-r--r-- | arch/h8300/include/asm/pci.h | 5 | ||||
-rw-r--r-- | arch/mips/pci/pci.c | 6 | ||||
-rw-r--r-- | arch/mn10300/unit-asb2305/pci-asb2305.c | 6 | ||||
-rw-r--r-- | arch/mn10300/unit-asb2305/pci-asb2305.h | 2 | ||||
-rw-r--r-- | arch/sh/drivers/pci/pci.c | 6 | ||||
-rw-r--r-- | arch/x86/include/asm/pci_x86.h | 2 | ||||
-rw-r--r-- | arch/x86/pci/i386.c | 6 | ||||
-rw-r--r-- | drivers/pci/pci.c | 29 | ||||
-rw-r--r-- | include/linux/pci.h | 3 |
12 files changed, 32 insertions, 45 deletions
diff --git a/arch/blackfin/include/asm/pci.h b/arch/blackfin/include/asm/pci.h index 99cae2e3bac7..74352c4597d9 100644 --- a/arch/blackfin/include/asm/pci.h +++ b/arch/blackfin/include/asm/pci.h | |||
@@ -10,10 +10,6 @@ | |||
10 | #define PCIBIOS_MIN_IO 0x00001000 | 10 | #define PCIBIOS_MIN_IO 0x00001000 |
11 | #define PCIBIOS_MIN_MEM 0x10000000 | 11 | #define PCIBIOS_MIN_MEM 0x10000000 |
12 | 12 | ||
13 | static inline void pcibios_set_master(struct pci_dev *dev) | ||
14 | { | ||
15 | /* No special bus mastering setup handling */ | ||
16 | } | ||
17 | static inline void pcibios_penalize_isa_irq(int irq) | 13 | static inline void pcibios_penalize_isa_irq(int irq) |
18 | { | 14 | { |
19 | /* We don't do dynamic PCI IRQ allocation */ | 15 | /* We don't do dynamic PCI IRQ allocation */ |
diff --git a/arch/frv/mb93090-mb00/pci-frv.c b/arch/frv/mb93090-mb00/pci-frv.c index 6b4fb28e9f99..6a0cd644d7cc 100644 --- a/arch/frv/mb93090-mb00/pci-frv.c +++ b/arch/frv/mb93090-mb00/pci-frv.c | |||
@@ -195,12 +195,6 @@ void __init pcibios_resource_survey(void) | |||
195 | pcibios_assign_resources(); | 195 | pcibios_assign_resources(); |
196 | } | 196 | } |
197 | 197 | ||
198 | /* | ||
199 | * If we set up a device for bus mastering, we need to check the latency | ||
200 | * timer as certain crappy BIOSes forget to set it properly. | ||
201 | */ | ||
202 | unsigned int pcibios_max_latency = 255; | ||
203 | |||
204 | void pcibios_set_master(struct pci_dev *dev) | 198 | void pcibios_set_master(struct pci_dev *dev) |
205 | { | 199 | { |
206 | u8 lat; | 200 | u8 lat; |
diff --git a/arch/frv/mb93090-mb00/pci-frv.h b/arch/frv/mb93090-mb00/pci-frv.h index f3fe55914793..089eeba4f3bc 100644 --- a/arch/frv/mb93090-mb00/pci-frv.h +++ b/arch/frv/mb93090-mb00/pci-frv.h | |||
@@ -26,8 +26,6 @@ extern unsigned int __nongpreldata pci_probe; | |||
26 | 26 | ||
27 | /* pci-frv.c */ | 27 | /* pci-frv.c */ |
28 | 28 | ||
29 | extern unsigned int pcibios_max_latency; | ||
30 | |||
31 | void pcibios_resource_survey(void); | 29 | void pcibios_resource_survey(void); |
32 | 30 | ||
33 | /* pci-vdk.c */ | 31 | /* pci-vdk.c */ |
diff --git a/arch/h8300/include/asm/pci.h b/arch/h8300/include/asm/pci.h index cc9762091c0a..0b2acaa3dd84 100644 --- a/arch/h8300/include/asm/pci.h +++ b/arch/h8300/include/asm/pci.h | |||
@@ -9,11 +9,6 @@ | |||
9 | 9 | ||
10 | #define pcibios_assign_all_busses() 0 | 10 | #define pcibios_assign_all_busses() 0 |
11 | 11 | ||
12 | static inline void pcibios_set_master(struct pci_dev *dev) | ||
13 | { | ||
14 | /* No special bus mastering setup handling */ | ||
15 | } | ||
16 | |||
17 | static inline void pcibios_penalize_isa_irq(int irq, int active) | 12 | static inline void pcibios_penalize_isa_irq(int irq, int active) |
18 | { | 13 | { |
19 | /* We don't do dynamic PCI IRQ allocation */ | 14 | /* We don't do dynamic PCI IRQ allocation */ |
diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c index 41af7fa2887b..f93f749b92e3 100644 --- a/arch/mips/pci/pci.c +++ b/arch/mips/pci/pci.c | |||
@@ -205,12 +205,6 @@ static int pcibios_enable_resources(struct pci_dev *dev, int mask) | |||
205 | return 0; | 205 | return 0; |
206 | } | 206 | } |
207 | 207 | ||
208 | /* | ||
209 | * If we set up a device for bus mastering, we need to check the latency | ||
210 | * timer as certain crappy BIOSes forget to set it properly. | ||
211 | */ | ||
212 | static unsigned int pcibios_max_latency = 255; | ||
213 | |||
214 | void pcibios_set_master(struct pci_dev *dev) | 208 | void pcibios_set_master(struct pci_dev *dev) |
215 | { | 209 | { |
216 | u8 lat; | 210 | u8 lat; |
diff --git a/arch/mn10300/unit-asb2305/pci-asb2305.c b/arch/mn10300/unit-asb2305/pci-asb2305.c index 8e6763e6f250..2b299c413ae5 100644 --- a/arch/mn10300/unit-asb2305/pci-asb2305.c +++ b/arch/mn10300/unit-asb2305/pci-asb2305.c | |||
@@ -213,12 +213,6 @@ void __init pcibios_resource_survey(void) | |||
213 | pcibios_allocate_resources(1); | 213 | pcibios_allocate_resources(1); |
214 | } | 214 | } |
215 | 215 | ||
216 | /* | ||
217 | * If we set up a device for bus mastering, we need to check the latency | ||
218 | * timer as certain crappy BIOSes forget to set it properly. | ||
219 | */ | ||
220 | unsigned int pcibios_max_latency = 255; | ||
221 | |||
222 | void pcibios_set_master(struct pci_dev *dev) | 216 | void pcibios_set_master(struct pci_dev *dev) |
223 | { | 217 | { |
224 | u8 lat; | 218 | u8 lat; |
diff --git a/arch/mn10300/unit-asb2305/pci-asb2305.h b/arch/mn10300/unit-asb2305/pci-asb2305.h index c3fa294b6e28..1194fe486b01 100644 --- a/arch/mn10300/unit-asb2305/pci-asb2305.h +++ b/arch/mn10300/unit-asb2305/pci-asb2305.h | |||
@@ -31,8 +31,6 @@ extern unsigned int pci_probe; | |||
31 | 31 | ||
32 | /* pci-asb2305.c */ | 32 | /* pci-asb2305.c */ |
33 | 33 | ||
34 | extern unsigned int pcibios_max_latency; | ||
35 | |||
36 | extern void pcibios_resource_survey(void); | 34 | extern void pcibios_resource_survey(void); |
37 | 35 | ||
38 | /* pci.c */ | 36 | /* pci.c */ |
diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c index c2691afe8f79..cfdb2f652949 100644 --- a/arch/sh/drivers/pci/pci.c +++ b/arch/sh/drivers/pci/pci.c | |||
@@ -243,12 +243,6 @@ int pcibios_enable_device(struct pci_dev *dev, int mask) | |||
243 | return pci_enable_resources(dev, mask); | 243 | return pci_enable_resources(dev, mask); |
244 | } | 244 | } |
245 | 245 | ||
246 | /* | ||
247 | * If we set up a device for bus mastering, we need to check and set | ||
248 | * the latency timer as it may not be properly set. | ||
249 | */ | ||
250 | static unsigned int pcibios_max_latency = 255; | ||
251 | |||
252 | void pcibios_set_master(struct pci_dev *dev) | 246 | void pcibios_set_master(struct pci_dev *dev) |
253 | { | 247 | { |
254 | u8 lat; | 248 | u8 lat; |
diff --git a/arch/x86/include/asm/pci_x86.h b/arch/x86/include/asm/pci_x86.h index e38197806853..b3a531746026 100644 --- a/arch/x86/include/asm/pci_x86.h +++ b/arch/x86/include/asm/pci_x86.h | |||
@@ -44,8 +44,6 @@ enum pci_bf_sort_state { | |||
44 | 44 | ||
45 | /* pci-i386.c */ | 45 | /* pci-i386.c */ |
46 | 46 | ||
47 | extern unsigned int pcibios_max_latency; | ||
48 | |||
49 | void pcibios_resource_survey(void); | 47 | void pcibios_resource_survey(void); |
50 | void pcibios_set_cache_line_size(void); | 48 | void pcibios_set_cache_line_size(void); |
51 | 49 | ||
diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c index 794b092d01ae..dd5806b0fc8b 100644 --- a/arch/x86/pci/i386.c +++ b/arch/x86/pci/i386.c | |||
@@ -254,12 +254,6 @@ void __init pcibios_resource_survey(void) | |||
254 | */ | 254 | */ |
255 | fs_initcall(pcibios_assign_resources); | 255 | fs_initcall(pcibios_assign_resources); |
256 | 256 | ||
257 | /* | ||
258 | * If we set up a device for bus mastering, we need to check the latency | ||
259 | * timer as certain crappy BIOSes forget to set it properly. | ||
260 | */ | ||
261 | unsigned int pcibios_max_latency = 255; | ||
262 | |||
263 | void pcibios_set_master(struct pci_dev *dev) | 257 | void pcibios_set_master(struct pci_dev *dev) |
264 | { | 258 | { |
265 | u8 lat; | 259 | u8 lat; |
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 924193ef4fe1..f9abe84cf5e0 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -88,6 +88,12 @@ enum pcie_bus_config_types pcie_bus_config = PCIE_BUS_TUNE_OFF; | |||
88 | u8 pci_dfl_cache_line_size __devinitdata = L1_CACHE_BYTES >> 2; | 88 | u8 pci_dfl_cache_line_size __devinitdata = L1_CACHE_BYTES >> 2; |
89 | u8 pci_cache_line_size; | 89 | u8 pci_cache_line_size; |
90 | 90 | ||
91 | /* | ||
92 | * If we set up a device for bus mastering, we need to check the latency | ||
93 | * timer as certain BIOSes forget to set it properly. | ||
94 | */ | ||
95 | unsigned int pcibios_max_latency = 255; | ||
96 | |||
91 | /** | 97 | /** |
92 | * pci_bus_max_busnr - returns maximum PCI bus number of given bus' children | 98 | * pci_bus_max_busnr - returns maximum PCI bus number of given bus' children |
93 | * @bus: pointer to PCI bus structure to search | 99 | * @bus: pointer to PCI bus structure to search |
@@ -2596,6 +2602,29 @@ static void __pci_set_master(struct pci_dev *dev, bool enable) | |||
2596 | } | 2602 | } |
2597 | 2603 | ||
2598 | /** | 2604 | /** |
2605 | * pcibios_set_master - enable PCI bus-mastering for device dev | ||
2606 | * @dev: the PCI device to enable | ||
2607 | * | ||
2608 | * Enables PCI bus-mastering for the device. This is the default | ||
2609 | * implementation. Architecture specific implementations can override | ||
2610 | * this if necessary. | ||
2611 | */ | ||
2612 | void __weak pcibios_set_master(struct pci_dev *dev) | ||
2613 | { | ||
2614 | u8 lat; | ||
2615 | |||
2616 | pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat); | ||
2617 | if (lat < 16) | ||
2618 | lat = (64 <= pcibios_max_latency) ? 64 : pcibios_max_latency; | ||
2619 | else if (lat > pcibios_max_latency) | ||
2620 | lat = pcibios_max_latency; | ||
2621 | else | ||
2622 | return; | ||
2623 | dev_printk(KERN_DEBUG, &dev->dev, "setting latency timer to %d\n", lat); | ||
2624 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat); | ||
2625 | } | ||
2626 | |||
2627 | /** | ||
2599 | * pci_set_master - enables bus-mastering for device dev | 2628 | * pci_set_master - enables bus-mastering for device dev |
2600 | * @dev: the PCI device to enable | 2629 | * @dev: the PCI device to enable |
2601 | * | 2630 | * |
diff --git a/include/linux/pci.h b/include/linux/pci.h index 569341d2d527..4c16a5788998 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
@@ -795,8 +795,11 @@ static inline int pci_is_managed(struct pci_dev *pdev) | |||
795 | } | 795 | } |
796 | 796 | ||
797 | void pci_disable_device(struct pci_dev *dev); | 797 | void pci_disable_device(struct pci_dev *dev); |
798 | |||
799 | extern unsigned int pcibios_max_latency; | ||
798 | void pci_set_master(struct pci_dev *dev); | 800 | void pci_set_master(struct pci_dev *dev); |
799 | void pci_clear_master(struct pci_dev *dev); | 801 | void pci_clear_master(struct pci_dev *dev); |
802 | |||
800 | int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state); | 803 | int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state); |
801 | int pci_set_cacheline_size(struct pci_dev *dev); | 804 | int pci_set_cacheline_size(struct pci_dev *dev); |
802 | #define HAVE_PCI_SET_MWI | 805 | #define HAVE_PCI_SET_MWI |