fix(pcie): compare retrain verdict against peer-capped max speed

The downstream-capability adjustment lowered f.MaxSpeed/f.MaxWidth to the
rate the endpoint supports, but the Degraded verdict still compared the
retrained speed against the stale local maxSpeed holding the bridge's own
uncapped capability. A Gen5 root port feeding a Gen4 HBA (or a Gen2 NIC)
was flagged DEGRADED even though the link ran at the fastest rate the pair
supports, failing the PCIe link check on healthy hardware.

Keep the local maxSpeed in sync with the peer-capped f.MaxSpeed so both
the pre-retrain and post-retrain verdicts use the real target.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mx6AvuXcJNT7jx3jjWw4hc
This commit is contained in:
Mikhail Chusavitin
2026-08-28 11:30:57 +03:00
co-authored by Claude Sonnet 5
parent c5c7a2dea3
commit 366c1d5f29
@@ -169,6 +169,12 @@ func retrainAndSamplePCIeDevice(ctx context.Context, verboseLog, bdf string, log
f.PortMaxWidth = f.MaxWidth f.PortMaxWidth = f.MaxWidth
f.MaxSpeed = minPCIeLinkSpeed(f.MaxSpeed, peerSpeed) f.MaxSpeed = minPCIeLinkSpeed(f.MaxSpeed, peerSpeed)
f.MaxWidth = minPositiveInt(f.MaxWidth, peerWidth) f.MaxWidth = minPositiveInt(f.MaxWidth, peerWidth)
// The degradation verdict below compares against maxSpeed, so
// it has to track the peer-capped target too — otherwise a
// bridge whose port out-specs its downstream device (e.g. a
// Gen5 root port feeding a Gen4 HBA) is flagged DEGRADED even
// though the link is at the fastest rate the pair supports.
maxSpeed = f.MaxSpeed
} }
} }