On Fri, 2025-12-05 at 09:35 +0900, Alexandre Courbot wrote:
> With one caveat: `new` now returns a 4K object on the stack, which we
> definitely want to avoid. So maybe we can have a wrapper for things we
> want to align the 4K:
> 
>   #[repr(C)]
>   pub(crate) struct GspPageAligned<T> {
>     pub(crate) inner: T,
>     padding: [u8; GSP_PAGE_SIZE - core::mem::size_of::<T>()],
>   }

This doesn't seem to work.

error: generic parameters may not be used in const operations
   --> drivers/gpu/nova-core/gsp/fw.rs:894:56
    |
894 | ...::mem::size_of::<T>()],
    |                     ^ cannot perform const operation using `T`
    |

I've tried different things and they all generate various compilation errors.

I'll just post a v3 with my version, and then you can experiment with it to see 
if you can get
GspPageAligned aligned to work on top of it.

> 
> We would then allocate the CoherentAllocation using a
> `GspPageAligned<GspArgumentsCached>`, and initialize its useful data
> with:
> 
>   dma_write!(rmargs[0].inner = fw::GspArgumentsCached::new(&cmdq))?;

So I assume you mean this:

        let rmargs = 
CoherentAllocation::<GspPageAligned<GspArgumentsCached>>::alloc_coherent(
            dev,
            1,
            GFP_KERNEL | __GFP_ZERO,
        )?;
        dma_write!(rmargs[0].inner = fw::GspArgumentsCached::new(&cmdq))?;

Reply via email to