Skip to content

Commit 58d26d4

Browse files
committed
gpu: nova-core: align LibosMemoryRegionInitArgument size to page size
On Turing and GA100 (i.e. the versions that use Libos v2), GSP-RM insists that the 'size' parameter of the LibosMemoryRegionInitArgument struct be aligned to 4KB. The logging buffers are already aligned to that size, so only the GSP_ARGUMENTS_CACHED struct needs to be adjusted. Make that adjustment by adding padding to the end of the struct. Signed-off-by: Timur Tabi <ttabi@nvidia.com> Reviewed-by: Gary Guo <gary@garyguo.net> Acked-by: Danilo Krummrich <dakr@kernel.org> Link: https://patch.msgid.link/20260122222848.2555890-12-ttabi@nvidia.com [acourbot@nvidia.com: GspArgumentsAligned -> GspArgumentsPadded] Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
1 parent dbfb5aa commit 58d26d4

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

drivers/gpu/nova-core/gsp.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub(crate) use fw::{
2727
use crate::{
2828
gsp::cmdq::Cmdq,
2929
gsp::fw::{
30-
GspArgumentsCached,
30+
GspArgumentsPadded,
3131
LibosMemoryRegionInitArgument, //
3232
},
3333
num,
@@ -114,7 +114,7 @@ pub(crate) struct Gsp {
114114
/// Command queue.
115115
pub(crate) cmdq: Cmdq,
116116
/// RM arguments.
117-
rmargs: CoherentAllocation<GspArgumentsCached>,
117+
rmargs: CoherentAllocation<GspArgumentsPadded>,
118118
}
119119

120120
impl Gsp {
@@ -133,7 +133,7 @@ impl Gsp {
133133
logintr: LogBuffer::new(dev)?,
134134
logrm: LogBuffer::new(dev)?,
135135
cmdq: Cmdq::new(dev)?,
136-
rmargs: CoherentAllocation::<GspArgumentsCached>::alloc_coherent(
136+
rmargs: CoherentAllocation::<GspArgumentsPadded>::alloc_coherent(
137137
dev,
138138
1,
139139
GFP_KERNEL | __GFP_ZERO,
@@ -149,7 +149,7 @@ impl Gsp {
149149
libos[1] = LibosMemoryRegionInitArgument::new("LOGINTR", &logintr.0)
150150
)?;
151151
dma_write!(libos[2] = LibosMemoryRegionInitArgument::new("LOGRM", &logrm.0))?;
152-
dma_write!(rmargs[0] = fw::GspArgumentsCached::new(cmdq))?;
152+
dma_write!(rmargs[0].inner = fw::GspArgumentsCached::new(cmdq))?;
153153
dma_write!(libos[3] = LibosMemoryRegionInitArgument::new("RMARGS", rmargs))?;
154154
},
155155
}))

drivers/gpu/nova-core/gsp/fw.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,9 +904,21 @@ impl GspArgumentsCached {
904904
// SAFETY: Padding is explicit and will not contain uninitialized data.
905905
unsafe impl AsBytes for GspArgumentsCached {}
906906

907+
/// On Turing and GA100, the entries in the `LibosMemoryRegionInitArgument`
908+
/// must all be a multiple of GSP_PAGE_SIZE in size, so add padding to force it
909+
/// to that size.
910+
#[repr(C)]
911+
pub(crate) struct GspArgumentsPadded {
912+
pub(crate) inner: GspArgumentsCached,
913+
_padding: [u8; GSP_PAGE_SIZE - core::mem::size_of::<bindings::GSP_ARGUMENTS_CACHED>()],
914+
}
915+
916+
// SAFETY: Padding is explicit and will not contain uninitialized data.
917+
unsafe impl AsBytes for GspArgumentsPadded {}
918+
907919
// SAFETY: This struct only contains integer types for which all bit patterns
908920
// are valid.
909-
unsafe impl FromBytes for GspArgumentsCached {}
921+
unsafe impl FromBytes for GspArgumentsPadded {}
910922

911923
/// Init arguments for the message queue.
912924
#[repr(transparent)]

0 commit comments

Comments
 (0)