]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
Merge tag 'drm-rust-next-2025-09-16' of https://gitlab.freedesktop.org/drm/rust/kerne...
authorDave Airlie <airlied@redhat.com>
Wed, 17 Sep 2025 06:09:24 +0000 (16:09 +1000)
committerDave Airlie <airlied@redhat.com>
Wed, 17 Sep 2025 06:13:49 +0000 (16:13 +1000)
DRM Rust changes for v6.18

Alloc
  - Add BorrowedPage type and AsPageIter trait
  - Implement Vmalloc::to_page() and VmallocPageIter
  - Implement AsPageIter for VBox and VVec

DMA & Scatterlist
  - Add dma::DataDirection and type alias for dma_addr_t
  - Abstraction for struct scatterlist and struct sg_table

DRM
  - In the DRM GEM module, simplify overall use of generics, add
    DriverFile type alias and drop Object::SIZE.

Nova (Core)
  - Various register!() macro improvements (paving the way for lifting
    it to common driver infrastructure)
  - Minor VBios fixes and refactoring
  - Minor firmware request refactoring
  - Advance firmware boot stages; process Booter and patch its
    signature, process GSP and GSP bootloader
  - Switch development fimrware version to r570.144
  - Add basic firmware bindings for r570.144
  - Move GSP boot code to its own module
  - Clean up and take advantage of pin-init features to store most of
    the driver's private data within a single allocation
  - Update ARef import from sync::aref
  - Add website to MAINTAINERS entry

Nova (DRM)
  - Update ARef import from sync::aref
  - Add website to MAINTAINERS entry

Pin-Init
  - Merge pin-init PR from Benno
    - `#[pin_data]` now generates a `*Projection` struct similar to the
      `pin-project` crate.

    - Add initializer code blocks to `[try_][pin_]init!` macros: make
      initializer macros accept any number of `_: {/* arbitrary code
      */},` & make them run the code at that point.

    - Make the `[try_][pin_]init!` macros expose initialized fields via
      a `let` binding as `&mut T` or `Pin<&mut T>` for later fields.

Rust
  - Various methods for AsBytes and FromBytes traits

Tyr
  - Initial Rust driver skeleton for ARM Mali GPUs.
    - It can power up the GPU, query for GPU metatdata through MMIO and
      provide the metadata to userspace via DRM device IOCTL (struct
      drm_panthor_dev_query).

Signed-off-by: Dave Airlie <airlied@redhat.com>
From: "Danilo Krummrich" <dakr@kernel.org>
Link: https://lore.kernel.org/r/DCUC4SY6SRBD.1ZLHAIQZOC6KG@kernel.org
1  2 
MAINTAINERS
rust/kernel/alloc/allocator.rs
rust/kernel/alloc/allocator_test.rs
rust/kernel/devres.rs
rust/kernel/lib.rs

diff --cc MAINTAINERS
index 5257d52679d60d084b85e2f023730286aa79311d,8a11e6c5dd809ea0087649786699236193e44bbc..838ae3c2b6fcf4b7babec04cf291af967ba8f311
@@@ -7237,18 -7251,20 +7250,20 @@@ F:   include/linux/dma-mapping.
  F:    include/linux/swiotlb.h
  F:    kernel/dma/
  
- DMA MAPPING HELPERS DEVICE DRIVER API [RUST]
+ DMA MAPPING & SCATTERLIST API [RUST]
 -M:    Abdiel Janulgue <abdiel.janulgue@gmail.com>
  M:    Danilo Krummrich <dakr@kernel.org>
 +R:    Abdiel Janulgue <abdiel.janulgue@gmail.com>
  R:    Daniel Almeida <daniel.almeida@collabora.com>
  R:    Robin Murphy <robin.murphy@arm.com>
  R:    Andreas Hindborg <a.hindborg@kernel.org>
  L:    rust-for-linux@vger.kernel.org
  S:    Supported
  W:    https://rust-for-linux.com
 -T:    git https://github.com/Rust-for-Linux/linux.git alloc-next
 +T:    git git://git.kernel.org/pub/scm/linux/kernel/git/driver-core/driver-core.git
  F:    rust/helpers/dma.c
