Re: [PATCH v2 5/6] rust: Add dma_fence abstractions

Philipp Stanner <[email protected]>
Newsgroups org.kernel.vger.rcu,org.freedesktop.lists.dri-devel,org.kernel.vger.linux-kernel,org.kernel.vger.linux-media,org.kernel.vger.rust-for-linux
Message-ID <[email protected]>
On Tue, 2026-06-16 at 15:47 +0300, Onur Özkan wrote:
> On Tue, 16 Jun 2026 10:28:17 +0200
> > +
> > +        // DriverFenceData is repr(C) and a Fence is its first member.
> > +        let fence_data_ptr = fence_ptr as *mut DriverFenceData<T>;
> 
> Either the field ordering on the type or this code is wrong because the first
> member of DriverFenceData is `rcu_head`.

Yeah, that's a bug introduced in this revision. Thx for pointing it
out. Already fixed it downstream.

I'm just wondering why my test did not blow up.

> > 
> > +}
> 
> I am unsure whether it is safe to cast the pointer in Fence::from_raw without
> Fence being #[repr(transparent)] as the layout compatibility is not guaranteed
> explicitly.

Shouldn't #[repr(C)] do that trick, too? Do you need both?

Who can answer that?


P.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.