linux/rust/helpers
Asahi Lina 80df573af9 rust: drm: gem: shmem: Add DRM shmem helper abstraction
The DRM shmem helper includes common code useful for drivers which
allocate GEM objects as anonymous shmem. Add a Rust abstraction for
this. Drivers can choose the raw GEM implementation or the shmem layer,
depending on their needs.

Signed-off-by: Asahi Lina <lina@asahilina.net>
Signed-off-by: Daniel Almeida <daniel.almeida@collabora.com>
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Signed-off-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Janne Grunau <j@jananu.net>
Tested-by: Deborah Brouwer <deborah.brouwer@collabora.com>
Link: https://patch.msgid.link/20260316211646.650074-6-lyude@redhat.com
[ * DRM_GEM_SHMEM_HELPER is a tristate; when a module driver selects it,
    it becomes =m. The Rust kernel crate and its C helpers are always
    built into vmlinux and can't reference symbols from a module,
    causing link errors.

    Thus, add RUST_DRM_GEM_SHMEM_HELPER bool Kconfig that selects
    DRM_GEM_SHMEM_HELPER, forcing it built-in when Rust drivers need it;
    use cfg(CONFIG_RUST_DRM_GEM_SHMEM_HELPER) for the shmem module.

  * Add cfg_attr(not(CONFIG_RUST_DRM_GEM_SHMEM_HELPER), expect(unused))
    on pub(crate) use impl_aref_for_gem_obj and BaseObjectPrivate, so
    that unused warnings are suppressed when shmem is not enabled.

  * Enable const_refs_to_static (stabilized in 1.83) to prevent build
    errors with older compilers.

  * Use &raw const for bindings::drm_gem_shmem_vm_ops and add
    #[allow(unused_unsafe, reason = "Safe since Rust 1.82.0")].

  * Fix incorrect C Header path and minor spelling and formatting
    issues.

  * Drop shmem::Object::sg_table() as the current implementation is
    unsound.

    - Danilo ]
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
2026-03-27 21:38:40 +01:00
..
atomic_ext.c rust: helpers: Add i8/i16 atomic try_cmpxchg_relaxed helpers 2026-01-09 19:01:41 +08:00
atomic.c rust: helpers: Move #define __rust_helper out of atomic.c 2026-01-09 19:01:42 +08:00
auxiliary.c rust: auxiliary: add __rust_helper to helpers 2025-12-15 22:19:53 +01:00
barrier.c rust: barrier: Add __rust_helper to helpers 2026-01-09 19:01:41 +08:00
binder.c rust: binder: add __rust_helper to helpers 2025-12-29 12:10:47 +01:00
bitmap.c rust: bitmap: add __rust_helper to helpers 2026-01-06 12:14:10 -05:00
bitops.c bitmap updates for v6.20 2026-02-10 11:39:45 -08:00
blk.c rust: blk: Add __rust_helper to helpers 2026-01-09 19:01:41 +08:00
bug.c rust: bug: add __rust_helper to helpers 2026-01-26 03:48:25 +01:00
build_assert.c
build_bug.c rust: err: add __rust_helper to helpers 2026-01-26 03:49:04 +01:00
clk.c rust: clk: Add helpers for Rust code 2025-05-19 12:55:40 +05:30
completion.c rust: completion: Add __rust_helper to helpers 2026-01-09 19:01:41 +08:00
cpu.c rust: cpu: Add __rust_helper to helpers 2026-01-09 19:01:41 +08:00
cpufreq.c rust: cpufreq: add __rust_helper to helpers 2026-01-27 11:21:22 +05:30
cpumask.c rust: cpumask: add __rust_helper to helpers 2026-01-06 12:14:10 -05:00
cred.c rust: cred: add __rust_helper to helpers 2026-01-06 20:30:09 -05:00
device.c rust: device: add device name method 2026-03-24 23:51:23 +01:00
dma-resv.c rust: helpers: Add bindings/wrappers for dma_resv_lock 2026-03-27 20:46:56 +01:00
dma.c rust: dma: add missing __rust_helper annotations 2026-02-06 20:19:09 +01:00
drm.c rust: drm: gem: shmem: Add DRM shmem helper abstraction 2026-03-27 21:38:40 +01:00
err.c rust: err: add __rust_helper to helpers 2026-01-26 03:49:04 +01:00
fs.c rust: fs: add __rust_helper to helpers 2025-12-15 14:13:03 +01:00
gpu.c rust: gpu: Add GPU buddy allocator bindings 2026-03-23 21:41:47 +01:00
helpers.c rust: helpers: Add bindings/wrappers for dma_resv_lock 2026-03-27 20:46:56 +01:00
io.c rust: io: add __rust_helper to helpers 2025-12-15 22:26:10 +01:00
irq.c rust: irq: add __rust_helper to helpers 2025-12-15 22:26:10 +01:00
jump_label.c rust: add static_branch_unlikely for static_key_false 2024-11-04 16:21:44 -05:00
kunit.c rust: kunit: add __rust_helper to helpers 2026-01-05 15:32:03 -07:00
list.c rust: interop: Add list module for C linked list interface 2026-03-23 20:29:28 +01:00
maple_tree.c rust: maple_tree: add __rust_helper to helpers 2026-01-26 03:49:09 +01:00
mm.c rust: mm: add __rust_helper to helpers 2026-01-26 03:49:56 +01:00
mutex.c rust: sync: Add __rust_helper to helpers 2026-01-09 19:01:42 +08:00
of.c rust: of: add __rust_helper to helpers 2026-01-26 03:50:21 +01:00
page.c rust: mm: add __rust_helper to helpers 2026-01-26 03:49:56 +01:00
pci.c rust: pci: add __rust_helper to helpers 2025-12-15 22:39:11 +01:00
pid_namespace.c rust: pid_namespace: add __rust_helper to helpers 2025-12-15 14:13:03 +01:00
platform.c rust: platform: add __rust_helper to helpers 2025-12-15 22:39:42 +01:00
poll.c rust: poll: add __rust_helper to helpers 2025-12-15 14:13:04 +01:00
processor.c rust: processor: Add __rust_helper to helpers 2026-01-09 19:01:41 +08:00
property.c rust: property: add __rust_helper to helpers 2025-12-15 22:39:42 +01:00
pwm.c rust: pwm: Add __rust_helper to helpers 2026-01-20 18:52:43 +01:00
rbtree.c rust: rbtree: add __rust_helper to helpers 2026-01-26 03:50:41 +01:00
rcu.c rust: rcu: Add __rust_helper to helpers 2026-01-09 19:01:42 +08:00
refcount.c rust: refcount: Add __rust_helper to helpers 2026-01-09 19:01:42 +08:00
regulator.c rust: regulator: add __rust_helper to helpers 2025-12-14 19:37:55 +09:00
scatterlist.c rust: scatterlist: add __rust_helper to helpers 2025-12-15 22:39:42 +01:00
security.c rust: security: add __rust_helper to helpers 2026-01-06 20:30:09 -05:00
signal.c rust: task: Add __rust_helper to helpers 2026-01-09 19:01:42 +08:00
slab.c rust: slab: add __rust_helper to helpers 2026-01-26 03:50:50 +01:00
spinlock.c rust: sync: Add __rust_helper to helpers 2026-01-09 19:01:42 +08:00
sync.c rust: sync: Add __rust_helper to helpers 2026-01-09 19:01:42 +08:00
task.c rust: task: Add __rust_helper to helpers 2026-01-09 19:01:42 +08:00
time.c rust: time: Add __rust_helper to helpers 2026-01-09 19:01:42 +08:00
uaccess.c rust: uaccess: add __rust_helper to helpers 2026-01-26 03:51:16 +01:00
usb.c rust: usb: add __rust_helper to helpers 2026-01-07 16:12:15 +01:00
vmalloc.c rust: mm: add __rust_helper to helpers 2026-01-26 03:49:56 +01:00
wait.c rust: wait: Add __rust_helper to helpers 2026-01-09 19:01:42 +08:00
workqueue.c rust: workqueue: add __rust_helper to helpers 2026-01-26 03:51:31 +01:00
xarray.c rust: xarray: add __rust_helper to helpers 2026-01-15 10:01:23 +01:00