Re: [PATCH v4 3/6] gpu: nova-core: gsp: logbuffer: add LogBuffers::init_arguments()
From: Danilo Krummrich
Date: Tue Dec 01 2026 - 09:22:25 EST
On Tue Dec 1, 2026 at 9:15 AM CET, Alexandre Courbot wrote:
> +/// Writer for the `LibosMemoryRegionInitArgument` array passed to the GSP bootloader.
> +struct LibosInitArgs<'a> {
> + buf: CoherentBox<'a, [LibosMemoryRegionInitArgument]>,
> + len: usize,
> +}
> +
> +impl<'a> LibosInitArgs<'a> {
> + /// Allocates a zeroed `LibosMemoryRegionInitArgument` array for `dev`.
> + fn new(dev: &'a device::Device<device::Bound>) -> Result<Self> {
> + Ok(Self {
> + buf: CoherentBox::zeroed_slice(
> + dev,
> + GSP_PAGE_SIZE / size_of::<LibosMemoryRegionInitArgument>(),
> + GFP_KERNEL,
> + )?,
> + len: 0,
> + })
> + }
> +
> + /// Appends an entry to the array.
> + fn push(&mut self, arg: impl Init<LibosMemoryRegionInitArgument>) -> Result {
> + self.buf.init_at(self.len, arg)?;
> + self.len += 1;
> + Ok(())
> + }
> +
> + /// Consumes the writer and returns the underlying coherent DMA allocation.
> + fn finish(self) -> Coherent<'a, [LibosMemoryRegionInitArgument]> {
> + self.buf.into()
> + }
> +}
NIT: Should this be named LibosBuilder instead? Or since it's not exactly the
builder pattern maybe just LibosWriter?