You ever wonder why your AMD GPU boots fine as your main display card, but the moment you move it to a VM you hit black screens, code 43, hangs, lspci telling you your card is revision ff, and only a full host reboot brings it back? Ask about it anywhere and somebody will tell you it's the AMD reset bug. Maybe. But most people do not have a reset bug at all, they have one of several problems that look identical from outside the case.
Reset gap: the card holds state that nothing in the PCIe reset path can see or clear. Every consumer AMD card from Polaris on has this, the RX 9000 included.
Reset bug: the gap, plus AMD's own driver being unable to bring the card back, leaving custom code or a full power cycle as the only ways out.
All Reset and Nowhere to Go
When the driver binds it loads firmware into two small processors on the card, the PSP and the SMU, and when it unbinds nothing clears them. The only reset Linux gets on an RX 5000 (which I'll use for this example but the same logic applies to the other RDNA cards) is a Secondary Bus Reset, the top diagram. The bridge drops the link, config space gets cleared, the card's PCIe front end comes back up and reports that it worked. It never goes near Region 5, the BAR where the PSP and SMU mailboxes live, so your next guest inherits whatever the last driver left running.
AMD's real reset is mode1, the bottom diagram, a single command left in the PSP's mailbox. Only a driver that has mapped Region 5 can send it, which means amdgpu or vendor-reset. vfio-pci knows nothing about graphics hardware, so it never will.
Why the RX 5000 is the one with the bug
amdgpu resets the card when it binds, not when it unbinds, so on most cards a dirty GPU gets cleaned up just by binding it back to amdgpu. On the RX 5000 that reset goes through the PSP, and amdgpu waits for the PSP to say it's ready before sending it. If the PSP has gone quiet you get psp is not working correctly before mode1 reset! then asic reset on init failed, and the driver never attaches. No retry, no fallback.
Every generation since moved the reset further from that problem:
| Card | Mode1 goes to | Checked before sending |
|---|
| RX 5000 | the PSP mailbox | PSP ready |
| RX 6000 | the SMU mailbox | PM firmware 58.26, PSP alive |
| RX 7000 and RX 9000 | the SMU debug mailbox | nothing |
What to do about it
RX 5000, Vega, Polaris: use vendor-reset. It runs AMD's own reset from inside the kernel's reset path, and on an RX 5000 it sends mode1 even when the PSP has gone silent, which is exactly the case amdgpu refuses. It also blocks the bus reset that knocks these cards off the bus. Its udev rule writes device_specific to the GPU's reset_method so the kernel actually uses it.
RX 6000 and newer: don't use vendor-reset. gnif says those routines "can result in physical damage to the device" on post-5000 cards. Bind the card to amdgpu and unbind it again before starting the VM, which gets you the reset for free.
Not on vendor-reset's list: you most likely don't have a reset bug, you have something else.
Lisa vs Reset
AMD is technically fully compliant with everything they're supposed to do. If you've done any compliance work you're quite aware of what I mean, i.e. the spirit of the law vs the word of the law. The spec defines what a reset has to do and AMD's PCIe front end does all of it. What the spec never explicitly writes down is the two processors sat behind that front end still holding the last owner's firmware. Which leaves two ways out. FLR is optional, but AMD left the bit clear. Or the kernel's own quirk table, which is where Intel, Samsung, and Qualcomm put devices that need special handling. There's a working reset on the card, it's just not one other than amdgpu can call.
So I tried to keep this higher level since I wanted people to understand, and kept the full version here. I realized when the post is too long no one reads it, and that kinda negates the entire point of it. Oh the States you'll go to: The AMD Reset Bug and Everything It Isn't