aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/probe.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/probe.c')
-rw-r--r--drivers/pci/probe.c121
1 files changed, 93 insertions, 28 deletions
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index e6a917b4acd3..ff94b69738a8 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1745,21 +1745,50 @@ static void program_hpp_type2(struct pci_dev *dev, struct hpp_type2 *hpp)
1745 */ 1745 */
1746} 1746}
1747 1747
1748static void pci_configure_extended_tags(struct pci_dev *dev) 1748int pci_configure_extended_tags(struct pci_dev *dev, void *ign)
1749{ 1749{
1750 u32 dev_cap; 1750 struct pci_host_bridge *host;
1751 u32 cap;
1752 u16 ctl;
1751 int ret; 1753 int ret;
1752 1754
1753 if (!pci_is_pcie(dev)) 1755 if (!pci_is_pcie(dev))
1754 return; 1756 return 0;
1755 1757
1756 ret = pcie_capability_read_dword(dev, PCI_EXP_DEVCAP, &dev_cap); 1758 ret = pcie_capability_read_dword(dev, PCI_EXP_DEVCAP, &cap);
1757 if (ret) 1759 if (ret)
1758 return; 1760 return 0;
1761
1762 if (!(cap & PCI_EXP_DEVCAP_EXT_TAG))
1763 return 0;
1764
1765 ret = pcie_capability_read_word(dev, PCI_EXP_DEVCTL, &ctl);
1766 if (ret)
1767 return 0;
1768
1769 host = pci_find_host_bridge(dev->bus);
1770 if (!host)
1771 return 0;
1759 1772
1760 if (dev_cap & PCI_EXP_DEVCAP_EXT_TAG) 1773 /*
1774 * If some device in the hierarchy doesn't handle Extended Tags
1775 * correctly, make sure they're disabled.
1776 */
1777 if (host->no_ext_tags) {
1778 if (ctl & PCI_EXP_DEVCTL_EXT_TAG) {
1779 dev_info(&dev->dev, "disabling Extended Tags\n");
1780 pcie_capability_clear_word(dev, PCI_EXP_DEVCTL,
1781 PCI_EXP_DEVCTL_EXT_TAG);
1782 }
1783 return 0;
1784 }
1785
1786 if (!(ctl & PCI_EXP_DEVCTL_EXT_TAG)) {
1787 dev_info(&dev->dev, "enabling Extended Tags\n");
1761 pcie_capability_set_word(dev, PCI_EXP_DEVCTL, 1788 pcie_capability_set_word(dev, PCI_EXP_DEVCTL,
1762 PCI_EXP_DEVCTL_EXT_TAG); 1789 PCI_EXP_DEVCTL_EXT_TAG);
1790 }
1791 return 0;
1763} 1792}
1764 1793
1765/** 1794/**
@@ -1810,7 +1839,7 @@ static void pci_configure_device(struct pci_dev *dev)
1810 int ret; 1839 int ret;
1811 1840
1812 pci_configure_mps(dev); 1841 pci_configure_mps(dev);
1813 pci_configure_extended_tags(dev); 1842 pci_configure_extended_tags(dev, NULL);
1814 pci_configure_relaxed_ordering(dev); 1843 pci_configure_relaxed_ordering(dev);
1815 1844
1816 memset(&hpp, 0, sizeof(hpp)); 1845 memset(&hpp, 0, sizeof(hpp));
@@ -1867,42 +1896,69 @@ struct pci_dev *pci_alloc_dev(struct pci_bus *bus)
1867} 1896}
1868EXPORT_SYMBOL(pci_alloc_dev); 1897EXPORT_SYMBOL(pci_alloc_dev);
1869 1898
1870bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *l, 1899static bool pci_bus_crs_vendor_id(u32 l)
1871 int crs_timeout) 1900{
1901 return (l & 0xffff) == 0x0001;
1902}
1903
1904static bool pci_bus_wait_crs(struct pci_bus *bus, int devfn, u32 *l,
1905 int timeout)
1872{ 1906{
1873 int delay = 1; 1907 int delay = 1;
1874 1908
1875 if (pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, l)) 1909 if (!pci_bus_crs_vendor_id(*l))
1876 return false; 1910 return true; /* not a CRS completion */
1877 1911
1878 /* some broken boards return 0 or ~0 if a slot is empty: */ 1912 if (!timeout)
1879 if (*l == 0xffffffff || *l == 0x00000000 || 1913 return false; /* CRS, but caller doesn't want to wait */
1880 *l == 0x0000ffff || *l == 0xffff0000)
1881 return false;
1882 1914
1883 /* 1915 /*
1884 * Configuration Request Retry Status. Some root ports return the 1916 * We got the reserved Vendor ID that indicates a completion with
1885 * actual device ID instead of the synthetic ID (0xFFFF) required 1917 * Configuration Request Retry Status (CRS). Retry until we get a
1886 * by the PCIe spec. Ignore the device ID and only check for 1918 * valid Vendor ID or we time out.
1887 * (vendor id == 1).
1888 */ 1919 */
1889 while ((*l & 0xffff) == 0x0001) { 1920 while (pci_bus_crs_vendor_id(*l)) {
1890 if (!crs_timeout) 1921 if (delay > timeout) {
1922 pr_warn("pci %04x:%02x:%02x.%d: not ready after %dms; giving up\n",
1923 pci_domain_nr(bus), bus->number,
1924 PCI_SLOT(devfn), PCI_FUNC(devfn), delay - 1);
1925
1891 return false; 1926 return false;
1927 }
1928 if (delay >= 1000)
1929 pr_info("pci %04x:%02x:%02x.%d: not ready after %dms; waiting\n",
1930 pci_domain_nr(bus), bus->number,
1931 PCI_SLOT(devfn), PCI_FUNC(devfn), delay - 1);
1892 1932
1893 msleep(delay); 1933 msleep(delay);
1894 delay *= 2; 1934 delay *= 2;
1935
1895 if (pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, l)) 1936 if (pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, l))
1896 return false; 1937 return false;
1897 /* Card hasn't responded in 60 seconds? Must be stuck. */
1898 if (delay > crs_timeout) {
1899 printk(KERN_WARNING "pci %04x:%02x:%02x.%d: not responding\n",
1900 pci_domain_nr(bus), bus->number, PCI_SLOT(devfn),
1901 PCI_FUNC(devfn));
1902 return false;
1903 }
1904 } 1938 }
1905 1939
1940 if (delay >= 1000)
1941 pr_info("pci %04x:%02x:%02x.%d: ready after %dms\n",
1942 pci_domain_nr(bus), bus->number,
1943 PCI_SLOT(devfn), PCI_FUNC(devfn), delay - 1);
1944
1945 return true;
1946}
1947
1948bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *l,
1949 int timeout)
1950{
1951 if (pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, l))
1952 return false;
1953
1954 /* some broken boards return 0 or ~0 if a slot is empty: */
1955 if (*l == 0xffffffff || *l == 0x00000000 ||
1956 *l == 0x0000ffff || *l == 0xffff0000)
1957 return false;
1958
1959 if (pci_bus_crs_vendor_id(*l))
1960 return pci_bus_wait_crs(bus, devfn, l, timeout);
1961
1906 return true; 1962 return true;
1907} 1963}
1908EXPORT_SYMBOL(pci_bus_read_dev_vendor_id); 1964EXPORT_SYMBOL(pci_bus_read_dev_vendor_id);
@@ -2331,6 +2387,15 @@ void pcie_bus_configure_settings(struct pci_bus *bus)
2331} 2387}
2332EXPORT_SYMBOL_GPL(pcie_bus_configure_settings); 2388EXPORT_SYMBOL_GPL(pcie_bus_configure_settings);
2333 2389
2390/*
2391 * Called after each bus is probed, but before its children are examined. This
2392 * is marked as __weak because multiple architectures define it.
2393 */
2394void __weak pcibios_fixup_bus(struct pci_bus *bus)
2395{
2396 /* nothing to do, expected to be removed in the future */
2397}
2398
2334unsigned int pci_scan_child_bus(struct pci_bus *bus) 2399unsigned int pci_scan_child_bus(struct pci_bus *bus)
2335{ 2400{
2336 unsigned int devfn, pass, max = bus->busn_res.start; 2401 unsigned int devfn, pass, max = bus->busn_res.start;