On Fri, 2026-01-30 at 08:31 +0000, Alice Ryhl wrote:
> On Wed, Jan 28, 2026 at 08:28:33PM -0600, Timur Tabi wrote:
> > [PATCH v6 3/7] gpu: nova-core: implement BinaryWriter for 
> > CoherentAllocation<u8>
> 
> The commit title says 'gpu: nova-core:' but this is primarily a change
> to rust/kernel/dma.rs, so it should say 'rust: dma:' or similar.

Ok.

> 
> > +// SAFETY: Sharing `&CoherentAllocation` across threads is safe if `T` is 
> > `Sync`, because
> > all
> > +// methods that access the buffer contents (`field_read`, `field_write`, 
> > `as_slice`,
> > +// `as_slice_mut`) are `unsafe`, and callers are responsible for ensuring 
> > no data races
> > occur.
> > +// The safe methods only return metadata or raw pointers whose use 
> > requires `unsafe`.
> > +unsafe impl<T: AsBytes + FromBytes + Sync> Sync for CoherentAllocation<T> 
> > {}
> 
> This change is unrelated to implementing BinaryWriter for
> CoherentAllocation.

Did you intend to reference this diff in gsp.rs?

 use kernel::{
+    debugfs,
     device,
     dma::{
         CoherentAllocation,

because that diff was mistakenly added to this commit.  However, I'm pretty 
sure the `Sync for
CoherentAllocation<T>` should be part of 'implement BinaryWriter for 
CoherentAllocation<u8>'
because debugfs::read_binary_file() requires T: BinaryWriter + Sync.

> > +impl debugfs::BinaryWriter for CoherentAllocation<u8> {
> > +    fn write_to_slice(
> > +        &self,
> > +        writer: &mut UserSliceWriter,
> > +        offset: &mut file::Offset,
> > +    ) -> Result<usize> {
> > +        if offset.is_negative() {
> > +            return Err(EINVAL);
> > +        }
> > +
> > +        let offset_val: usize = (*offset).try_into().map_err(|_| EINVAL)?;
> 
> If the user seeks to a large offset, this leads to EINVAL. But the
> correct behavior for a file is to simply return Ok(0) in such case.

Will fix in 7.  Thanks.

Reply via email to