mirror of
https://github.com/QuixiAI/nvdriver.git
synced 2026-12-06 06:28:39 +00:00
* gv100: fall back to PMU VBIOS power telemetry when baseboard INA3221 is absent (#484) * gv100: gate automatic VBIOS capture on stopped/halted PMU CPUCTL * gv100: log when PMU power fallback is skipped due to unavailable VBIOS capture --------- Co-authored-by: Eric Hartford <eric@quixi.ai>
This commit is contained in:
@ -365,7 +365,7 @@ u32 nv_rs_v100_p0_volt_uv(void) {
|
||||
* observed on one card, not yet REA-confirmed. */
|
||||
static bool v100_pmu_power = false;
|
||||
module_param(v100_pmu_power, bool, 0444);
|
||||
MODULE_PARM_DESC(v100_pmu_power, "GV100: build the PMU PERF/PMGR groups from the VBIOS for live board power and power capping (#136; default: 0)");
|
||||
MODULE_PARM_DESC(v100_pmu_power, "GV100: force PMU PERF/PMGR groups from VBIOS for live board power even when INA3221 is present (#136/#484; automatic fallback when INA3221 is absent)");
|
||||
bool nv_rs_v100_pmu_power(void) { return v100_pmu_power; }
|
||||
void nv_rs_pmu_power_log(u32 gpu_id, u32 stage, u32 a, u32 b, u32 c)
|
||||
{
|
||||
|
||||
@ -2029,20 +2029,26 @@ fn init_locked(registers: &mut LockedGpuRegisters, parts: &mut Parts<'_>) -> boo
|
||||
// Nothing reads the state before this.
|
||||
unsafe { Persist::initialise(persist.as_ptr(), 0) };
|
||||
let mut io = PmuIo { registers, parts };
|
||||
// #136 (`v100_pmu_power`): capture the VBIOS now, while the PMU is stopped (reading the
|
||||
// PROM while it runs halted it on its next command, VFIO VM).
|
||||
// #136 / #484: capture the GV100 VBIOS now, while the PMU is confirmed stopped/halted
|
||||
// (reading the PROM while a PMU is running halts it on its next command, VFIO VM).
|
||||
// Used when `v100_pmu_power=1` or automatically as fallback when baseboard INA3221 is
|
||||
// absent; dropped immediately after `runtime_ina3221_init` when not needed.
|
||||
#[cfg(not(nv_rs_edu_guest))]
|
||||
if unsafe { nv_rs_v100_pmu_power() } {
|
||||
let captured = pmu_vbios_capture(&mut io);
|
||||
// Stage 1: VBIOS capture failed (error code, see `pmu_vbios_capture`); 2 = not a
|
||||
// GV100, which is expected and not logged.
|
||||
if let Err(e) = captured.as_ref() {
|
||||
if *e != 2 {
|
||||
let gpu_id = unsafe { nv_rs_pci_gpu_id(io.registers.pci_token()) };
|
||||
unsafe { nv_rs_pmu_power_log(gpu_id, 1, *e, 0, 0) };
|
||||
{
|
||||
let cpuctl = io.registers.read32(0x0010_a100).unwrap_or(0);
|
||||
let pmu_stopped = cpuctl == 0 || (cpuctl & 0x10) != 0;
|
||||
if unsafe { nv_rs_v100_pmu_power() } || pmu_stopped {
|
||||
let captured = pmu_vbios_capture(&mut io);
|
||||
// Stage 1: VBIOS capture failed (error code, see `pmu_vbios_capture`); 2 = not a
|
||||
// GV100, which is expected and not logged.
|
||||
if let Err(e) = captured.as_ref() {
|
||||
if *e != 2 {
|
||||
let gpu_id = unsafe { nv_rs_pci_gpu_id(io.registers.pci_token()) };
|
||||
unsafe { nv_rs_pmu_power_log(gpu_id, 1, *e, 0, 0) };
|
||||
}
|
||||
}
|
||||
*field!(io, pmu_vbios) = captured.ok();
|
||||
}
|
||||
*field!(io, pmu_vbios) = captured.ok();
|
||||
}
|
||||
// KernelFifo+170 (core `gr_fecs_start::subcontext_count`): the original
|
||||
// reads it once, before the FIFO load, and keeps the value.
|
||||
@ -2657,10 +2663,15 @@ impl gr_bringup::WhileLoaded for Start<'_, '_> {
|
||||
// 3) Probe live hardware board power via GV100 PMGR HW I2C INA3221
|
||||
// (scan active pull-up ports 0 & 2, 7-bit addrs 0x40..=0x43).
|
||||
let ina3221_loc = runtime_ina3221_init(io.registers);
|
||||
// #136: PMU-owned board power (opt-in, `v100_pmu_power`).
|
||||
// #136 / #484: PMU-owned board power — runs when opted in via
|
||||
// `v100_pmu_power=1` or automatically as fallback when no
|
||||
// baseboard INA3221 shunt is present (e.g. V100-SXM2 on PCIe
|
||||
// carrier or V100-PCIe-32GB).
|
||||
#[cfg(not(nv_rs_edu_guest))]
|
||||
if unsafe { nv_rs_v100_pmu_power() } {
|
||||
if unsafe { nv_rs_v100_pmu_power() } || ina3221_loc.is_none() {
|
||||
runtime_pmu_power_bringup(&mut io);
|
||||
} else {
|
||||
drop(field!(io, pmu_vbios).take());
|
||||
}
|
||||
// The cap is driver policy; when it lowers the operator's
|
||||
// request and the capped clock is in effect, say so next to
|
||||
@ -2753,9 +2764,18 @@ impl gr_bringup::WhileLoaded for Start<'_, '_> {
|
||||
&init_ecc,
|
||||
);
|
||||
}
|
||||
let init_power_mw = ina3221_loc.and_then(|(port, addr)| {
|
||||
runtime_ina3221_poll(io.registers, port, addr)
|
||||
});
|
||||
let init_power_mw = ina3221_loc
|
||||
.and_then(|(port, addr)| {
|
||||
runtime_ina3221_poll(io.registers, port, addr)
|
||||
})
|
||||
.or_else(|| {
|
||||
#[cfg(not(nv_rs_edu_guest))]
|
||||
{
|
||||
pmu_power_read(&mut io)
|
||||
}
|
||||
#[cfg(nv_rs_edu_guest)]
|
||||
None
|
||||
});
|
||||
unsafe {
|
||||
crate::rmapi_node::update_live_telemetry(
|
||||
io.registers.pci_token(),
|
||||
@ -4130,6 +4150,9 @@ fn runtime_pmu_power_bringup(io: &mut PmuIo<'_, '_>) {
|
||||
let gpu_id = unsafe { nv_rs_pci_gpu_id(io.registers.pci_token()) };
|
||||
// Taken here, so the image is freed when this returns.
|
||||
let Some(captured) = field!(io, pmu_vbios).take() else {
|
||||
// Stage 1, code 8: VBIOS capture was skipped (e.g. PMU already running at init_locked)
|
||||
// or failed earlier; PMU power fallback cannot upload VBIOS tables.
|
||||
unsafe { nv_rs_pmu_power_log(gpu_id, 1, 8, 0, 0) };
|
||||
return;
|
||||
};
|
||||
let Some(vb) = gv100_pmu_tables::Vbios::new(
|
||||
|
||||
Reference in New Issue
Block a user