diff options
-rw-r--r-- | drivers/pci/pci.c | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 7aa11b1fbee3..9493b97436c3 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -126,6 +126,9 @@ static int __init pcie_port_pm_setup(char *str) | |||
126 | } | 126 | } |
127 | __setup("pcie_port_pm=", pcie_port_pm_setup); | 127 | __setup("pcie_port_pm=", pcie_port_pm_setup); |
128 | 128 | ||
129 | /* Time to wait after a reset for device to become responsive */ | ||
130 | #define PCIE_RESET_READY_POLL_MS 60000 | ||
131 | |||
129 | /** | 132 | /** |
130 | * pci_bus_max_busnr - returns maximum PCI bus number of given bus' children | 133 | * pci_bus_max_busnr - returns maximum PCI bus number of given bus' children |
131 | * @bus: pointer to PCI bus structure to search | 134 | * @bus: pointer to PCI bus structure to search |
@@ -4017,20 +4020,13 @@ int pci_wait_for_pending_transaction(struct pci_dev *dev) | |||
4017 | } | 4020 | } |
4018 | EXPORT_SYMBOL(pci_wait_for_pending_transaction); | 4021 | EXPORT_SYMBOL(pci_wait_for_pending_transaction); |
4019 | 4022 | ||
4020 | static int pci_flr_wait(struct pci_dev *dev) | 4023 | static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout) |
4021 | { | 4024 | { |
4022 | int delay = 1, timeout = 60000; | 4025 | int delay = 1; |
4023 | u32 id; | 4026 | u32 id; |
4024 | 4027 | ||
4025 | /* | 4028 | /* |
4026 | * Per PCIe r3.1, sec 6.6.2, a device must complete an FLR within | 4029 | * After reset, the device should not silently discard config |
4027 | * 100ms, but may silently discard requests while the FLR is in | ||
4028 | * progress. Wait 100ms before trying to access the device. | ||
4029 | */ | ||
4030 | msleep(100); | ||
4031 | |||
4032 | /* | ||
4033 | * After 100ms, the device should not silently discard config | ||
4034 | * requests, but it may still indicate that it needs more time by | 4030 | * requests, but it may still indicate that it needs more time by |
4035 | * responding to them with CRS completions. The Root Port will | 4031 | * responding to them with CRS completions. The Root Port will |
4036 | * generally synthesize ~0 data to complete the read (except when | 4032 | * generally synthesize ~0 data to complete the read (except when |
@@ -4044,14 +4040,14 @@ static int pci_flr_wait(struct pci_dev *dev) | |||
4044 | pci_read_config_dword(dev, PCI_COMMAND, &id); | 4040 | pci_read_config_dword(dev, PCI_COMMAND, &id); |
4045 | while (id == ~0) { | 4041 | while (id == ~0) { |
4046 | if (delay > timeout) { | 4042 | if (delay > timeout) { |
4047 | pci_warn(dev, "not ready %dms after FLR; giving up\n", | 4043 | pci_warn(dev, "not ready %dms after %s; giving up\n", |
4048 | 100 + delay - 1); | 4044 | delay - 1, reset_type); |
4049 | return -ENOTTY; | 4045 | return -ENOTTY; |
4050 | } | 4046 | } |
4051 | 4047 | ||
4052 | if (delay > 1000) | 4048 | if (delay > 1000) |
4053 | pci_info(dev, "not ready %dms after FLR; waiting\n", | 4049 | pci_info(dev, "not ready %dms after %s; waiting\n", |
4054 | 100 + delay - 1); | 4050 | delay - 1, reset_type); |
4055 | 4051 | ||
4056 | msleep(delay); | 4052 | msleep(delay); |
4057 | delay *= 2; | 4053 | delay *= 2; |
@@ -4059,7 +4055,8 @@ static int pci_flr_wait(struct pci_dev *dev) | |||
4059 | } | 4055 | } |
4060 | 4056 | ||
4061 | if (delay > 1000) | 4057 | if (delay > 1000) |
4062 | pci_info(dev, "ready %dms after FLR\n", 100 + delay - 1); | 4058 | pci_info(dev, "ready %dms after %s\n", delay - 1, |
4059 | reset_type); | ||
4063 | 4060 | ||
4064 | return 0; | 4061 | return 0; |
4065 | } | 4062 | } |
@@ -4096,7 +4093,15 @@ int pcie_flr(struct pci_dev *dev) | |||
4096 | pci_err(dev, "timed out waiting for pending transaction; performing function level reset anyway\n"); | 4093 | pci_err(dev, "timed out waiting for pending transaction; performing function level reset anyway\n"); |
4097 | 4094 | ||
4098 | pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_BCR_FLR); | 4095 | pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_BCR_FLR); |
4099 | return pci_flr_wait(dev); | 4096 | |
4097 | /* | ||
4098 | * Per PCIe r4.0, sec 6.6.2, a device must complete an FLR within | ||
4099 | * 100ms, but may silently discard requests while the FLR is in | ||
4100 | * progress. Wait 100ms before trying to access the device. | ||
4101 | */ | ||
4102 | msleep(100); | ||
4103 | |||
4104 | return pci_dev_wait(dev, "FLR", PCIE_RESET_READY_POLL_MS); | ||
4100 | } | 4105 | } |
4101 | EXPORT_SYMBOL_GPL(pcie_flr); | 4106 | EXPORT_SYMBOL_GPL(pcie_flr); |
4102 | 4107 | ||
@@ -4129,7 +4134,16 @@ static int pci_af_flr(struct pci_dev *dev, int probe) | |||
4129 | pci_err(dev, "timed out waiting for pending transaction; performing AF function level reset anyway\n"); | 4134 | pci_err(dev, "timed out waiting for pending transaction; performing AF function level reset anyway\n"); |
4130 | 4135 | ||
4131 | pci_write_config_byte(dev, pos + PCI_AF_CTRL, PCI_AF_CTRL_FLR); | 4136 | pci_write_config_byte(dev, pos + PCI_AF_CTRL, PCI_AF_CTRL_FLR); |
4132 | return pci_flr_wait(dev); | 4137 | |
4138 | /* | ||
4139 | * Per Advanced Capabilities for Conventional PCI ECN, 13 April 2006, | ||
4140 | * updated 27 July 2006; a device must complete an FLR within | ||
4141 | * 100ms, but may silently discard requests while the FLR is in | ||
4142 | * progress. Wait 100ms before trying to access the device. | ||
4143 | */ | ||
4144 | msleep(100); | ||
4145 | |||
4146 | return pci_dev_wait(dev, "AF_FLR", PCIE_RESET_READY_POLL_MS); | ||
4133 | } | 4147 | } |
4134 | 4148 | ||
4135 | /** | 4149 | /** |