aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMyron Stowe <mstowe@redhat.com>2011-10-28 17:48:38 -0400
committerJesse Barnes <jbarnes@virtuousgeek.org>2012-01-06 15:10:42 -0500
commit96c5590058d7fded14f43af2ab521436cecf3125 (patch)
tree673577f86b1ee8886c27cc86333fdfdc6cc783ac
parent9cdce18d6f0baae53f012fb3f50e66e7ff24c509 (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.h4
-rw-r--r--arch/frv/mb93090-mb00/pci-frv.c6
-rw-r--r--arch/frv/mb93090-mb00/pci-frv.h2
-rw-r--r--arch/h8300/include/asm/pci.h5
-rw-r--r--arch/mips/pci/pci.c6
-rw-r--r--arch/mn10300/unit-asb2305/pci-asb2305.c6
-rw-r--r--arch/mn10300/unit-asb2305/pci-asb2305.h2
-rw-r--r--arch/sh/drivers/pci/pci.c6
-rw-r--r--arch/x86/include/asm/pci_x86.h2
-rw-r--r--arch/x86/pci/i386.c6
-rw-r--r--drivers/pci/pci.c29
-rw-r--r--include/linux/pci.h3
12 files changed, 32 insertions, 45 deletions
diff --git a/arch/blackfin/include/asm/pci.h b/arch/blackfin/include/asm/pci.h
index 99cae2e3bac..74352c4597d 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
13static inline void pcibios_set_master(struct pci_dev *dev)
14{
15 /* No special bus mastering setup handling */
16}
17static inline void pcibios_penalize_isa_irq(int irq) 13static 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 6b4fb28e9f9..6a0cd644d7c 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 */
202unsigned int pcibios_max_latency = 255;
203
204void pcibios_set_master(struct pci_dev *dev) 198void 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 f3fe5591479..089eeba4f3b 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
29extern unsigned int pcibios_max_latency;
30
31void pcibios_resource_survey(void); 29void 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 cc9762091c0..0b2acaa3dd8 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
12static inline void pcibios_set_master(struct pci_dev *dev)
13{
14 /* No special bus mastering setup handling */
15}
16
17static inline void pcibios_penalize_isa_irq(int irq, int active) 12static 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 41af7fa2887..f93f749b92e 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 */
212static unsigned int pcibios_max_latency = 255;
213
214void pcibios_set_master(struct pci_dev *dev) 208void 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 8e6763e6f25..2b299c413ae 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 */
220unsigned int pcibios_max_latency = 255;
221
222void pcibios_set_master(struct pci_dev *dev) 216void 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 c3fa294b6e2..1194fe486b0 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
34extern unsigned int pcibios_max_latency;
35
36extern void pcibios_resource_survey(void); 34extern 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 c2691afe8f7..cfdb2f65294 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 */
250static unsigned int pcibios_max_latency = 255;
251
252void pcibios_set_master(struct pci_dev *dev) 246void 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 e3819780685..b3a53174602 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
47extern unsigned int pcibios_max_latency;
48
49void pcibios_resource_survey(void); 47void pcibios_resource_survey(void);
50void pcibios_set_cache_line_size(void); 48void pcibios_set_cache_line_size(void);
51 49
diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c
index 794b092d01a..dd5806b0fc8 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 */
255fs_initcall(pcibios_assign_resources); 255fs_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 */
261unsigned int pcibios_max_latency = 255;
262
263void pcibios_set_master(struct pci_dev *dev) 257void 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 924193ef4fe..f9abe84cf5e 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;
88u8 pci_dfl_cache_line_size __devinitdata = L1_CACHE_BYTES >> 2; 88u8 pci_dfl_cache_line_size __devinitdata = L1_CACHE_BYTES >> 2;
89u8 pci_cache_line_size; 89u8 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 */
95unsigned 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 */
2612void __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 569341d2d52..4c16a578899 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
797void pci_disable_device(struct pci_dev *dev); 797void pci_disable_device(struct pci_dev *dev);
798
799extern unsigned int pcibios_max_latency;
798void pci_set_master(struct pci_dev *dev); 800void pci_set_master(struct pci_dev *dev);
799void pci_clear_master(struct pci_dev *dev); 801void pci_clear_master(struct pci_dev *dev);
802
800int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state); 803int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state);
801int pci_set_cacheline_size(struct pci_dev *dev); 804int pci_set_cacheline_size(struct pci_dev *dev);
802#define HAVE_PCI_SET_MWI 805#define HAVE_PCI_SET_MWI