Skip to content

Commit bfcb15e

Browse files
Stela contributorclaude
andcommitted
fix(amd): a Radeon without a function reset is left for amdgpu to reset, not bus-reset
The first VM trial with the Radeon lent reached the cold handoff, which reset the card's bus: "PCI link did not come back after its bus reset". A Navi 48 does not survive a Secondary Bus Reset in passthrough, and amdgpu never asks for one: it resets the ASIC through its PSP (mode 1) when it finds firmware left running. A Radeon with no function-local reset now starts unreset, as under Linux; the card went back to amdgpu on the host after the trial. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 373419d commit bfcb15e

2 files changed

Lines changed: 69 additions & 0 deletions

File tree

‎crates/stela-driver-gpu/src/cold.rs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,11 @@ fn preflight<C: ConfigSpace>(
192192
if !matches!(function.vendor, NVIDIA | AMD) || function.class[0] != DISPLAY {
193193
return Err(Error::Identity);
194194
}
195+
// AMD fork: a Navi 48 lent to a VM did not bring its link back after a
196+
// Secondary Bus Reset (the Radeon reset bug). A Radeon is never reset
197+
// through its bus: amdgpu resets it itself (PSP mode 1) as it starts,
198+
// and without a function reset it starts as left, with translation.
199+
let bus_reset = bus_reset && function.vendor != AMD;
195200
requester::validate_stopped(function).map_err(Error::Claim)?;
196201
let mut express = None;
197202
for entry in capability::capabilities(function.config()) {
@@ -211,6 +216,12 @@ fn preflight<C: ConfigSpace>(
211216
// on.
212217
match function.reset_method().map_err(Error::Reset)? {
213218
Some(method) => Ok(Some(Reset::Function(method))),
219+
// AMD fork (J6): a Radeon without a function-local reset is not
220+
// reset through its bus, which a Navi 48 does not come back from
221+
// (its link stays down, as the first VM trial saw). amdgpu resets
222+
// it itself, through its PSP (mode 1), when it finds the firmware
223+
// an earlier driver left running, as it does under Linux.
224+
None if function.vendor == AMD => Ok(None),
214225
None if bus_reset => Ok(Some(Reset::SecondaryBus)),
215226
None if translated => Ok(None),
216227
None => Err(Error::ResetUnavailable),

‎crates/stela-driver-gpu/src/cold/tests.rs‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,64 @@ fn a_radeon_takes_the_same_cold_handoff() {
272272
drop(failure(Cold::new(inputs).quiesce_and_bind()));
273273
assert!(state.borrow().events.is_empty());
274274
}
275+
/// AMD fork (J6): a Radeon without a function-local reset starts unreset,
276+
/// even untranslated with a bus reset on offer: amdgpu resets it itself.
277+
#[test]
278+
fn a_radeon_without_a_function_reset_is_left_to_amdgpu() {
279+
let (mut inputs, state) = inputs_for(0x7550_1002);
280+
{
281+
let words = &mut inputs.requester.function.config().words;
282+
words[0x44 / 4] = 0;
283+
words[0x84 / 4] = 8;
284+
}
285+
state.borrow_mut().bus_reset = true;
286+
let candidate = check_candidate(
287+
&mut inputs.requester.function,
288+
&PhysicalTimer(state.clone()),
289+
false,
290+
true,
291+
);
292+
assert_eq!(candidate, Ok(None));
293+
let ready = Cold::new(inputs)
294+
.quiesce_and_bind()
295+
.unwrap_or_else(|error| panic!("{:?}", error.error));
296+
assert_eq!(ready.reset(), None);
297+
assert_eq!(state.borrow().events, ["views-seal", "root-drain", "bind"]);
298+
}
299+
/// AMD fork: a Radeon without a function reset is never reset through its
300+
/// bus; translated, it starts as left, and untranslated it is refused.
301+
#[test]
302+
fn a_radeon_is_never_reset_through_its_bus() {
303+
for translated in [true, false] {
304+
let (mut inputs, state) = inputs_for(0x7550_1002);
305+
{
306+
let words = &mut inputs.requester.function.config().words;
307+
words[0x44 / 4] = 0;
308+
words[0x84 / 4] = 8;
309+
}
310+
state.borrow_mut().bus_reset = true;
311+
let candidate = check_candidate(
312+
&mut inputs.requester.function,
313+
&PhysicalTimer(state.clone()),
314+
translated,
315+
true,
316+
);
317+
if !translated {
318+
assert_eq!(candidate, Err(Error::ResetUnavailable));
319+
continue;
320+
}
321+
assert_eq!(candidate, Ok(None));
322+
// SAFETY: the symbolic domain stands for a translating one.
323+
let ready = unsafe { Cold::new(inputs).translated() }
324+
.quiesce_and_bind()
325+
.unwrap_or_else(|error| panic!("{:?}", error.error));
326+
assert_eq!(ready.reset(), None);
327+
assert_eq!(
328+
state.borrow().events,
329+
["views-seal", "root-drain", "bind"]
330+
);
331+
}
332+
}
275333
#[test]
276334
fn preflight_never_seals_or_resets_an_unsupported_or_foreign_source() {
277335
for case in 0..4 {

0 commit comments

Comments
 (0)