On Fri Dec 19, 2025 at 1:34 PM JST, Timur Tabi wrote: > On Fri, 2025-12-19 at 12:43 +0900, Alexandre Courbot wrote: >> >> Yes, the patch I sent in my previous message was in replacement of >> yours, not to be applied on top - I should have mentioned that. > > Ok, I will replace my patch with yours. > >> > and with the padding removed, doesn't this >> > >> > dma_write!(rmargs[0].inner = fw::GspArgumentsCached::new(&cmdq))?; >> > >> > now only copy the args and leave the padding completely uninitialized? >> > That's okay, I >> > think, I just >> > want to make sure I'm not missing anything. >> >> Since we call `alloc_coherent` with `__GFP_ZERO`, all memory will be >> initialized to zero before that line is run. It's not 100% ideal but >> does work. > > Ok, I get it now. You allocate the block, and then dma_write! memcpys the > GspArgumentsCached > that's on the stack to it. > > When you say it's not ideal, is that because it still has to do a memcpy from > the stack to the > DMA buffer, whereas Nouveau was able to write to the buffer directly?
It is not ideal because you can end up DMAing uninitialized data to the GSP if you don't allocate using `__GFP_ZERO`. In this case it is not a big issue as the data is not expected to be valid, and is never accessed through a slice, but it is not 100% bulletproof by design.
