From: John Hubbard <[email protected]> `Gsp::new()` names each log buffer in the init argument array itself, which requires the buffers to be visible outside of their module.
Move that code into `LogBuffers::init_arguments()`, and add `LogBuffers::COUNT` for the index of the argument that follows. No functional change. Signed-off-by: John Hubbard <[email protected]> Signed-off-by: Alexandre Courbot <[email protected]> --- drivers/gpu/nova-core/gsp.rs | 14 +++---------- drivers/gpu/nova-core/gsp/logbuffer.rs | 37 ++++++++++++++++++++++++++++++---- 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/nova-core/gsp.rs b/drivers/gpu/nova-core/gsp.rs index bf0028e52e3c..eb5b62aa8bc0 100644 --- a/drivers/gpu/nova-core/gsp.rs +++ b/drivers/gpu/nova-core/gsp.rs @@ -137,19 +137,11 @@ pub(crate) fn new( GFP_KERNEL, )?; + log_buffers.init_arguments(&mut libos)?; libos.init_at( - 0, - LibosMemoryRegionInitArgument::new("LOGINIT", &log_buffers.loginit.0), + LogBuffers::COUNT, + LibosMemoryRegionInitArgument::new("RMARGS", rmargs), )?; - libos.init_at( - 1, - LibosMemoryRegionInitArgument::new("LOGINTR", &log_buffers.logintr.0), - )?; - libos.init_at( - 2, - LibosMemoryRegionInitArgument::new("LOGRM", &log_buffers.logrm.0), - )?; - libos.init_at(3, LibosMemoryRegionInitArgument::new("RMARGS", rmargs))?; libos.into() }, diff --git a/drivers/gpu/nova-core/gsp/logbuffer.rs b/drivers/gpu/nova-core/gsp/logbuffer.rs index 5455d990ffb4..a825cb57dba5 100644 --- a/drivers/gpu/nova-core/gsp/logbuffer.rs +++ b/drivers/gpu/nova-core/gsp/logbuffer.rs @@ -5,7 +5,10 @@ use kernel::{ debugfs, device, - dma::Coherent, + dma::{ + Coherent, + CoherentBox, // + }, io::{ io_project, Io, // @@ -20,6 +23,7 @@ use crate::{ gsp::{ + LibosMemoryRegionInitArgument, PteArray, GSP_PAGE_SIZE, // }, @@ -90,14 +94,17 @@ pub(super) struct LogBuffers<'a> { /// Device the buffers belong to. dev: &'a device::Device<device::Bound>, /// Init log buffer. - pub(super) loginit: LogBuffer<'a>, + loginit: LogBuffer<'a>, /// Interrupts log buffer. - pub(super) logintr: LogBuffer<'a>, + logintr: LogBuffer<'a>, /// RM log buffer. - pub(super) logrm: LogBuffer<'a>, + logrm: LogBuffer<'a>, } impl<'a> LogBuffers<'a> { + /// Number of log buffers. + pub(super) const COUNT: usize = 3; + /// Allocates the log buffers of `dev`. pub(super) fn new(dev: &'a device::Device<device::Bound>) -> Result<Self> { Ok(Self { @@ -108,6 +115,28 @@ pub(super) fn new(dev: &'a device::Device<device::Bound>) -> Result<Self> { }) } + /// Fills the first [`Self::COUNT`] entries of `libos` with the log buffers, under the names + /// that GSP-RM looks them up by. + pub(super) fn init_arguments( + &self, + libos: &mut CoherentBox<'_, [LibosMemoryRegionInitArgument]>, + ) -> Result { + libos.init_at( + 0, + LibosMemoryRegionInitArgument::new("LOGINIT", &self.loginit.0), + )?; + libos.init_at( + 1, + LibosMemoryRegionInitArgument::new("LOGINTR", &self.logintr.0), + )?; + libos.init_at( + 2, + LibosMemoryRegionInitArgument::new("LOGRM", &self.logrm.0), + )?; + + Ok(()) + } + /// Exposes the buffers in debugfs, in a directory named after their device. pub(super) fn into_debugfs_scope(self) -> impl PinInit<debugfs::Scope<Self>> + 'a { let dev = self.dev; -- 2.56.1
