aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/pci.c
diff options
context:
space:
mode:
authorYijing Wang <wangyijing@huawei.com>2013-01-14 22:12:16 -0500
committerBjorn Helgaas <bhelgaas@google.com>2013-01-24 13:42:14 -0500
commitb0cc6020e1cc62f1253215f189611b34be4a83c7 (patch)
treefd798c95fe1ebe506dc2a3d2e7576777393408e6 /drivers/pci/pci.c
parentd1c3ed669a2d452cacfb48c2d171a1f364dae2ed (diff)
PCI: Enable ARI if dev and upstream bridge support it; disable otherwise
Currently, we enable ARI in a device's upstream bridge if the bridge and the device support it. But we never disable ARI, even if the device is removed and replaced with a device that doesn't support ARI. This means that if we hot-remove an ARI device and replace it with a non-ARI multi-function device, we find only function 0 of the new device because the upstream bridge still has ARI enabled, and next_ari_fn() only returns function 0 for the new non-ARI device. This patch disables ARI in the upstream bridge if the device doesn't support ARI. See the PCIe spec, r3.0, sec 6.13. [bhelgaas: changelog, function comment] Signed-off-by: Yijing Wang <wangyijing@huawei.com> Signed-off-by: Jiang Liu <jiang.liu@huawei.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci/pci.c')
-rw-r--r--drivers/pci/pci.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 5cb5820fae40..8b47f70b7d8f 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -2069,6 +2069,9 @@ void pci_free_cap_save_buffers(struct pci_dev *dev)
2069/** 2069/**
2070 * pci_enable_ari - enable ARI forwarding if hardware support it 2070 * pci_enable_ari - enable ARI forwarding if hardware support it
2071 * @dev: the PCI device 2071 * @dev: the PCI device
2072 *
2073 * If @dev and its upstream bridge both support ARI, enable ARI in the
2074 * bridge. Otherwise, disable ARI in the bridge.
2072 */ 2075 */
2073void pci_enable_ari(struct pci_dev *dev) 2076void pci_enable_ari(struct pci_dev *dev)
2074{ 2077{
@@ -2078,9 +2081,6 @@ void pci_enable_ari(struct pci_dev *dev)
2078 if (pcie_ari_disabled || !pci_is_pcie(dev) || dev->devfn) 2081 if (pcie_ari_disabled || !pci_is_pcie(dev) || dev->devfn)
2079 return; 2082 return;
2080 2083
2081 if (!pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ARI))
2082 return;
2083
2084 bridge = dev->bus->self; 2084 bridge = dev->bus->self;
2085 if (!bridge) 2085 if (!bridge)
2086 return; 2086 return;
@@ -2089,8 +2089,15 @@ void pci_enable_ari(struct pci_dev *dev)
2089 if (!(cap & PCI_EXP_DEVCAP2_ARI)) 2089 if (!(cap & PCI_EXP_DEVCAP2_ARI))
2090 return; 2090 return;
2091 2091
2092 pcie_capability_set_word(bridge, PCI_EXP_DEVCTL2, PCI_EXP_DEVCTL2_ARI); 2092 if (pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ARI)) {
2093 bridge->ari_enabled = 1; 2093 pcie_capability_set_word(bridge, PCI_EXP_DEVCTL2,
2094 PCI_EXP_DEVCTL2_ARI);
2095 bridge->ari_enabled = 1;
2096 } else {
2097 pcie_capability_clear_word(bridge, PCI_EXP_DEVCTL2,
2098 PCI_EXP_DEVCTL2_ARI);
2099 bridge->ari_enabled = 0;
2100 }
2094} 2101}
2095 2102
2096/** 2103/**