Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Myron Stowe and committed by
Jesse Barnes
96c55900 9cdce18d

+32 -45
-4
arch/blackfin/include/asm/pci.h
··· 10 10 #define PCIBIOS_MIN_IO 0x00001000 11 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 13 static inline void pcibios_penalize_isa_irq(int irq) 18 14 { 19 15 /* We don't do dynamic PCI IRQ allocation */
-6
arch/frv/mb93090-mb00/pci-frv.c
··· 195 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 198 void pcibios_set_master(struct pci_dev *dev) 205 199 { 206 200 u8 lat;
-2
arch/frv/mb93090-mb00/pci-frv.h
··· 26 26 27 27 /* pci-frv.c */ 28 28 29 - extern unsigned int pcibios_max_latency; 30 - 31 29 void pcibios_resource_survey(void); 32 30 33 31 /* pci-vdk.c */
-5
arch/h8300/include/asm/pci.h
··· 9 9 10 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 12 static inline void pcibios_penalize_isa_irq(int irq, int active) 18 13 { 19 14 /* We don't do dynamic PCI IRQ allocation */
-6
arch/mips/pci/pci.c
··· 205 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 208 void pcibios_set_master(struct pci_dev *dev) 215 209 { 216 210 u8 lat;
-6
arch/mn10300/unit-asb2305/pci-asb2305.c
··· 213 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 216 void pcibios_set_master(struct pci_dev *dev) 223 217 { 224 218 u8 lat;
-2
arch/mn10300/unit-asb2305/pci-asb2305.h
··· 31 31 32 32 /* pci-asb2305.c */ 33 33 34 - extern unsigned int pcibios_max_latency; 35 - 36 34 extern void pcibios_resource_survey(void); 37 35 38 36 /* pci.c */
-6
arch/sh/drivers/pci/pci.c
··· 243 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 246 void pcibios_set_master(struct pci_dev *dev) 253 247 { 254 248 u8 lat;
-2
arch/x86/include/asm/pci_x86.h
··· 44 44 45 45 /* pci-i386.c */ 46 46 47 - extern unsigned int pcibios_max_latency; 48 - 49 47 void pcibios_resource_survey(void); 50 48 void pcibios_set_cache_line_size(void); 51 49
-6
arch/x86/pci/i386.c
··· 254 254 */ 255 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 257 void pcibios_set_master(struct pci_dev *dev) 264 258 { 265 259 u8 lat;
+29
drivers/pci/pci.c
··· 88 88 u8 pci_dfl_cache_line_size __devinitdata = L1_CACHE_BYTES >> 2; 89 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 98 * pci_bus_max_busnr - returns maximum PCI bus number of given bus' children 93 99 * @bus: pointer to PCI bus structure to search ··· 2599 2593 pci_write_config_word(dev, PCI_COMMAND, cmd); 2600 2594 } 2601 2595 dev->is_busmaster = enable; 2596 + } 2597 + 2598 + /** 2599 + * pcibios_set_master - enable PCI bus-mastering for device dev 2600 + * @dev: the PCI device to enable 2601 + * 2602 + * Enables PCI bus-mastering for the device. This is the default 2603 + * implementation. Architecture specific implementations can override 2604 + * this if necessary. 2605 + */ 2606 + void __weak pcibios_set_master(struct pci_dev *dev) 2607 + { 2608 + u8 lat; 2609 + 2610 + pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat); 2611 + if (lat < 16) 2612 + lat = (64 <= pcibios_max_latency) ? 64 : pcibios_max_latency; 2613 + else if (lat > pcibios_max_latency) 2614 + lat = pcibios_max_latency; 2615 + else 2616 + return; 2617 + dev_printk(KERN_DEBUG, &dev->dev, "setting latency timer to %d\n", lat); 2618 + pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat); 2602 2619 } 2603 2620 2604 2621 /**
+3
include/linux/pci.h
··· 795 795 } 796 796 797 797 void pci_disable_device(struct pci_dev *dev); 798 + 799 + extern unsigned int pcibios_max_latency; 798 800 void pci_set_master(struct pci_dev *dev); 799 801 void pci_clear_master(struct pci_dev *dev); 802 + 800 803 int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state); 801 804 int pci_set_cacheline_size(struct pci_dev *dev); 802 805 #define HAVE_PCI_SET_MWI