+ F:    rust/helpers/scatterlist.c
  F:    rust/kernel/dma.rs
+ F:    rust/kernel/scatterlist.rs
  F:    samples/rust/rust_dma.rs
  
  DMA-BUF HEAPS FRAMEWORK
Simple merge
index 90dd987d40e452fa68551a885c4ba71e3a1065e3,f46b4b671389cdb771c2423444ce0a1de4c1dfde..7b10e276f6211dfd3c08ee43ac20643cb2d69b2a
@@@ -22,17 -24,33 +24,44 @@@ pub type Kmalloc = Cmalloc
  pub type Vmalloc = Kmalloc;
  pub type KVmalloc = Kmalloc;
  
 +impl Cmalloc {
 +    /// Returns a [`Layout`] that makes [`Kmalloc`] fulfill the requested size and alignment of
 +    /// `layout`.
 +    pub fn aligned_layout(layout: Layout) -> Layout {
 +        // Note that `layout.size()` (after padding) is guaranteed to be a multiple of
 +        // `layout.align()` which together with the slab guarantees means that `Kmalloc` will return
 +        // a properly aligned object (see comments in `kmalloc()` for more information).
 +        layout.pad_to_align()
 +    }
 +}
 +
+ pub struct VmallocPageIter<'a> {
+     _p: PhantomData<page::BorrowedPage<'a>>,
+ }
+ impl<'a> Iterator for VmallocPageIter<'a> {
+     type Item = page::BorrowedPage<'a>;
+     fn next(&mut self) -> Option<Self::Item> {
+         None
+     }
+ }
+ impl<'a> VmallocPageIter<'a> {
+     #[allow(clippy::missing_safety_doc)]
+     pub unsafe fn new(_buf: NonNull<u8>, _size: usize) -> Self {
+         Self { _p: PhantomData }
+     }
+     pub fn size(&self) -> usize {
+         0
+     }
+     pub fn page_count(&self) -> usize {
+         0
+     }
+ }
  extern "C" {
      #[link_name = "aligned_alloc"]
      fn libc_aligned_alloc(align: usize, size: usize) -> *mut crate::ffi::c_void;
index d04e3fcebafbb39470f6084fe41973035685b127,91dbf3f4b166ad88f395a003166419f70a92ae17..aea6b7e31170e40c91b2f1284f045d1cb5ab1799
@@@ -135,21 -134,11 +135,19 @@@ impl<T: Send> Devres<T> 
          T: 'a,
          Error: From<E>,
      {
-         let callback = Self::devres_callback;
          try_pin_init!(&this in Self {
              dev: dev.into(),
-             callback,
+             callback: Self::devres_callback,
              // INVARIANT: `inner` is properly initialized.
 -            inner <- {
 +            inner <- Opaque::pin_init(try_pin_init!(Inner {
 +                    devm <- Completion::new(),
 +                    revoke <- Completion::new(),
 +                    data <- Revocable::new(data),
 +            })),
 +            // TODO: Replace with "initializer code blocks" [1] once available.
 +            //
 +            // [1] https://github.com/Rust-for-Linux/pin-init/pull/69
 +            _add_action: {
                  // SAFETY: `this` is a valid pointer to uninitialized memory.
                  let inner = unsafe { &raw mut (*this.as_ptr()).inner };
  
                  //    properly initialized, because we require `dev` (i.e. the *bound* device) to
                  //    live at least as long as the returned `impl PinInit<Self, Error>`.
                  to_result(unsafe {
-                     bindings::devm_add_action(dev.as_raw(), Some(callback), inner.cast())
+                     bindings::devm_add_action(dev.as_raw(), Some(*callback), inner.cast())
 -                })?;
 +                }).inspect_err(|_| {
 +                    let inner = Opaque::cast_into(inner);
  
 -                Opaque::pin_init(try_pin_init!(Inner {
 -                    devm <- Completion::new(),
 -                    revoke <- Completion::new(),
 -                    data <- Revocable::new(data),
 -                }))
 +                    // SAFETY: `inner` is a valid pointer to an `Inner<T>` and valid for both reads
 +                    // and writes.
 +                    unsafe { core::ptr::drop_in_place(inner) };
 +                })?;
              },
          })
      }
Simple merge