Implement a sequencer opcode which for delay operations. Signed-off-by: Joel Fernandes <joelagn...@nvidia.com> --- drivers/gpu/nova-core/gsp/sequencer.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
diff --git a/drivers/gpu/nova-core/gsp/sequencer.rs b/drivers/gpu/nova-core/gsp/sequencer.rs index 75672ae0a687..803956a74c8c 100644 --- a/drivers/gpu/nova-core/gsp/sequencer.rs +++ b/drivers/gpu/nova-core/gsp/sequencer.rs @@ -4,6 +4,7 @@ use core::mem::size_of; use kernel::alloc::flags::GFP_KERNEL; +use kernel::bindings; use kernel::device; use kernel::prelude::*; use kernel::time::Delta; @@ -37,6 +38,7 @@ pub(crate) enum GspSeqCmd { RegWrite(fw::GSP_SEQ_BUF_PAYLOAD_REG_WRITE), RegModify(fw::GSP_SEQ_BUF_PAYLOAD_REG_MODIFY), RegPoll(fw::GSP_SEQ_BUF_PAYLOAD_REG_POLL), + DelayUs(fw::GSP_SEQ_BUF_PAYLOAD_DELAY_US), RegStore(fw::GSP_SEQ_BUF_PAYLOAD_REG_STORE), } @@ -55,6 +57,9 @@ pub(crate) fn from_fw_cmd(cmd: &fw::GSP_SEQUENCER_BUFFER_CMD) -> Result<Self> { fw::GSP_SEQ_BUF_OPCODE_GSP_SEQ_BUF_OPCODE_REG_POLL => { Ok(GspSeqCmd::RegPoll(unsafe { cmd.payload.regPoll })) } + fw::GSP_SEQ_BUF_OPCODE_GSP_SEQ_BUF_OPCODE_DELAY_US => { + Ok(GspSeqCmd::DelayUs(unsafe { cmd.payload.delayUs })) + } fw::GSP_SEQ_BUF_OPCODE_GSP_SEQ_BUF_OPCODE_REG_STORE => { Ok(GspSeqCmd::RegStore(unsafe { cmd.payload.regStore })) } @@ -85,6 +90,7 @@ pub(crate) fn size_bytes(&self) -> usize { opcode_size + size_of::<fw::GSP_SEQ_BUF_PAYLOAD_REG_MODIFY>() } GspSeqCmd::RegPoll(_) => opcode_size + size_of::<fw::GSP_SEQ_BUF_PAYLOAD_REG_POLL>(), + GspSeqCmd::DelayUs(_) => opcode_size + size_of::<fw::GSP_SEQ_BUF_PAYLOAD_DELAY_US>(), GspSeqCmd::RegStore(_) => opcode_size + size_of::<fw::GSP_SEQ_BUF_PAYLOAD_REG_STORE>(), } } @@ -177,6 +183,21 @@ fn run(&self, sequencer: &GspSequencer<'_>) -> Result { } } +impl GspSeqCmdRunner for fw::GSP_SEQ_BUF_PAYLOAD_DELAY_US { + fn run(&self, sequencer: &GspSequencer<'_>) -> Result { + dev_dbg!(sequencer.dev, "DelayUs: val=0x{:x}\n", self.val); + // SAFETY: `usleep_range_state` is safe to call with any parameter. + unsafe { + bindings::usleep_range_state( + self.val as usize, + self.val as usize, + bindings::TASK_UNINTERRUPTIBLE as u32, + ) + }; + Ok(()) + } +} + impl GspSeqCmdRunner for fw::GSP_SEQ_BUF_PAYLOAD_REG_STORE { fn run(&self, sequencer: &GspSequencer<'_>) -> Result { let addr = self.addr as usize; @@ -202,6 +223,7 @@ fn run(&self, seq: &GspSequencer<'_>) -> Result { GspSeqCmd::RegWrite(cmd) => cmd.run(seq), GspSeqCmd::RegModify(cmd) => cmd.run(seq), GspSeqCmd::RegPoll(cmd) => cmd.run(seq), + GspSeqCmd::DelayUs(cmd) => cmd.run(seq), GspSeqCmd::RegStore(cmd) => cmd.run(seq), } } -- 2.34.1