fix(reset): coordinate V80 SBR with PCIe hotplug - #203
Draft
amd-vserbu wants to merge 1 commit into
Draft
Conversation
Signed-off-by: Vlad-Gabriel Serbu <Vlad-Gabriel.Serbu@amd.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Make a V80 secondary-bus reset one serialized operation that suppresses reset-induced PCIe hotplug events, waits for PDI reload and stable link training, and returns control only when userspace can safely rescan and reopen all three functions.
Reset race
A V80 SBR triggers a full PDI reload rather than only retraining an ordinary endpoint link. The existing path releases PCI topology serialization before reset and relies on fixed sleeps. During that interval, pciehp can interpret the expected link transitions as physical removal events, while userspace may rescan before PF0, PF1, PF2, their drivers, and udev permissions are ready.
The reset contract also permits callers to leave functions on the secondary bus, which makes it possible to reset underneath live driver state.
Changes
The hotplug ioctl now requires an empty secondary bus and holds
pci_lock_rescan_remove()through reset and link recovery. On a hotplug-capable bridge it temporarily sets the legacyignore_hotplugflag, performspci_bridge_secondary_bus_reset(), allows five seconds for the V80 PDI reload, and then requires DLL Link Active to remain asserted across two 100 ms polls. The ioctl times out after a further 25 seconds and restores the previous hotplug state on every exit path.Holding the global PCI rescan/remove lock can block unrelated PCI topology changes for up to 30 seconds. This is deliberate: the V80 must remain one atomic topology transition, and supported kernels do not export the newer PCI hotplug coordination helper to this out-of-tree module.
After the ioctl succeeds, vrtd rescans immediately instead of adding another fixed post-SBR sleep. It polls every 100 ms for PF0 AMI readiness and accessible PF1 QDMA and PF2 control nodes, retaining the AMI handle while udev finishes the remaining nodes. A rescan that does not produce all three functions within ten seconds is retried up to five times.
Draft
Needs rebase and testing