dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Fix import of dma-buf buffers as DRM GEM shmem objects
@ 2026-10-26 11:14 Janne Grunau
  2026-10-26 11:14 ` [PATCH 1/3] rust: drm: gem: shmem: implement gem_create_object for prime imports Janne Grunau
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Janne Grunau @ 2026-10-26 11:14 UTC (permalink / raw)
  To: Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
	Alexandre Courbot, Onur Özkan, David Airlie, Simona Vetter,
	Janne Grunau, Sami Tolvanen, Lyude Paul
  Cc: rust-for-linux, linux-kernel, dri-devel, nova-gpu, Janne Grunau,
	stable+noautosel

Hej,

this is triggered by the discussion of gem/shmem.rs SGTableMap issues
in [1] which has an additional issue with imported object.
Imported objects are supported since GEM shmem's AllocOps use
drm_gem_shmem_prime_import_sg_table() as gem_prime_import_sg_table which
sets the same function pointer field in struct drm_driver.

The code is broken in two ways. SGTableMap::drop() calls
__drm_gem_shmem_free_sgt_locked() uncondiftionally which it must not do
for imported objects as the object does not own `sgt`.
The second issue is that the imported object is allocated by
__drm_gem_shmem_create() with sizeof(struct drm_gem_shmem_object) as
size instead of the size of Rust's Object<T>.

The second issue is already fixed in tyr's downstream driver by adding a
`gem_create_object` callback which is used instead of the minimal
allocation in the C helper.
The first issue is fixed in the Asahi downstream driver together with a
drm_gem_is_imported() wrapper change taken from the tyr downstream
driver.

All three patches are tested in the Asahi downstream driver. As this is
unused code in-tree I marked the fixes as not suitable for stable
backports. The known downstream users of the code are aware of the
issues and carry fixes downstream. I don't expect new Rust DRM drivers
to be based on the (old) stable trees.

Link: https://lore.kernel.org/rust-for-linux/20261019-rust-shmem-fixes-v1-1-3f7f6de5b5e7@google.com/ [1]
Signed-off-by: Janne Grunau <j@jannau.net>
---
Janne Grunau (1):
      rust: drm: gem: shmem: Do not free SG table of imported objects

Sami Tolvanen (2):
      rust: drm: gem: shmem: implement gem_create_object for prime imports
      rust: drm: gem: add an is_imported() accessor

 drivers/gpu/drm/nova/gem.rs  |  4 +++
 drivers/gpu/drm/tyr/gem.rs   |  4 +++
 rust/helpers/drm.c           |  6 +++++
 rust/kernel/drm/gem/mod.rs   | 16 ++++++++++++
 rust/kernel/drm/gem/shmem.rs | 62 +++++++++++++++++++++++++++++++++++++++++++-
 5 files changed, 91 insertions(+), 1 deletion(-)
---
base-commit: 3497a403264b094ebd61b8b755165d56e7d9dc37
change-id: 20261026-rust-drm-gem-shmem-imported-sgt-85c4a45be283

Best regards,
-- 
Janne Grunau <j@jannau.net>


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-10-26 11:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-26 11:14 [PATCH 0/3] Fix import of dma-buf buffers as DRM GEM shmem objects Janne Grunau
2026-10-26 11:14 ` [PATCH 1/3] rust: drm: gem: shmem: implement gem_create_object for prime imports Janne Grunau
2026-10-26 11:14 ` [PATCH 2/3] rust: drm: gem: add an is_imported() accessor Janne Grunau
2026-10-26 11:53   ` sashiko-bot
2026-10-26 11:14 ` [PATCH 3/3] rust: drm: gem: shmem: Do not free SG table of imported objects Janne Grunau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox