On 11/25/2026 3:51 PM, Danilo Krummrich wrote:
>> +impl RuntimeActive {
>> + fn new(dev: &device::Device<device::Bound>) -> Result<Self> {
>> + // SAFETY: `dev` is a valid device. This is
>> `pm_runtime_get_sync()`, which takes a usage
>> + // reference even if it fails.
>> + #[cfg(CONFIG_PM)]
>> + let ret =
>> + unsafe { bindings::__pm_runtime_resume(dev.as_raw(),
>> bindings::RPM_GET_PUT as c_int) };
>> + #[cfg(not(CONFIG_PM))]
>> + let ret = 0;
>> + // INVARIANT: `this` owns the usage reference, and drops it if the
>> resume failed.
>> + let this = Self(dev.into());
>> + to_result(ret)?;
>> + Ok(this)
>> + }
>> +}
>> +
>> +impl Drop for RuntimeActive {
>> + fn drop(&mut self) {
>> + // SAFETY: `self.0` is a valid device, and `new()` took the usage
>> reference dropped
>> + // here. This is `pm_runtime_put()`.
>> + #[cfg(CONFIG_PM)]
>> + unsafe {
>> + bindings::__pm_runtime_idle(
>> + self.0.as_raw(),
>> + (bindings::RPM_GET_PUT | bindings::RPM_ASYNC) as c_int,
>> + )
>> + };
>> + }
>> +}
>
> This seems reasonable, but doesn't belong into VFIO core code. This should
> e.g.
> go under rust/kernel/device/pm.rs.
>
> However, it would become dead code once we land the runtime PM stuff and
> enable
> it for PCI, right? I think an alternative could be to just make nova-vgpu
> depend
> on !PM.
>
Right, this goes away once driver has runtime PM callbacks, I tried !PM and it
works, but CONFIG_PM
is set in x86_64_defconfig and allmodconfig, so driver won't be built there
with default option for
x86, would you rather keep RuntimeActive and moved it to pm.rs or prefer to
depend on the CONFIG_PM
until the runtime PM for PCI lands?