mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-09 06:33:34 +00:00
Merge branch 'pci/enumeration'
- Clear LBMS bit after a manual link retrain so we don't try to retrain a link when there's no downstream device anymore (Maciej W. Rozycki) - Revert to the original link speed after retraining fails instead of leaving it restricted to 2.5GT/s, so a future device has a chance to use higher speeds (Maciej W. Rozycki) - Correct interpretation of pcie_retrain_link() return status and update it to return 0/errno instead of true/false (Maciej W. Rozycki) * pci/enumeration: PCI: Use an error code with PCIe failed link retraining PCI: Correct error reporting with PCIe failed link retraining PCI: Revert to the original speed after PCIe failed link retraining PCI: Clear the LBMS bit after a link retrain
This commit is contained in:
commit
dffe4cca2e
@ -1339,7 +1339,7 @@ static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout)
|
||||
if (delay > PCI_RESET_WAIT) {
|
||||
if (retrain) {
|
||||
retrain = false;
|
||||
if (pcie_failed_link_retrain(bridge)) {
|
||||
if (pcie_failed_link_retrain(bridge) == 0) {
|
||||
delay = 1;
|
||||
continue;
|
||||
}
|
||||
@ -4732,7 +4732,15 @@ int pcie_retrain_link(struct pci_dev *pdev, bool use_lt)
|
||||
pcie_capability_clear_word(pdev, PCI_EXP_LNKCTL, PCI_EXP_LNKCTL_RL);
|
||||
}
|
||||
|
||||
return pcie_wait_for_link_status(pdev, use_lt, !use_lt);
|
||||
rc = pcie_wait_for_link_status(pdev, use_lt, !use_lt);
|
||||
|
||||
/*
|
||||
* Clear LBMS after a manual retrain so that the bit can be used
|
||||
* to track link speed or width changes made by hardware itself
|
||||
* in attempt to correct unreliable link operation.
|
||||
*/
|
||||
pcie_capability_write_word(pdev, PCI_EXP_LNKSTA, PCI_EXP_LNKSTA_LBMS);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -611,7 +611,7 @@ void pci_acs_init(struct pci_dev *dev);
|
||||
int pci_dev_specific_acs_enabled(struct pci_dev *dev, u16 acs_flags);
|
||||
int pci_dev_specific_enable_acs(struct pci_dev *dev);
|
||||
int pci_dev_specific_disable_acs_redir(struct pci_dev *dev);
|
||||
bool pcie_failed_link_retrain(struct pci_dev *dev);
|
||||
int pcie_failed_link_retrain(struct pci_dev *dev);
|
||||
#else
|
||||
static inline int pci_dev_specific_acs_enabled(struct pci_dev *dev,
|
||||
u16 acs_flags)
|
||||
@ -626,9 +626,9 @@ static inline int pci_dev_specific_disable_acs_redir(struct pci_dev *dev)
|
||||
{
|
||||
return -ENOTTY;
|
||||
}
|
||||
static inline bool pcie_failed_link_retrain(struct pci_dev *dev)
|
||||
static inline int pcie_failed_link_retrain(struct pci_dev *dev)
|
||||
{
|
||||
return false;
|
||||
return -ENOTTY;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -66,7 +66,7 @@
|
||||
* apply this erratum workaround to any downstream ports as long as they
|
||||
* support Link Active reporting and have the Link Control 2 register.
|
||||
* Restrict the speed to 2.5GT/s then with the Target Link Speed field,
|
||||
* request a retrain and wait 200ms for the data link to go up.
|
||||
* request a retrain and check the result.
|
||||
*
|
||||
* If this turns out successful and we know by the Vendor:Device ID it is
|
||||
* safe to do so, then lift the restriction, letting the devices negotiate
|
||||
@ -74,33 +74,45 @@
|
||||
* firmware may have already arranged and lift it with ports that already
|
||||
* report their data link being up.
|
||||
*
|
||||
* Return TRUE if the link has been successfully retrained, otherwise FALSE.
|
||||
* Otherwise revert the speed to the original setting and request a retrain
|
||||
* again to remove any residual state, ignoring the result as it's supposed
|
||||
* to fail anyway.
|
||||
*
|
||||
* Return 0 if the link has been successfully retrained. Return an error
|
||||
* if retraining was not needed or we attempted a retrain and it failed.
|
||||
*/
|
||||
bool pcie_failed_link_retrain(struct pci_dev *dev)
|
||||
int pcie_failed_link_retrain(struct pci_dev *dev)
|
||||
{
|
||||
static const struct pci_device_id ids[] = {
|
||||
{ PCI_VDEVICE(ASMEDIA, 0x2824) }, /* ASMedia ASM2824 */
|
||||
{}
|
||||
};
|
||||
u16 lnksta, lnkctl2;
|
||||
int ret = -ENOTTY;
|
||||
|
||||
if (!pci_is_pcie(dev) || !pcie_downstream_port(dev) ||
|
||||
!pcie_cap_has_lnkctl2(dev) || !dev->link_active_reporting)
|
||||
return false;
|
||||
return ret;
|
||||
|
||||
pcie_capability_read_word(dev, PCI_EXP_LNKCTL2, &lnkctl2);
|
||||
pcie_capability_read_word(dev, PCI_EXP_LNKSTA, &lnksta);
|
||||
if ((lnksta & (PCI_EXP_LNKSTA_LBMS | PCI_EXP_LNKSTA_DLLLA)) ==
|
||||
PCI_EXP_LNKSTA_LBMS) {
|
||||
u16 oldlnkctl2 = lnkctl2;
|
||||
|
||||
pci_info(dev, "broken device, retraining non-functional downstream link at 2.5GT/s\n");
|
||||
|
||||
lnkctl2 &= ~PCI_EXP_LNKCTL2_TLS;
|
||||
lnkctl2 |= PCI_EXP_LNKCTL2_TLS_2_5GT;
|
||||
pcie_capability_write_word(dev, PCI_EXP_LNKCTL2, lnkctl2);
|
||||
|
||||
if (pcie_retrain_link(dev, false)) {
|
||||
ret = pcie_retrain_link(dev, false);
|
||||
if (ret) {
|
||||
pci_info(dev, "retraining failed\n");
|
||||
return false;
|
||||
pcie_capability_write_word(dev, PCI_EXP_LNKCTL2,
|
||||
oldlnkctl2);
|
||||
pcie_retrain_link(dev, true);
|
||||
return ret;
|
||||
}
|
||||
|
||||
pcie_capability_read_word(dev, PCI_EXP_LNKSTA, &lnksta);
|
||||
@ -117,13 +129,14 @@ bool pcie_failed_link_retrain(struct pci_dev *dev)
|
||||
lnkctl2 |= lnkcap & PCI_EXP_LNKCAP_SLS;
|
||||
pcie_capability_write_word(dev, PCI_EXP_LNKCTL2, lnkctl2);
|
||||
|
||||
if (pcie_retrain_link(dev, false)) {
|
||||
ret = pcie_retrain_link(dev, false);
|
||||
if (ret) {
|
||||
pci_info(dev, "retraining failed\n");
|
||||
return false;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ktime_t fixup_debug_start(struct pci_dev *dev,
|
||||
|
Loading…
Reference in New Issue
Block a user