aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci
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 /drivers/pci
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>
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/pci.c29
1 files changed, 29 insertions, 0 deletions
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;
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 *