* [PATCH v2] rust/drm/gem: initialize callbacks with ..pin_init::zeroed()
@ 2026-09-09 17:31 Klara Modin
2026-09-10 13:15 ` Alex Deucher
0 siblings, 1 reply; 2+ messages in thread
From: Klara Modin @ 2026-09-09 17:31 UTC (permalink / raw)
To: David Airlie, Simona Vetter, Danilo Krummrich, Alice Ryhl
Cc: Miguel Ojeda, Alex Deucher, Mukul Joshi, Felix Kuehling,
Christian König, Thorsten Leemhuis, Manuel Ebner, Gary Guo,
Thomas Zimmermann, dri-devel, rust-for-linux, linux-kernel,
amd-gfx, Klara Modin
When the commit b67d2d039f64 ("drm/gem: Add callback for when handle
count goes to 0") added the handle_free callback, it did not update the
rust abstraction, which will cause a build failure when that is enabled.
Rather than just adding another None initializer, use
..pin_init::zeroed() to make all unlisted callbacks None, and remove the
existing zero-initializations.
Fixes: b67d2d039f64 ("drm/gem: Add callback for when handle count goes to 0")
Reported-by: Thorsten Leemhuis <linux@leemhuis.info>
Closes: https://lore.kernel.org/all/aaef18cd-ab55-4fb8-8563-ca3a5ea9cbc6@leemhuis.info
Reported-by: Thomas Zimmermann <tzimmermann@suse.de>
Closes: https://lore.kernel.org/all/4da62a4b-c4ef-492a-9a27-b56bd4784acf@suse.de
Suggested-by: Gary Guo <gary@garyguo.net>
Signed-off-by: Klara Modin <klarasmodin@gmail.com>
---
v2:
- also remove initialization of vm_ops, which is also handled by
..pin_init::zeroed() (thanks Gary)
- fix the same issue in the shmem helper (thanks Thomas, also reported
by Sashiko)
- v1: https://lore.kernel.org/lkml/20260908175427.47207-1-klarasmodin@gmail.com
---
rust/kernel/drm/gem/mod.rs | 13 +------------
rust/kernel/drm/gem/shmem.rs | 5 +----
2 files changed, 2 insertions(+), 16 deletions(-)
diff --git a/rust/kernel/drm/gem/mod.rs b/rust/kernel/drm/gem/mod.rs
index 80d8f524f9d5..9d4280002765 100644
--- a/rust/kernel/drm/gem/mod.rs
+++ b/rust/kernel/drm/gem/mod.rs
@@ -266,18 +266,7 @@ impl<T: DriverObject, Ctx: DeviceContext> Object<T, Ctx> {
free: Some(Self::free_callback),
open: Some(open_callback::<T>),
close: Some(close_callback::<T>),
- print_info: None,
- export: None,
- pin: None,
- unpin: None,
- get_sg_table: None,
- vmap: None,
- vunmap: None,
- mmap: None,
- status: None,
- vm_ops: core::ptr::null_mut(),
- evict: None,
- rss: None,
+ ..pin_init::zeroed()
};
/// Returns the `Device` that owns this GEM object.
diff --git a/rust/kernel/drm/gem/shmem.rs b/rust/kernel/drm/gem/shmem.rs
index a687d46d170d..24cb5343e0db 100644
--- a/rust/kernel/drm/gem/shmem.rs
+++ b/rust/kernel/drm/gem/shmem.rs
@@ -132,19 +132,16 @@ impl<T: DriverObject> Object<T> {
open: Some(super::open_callback::<T>),
close: Some(super::close_callback::<T>),
print_info: Some(bindings::drm_gem_shmem_object_print_info),
- export: None,
pin: Some(bindings::drm_gem_shmem_object_pin),
unpin: Some(bindings::drm_gem_shmem_object_unpin),
get_sg_table: Some(bindings::drm_gem_shmem_object_get_sg_table),
vmap: Some(bindings::drm_gem_shmem_object_vmap),
vunmap: Some(bindings::drm_gem_shmem_object_vunmap),
mmap: Some(bindings::drm_gem_shmem_object_mmap),
- status: None,
- rss: None,
#[allow(unused_unsafe, reason = "Safe since Rust 1.82.0")]
// SAFETY: `drm_gem_shmem_vm_ops` is a valid, static const on the C side.
vm_ops: unsafe { &raw const bindings::drm_gem_shmem_vm_ops },
- evict: None,
+ ..pin_init::zeroed()
};
/// Return a raw pointer to the embedded drm_gem_shmem_object.
--
2.55.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] rust/drm/gem: initialize callbacks with ..pin_init::zeroed()
2026-09-09 17:31 [PATCH v2] rust/drm/gem: initialize callbacks with ..pin_init::zeroed() Klara Modin
@ 2026-09-10 13:15 ` Alex Deucher
0 siblings, 0 replies; 2+ messages in thread
From: Alex Deucher @ 2026-09-10 13:15 UTC (permalink / raw)
To: Klara Modin
Cc: David Airlie, Simona Vetter, Danilo Krummrich, Alice Ryhl,
Miguel Ojeda, Alex Deucher, Mukul Joshi, Felix Kuehling,
Christian König, Thorsten Leemhuis, Manuel Ebner, Gary Guo,
Thomas Zimmermann, dri-devel, rust-for-linux, linux-kernel,
amd-gfx
Applied. Thanks.
Alex
On Thu, Sep 10, 2026 at 6:08 AM Klara Modin <klarasmodin@gmail.com> wrote:
>
> When the commit b67d2d039f64 ("drm/gem: Add callback for when handle
> count goes to 0") added the handle_free callback, it did not update the
> rust abstraction, which will cause a build failure when that is enabled.
> Rather than just adding another None initializer, use
> ..pin_init::zeroed() to make all unlisted callbacks None, and remove the
> existing zero-initializations.
>
> Fixes: b67d2d039f64 ("drm/gem: Add callback for when handle count goes to 0")
> Reported-by: Thorsten Leemhuis <linux@leemhuis.info>
> Closes: https://lore.kernel.org/all/aaef18cd-ab55-4fb8-8563-ca3a5ea9cbc6@leemhuis.info
> Reported-by: Thomas Zimmermann <tzimmermann@suse.de>
> Closes: https://lore.kernel.org/all/4da62a4b-c4ef-492a-9a27-b56bd4784acf@suse.de
> Suggested-by: Gary Guo <gary@garyguo.net>
> Signed-off-by: Klara Modin <klarasmodin@gmail.com>
> ---
> v2:
> - also remove initialization of vm_ops, which is also handled by
> ..pin_init::zeroed() (thanks Gary)
> - fix the same issue in the shmem helper (thanks Thomas, also reported
> by Sashiko)
> - v1: https://lore.kernel.org/lkml/20260908175427.47207-1-klarasmodin@gmail.com
> ---
> rust/kernel/drm/gem/mod.rs | 13 +------------
> rust/kernel/drm/gem/shmem.rs | 5 +----
> 2 files changed, 2 insertions(+), 16 deletions(-)
>
> diff --git a/rust/kernel/drm/gem/mod.rs b/rust/kernel/drm/gem/mod.rs
> index 80d8f524f9d5..9d4280002765 100644
> --- a/rust/kernel/drm/gem/mod.rs
> +++ b/rust/kernel/drm/gem/mod.rs
> @@ -266,18 +266,7 @@ impl<T: DriverObject, Ctx: DeviceContext> Object<T, Ctx> {
> free: Some(Self::free_callback),
> open: Some(open_callback::<T>),
> close: Some(close_callback::<T>),
> - print_info: None,
> - export: None,
> - pin: None,
> - unpin: None,
> - get_sg_table: None,
> - vmap: None,
> - vunmap: None,
> - mmap: None,
> - status: None,
> - vm_ops: core::ptr::null_mut(),
> - evict: None,
> - rss: None,
> + ..pin_init::zeroed()
> };
>
> /// Returns the `Device` that owns this GEM object.
> diff --git a/rust/kernel/drm/gem/shmem.rs b/rust/kernel/drm/gem/shmem.rs
> index a687d46d170d..24cb5343e0db 100644
> --- a/rust/kernel/drm/gem/shmem.rs
> +++ b/rust/kernel/drm/gem/shmem.rs
> @@ -132,19 +132,16 @@ impl<T: DriverObject> Object<T> {
> open: Some(super::open_callback::<T>),
> close: Some(super::close_callback::<T>),
> print_info: Some(bindings::drm_gem_shmem_object_print_info),
> - export: None,
> pin: Some(bindings::drm_gem_shmem_object_pin),
> unpin: Some(bindings::drm_gem_shmem_object_unpin),
> get_sg_table: Some(bindings::drm_gem_shmem_object_get_sg_table),
> vmap: Some(bindings::drm_gem_shmem_object_vmap),
> vunmap: Some(bindings::drm_gem_shmem_object_vunmap),
> mmap: Some(bindings::drm_gem_shmem_object_mmap),
> - status: None,
> - rss: None,
> #[allow(unused_unsafe, reason = "Safe since Rust 1.82.0")]
> // SAFETY: `drm_gem_shmem_vm_ops` is a valid, static const on the C side.
> vm_ops: unsafe { &raw const bindings::drm_gem_shmem_vm_ops },
> - evict: None,
> + ..pin_init::zeroed()
> };
>
> /// Return a raw pointer to the embedded drm_gem_shmem_object.
> --
> 2.55.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-10 13:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-09 17:31 [PATCH v2] rust/drm/gem: initialize callbacks with ..pin_init::zeroed() Klara Modin
2026-09-10 13:15 ` Alex Deucher
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox