Re: [PATCH v5 15/35] gpu: nova-core: mm: add SharedGpuMm

From: Danilo Krummrich

Date: Thu Nov 26 2026 - 16:38:58 EST


On Tue Nov 24, 2026 at 2:59 PM CET, Alok Kumar wrote:
> +/// A [`GpuMm`] shared between several users, serialized by a mutex.
> +#[pin_data]
> +pub(crate) struct SharedGpuMm<'gpu>
> +where
> + // Hide the mutex's invariant resource lifetime so `SharedGpuMm` remains covariant.
> + exists<'res>: 'gpu,
> +{
> + #[pin]
> + #[uses('res: invariant)]
> + inner: Mutex<GpuMm<'res>>,
> +}

I don't think GpuMm should have a global lock; it contains GpuBuddy, Pramin and
Tlb.

The reason some APIs want &mut GpuMm<'a> is that the contained Pramin does not
implement mutal exclusion; GpuBuddy and Tlb already have inner locks.

Please also consider, if GpuBuddy, Pramin and Tlb share a common lock, this
would violate DMA fence rules if Pramin and Tlb are used from the fence
signaling critical path.

I just came across this independently from this series and sent out a patch
series [1] for this.

[1] https://lore.kernel.org/nova-gpu/20261126213652.3716162-1-dakr@xxxxxxxxxx/