[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250422-gpuvm-v2-0-44d4fc25e411@collabora.com>
Date: Tue, 22 Apr 2025 13:41:51 -0300
From: Daniel Almeida <daniel.almeida@...labora.com>
To: Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>,
Andreas Hindborg <a.hindborg@...nel.org>, Alice Ryhl <aliceryhl@...gle.com>,
Trevor Gross <tmgross@...ch.edu>, Sumit Semwal <sumit.semwal@...aro.org>,
Christian König <christian.koenig@....com>,
Boris Brezillon <boris.brezillon@...labora.com>,
Danilo Krummrich <dakr@...nel.org>,
Alyssa Rosenzweig <alyssa@...enzweig.io>, Lyude Paul <lyude@...hat.com>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>, Thomas Zimmermann <tzimmermann@...e.de>,
David Airlie <airlied@...il.com>, Simona Vetter <simona@...ll.ch>
Cc: linux-kernel@...r.kernel.org, rust-for-linux@...r.kernel.org,
dri-devel@...ts.freedesktop.org, Asahi Lina <lina@...hilina.net>,
Daniel Almeida <daniel.almeida@...labora.com>
Subject: [PATCH v2 0/2] Add a Rust GPUVM abstraction
Changes from v1:
- Added more people to cc.
- Used Benno's suggestion to remove the #[allow] (thanks, Benno, that is
indeed better!)
- Added markdown as applicable in the docs/comments (please let me know
whether I missed any)
- Changed the order between docs and attributes to match the rest of the
code in the Rust crate.
- Did *not* remove the # Arguments section from a few functions yet, let's
push this dicussion down the line, Miguel.
- Changed the placement of OpRemap, i.e.: it was not next to its impl block by
mistake.
- Misc doc fixes, i.e. missing periods, missing ///, lines that would
not render properly on the browser, etc (thanks, Miguel)
- Removed spurious clang-format change from patch 1.
- Added a return statement for find_bo/obtain_bo (thanks, Charalampos!)
Changes from v0:
This version changes how `LockedGpuVm` operates. The previous code assumed
that the interval tree would be protected if all the associated GEM's resvs
were locked, but this is completely unrelated. In fact, this initial version
only aims to support the core VA range management feature of GPUVM, and not any
of the "convenience" functions like "exec_lock()" and friends, so this function
was removed accordingly.
LockedGpuVm is now produced by a call to GpuVm::lock(). This takes a generic
guard type to signal that the driver-specific locks have been acquired in order
to protect the VMs tree, and hence its view of the address space. This approach
is somewhat similar to CondVar, but also incurs in the same pitfall: it is up
to the caller to give meaning to the guard by ensuring that it actually
protects against concurrent access to the VM. Maybe this is a good candidate to
the upcoming "Pitfall" docs section?
Note that LockedGpuVm::obj was removed. I'm not really sure why this field
was there in the first place, but callers should indicate the object through
the sm_map() and sm_unmap() APIs instead.
I am not sure why GpuVm::inner uses UnsafeCell, though. I did not touch this
so that we can first discuss whether UnsafeCell is really needed.
The docs were also updated. Care was taken to reuse the C documentation as
much as possible.
Itemized changes:
- Rebased on top of nova-drm
- Use `srctree` in the docs
- Add docs as appropriate and remove #[allow(missing_docs)]
- Remove `impl DriverGpuVa for ()`. Drivers can to that themselves, if they want.
- Added #[inline] to getters, as Rust cannot inline across crates otherwise (unless this changed recently?)
- Exposed `drm_gpuva_op_unmap::keep`.
- Removed `pub(super)` from unsafe fns meant to be called from the C code.
- Added "# Safety" blocks to the above.
- Removed `exec_lock_gem_object()`.
- Removed `exec_lock()`
- Removed `LockedGpuVm::vm_exec`. This initial version does not support `exec` calls at all.
- By the same token, removed `LockedGpuVm::drop()`
- Removed `LockedGpuVm::obj`. This object has to be passed explicitly.
---
Asahi Lina (2):
rust: helpers: Add bindings/wrappers for dma_resv
rust: drm: Add GPUVM abstraction
rust/bindings/bindings_helper.h | 2 +
rust/helpers/dma-resv.c | 13 +
rust/helpers/drm_gpuvm.c | 29 ++
rust/helpers/helpers.c | 2 +
rust/kernel/drm/gpuvm.rs | 807 ++++++++++++++++++++++++++++++++++++++++
rust/kernel/drm/mod.rs | 2 +
6 files changed, 855 insertions(+)
---
base-commit: e7de41cc4b01dd5500a0c2533c64bdb3f5360567
change-id: 20250320-gpuvm-29d3e0726f34
Best regards,
--
Daniel Almeida <daniel.almeida@...labora.com>
Powered by blists - more mailing lists