[PATCH] rust/drm/gem: initialize callbacks with ..pin_init::zeroed()

Klara Modin posted 1 patch 2 weeks, 3 days ago
There is a newer version of this series
rust/kernel/drm/gem/mod.rs | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
[PATCH] rust/drm/gem: initialize callbacks with ..pin_init::zeroed()
Posted by Klara Modin 2 weeks, 3 days ago
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 None-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
Suggested-by: Gary Guo <gary@garyguo.net>
Signed-off-by: Klara Modin <klarasmodin@gmail.com>
---
 rust/kernel/drm/gem/mod.rs | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/rust/kernel/drm/gem/mod.rs b/rust/kernel/drm/gem/mod.rs
index 80d8f524f9d5..af8274134a71 100644
--- a/rust/kernel/drm/gem/mod.rs
+++ b/rust/kernel/drm/gem/mod.rs
@@ -266,18 +266,8 @@ 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.
-- 
2.55.0
Re: [PATCH] rust/drm/gem: initialize callbacks with ..pin_init::zeroed()
Posted by Thomas Zimmermann 2 weeks, 2 days ago
Hi

Am 08.09.26 um 19:54 schrieb 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 None-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
> Suggested-by: Gary Guo <gary@garyguo.net>
> Signed-off-by: Klara Modin <klarasmodin@gmail.com>

Please see my bug report at [1].  This patch fixes half of it. I still get

error[E0063]: missing field `handle_free` in initializer of 
`drm_gem_object_funcs`
    --> /home/tzimmermann/Projekte/linux/rust/kernel/drm/gem/shmem.rs:130:52
     |
130 |     const VTABLE: bindings::drm_gem_object_funcs = 
bindings::drm_gem_object_funcs {
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `handle_free`

error: aborting due to 1 previous error

[1] 
https://lore.kernel.org/dri-devel/CANiq72mUW5d1dOQDgpYjuKoUaZAi-im7j3v30Wd4KTDznmM9zw@mail.gmail.com/T/#r8f10eefc91d3bbce58869433b8258882c2d19ff5

Best regards
Thomas



> ---
>   rust/kernel/drm/gem/mod.rs | 12 +-----------
>   1 file changed, 1 insertion(+), 11 deletions(-)
>
> diff --git a/rust/kernel/drm/gem/mod.rs b/rust/kernel/drm/gem/mod.rs
> index 80d8f524f9d5..af8274134a71 100644
> --- a/rust/kernel/drm/gem/mod.rs
> +++ b/rust/kernel/drm/gem/mod.rs
> @@ -266,18 +266,8 @@ 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.

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, (HRB 36809, AG Nürnberg)


Re: [PATCH] rust/drm/gem: initialize callbacks with ..pin_init::zeroed()
Posted by Miguel Ojeda 2 weeks, 2 days ago
On Wed, Sep 9, 2026 at 10:01 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>
> Please see my bug report at [1].  This patch fixes half of it. I still get

I think fixing that is the respin that Klara meant in

  https://lore.kernel.org/rust-for-linux/aqBf1UYNR-Q3T-cs@soda.int.kasm.eu/

Cheers,
Miguel
Re: [PATCH] rust/drm/gem: initialize callbacks with ..pin_init::zeroed()
Posted by Thomas Zimmermann 2 weeks, 2 days ago
Hi

Am 09.09.26 um 10:05 schrieb Miguel Ojeda:
> On Wed, Sep 9, 2026 at 10:01 AM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>> Please see my bug report at [1].  This patch fixes half of it. I still get
> I think fixing that is the respin that Klara meant in
>
>    https://lore.kernel.org/rust-for-linux/aqBf1UYNR-Q3T-cs@soda.int.kasm.eu/

Sure. I do have Tyr enabled FTR.

Best regards
Thomas

>
> Cheers,
> Miguel

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, (HRB 36809, AG Nürnberg)


Re: [PATCH] rust/drm/gem: initialize callbacks with ..pin_init::zeroed()
Posted by Gary Guo 2 weeks, 2 days ago
On Tue Sep 8, 2026 at 6:54 PM BST, Klara Modin 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 None-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
> Suggested-by: Gary Guo <gary@garyguo.net>
> Signed-off-by: Klara Modin <klarasmodin@gmail.com>
> ---
>  rust/kernel/drm/gem/mod.rs | 12 +-----------
>  1 file changed, 1 insertion(+), 11 deletions(-)
>
> diff --git a/rust/kernel/drm/gem/mod.rs b/rust/kernel/drm/gem/mod.rs
> index 80d8f524f9d5..af8274134a71 100644
> --- a/rust/kernel/drm/gem/mod.rs
> +++ b/rust/kernel/drm/gem/mod.rs
> @@ -266,18 +266,8 @@ 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(),

This line can be gone too.

Best,
Gary

> -        evict: None,
> -        rss: None,
> +        ..pin_init::zeroed()
>      };
>  
>      /// Returns the `Device` that owns this GEM object.