phb4: Retrain link if degraded
phb4: Retrain link if degraded

On P9 Scale Out (Nimbus) DD2.0 and Scale in (Cumulus) DD1.0 (and
below) the PCIe PHY can lockup causing training issues. This can cause
a degradation in speed or width in ~5% of training cases (depending on
the card). This is fixed in later chip revisions. This issue can also
cause PCIe links to not train at all, but this case is already
handled.

This patch checks if the PCIe link has trained optimally and if not,
does a full PHB reset (to fix the PHY lockup) and retrain.

One complication is some devices are known to train degraded unless
device specific configuration is performed. Because of this, we only
retrain when the device is in a whitelist. All devices in the current
whitelist have been testing on a P9DSU/Boston, ZZ and Witherspoon.

We always gather information on the link and print it in the logs even
if the card is not in the whitelist.

For testing purposes, there's an nvram to retry all PCIe cards and all
P9 chips when a degraded link is detected. The new option is
'pci-retry-all=true' which can be set using:
  nvram -p ibm,skiboot --update-config pci-retry-all=true
This option may increase the boot time if used on a badly behaving
card.

Signed-off-by: Michael Neuling <7b0ab45a730e48a69239010b5b8fe5fa4e8eaac6@neuling.org>
[ec31ab75ddf977353c8f660f92ea8b23f64aef25@linux.vnet.ibm.com: fix Cumulus VERS_MAJ r.e. Mikey mail]
Signed-off-by: Stewart Smith <ec31ab75ddf977353c8f660f92ea8b23f64aef25@linux.vnet.ibm.com>

open-power/skiboot,qemu/skiboot,shenki/skiboot,stewart-ibm/skiboot,shenki/skiboot,qemu/skiboot,qemu/skiboot,shenki/skiboot,legoater/skiboot,open-power/skiboot,legoater/skiboot,open-power/skiboot,stewart-ibm/skiboot,shenki/skiboot,legoater/skiboot,open-power/skiboot,qemu/skiboot,stewart-ibm/skiboot,shenki/skiboot,qemu/skiboot,open-power/skiboot,legoater/skiboot,legoater/skiboot