* [PATCH] rust: drm: gem: add missing handle_free to the object vtables
@ 2026-09-09 9:47 Mike Lothian
2026-09-09 15:51 ` Gary Guo
2026-09-09 15:57 ` Alex Deucher
0 siblings, 2 replies; 4+ messages in thread
From: Mike Lothian @ 2026-09-09 9:47 UTC (permalink / raw)
To: dri-devel
Cc: dakr, aliceryhl, alexander.deucher, mukul.joshi, rust-for-linux,
amd-gfx, Mike Lothian
Both OBJECT_FUNCS and the shmem VTABLE initialise every member of
drm_gem_object_funcs explicitly, so adding a field to the C struct
breaks the Rust build:
error[E0063]: missing field `handle_free` in initializer of
`drm_gem_object_funcs`
The callback is optional and the Rust abstraction has no equivalent
DriverObject method, so leave it unset.
The shmem copy is only built with CONFIG_RUST_DRM_GEM_SHMEM_HELPER,
which DRM_TYR selects.
Fixes: b67d2d039f64 ("drm/gem: Add callback for when handle count goes to 0")
Signed-off-by: Mike Lothian <mike@fireburn.co.uk>
Assisted-by: Claude:Opus-5 [Claude Code]
---
b67d2d039f64 is only in agd5f/drm-next, so this can be squashed into it
instead if you would rather keep that branch bisectable.
The shmem hunk is by inspection - CONFIG_RUST_DRM_GEM_SHMEM_HELPER is
not set in my config, so only the mod.rs copy is compile-tested.
rust/kernel/drm/gem/mod.rs | 1 +
rust/kernel/drm/gem/shmem.rs | 1 +
2 files changed, 2 insertions(+)
diff --git a/rust/kernel/drm/gem/mod.rs b/rust/kernel/drm/gem/mod.rs
index 80d8f524f9d5..ae61ca7e1246 100644
--- a/rust/kernel/drm/gem/mod.rs
+++ b/rust/kernel/drm/gem/mod.rs
@@ -278,6 +278,7 @@ impl<T: DriverObject, Ctx: DeviceContext> Object<T, Ctx> {
vm_ops: core::ptr::null_mut(),
evict: None,
rss: None,
+ handle_free: None,
};
/// 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..d08a03cb7a13 100644
--- a/rust/kernel/drm/gem/shmem.rs
+++ b/rust/kernel/drm/gem/shmem.rs
@@ -145,6 +145,7 @@ impl<T: DriverObject> Object<T> {
// 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,
+ handle_free: None,
};
/// Return a raw pointer to the embedded drm_gem_shmem_object.
--
2.55.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] rust: drm: gem: add missing handle_free to the object vtables
2026-09-09 9:47 [PATCH] rust: drm: gem: add missing handle_free to the object vtables Mike Lothian
@ 2026-09-09 15:51 ` Gary Guo
2026-09-09 15:57 ` Alex Deucher
1 sibling, 0 replies; 4+ messages in thread
From: Gary Guo @ 2026-09-09 15:51 UTC (permalink / raw)
To: Mike Lothian, dri-devel
Cc: dakr, aliceryhl, alexander.deucher, mukul.joshi, rust-for-linux,
amd-gfx
On Wed Sep 9, 2026 at 10:47 AM BST, Mike Lothian wrote:
> Both OBJECT_FUNCS and the shmem VTABLE initialise every member of
> drm_gem_object_funcs explicitly, so adding a field to the C struct
> breaks the Rust build:
>
> error[E0063]: missing field `handle_free` in initializer of
> `drm_gem_object_funcs`
>
> The callback is optional and the Rust abstraction has no equivalent
> DriverObject method, so leave it unset.
>
> The shmem copy is only built with CONFIG_RUST_DRM_GEM_SHMEM_HELPER,
> which DRM_TYR selects.
>
> Fixes: b67d2d039f64 ("drm/gem: Add callback for when handle count goes to 0")
> Signed-off-by: Mike Lothian <mike@fireburn.co.uk>
> Assisted-by: Claude:Opus-5 [Claude Code]
There's
https://lore.kernel.org/dri-devel/20260908175427.47207-1-klarasmodin@gmail.com/.
Best,
Gary
> ---
>
> b67d2d039f64 is only in agd5f/drm-next, so this can be squashed into it
> instead if you would rather keep that branch bisectable.
>
> The shmem hunk is by inspection - CONFIG_RUST_DRM_GEM_SHMEM_HELPER is
> not set in my config, so only the mod.rs copy is compile-tested.
>
> rust/kernel/drm/gem/mod.rs | 1 +
> rust/kernel/drm/gem/shmem.rs | 1 +
> 2 files changed, 2 insertions(+)
>
> diff --git a/rust/kernel/drm/gem/mod.rs b/rust/kernel/drm/gem/mod.rs
> index 80d8f524f9d5..ae61ca7e1246 100644
> --- a/rust/kernel/drm/gem/mod.rs
> +++ b/rust/kernel/drm/gem/mod.rs
> @@ -278,6 +278,7 @@ impl<T: DriverObject, Ctx: DeviceContext> Object<T, Ctx> {
> vm_ops: core::ptr::null_mut(),
> evict: None,
> rss: None,
> + handle_free: None,
> };
>
> /// 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..d08a03cb7a13 100644
> --- a/rust/kernel/drm/gem/shmem.rs
> +++ b/rust/kernel/drm/gem/shmem.rs
> @@ -145,6 +145,7 @@ impl<T: DriverObject> Object<T> {
> // 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,
> + handle_free: None,
> };
>
> /// Return a raw pointer to the embedded drm_gem_shmem_object.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] rust: drm: gem: add missing handle_free to the object vtables
2026-09-09 9:47 [PATCH] rust: drm: gem: add missing handle_free to the object vtables Mike Lothian
2026-09-09 15:51 ` Gary Guo
@ 2026-09-09 15:57 ` Alex Deucher
2026-09-09 17:45 ` Klara Modin
1 sibling, 1 reply; 4+ messages in thread
From: Alex Deucher @ 2026-09-09 15:57 UTC (permalink / raw)
To: Mike Lothian, Klara Modin, Thomas Zimmermann, Thorsten Leemhuis,
Gary Guo
Cc: dri-devel, dakr, aliceryhl, alexander.deucher, mukul.joshi,
rust-for-linux, amd-gfx
Adding a few people. Alternative patch at:
https://lists.freedesktop.org/archives/amd-gfx/2026-September/152673.html
Alex
On Wed, Sep 9, 2026 at 5:47 AM Mike Lothian <mike@fireburn.co.uk> wrote:
>
> Both OBJECT_FUNCS and the shmem VTABLE initialise every member of
> drm_gem_object_funcs explicitly, so adding a field to the C struct
> breaks the Rust build:
>
> error[E0063]: missing field `handle_free` in initializer of
> `drm_gem_object_funcs`
>
> The callback is optional and the Rust abstraction has no equivalent
> DriverObject method, so leave it unset.
>
> The shmem copy is only built with CONFIG_RUST_DRM_GEM_SHMEM_HELPER,
> which DRM_TYR selects.
>
> Fixes: b67d2d039f64 ("drm/gem: Add callback for when handle count goes to 0")
> Signed-off-by: Mike Lothian <mike@fireburn.co.uk>
> Assisted-by: Claude:Opus-5 [Claude Code]
> ---
>
> b67d2d039f64 is only in agd5f/drm-next, so this can be squashed into it
> instead if you would rather keep that branch bisectable.
>
> The shmem hunk is by inspection - CONFIG_RUST_DRM_GEM_SHMEM_HELPER is
> not set in my config, so only the mod.rs copy is compile-tested.
>
> rust/kernel/drm/gem/mod.rs | 1 +
> rust/kernel/drm/gem/shmem.rs | 1 +
> 2 files changed, 2 insertions(+)
>
> diff --git a/rust/kernel/drm/gem/mod.rs b/rust/kernel/drm/gem/mod.rs
> index 80d8f524f9d5..ae61ca7e1246 100644
> --- a/rust/kernel/drm/gem/mod.rs
> +++ b/rust/kernel/drm/gem/mod.rs
> @@ -278,6 +278,7 @@ impl<T: DriverObject, Ctx: DeviceContext> Object<T, Ctx> {
> vm_ops: core::ptr::null_mut(),
> evict: None,
> rss: None,
> + handle_free: None,
> };
>
> /// 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..d08a03cb7a13 100644
> --- a/rust/kernel/drm/gem/shmem.rs
> +++ b/rust/kernel/drm/gem/shmem.rs
> @@ -145,6 +145,7 @@ impl<T: DriverObject> Object<T> {
> // 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,
> + handle_free: None,
> };
>
> /// Return a raw pointer to the embedded drm_gem_shmem_object.
> --
> 2.55.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] rust: drm: gem: add missing handle_free to the object vtables
2026-09-09 15:57 ` Alex Deucher
@ 2026-09-09 17:45 ` Klara Modin
0 siblings, 0 replies; 4+ messages in thread
From: Klara Modin @ 2026-09-09 17:45 UTC (permalink / raw)
To: Mike Lothian
Cc: Alex Deucher, Thomas Zimmermann, Thorsten Leemhuis, Gary Guo,
dri-devel, dakr, aliceryhl, alexander.deucher, mukul.joshi,
rust-for-linux, amd-gfx
On 2026-09-09 11:57:37 -0400, Alex Deucher wrote:
> Adding a few people. Alternative patch at:
> https://lists.freedesktop.org/archives/amd-gfx/2026-September/152673.html
>
> Alex
>
> On Wed, Sep 9, 2026 at 5:47 AM Mike Lothian <mike@fireburn.co.uk> wrote:
> >
> > Both OBJECT_FUNCS and the shmem VTABLE initialise every member of
> > drm_gem_object_funcs explicitly, so adding a field to the C struct
> > breaks the Rust build:
> >
> > error[E0063]: missing field `handle_free` in initializer of
> > `drm_gem_object_funcs`
> >
> > The callback is optional and the Rust abstraction has no equivalent
> > DriverObject method, so leave it unset.
> >
> > The shmem copy is only built with CONFIG_RUST_DRM_GEM_SHMEM_HELPER,
> > which DRM_TYR selects.
Sorry, I missed you when sending my v2. It's at
https://lore.kernel.org/lkml/20260909173103.73656-1-klarasmodin@gmail.com/T/#u
if you want to have a look.
Regards,
Klara Modin
> >
> > Fixes: b67d2d039f64 ("drm/gem: Add callback for when handle count goes to 0")
> > Signed-off-by: Mike Lothian <mike@fireburn.co.uk>
> > Assisted-by: Claude:Opus-5 [Claude Code]
> > ---
> >
> > b67d2d039f64 is only in agd5f/drm-next, so this can be squashed into it
> > instead if you would rather keep that branch bisectable.
> >
> > The shmem hunk is by inspection - CONFIG_RUST_DRM_GEM_SHMEM_HELPER is
> > not set in my config, so only the mod.rs copy is compile-tested.
> >
> > rust/kernel/drm/gem/mod.rs | 1 +
> > rust/kernel/drm/gem/shmem.rs | 1 +
> > 2 files changed, 2 insertions(+)
> >
> > diff --git a/rust/kernel/drm/gem/mod.rs b/rust/kernel/drm/gem/mod.rs
> > index 80d8f524f9d5..ae61ca7e1246 100644
> > --- a/rust/kernel/drm/gem/mod.rs
> > +++ b/rust/kernel/drm/gem/mod.rs
> > @@ -278,6 +278,7 @@ impl<T: DriverObject, Ctx: DeviceContext> Object<T, Ctx> {
> > vm_ops: core::ptr::null_mut(),
> > evict: None,
> > rss: None,
> > + handle_free: None,
> > };
> >
> > /// 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..d08a03cb7a13 100644
> > --- a/rust/kernel/drm/gem/shmem.rs
> > +++ b/rust/kernel/drm/gem/shmem.rs
> > @@ -145,6 +145,7 @@ impl<T: DriverObject> Object<T> {
> > // 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,
> > + handle_free: None,
> > };
> >
> > /// Return a raw pointer to the embedded drm_gem_shmem_object.
> > --
> > 2.55.0
> >
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-09-09 17:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-09 9:47 [PATCH] rust: drm: gem: add missing handle_free to the object vtables Mike Lothian
2026-09-09 15:51 ` Gary Guo
2026-09-09 15:57 ` Alex Deucher
2026-09-09 17:45 ` Klara Modin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox