[PATCH v2 1/2] drm/gpuvm: add deferred vm_bo cleanup

2025-09-20 Thread Alice Ryhl
thods can only be used with DRM_GPUVM_IMMEDIATE_MODE. Signed-off-by: Alice Ryhl --- drivers/gpu/drm/drm_gpuvm.c | 174 include/drm/drm_gpuvm.h | 26 +++ 2 files changed, 200 insertions(+) diff --git a/drivers/gpu/drm/drm_gpuvm.c b/drivers/gp

Re: [PATCH v2 2/2] panthor: use drm_gpuva_unlink_defer()

2025-09-18 Thread Alice Ryhl
On Thu, Sep 11, 2025 at 12:15:37PM +0200, Boris Brezillon wrote: > On Tue, 09 Sep 2025 13:36:23 + > Alice Ryhl wrote: > > > static void panthor_vma_init(struct panthor_vma *vma, u32 flags) > > @@ -2084,12 +2010,12 @@ static int panthor_gpuva_sm_step_map(struct >

[PATCH] rust: io: use const generics for read/write offsets

2025-09-18 Thread Alice Ryhl
Using build_assert! to assert that offsets are in bounds is really fragile and likely to result in spurious and hard-to-debug build failures. Therefore, build_assert! should be avoided for this case. Thus, update the code to perform the check in const evaluation instead. Signed-off-by: Alice Ryhl

Re: [PATCH v4 3/3] rust: Add dma_buf stub bindings

2025-09-12 Thread Alice Ryhl
On Thu, Sep 11, 2025 at 06:57:40PM -0400, Lyude Paul wrote: > In order to implement the gem export callback, we need a type to represent > struct dma_buf. So - this commit introduces a set of stub bindings for > dma_buf. These bindings provide a ref-counted DmaBuf object, but don't > currently impl

Re: [PATCH v4 0/3] rust/drm: Misc. gem bindings cleanup

2025-09-11 Thread Alice Ryhl
On Mon, Sep 08, 2025 at 02:46:35PM -0400, Lyude Paul wrote: > This is the first few patches that were originally part of the series to > introduce gem shmem bindings for rust into the Linux kernel, which can > be found here: > > https://lkml.org/lkml/2025/8/29/1533 > > These patches don't have an

Re: [PATCH v3] rust: drm: Introduce the Tyr driver for Arm Mali GPUs

2025-09-11 Thread Alice Ryhl
so > rust_platform_driver.rs. > > Lastly, the name "Tyr" is inspired by Norse mythology, reflecting ARM's > tradition of naming their GPUs after Nordic mythological figures and > places. > > Co-developed-by: Alice Ryhl > Signed-off-by: Alice Ryhl > Co-dev

Re: [PATCH v2 1/2] drm/gpuvm: add deferred vm_bo cleanup

2025-09-09 Thread Alice Ryhl
On Tue, Sep 09, 2025 at 04:20:32PM +0200, Thomas Hellström wrote: > On Tue, 2025-09-09 at 13:36 +0000, Alice Ryhl wrote: > > When using GPUVM in immediate mode, it is necessary to call > > drm_gpuvm_unlink() from the fence signalling critical path. However, > > unlink may

Re: [PATCH v2 1/2] drm/gpuvm: add deferred vm_bo cleanup

2025-09-09 Thread Alice Ryhl
On Tue, Sep 09, 2025 at 01:36:22PM +, Alice Ryhl wrote: > When using GPUVM in immediate mode, it is necessary to call > drm_gpuvm_unlink() from the fence signalling critical path. However, > unlink may call drm_gpuvm_bo_put(), which causes some challenges: > > 1. drm_gpuvm

[PATCH v2 0/2] Defer vm_bo cleanup in GPUVM with DRM_GPUVM_IMMEDIATE_MODE

2025-09-09 Thread Alice Ryhl
vm_bo cleanup. Take inspiration from that by moving the logic into GPUVM, and adjust Panthor to use the new GPUVM logic. Signed-off-by: Alice Ryhl --- Changes in v2: - Fix missing kfree in Panthor. - Rework mutex_lock() calls to be less confusing. - Add note about resv lock in drm_gpuvm_bo_is_dead(

[PATCH v2 2/2] panthor: use drm_gpuva_unlink_defer()

2025-09-09 Thread Alice Ryhl
preserved the behavior where panthor_gpuva_sm_step_map() drops the refcount right away rather than letting panthor_vm_cleanup_op_ctx() do it later. Signed-off-by: Alice Ryhl --- drivers/gpu/drm/panthor/panthor_mmu.c | 113 ++ 1 file changed, 19 insertions(+), 94

Re: [PATCH 1/2] drm/gpuvm: add deferred vm_bo cleanup

2025-09-09 Thread Alice Ryhl
On Tue, Sep 9, 2025 at 1:11 PM Thomas Hellström wrote: > > On Tue, 2025-09-09 at 12:47 +0200, Danilo Krummrich wrote: > > On 9/9/25 12:39 PM, Thomas Hellström wrote: > > > On 9/8/25 14:20, Danilo Krummrich wrote: > > > > On 9/8/25 2:11 PM, Boris Brezillon wrote: > > > > > On Mon, 08 Sep 2025 13:11

Re: [PATCH v4 0/3] rust/drm: Misc. gem bindings cleanup

2025-09-08 Thread Alice Ryhl
/gem.rs | 8 ++-- > rust/kernel/drm/driver.rs | 3 ++ > rust/kernel/drm/gem/mod.rs | 93 - > 3 files changed, 47 insertions(+), 57 deletions(-) For all 3 patches: Reviewed-by: Alice Ryhl

Re: [PATCH 1/2] drm/gpuvm: add deferred vm_bo cleanup

2025-09-08 Thread Alice Ryhl
On Mon, Sep 08, 2025 at 09:11:40AM +0200, Boris Brezillon wrote: > Hi Alice, > > On Sun, 7 Sep 2025 11:39:41 +0000 > Alice Ryhl wrote: > > > Yeah I guess we could have unlink remove the gpuva, but then allow the > > end-user to attach the gpuva to a list of gpu

[PULL] drm-rust-fixes 2025-09-05

2025-09-07 Thread Alice Ryhl
Hi Dave and Sima, Here's the first PR for the drm-rust-fixes branch. It includes the commit to add the drm-rust repository to MAINTAINERS. The following changes since commit b320789d6883cc00ac78ce83bccbfe7ed58afcf0: Linux 6.17-rc4 (2025-08-31 15:33:07 -0700) are available in the Git repositor

Re: [PATCH 1/2] drm/gpuvm: add deferred vm_bo cleanup

2025-09-07 Thread Alice Ryhl
On Sun, Sep 07, 2025 at 01:28:05PM +0200, Danilo Krummrich wrote: > On Sun Sep 7, 2025 at 1:15 PM CEST, Alice Ryhl wrote: > > On Sat, Sep 06, 2025 at 12:47:36AM +0200, Danilo Krummrich wrote: > >> On Fri Sep 5, 2025 at 8:18 PM CEST, Alice Ryhl wrote: > >> > On Fri

Re: [PATCH 1/2] drm/gpuvm: add deferred vm_bo cleanup

2025-09-07 Thread Alice Ryhl
On Sat, Sep 06, 2025 at 12:47:36AM +0200, Danilo Krummrich wrote: > On Fri Sep 5, 2025 at 8:18 PM CEST, Alice Ryhl wrote: > > On Fri, Sep 5, 2025 at 3:25 PM Boris Brezillon > > wrote: > >> On Fri, 05 Sep 2025 12:11:28 + > >> Alice Ryhl wrote: > >> &

Re: [PATCH 04/10] gpu: nova-core: Add a slice-buffer (sbuffer) datastructure

2025-09-07 Thread Alice Ryhl
On Wed, Aug 27, 2025 at 06:20:01PM +1000, Alistair Popple wrote: > From: Joel Fernandes > > A data structure that can be used to write across multiple slices which > may be out of order in memory. This lets SBuffer user correctly and > safely write out of memory order, without error-prone trackin

Re: [PATCH 1/2] drm/gpuvm: add deferred vm_bo cleanup

2025-09-05 Thread Alice Ryhl
On Fri, Sep 5, 2025 at 3:25 PM Boris Brezillon wrote: > > On Fri, 05 Sep 2025 12:11:28 +0000 > Alice Ryhl wrote: > > > When using GPUVM in immediate mode, it is necessary to call > > drm_gpuvm_unlink() from the fence signalling critical path. However, > > un

Re: [PATCH 2/2] panthor: use drm_gpuva_unlink_defer()

2025-09-05 Thread Alice Ryhl
On Fri, Sep 5, 2025 at 2:53 PM Boris Brezillon wrote: > > On Fri, 05 Sep 2025 12:11:29 +0000 > Alice Ryhl wrote: > > > static void panthor_vm_cleanup_op_ctx(struct panthor_vm_op_ctx *op_ctx, > > struct panthor_vm *vm) > > { >

[PATCH 1/2] drm/gpuvm: add deferred vm_bo cleanup

2025-09-05 Thread Alice Ryhl
thods can only be used with DRM_GPUVM_IMMEDIATE_MODE. Signed-off-by: Alice Ryhl --- drivers/gpu/drm/drm_gpuvm.c | 167 include/drm/drm_gpuvm.h | 26 +++ 2 files changed, 193 insertions(+) diff --git a/drivers/gpu/drm/drm_gpuvm.c b/drivers/gp

[PATCH 2/2] panthor: use drm_gpuva_unlink_defer()

2025-09-05 Thread Alice Ryhl
preserved the behavior where panthor_gpuva_sm_step_map() drops the refcount right away rather than letting panthor_vm_cleanup_op_ctx() do it later. Signed-off-by: Alice Ryhl --- drivers/gpu/drm/panthor/panthor_mmu.c | 112 ++ 1 file changed, 18 insertions(+), 94

[PATCH 0/2] Defer vm_bo cleanup in GPUVM with DRM_GPUVM_IMMEDIATE_MODE

2025-09-05 Thread Alice Ryhl
vm_bo cleanup. Take inspiration from that by moving the logic into GPUVM, and adjust Panthor to use the new GPUVM logic. Signed-off-by: Alice Ryhl --- Alice Ryhl (2): drm/gpuvm: add deferred vm_bo cleanup panthor: use drm_gpuva_unlink_defer() drivers/gpu/drm/drm_gpu

Re: [PATCH] MAINTAINERS: Add drm-rust tree for Rust DRM drivers and infrastructure

2025-09-05 Thread Alice Ryhl
driver > trees respectively. Until then, drm-rust provides a dedicated place to > coordinate development without disrupting existing workflows too much. > > Cc: Alice Ryhl > Cc: David Airlie > Cc: Simona Vetter > Cc: Maarten Lankhorst > Cc: Maxime Ripard > Cc: Th

Re: [PATCH v3 06/14] rust: drm: gem: Add raw_dma_resv() function

2025-09-04 Thread Alice Ryhl
On Sat, Aug 30, 2025 at 12:42 AM Lyude Paul wrote: > > For retrieving a pointer to the struct dma_resv for a given GEM object. We > also introduce it in a new trait, BaseObjectPrivate, which we automatically > implement for all gem objects and don't expose to users outside of the > crate. > > Sign

Re: [PATCH] MAINTAINERS: Add drm-rust tree for Rust DRM drivers and infrastructure

2025-09-04 Thread Alice Ryhl
driver > trees respectively. Until then, drm-rust provides a dedicated place to > coordinate development without disrupting existing workflows too much. > > Cc: Alice Ryhl > Cc: David Airlie > Cc: Simona Vetter > Cc: Maarten Lankhorst > Cc: Maxime Ripard > Cc: Th

Re: [PATCH] MAINTAINERS: Add drm-rust tree for Rust DRM drivers and infrastructure

2025-09-02 Thread Alice Ryhl
driver > trees respectively. Until then, drm-rust provides a dedicated place to > coordinate development without disrupting existing workflows too much. > > Cc: Alice Ryhl > Cc: David Airlie > Cc: Simona Vetter > Cc: Maarten Lankhorst > Cc: Maxime Ripard > Cc: Th

Re: [PATCH] drm/test: drm_exec: use kzalloc() to allocate GEM objects

2025-08-29 Thread Alice Ryhl
nings being treated as errors > make[6]: *** [scripts/Makefile.build:287: > drivers/gpu/drm/tests/drm_exec_test.o] Error 1 > make[6]: *** Waiting for unfinished jobs > > In order to fix this, allocate the GEM objects in test_prepare_array() > with kzalloc(), rather than placing the

Re: [PATCH v3 3/3] gpuvm: remove gem.gpuva.lock_dep_map

2025-08-28 Thread Alice Ryhl
On Thu, Aug 28, 2025 at 11:27 AM Danilo Krummrich wrote: > > On Wed Aug 27, 2025 at 3:38 PM CEST, Alice Ryhl wrote: > > #ifdef CONFIG_LOCKDEP > > -/** > > - * drm_gem_gpuva_set_lock() - Set the lock protecting accesses to the > > gpuva list. > > - * @obj: th

[PATCH v3 1/3] drm_gem: add mutex to drm_gem_object.gpuva

2025-08-27 Thread Alice Ryhl
m_bo could lead to the GEM object getting destroyed. The requirement that GEM object cleanup is fence signalling safe is dubious and likely to be violated in practice. Panthor already has its own custom implementation of postponing vm_bo cleanup. Reviewed-by: Boris Brezillon Signed-off-by:

[PATCH v3 3/3] gpuvm: remove gem.gpuva.lock_dep_map

2025-08-27 Thread Alice Ryhl
e the intent is that the flag will also cause vm_bo cleanup to become deferred. However, that will happen in a follow-up patch. Reviewed-by: Boris Brezillon Signed-off-by: Alice Ryhl --- drivers/gpu/drm/drm_gpuvm.c | 30 - drivers/gpu/drm/panthor/panthor_gem.c

[PATCH v3 2/3] panthor: use drm_gem_object.gpuva.lock instead of gpuva_list_lock

2025-08-27 Thread Alice Ryhl
Now that drm_gem_object has a dedicated mutex for the gpuva list that is intended to be used in cases that must be fence signalling safe, use it in Panthor. Reviewed-by: Boris Brezillon Signed-off-by: Alice Ryhl --- drivers/gpu/drm/panthor/panthor_gem.c | 4 +--- drivers/gpu/drm/panthor

[PATCH v3 0/3] Add mutex to drm_gem_object.gpuva list

2025-08-27 Thread Alice Ryhl
See the first patch for motivation. Signed-off-by: Alice Ryhl --- Changes in v3: - Documentation improvements in patch 1 and 3. - No code changes. - Link to v2: https://lore.kernel.org/r/20250822-gpuva-mutex-in-gem-v2-0-c41a10d1d...@google.com Changes in v2: - Move the mutex_destroy() call to

Re: [PATCH v2 3/3] gpuvm: remove gem.gpuva.lock_dep_map

2025-08-27 Thread Alice Ryhl
On Fri, Aug 22, 2025 at 12:25 PM Danilo Krummrich wrote: > > On Fri Aug 22, 2025 at 11:28 AM CEST, Alice Ryhl wrote: > > diff --git a/include/drm/drm_gpuvm.h b/include/drm/drm_gpuvm.h > > index > > 4a22b9d848f7b3d5710ca554f5b01556abf95985..598ba376b9430cdd4ab7bacdc15d

[PATCH] drm/gpuvm: fix various typos in .c and .h gpuvm file

2025-08-25 Thread Alice Ryhl
After working with this code for a while, I came across several typos. This patch fixes them. Signed-off-by: Alice Ryhl --- drivers/gpu/drm/drm_gpuvm.c | 80 ++--- include/drm/drm_gpuvm.h | 10 +++--- 2 files changed, 45 insertions(+), 45 deletions

Re: [PATCH 1/5] rust: transmute: add `from_bytes_copy` method to `FromBytes` trait

2025-08-22 Thread Alice Ryhl
n owned value > that is populated using an unaligned read, removing the lifetime > constraint and making it usable even on non-aligned byte slices. > > Signed-off-by: Alexandre Courbot Reviewed-by: Alice Ryhl

Re: [PATCH v2 3/3] gpuvm: remove gem.gpuva.lock_dep_map

2025-08-22 Thread Alice Ryhl
On Fri, Aug 22, 2025 at 12:25:34PM +0200, Danilo Krummrich wrote: > On Fri Aug 22, 2025 at 11:28 AM CEST, Alice Ryhl wrote: > > diff --git a/include/drm/drm_gpuvm.h b/include/drm/drm_gpuvm.h > > index > > 4a22b9d848f7b3d5710ca554f5b01556abf95985..598ba376b9430cdd4ab

Re: [PATCH v2 1/3] drm_gem: add mutex to drm_gem_object.gpuva

2025-08-22 Thread Alice Ryhl
On Fri, Aug 22, 2025 at 11:52:21AM +0200, Boris Brezillon wrote: > On Fri, 22 Aug 2025 09:28:24 + > > Maybe it's time we start moving some bits of the gpuva field docs next > to the fields they describe: > > /** >* @gpuva: Fields used by GPUVM to manage mappings pointing to this

[PATCH v2 0/3] Add mutex to drm_gem_object.gpuva list

2025-08-22 Thread Alice Ryhl
See the first patch for motivation. Signed-off-by: Alice Ryhl --- Changes in v2: - Move the mutex_destroy() call to drm_gem_private_object_fini() - Add a third patch to get rid of the lockdep map. - Link to v1: https://lore.kernel.org/r/20250814-gpuva-mutex-in-gem-v1-0-e202cbfe6...@google.com

[PATCH v2 1/3] drm_gem: add mutex to drm_gem_object.gpuva

2025-08-22 Thread Alice Ryhl
m_bo could lead to the GEM object getting destroyed. The requirement that GEM object cleanup is fence signalling safe is dubious and likely to be violated in practice. Panthor already has its own custom implementation of postponing vm_bo cleanup. Signed-off-by: Alice Ryhl --- drivers/gpu/drm/drm

[PATCH v2 3/3] gpuvm: remove gem.gpuva.lock_dep_map

2025-08-22 Thread Alice Ryhl
e the intent is that the flag will also cause vm_bo cleanup to become deferred. However, that will happen in a follow-up patch. Signed-off-by: Alice Ryhl --- drivers/gpu/drm/drm_gpuvm.c | 30 +-- drivers/gpu/drm/panthor/panthor_gem.c | 1 - drivers/gpu/drm/pa

[PATCH v2 2/3] panthor: use drm_gem_object.gpuva.lock instead of gpuva_list_lock

2025-08-22 Thread Alice Ryhl
Now that drm_gem_object has a dedicated mutex for the gpuva list that is intended to be used in cases that must be fence signalling safe, use it in Panthor. Reviewed-by: Boris Brezillon Signed-off-by: Alice Ryhl --- drivers/gpu/drm/panthor/panthor_gem.c | 4 +--- drivers/gpu/drm/panthor

Re: [PATCH 1/2] drm_gem: add mutex to drm_gem_object.gpuva

2025-08-14 Thread Alice Ryhl
On Thu, Aug 14, 2025 at 4:59 PM Danilo Krummrich wrote: > > On Thu Aug 14, 2025 at 3:53 PM CEST, Alice Ryhl wrote: > > There are two main ways that GPUVM might be used: > > > > * staged mode, where VM_BIND ioctls update the GPUVM immediately so that > > the GPUV

[PATCH 2/2] panthor: use drm_gem_object.gpuva.lock instead of gpuva_list_lock

2025-08-14 Thread Alice Ryhl
Now that drm_gem_object has a dedicated mutex for the gpuva list that is intended to be used in cases that must be fence signalling safe, use it in Panthor. Signed-off-by: Alice Ryhl --- drivers/gpu/drm/panthor/panthor_gem.c | 4 +--- drivers/gpu/drm/panthor/panthor_gem.h | 12

[PATCH 1/2] drm_gem: add mutex to drm_gem_object.gpuva

2025-08-14 Thread Alice Ryhl
m_bo could lead to the GEM object getting destroyed. The requirement that GEM object cleanup is fence signalling safe is dubious and likely to be violated in practice. Panthor already has its own custom implementation of postponing vm_bo cleanup. Signed-off-by: Alice Ryhl --- drivers/gpu/drm/drm

[PATCH 0/2] Add mutex to drm_gem_object.gpuva list

2025-08-14 Thread Alice Ryhl
See the first patch for motivation. Signed-off-by: Alice Ryhl --- Alice Ryhl (2): drm_gem: add mutex to drm_gem_object.gpuva panthor: use drm_gem_object.gpuva.lock instead of gpuva_list_lock drivers/gpu/drm/drm_gem.c | 2 ++ drivers/gpu/drm/panthor/panthor_gem.c | 4

Re: [PATCH v2 00/19] rust: replace `kernel::c_str!` with C-Strings

2025-08-14 Thread Alice Ryhl
On Wed, Aug 13, 2025 at 09:11:51PM +0100, Mark Brown wrote: > On Wed, Aug 13, 2025 at 11:59:10AM -0400, Tamir Duberstein wrote: > > This series depends on step 3[0] which depends on steps 2a[1] and 2b[2] > > which both depend on step 1[3]. > > > > This series also has a minor merge conflict with a

Re: [PATCH] MAINTAINERS: entry for DRM GPUVM

2025-08-08 Thread Alice Ryhl
On Fri, Aug 08, 2025 at 11:20:49AM +0200, Danilo Krummrich wrote: > GPUVM deserves a bit more coordination, also given the upcoming Rust > work for GPUVM, hence add a dedicated maintainers entry for DRM GPUVM. > > Cc: Boris Brezillon > Cc: Matthew Brost > Cc: Thomas Hellström

Re: [PATCH 2/4] rust: drm: ensure kmalloc() compatible Layout

2025-08-04 Thread Alice Ryhl
d create a proper > kmalloc() compatible Layout. > > Fixes: 1e4b8896c0f3 ("rust: drm: add device abstraction") > Signed-off-by: Danilo Krummrich Reviewed-by: Alice Ryhl

Re: [PATCH 2/4] rust: drm: ensure kmalloc() compatible Layout

2025-08-04 Thread Alice Ryhl
On Fri, Aug 1, 2025 at 11:29 AM Danilo Krummrich wrote: > > On Fri Aug 1, 2025 at 11:18 AM CEST, Alice Ryhl wrote: > > On Thu, Jul 31, 2025 at 05:48:07PM +0200, Danilo Krummrich wrote: > >> drm::Device is allocated through __drm_dev_alloc() (which uses > >> kmalloc(

Re: [PATCH 2/4] rust: drm: ensure kmalloc() compatible Layout

2025-08-01 Thread Alice Ryhl
On Thu, Jul 31, 2025 at 05:48:07PM +0200, Danilo Krummrich wrote: > drm::Device is allocated through __drm_dev_alloc() (which uses > kmalloc()) and the driver private data, ::Data, is > initialized in-place. > > Due to the order of fields in drm::Device > > pub struct Device { > dev: Opaqu

Re: [PATCH 1/4] rust: alloc: replace aligned_size() with Kmalloc::aligned_layout()

2025-08-01 Thread Alice Ryhl
h have to call subsystem specific kmalloc() based > allocation primitives directly, can make use of it. > > Fixes: 8a799831fc63 ("rust: alloc: implement `ReallocFunc`") > Signed-off-by: Danilo Krummrich I guess vmalloc handles alignment in a different way ... ok makes sense to me. Reviewed-by: Alice Ryhl

Re: [PATCH 4/4] rust: drm: don't pass the address of drm::Device to drm_dev_put()

2025-08-01 Thread Alice Ryhl
} I think it would somewhat more consistent to use the naming raw_get() or cast_into(), but I am ok with this naming too. Reviewed-by: Alice Ryhl Alice

Re: [PATCH v2] drm/panic: Add a u64 divide by 10 for arm32

2025-08-01 Thread Alice Ryhl
-project/issues/37280 [1] > Reported-by: Andrei Lalaev > Closes: > https://lore.kernel.org/dri-devel/c0a2771c-f3f5-4d4c-aa82-d673b3c5c...@gmail.com/ > Fixes: 675008f196ca ("drm/panic: Use a decimal fifo to avoid u64 by u64 > divide") > Signed-off-by: Jocelyn Falempe Reviewed-by: Alice Ryhl

Re: [PATCH v5] rust: drm: Drop the use of Opaque for ioctl arguments

2025-07-21 Thread Alice Ryhl
. > > Signed-off-by: Beata Michalska > Acked-by: Danilo Krummrich > Reviewed-by: Boqun Feng I'm guessing this should go through the DRM tree? Reviewed-by: Alice Ryhl

Re: [PATCH v2] gpu: nova-core: vbios: change PmuLookupTableEntry to relax alignment

2025-07-14 Thread Alice Ryhl
On Mon, Jul 14, 2025 at 4:49 PM Joel Fernandes wrote: > > Hello, Rhys, > > On Mon, Jul 14, 2025 at 04:02:23AM -0700, Rhys Lloyd wrote: > > Instead of the data field containing a u32 and changing the alignment, > > change data to [u8; 4] and convert to u32 with a helper function. > > Removes anothe

[PATCH v2 1/2] device: rust: rename Device::as_ref() to Device::from_raw()

2025-07-11 Thread Alice Ryhl
::from_raw, fs::File::from_raw_file, Kuid::from_raw, ARef::from_raw, SeqFile::from_raw, VmaNew::from_raw, Io::from_raw. Link: https://lore.kernel.org/r/aCd8D5IA0RXZvtcv@pollux Signed-off-by: Alice Ryhl --- rust/kernel/auxiliary.rs | 2 +- rust/kernel/cpu.rs| 2 +- rust/kernel/device.rs

[PATCH v2 2/2] drm: rust: rename as_ref() to from_raw() for drm constructors

2025-07-11 Thread Alice Ryhl
::from_raw, fs::File::from_raw_file, Kuid::from_raw, ARef::from_raw, SeqFile::from_raw, VmaNew::from_raw, Io::from_raw. Link: https://lore.kernel.org/r/aCd8D5IA0RXZvtcv@pollux Signed-off-by: Alice Ryhl --- rust/kernel/drm/device.rs | 2 +- rust/kernel/drm/file.rs| 8 rust/kernel

[PATCH v2 0/2] Rename Device::as_ref() to from_raw()

2025-07-11 Thread Alice Ryhl
::from_raw, fs::File::from_raw_file, Kuid::from_raw, ARef::from_raw, SeqFile::from_raw, VmaNew::from_raw, Io::from_raw. For more, see: https://lore.kernel.org/r/aCd8D5IA0RXZvtcv@pollux Signed-off-by: Alice Ryhl --- Changes in v2: - Split into two patches. - Use a different lore link. - Link to v1

Re: [PATCH 0/6] Replace `kernel::str::CStr` with `core::ffi::CStr` (cycle 1)

2025-07-10 Thread Alice Ryhl
str.rs| 97 > --- > samples/rust/rust_print_main.rs | 2 +- > 10 files changed, 83 insertions(+), 50 deletions(-) > --- > base-commit: 769e324b66b0d92d04f315d0c45a0f72737c7494 > change-id: 20250704-core-cstr-prepare-9b9e6a7bd57e > > Best regards, > -- > Tamir Duberstein > Reviewed-by: Alice Ryhl

Re: [PATCH] drm: rust: rename Device::as_ref() to Device::from_raw()

2025-07-09 Thread Alice Ryhl
On Wed, Jul 9, 2025 at 4:07 PM Danilo Krummrich wrote: > > On Wed Jul 9, 2025 at 3:53 PM CEST, Alice Ryhl wrote: > > The prefix as_* should not be used for a constructor. Constructors > > usually use the prefix from_* instead. > > > > Some prior art in the stdlib: Bo

[PATCH] drm: rust: rename Device::as_ref() to Device::from_raw()

2025-07-09 Thread Alice Ryhl
::from_raw, fs::File::from_raw_file, Kuid::from_raw, ARef::from_raw, SeqFile::from_raw, VmaNew::from_raw, Io::from_raw. Link: https://lore.kernel.org/r/aCZYcs6Aj-cz81qs@pollux Signed-off-by: Alice Ryhl --- rust/kernel/auxiliary.rs | 2 +- rust/kernel/cpu.rs | 2 +- rust/kernel

Re: [PATCH 4/6] rust: str: remove unnecessary qualification

2025-07-05 Thread Alice Ryhl
On Fri, Jul 4, 2025 at 10:16 PM Tamir Duberstein wrote: > > `core::ffi::*` is in the prelude, which is imported here. > > Signed-off-by: Tamir Duberstein Reviewed-by: Alice Ryhl

Re: [PATCH] rust: drm: device: drop_in_place() the drm::Device in release()

2025-07-03 Thread Alice Ryhl
27;s release callback. > > Fixes: 1e4b8896c0f3 ("rust: drm: add device abstraction") > Signed-off-by: Danilo Krummrich Reviewed-by: Alice Ryhl

Re: [PATCH v12 0/5] rust: replace kernel::str::CStr w/ core::ffi::CStr

2025-07-01 Thread Alice Ryhl
people to never use core::ffi as the integer types are wrong, and I think it would be nice if we can continue to tell people "never use core::ffi". Either way, for the whole series: Reviewed-by: Alice Ryhl Alice

Re: [PATCH] drm/panic: Add a u64 divide by 10 for arm32

2025-06-27 Thread Alice Ryhl
On Fri, Jun 27, 2025 at 11:41 AM Jocelyn Falempe wrote: > > On 32bits ARM, u64 divided by a constant is not optimized to a > multiply by inverse by the compiler [1]. > So do the multiply by inverse explicitly for this architecture. > > Link: https://github.com/llvm/llvm-project/issues/37280 [1] >

[PATCH v2 0/2] Add Opaque::cast_from

2025-06-24 Thread Alice Ryhl
t changing the inner type. Also rename raw_get() to cast_into() for naming consistency. Signed-off-by: Alice Ryhl --- Changes in v2: - Use new naming, and rename raw_get(). - Link to v1: https://lore.kernel.org/r/20250617-opaque-from-raw-v1-1-a2e99efa3...@google.com --- Alice Ryhl (2): rust:

[PATCH v2 1/2] rust: types: add Opaque::cast_from

2025-06-24 Thread Alice Ryhl
t changing the inner type. Also update the docs to reflect this as well as some existing users. Signed-off-by: Alice Ryhl --- rust/kernel/drm/device.rs | 4 +--- rust/kernel/drm/gem/mod.rs | 4 +--- rust/kernel/lib.rs | 7 +++ rust/kernel/types.rs | 5 + 4 files changed, 14

[PATCH v2 2/2] rust: types: rename Opaque::raw_get to cast_into

2025-06-24 Thread Alice Ryhl
. However, I could not find a great naming scheme that works with raw_get(). The previous version of this patch used from_raw(), but functions of that name typically have a different signature, so that's not a great option. Suggested-by: Danilo Krummrich Signed-off-by: Alice Ryhl --- rust/k

Re: [PATCH] rust: drm: Drop the use of Opaque for ioctl arguments

2025-06-19 Thread Alice Ryhl
On Thu, Jun 19, 2025 at 1:01 PM Benno Lossin wrote: > > On Thu Jun 19, 2025 at 12:55 PM CEST, Danilo Krummrich wrote: > > On Thu, Jun 19, 2025 at 12:21:02PM +0200, Beata Michalska wrote: > >> diff --git a/rust/kernel/drm/ioctl.rs b/rust/kernel/drm/ioctl.rs > >> index 445639404fb7..12b296131672 100

Re: [PATCH] rust: types: add Opaque::from_raw

2025-06-18 Thread Alice Ryhl
On Tue, Jun 17, 2025 at 03:54:19PM +0200, Danilo Krummrich wrote: > On Tue, Jun 17, 2025 at 01:36:47PM +0000, Alice Ryhl wrote: > > Since commit b20fbbc08a36 ("rust: check type of `$ptr` in > > `container_of!`") we have enforced that the field pointer passed to > &g

[PATCH] rust: types: add Opaque::from_raw

2025-06-17 Thread Alice Ryhl
anging the inner type. Signed-off-by: Alice Ryhl --- rust/kernel/drm/device.rs | 4 +--- rust/kernel/drm/gem/mod.rs | 4 +--- rust/kernel/lib.rs | 7 +++ rust/kernel/types.rs | 5 + 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/rust/kernel/drm/device

Re: [PATCH v2 0/6] rust: add support for port io

2025-06-16 Thread Alice Ryhl
On Wed, May 14, 2025 at 12:58 PM Andrew Ballance wrote: > > currently the rust `Io` type maps to the c read{b, w, l, q}/write{b, w, l, q} > functions and have no support for port io. this can be a problem for pci::Bar > because the pointer returned by pci_iomap can be either PIO or MMIO [0]. > > t

Re: [PATCH v11 3/5] rust: replace `CStr` with `core::ffi::CStr`

2025-06-02 Thread Alice Ryhl
On Fri, May 30, 2025 at 08:27:44AM -0400, Tamir Duberstein wrote: > `kernel::ffi::CStr` was introduced in commit d126d2380131 ("rust: str: > add `CStr` type") in November 2022 as an upstreaming of earlier work > that was done in May 2021[0]. That earlier work, having predated the > inclusion of `CS

Re: [PATCH v11 4/5] rust: replace `kernel::c_str!` with C-Strings

2025-06-02 Thread Alice Ryhl
On Fri, May 30, 2025 at 08:27:45AM -0400, Tamir Duberstein wrote: > C-String literals were added in Rust 1.77. Replace instances of > `kernel::c_str!` with C-String literals where possible and rename > `kernel::c_str!` to `str_to_cstr!` to clarify its intended use. > > Closes: https://github.com/R

Re: [PATCH v4 04/20] rust: add new `num` module with useful integer operations

2025-05-28 Thread Alice Ryhl
On Wed, May 21, 2025 at 8:45 AM Alexandre Courbot wrote: > > Introduce the `num` module, featuring the `NumExt` extension trait > that expands unsigned integers with useful operations for the kernel. > > These are to be used by the nova-core driver, but they are so ubiquitous > that other drivers

Re: [PATCH v10 0/5] rust: replace kernel::str::CStr w/ core::ffi::CStr

2025-05-28 Thread Alice Ryhl
On Sat, May 24, 2025 at 04:33:00PM -0400, Tamir Duberstein wrote: > This picks up from Michal Rostecki's work[0]. Per Michal's guidance I > have omitted Co-authored tags, as the end result is quite different. > > Link: > https://lore.kernel.org/rust-for-linux/20240819153656.28807-2-vadorov...@pro

Re: [PATCH v10 4/5] rust: replace `kernel::c_str!` with C-Strings

2025-05-28 Thread Alice Ryhl
On Mon, May 26, 2025 at 06:29:46PM -0400, Tamir Duberstein wrote: > On Mon, May 26, 2025 at 11:04 AM Benno Lossin wrote: > > > > On Sat May 24, 2025 at 10:33 PM CEST, Tamir Duberstein wrote: > > > +macro_rules! c_str_avoid_literals { > > > > I don't like this name, how about `concat_to_c_str` or >

Re: [PATCH v10 2/5] rust: support formatting of foreign types

2025-05-27 Thread Alice Ryhl
On Tue, May 27, 2025 at 12:18 AM Tamir Duberstein wrote: > > > +} > > > + > > > +fn make_ident<'a, T: IntoIterator>( > > > +span: Span, > > > +names: T, > > > +) -> impl Iterator + use<'a, T> { > > > +names.into_iter().flat_map(move |name| { > > > +[ > > > +TokenTre

Re: [PATCH v3 4/5] print: use new #[export] macro for rust_fmt_argument

2025-03-03 Thread Alice Ryhl
On Mon, Mar 3, 2025 at 10:46 AM Andy Shevchenko wrote: > > On Mon, Mar 03, 2025 at 08:45:15AM +, Alice Ryhl wrote: > > This moves the rust_fmt_argument function over to use the new #[export] > > macro, which will verify at compile-time that the function signature > >

[PATCH v3 4/5] print: use new #[export] macro for rust_fmt_argument

2025-03-03 Thread Alice Ryhl
This moves the rust_fmt_argument function over to use the new #[export] macro, which will verify at compile-time that the function signature matches what is in the header file. Reviewed-by: Andreas Hindborg Reviewed-by: Tamir Duberstein Acked-by: Greg Kroah-Hartman Signed-off-by: Alice Ryhl

Re: [PATCH v2 5/5] panic_qr: use new #[export] macro

2025-03-03 Thread Alice Ryhl
On Fri, Feb 28, 2025 at 6:15 PM Tamir Duberstein wrote: > > On Fri, Feb 28, 2025 at 12:08 PM Alice Ryhl wrote: > > > > On Fri, Feb 28, 2025 at 4:55 PM Tamir Duberstein wrote: > > > > > > On Fri, Feb 28, 2025 at 7:41 AM Alice Ryhl wrote: > > > &g

[PATCH v3 2/5] rust: macros: support additional tokens in quote!

2025-03-03 Thread Alice Ryhl
Kroah-Hartman Signed-off-by: Alice Ryhl --- rust/macros/quote.rs | 27 +-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/rust/macros/quote.rs b/rust/macros/quote.rs index 33a199e4f176..31b7ebe504f4 100644 --- a/rust/macros/quote.rs +++ b/rust/macros/quo

[PATCH v3 5/5] panic_qr: use new #[export] macro

2025-03-03 Thread Alice Ryhl
a header file so it can be included in the Rust bindings helper, and the extern keyword is removed as it is unnecessary. Reviewed-by: Andreas Hindborg Reviewed-by: Tamir Duberstein Acked-by: Simona Vetter Acked-by: Greg Kroah-Hartman Signed-off-by: Alice Ryhl --- drivers/gpu/drm/d

[PATCH v3 3/5] rust: add #[export] macro

2025-03-03 Thread Alice Ryhl
. Reviewed-by: Tamir Duberstein Reviewed-by: Andreas Hindborg Acked-by: Greg Kroah-Hartman Signed-off-by: Alice Ryhl --- rust/kernel/prelude.rs | 2 +- rust/macros/export.rs | 29 + rust/macros/helpers.rs | 19 ++- rust/macros/lib.rs | 24

[PATCH v3 1/5] rust: fix signature of rust_fmt_argument

2025-03-03 Thread Alice Ryhl
`%pA` format specifier") Reviewed-by: Tamir Duberstein Acked-by: Greg Kroah-Hartman Signed-off-by: Alice Ryhl --- lib/vsprintf.c | 2 +- rust/kernel/print.rs | 7 +++ 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 56fe96319292..a

[PATCH v3 0/5] Check Rust signatures at compile time

2025-03-03 Thread Alice Ryhl
The main commit of this series is "rust: add #[export] macro". Signed-off-by: Alice Ryhl --- Changes in v3: - Reword commit message about cbindgen to remove cargo comment. - Add # token to quote! macro and mention allow(unused_mut) warning. - Use quote! macro for #[no_mangle] in #[export

Re: [PATCH v2 3/5] rust: add #[export] macro

2025-03-03 Thread Alice Ryhl
On Fri, Feb 28, 2025 at 4:40 PM Tamir Duberstein wrote: > > On Fri, Feb 28, 2025 at 7:40 AM Alice Ryhl wrote: > > > > Rust has two different tools for generating function declarations to > > call across the FFI boundary: > > > > * bindgen. Generat

Re: [PATCH v2 2/5] rust: macros: support additional tokens in quote!

2025-03-03 Thread Alice Ryhl
On Fri, Feb 28, 2025 at 4:26 PM Tamir Duberstein wrote: > > On Fri, Feb 28, 2025 at 7:42 AM Alice Ryhl wrote: > > > > This gives the quote! macro support for the following additional tokens: > > > > * The = token. > > * The _ token. > > *

Re: [PATCH v2 5/5] panic_qr: use new #[export] macro

2025-02-28 Thread Alice Ryhl
On Fri, Feb 28, 2025 at 4:55 PM Tamir Duberstein wrote: > > On Fri, Feb 28, 2025 at 7:41 AM Alice Ryhl wrote: > > > > This validates at compile time that the signatures match what is in the > > header file. It highlights one annoyance with the compile-time check, > >

Re: [PATCH v2 4/5] print: use new #[export] macro for rust_fmt_argument

2025-02-28 Thread Alice Ryhl
On Fri, Feb 28, 2025 at 4:37 PM Andy Shevchenko wrote: > > On Fri, Feb 28, 2025 at 12:39:33PM +, Alice Ryhl wrote: > > This moves the rust_fmt_argument function over to use the new #[export] > > macro, which will verify at compile-time that the function signature > >

Re: [PATCH v2 5/5] panic_qr: use new #[export] macro

2025-02-28 Thread Alice Ryhl
On Fri, Feb 28, 2025 at 4:34 PM Andy Shevchenko wrote: > > On Fri, Feb 28, 2025 at 12:39:34PM +, Alice Ryhl wrote: > > This validates at compile time that the signatures match what is in the > > header file. It highlights one annoyance with the compile-time check, > &

[PATCH v2 2/5] rust: macros: support additional tokens in quote!

2025-02-28 Thread Alice Ryhl
} else { #name }; }; where #name has type Ident. Signed-off-by: Alice Ryhl --- rust/macros/quote.rs | 21 +++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/rust/macros/quote.rs b/rust/macros/quote.rs index 33a199e4f176

Re: [PATCH v2 0/5] Check Rust signatures at compile time

2025-02-28 Thread Alice Ryhl
On Fri, Feb 28, 2025 at 2:12 PM Miguel Ojeda wrote: > > On Fri, Feb 28, 2025 at 1:40 PM Alice Ryhl wrote: > > > > This is because cbindgen assumes a > > cargo-based buildsystem, so it is not compatible with the kernel's build > > system. > > I don't

[PATCH v2 5/5] panic_qr: use new #[export] macro

2025-02-28 Thread Alice Ryhl
pected unsafe fn, found safe fn | = note: expected fn item `unsafe extern "C" fn(_, _) -> _ {kernel::bindings::drm_panic_qr_max_data_size}` found fn item `extern "C" fn(_, _) -> _ {drm_panic_qr_max_data_size}` Reviewed-by: Andreas Hindborg Signe

[PATCH v2 4/5] print: use new #[export] macro for rust_fmt_argument

2025-02-28 Thread Alice Ryhl
This moves the rust_fmt_argument function over to use the new #[export] macro, which will verify at compile-time that the function signature matches what is in the header file. Reviewed-by: Andreas Hindborg Signed-off-by: Alice Ryhl --- I'm not sure which header file to put this in. Any a

[PATCH v2 3/5] rust: add #[export] macro

2025-02-28 Thread Alice Ryhl
c_void) -> *mut i8 {print::rust_fmt_argument}` It is unfortunate that the error message starts out by saying "`if` and `else` have incompatible types", but I believe the rest of the error message is reasonably clear and not too confusing. Signed-off-by: Alice Ryhl ---

[PATCH v2 1/5] rust: fix signature of rust_fmt_argument

2025-02-28 Thread Alice Ryhl
-> *mut i8 {print::rust_fmt_argument}` The error may be different depending on the architecture. To fix this, change the void pointer argument to use a const pointer, and change the imports to use crate::ffi instead of core::ffi for integer types. Fixes: 787983da7718 ("vsprintf: add new `

[PATCH v2 0/5] Check Rust signatures at compile time

2025-02-28 Thread Alice Ryhl
Please see its commit message for more details. Signed-off-by: Alice Ryhl --- Changes in v2: - Various improvements to documentation. - Split out quote! changes into its own commit. - Link to v1: https://lore.kernel.org/r/20250227-export-macro-v1-0-948775fc3...@google.com --- Alice Ryhl (5):

Re: [PATCH 0/4] Check Rust signatures at compile time

2025-02-28 Thread Alice Ryhl
On Thu, Feb 27, 2025 at 8:31 PM Greg Kroah-Hartman wrote: > > On Thu, Feb 27, 2025 at 05:01:58PM +, Alice Ryhl wrote: > > Signed-off-by: Alice Ryhl > > It's a bit odd to sign off on a 0/X email with no patch or description > :) > > Seriously, nice work! Thi

Re: [PATCH 2/4] rust: add #[export] macro

2025-02-28 Thread Alice Ryhl
On Fri, Feb 28, 2025 at 9:20 AM Andreas Hindborg wrote: > > "Alice Ryhl" writes: > > > This macro behaves like #[no_mangle], but also performs an assertion > > that the Rust function has the same signature as what is declared in the > > C header. > >

  1   2   >