Re: [RFC PATCH] drm: panthor: add dev_coredumpv support
From: Dave Airlie
Date: Fri Jul 12 2024 - 20:49:02 EST
On Sat, 13 Jul 2024 at 01:32, Danilo Krummrich <dakr@xxxxxxxxxx> wrote:
>
> On Fri, Jul 12, 2024 at 12:13:15PM -0300, Daniel Almeida wrote:
> >
> >
> > > On 12 Jul 2024, at 11:53, Danilo Krummrich <dakr@xxxxxxxxxx> wrote:
> > >
> > > You could also just define those structures in a C header directly and use it
> > > from Rust, can't you?
> > >
> >
> >
> > Sure, I am open to any approach here. Although this looks a bit reversed to me.
> >
> > i.e.: why should I declare these structs in a separate language and file, and then use them in Rust through bindgen? Sounds clunky.
>
> The kernel exposes the uAPI as C header files. You just choose to do the
> implementation in the kernel in Rust.
>
> Hence, I'd argue that the uAPI header is the actual source. So, we should
> generate stuff from those headers and not the other way around I think.
>
> >
> > Right now, they are declared right next to where they are used in the code, i.e.: in the same Rust file. And so long as they’re #[repr(C)] we know that an equivalent C version can generated by cbindgen.
> >
>
> I'm not sure whether it's a good idea to generate uAPI header files in general.
>
> How do we ensure that the generated header file are useful for userspace in
> terms of readability and documentation?
>
> How do we (easily) verify that changes in the Rust code don't break the uAPI by
> due to leading to changes in the generated header files?
>
> Do we have guarantees that future releases of cbindgen can't break anything?
I think I'm on the uapi should remain in C for now, we define uapi
types with the kernel types and we have downstream tools to scan and
parse them to deal with alignments and padding (I know FEX relies on
it), so I think we should be bindgen from uapi headers into rust for
now. There might be a future where this changes, but that isn't now
and I definitely don't want to mix C and rust uapi in one driver.
Dave.