These methods hold a range invariant for the read/write pointers (namely, that the pointers are always in the `0..MSGQ_NUM_PAGES` range).
The calling code depends on these invariants to build properly, so make them `#[inline(always)]` to ensure that they are propagated where they need to be. Signed-off-by: Alexandre Courbot <[email protected]> --- drivers/gpu/nova-core/gsp/cmdq.rs | 4 ++++ drivers/gpu/nova-core/gsp/fw.rs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/drivers/gpu/nova-core/gsp/cmdq.rs b/drivers/gpu/nova-core/gsp/cmdq.rs index 2224896ccc89..72e9b79619eb 100644 --- a/drivers/gpu/nova-core/gsp/cmdq.rs +++ b/drivers/gpu/nova-core/gsp/cmdq.rs @@ -384,6 +384,7 @@ fn allocate_command(&mut self, size: usize, timeout: Delta) -> Result<GspCommand // # Invariants // // - The returned value is within `0..MSGQ_NUM_PAGES`. + #[inline(always)] fn gsp_write_ptr(&self) -> u32 { super::fw::gsp_mem::gsp_write_ptr(&self.0) } @@ -393,6 +394,7 @@ fn gsp_write_ptr(&self) -> u32 { // # Invariants // // - The returned value is within `0..MSGQ_NUM_PAGES`. + #[inline(always)] fn gsp_read_ptr(&self) -> u32 { super::fw::gsp_mem::gsp_read_ptr(&self.0) } @@ -402,6 +404,7 @@ fn gsp_read_ptr(&self) -> u32 { // # Invariants // // - The returned value is within `0..MSGQ_NUM_PAGES`. + #[inline(always)] fn cpu_read_ptr(&self) -> u32 { super::fw::gsp_mem::cpu_read_ptr(&self.0) } @@ -416,6 +419,7 @@ fn advance_cpu_read_ptr(&mut self, elem_count: u32) { // # Invariants // // - The returned value is within `0..MSGQ_NUM_PAGES`. + #[inline(always)] fn cpu_write_ptr(&self) -> u32 { super::fw::gsp_mem::cpu_write_ptr(&self.0) } diff --git a/drivers/gpu/nova-core/gsp/fw.rs b/drivers/gpu/nova-core/gsp/fw.rs index 0c8a74f0e8ac..e2c0e9bf310e 100644 --- a/drivers/gpu/nova-core/gsp/fw.rs +++ b/drivers/gpu/nova-core/gsp/fw.rs @@ -58,14 +58,17 @@ pub(super) mod gsp_mem { MSGQ_NUM_PAGES, // }; + #[inline(always)] pub(in crate::gsp) fn gsp_write_ptr(qs: &Coherent<GspMem>) -> u32 { dma_read!(qs, .gspq.tx.0.writePtr) % MSGQ_NUM_PAGES } + #[inline(always)] pub(in crate::gsp) fn gsp_read_ptr(qs: &Coherent<GspMem>) -> u32 { dma_read!(qs, .gspq.rx.0.readPtr) % MSGQ_NUM_PAGES } + #[inline(always)] pub(in crate::gsp) fn cpu_read_ptr(qs: &Coherent<GspMem>) -> u32 { dma_read!(qs, .cpuq.rx.0.readPtr) % MSGQ_NUM_PAGES } @@ -79,6 +82,7 @@ pub(in crate::gsp) fn advance_cpu_read_ptr(qs: &Coherent<GspMem>, count: u32) { dma_write!(qs, .cpuq.rx.0.readPtr, rptr); } + #[inline(always)] pub(in crate::gsp) fn cpu_write_ptr(qs: &Coherent<GspMem>) -> u32 { dma_read!(qs, .cpuq.tx.0.writePtr) % MSGQ_NUM_PAGES } -- 2.53.0
