Skip to content

Commit e386680

Browse files
Joel FernandesGnurou
authored andcommitted
gpu: nova-core: sequencer: Add delay opcode support
Implement a sequencer opcode for delay operations. Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com> Reviewed-by: Lyude Paul <lyude@redhat.com> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com> Message-ID: <20251114195552.739371-10-joelagnelf@nvidia.com>
1 parent 2367ce2 commit e386680

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,6 @@ unsafe impl AsBytes for RegPollPayload {}
473473
#[derive(Copy, Clone)]
474474
pub(crate) struct DelayUsPayload(r570_144::GSP_SEQ_BUF_PAYLOAD_DELAY_US);
475475

476-
#[expect(unused)]
477476
impl DelayUsPayload {
478477
/// Returns the delay value in microseconds.
479478
pub(crate) fn val(&self) -> u32 {
@@ -515,7 +514,6 @@ unsafe impl AsBytes for RegStorePayload {}
515514
#[repr(transparent)]
516515
pub(crate) struct SequencerBufferCmd(r570_144::GSP_SEQUENCER_BUFFER_CMD);
517516

518-
#[expect(unused)]
519517
impl SequencerBufferCmd {
520518
/// Returns the opcode as a `SeqBufOpcode` enum, or error if invalid.
521519
pub(crate) fn opcode(&self) -> Result<SeqBufOpcode> {

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ use kernel::{
1414
device,
1515
io::poll::read_poll_timeout,
1616
prelude::*,
17-
time::Delta,
17+
time::{
18+
delay::fsleep,
19+
Delta, //
20+
},
1821
transmute::FromBytes,
1922
types::ARef, //
2023
};
@@ -71,6 +74,7 @@ pub(crate) enum GspSeqCmd {
7174
RegWrite(fw::RegWritePayload),
7275
RegModify(fw::RegModifyPayload),
7376
RegPoll(fw::RegPollPayload),
77+
DelayUs(fw::DelayUsPayload),
7478
RegStore(fw::RegStorePayload),
7579
}
7680

@@ -96,6 +100,11 @@ impl GspSeqCmd {
96100
let size = opcode_size + size_of_val(&payload);
97101
(GspSeqCmd::RegPoll(payload), size)
98102
}
103+
fw::SeqBufOpcode::DelayUs => {
104+
let payload = fw_cmd.delay_us_payload()?;
105+
let size = opcode_size + size_of_val(&payload);
106+
(GspSeqCmd::DelayUs(payload), size)
107+
}
99108
fw::SeqBufOpcode::RegStore => {
100109
let payload = fw_cmd.reg_store_payload()?;
101110
let size = opcode_size + size_of_val(&payload);
@@ -182,6 +191,13 @@ impl GspSeqCmdRunner for fw::RegPollPayload {
182191
}
183192
}
184193

194+
impl GspSeqCmdRunner for fw::DelayUsPayload {
195+
fn run(&self, _sequencer: &GspSequencer<'_>) -> Result {
196+
fsleep(Delta::from_micros(i64::from(self.val())));
197+
Ok(())
198+
}
199+
}
200+
185201
impl GspSeqCmdRunner for fw::RegStorePayload {
186202
fn run(&self, sequencer: &GspSequencer<'_>) -> Result {
187203
let addr = usize::from_safe_cast(self.addr());
@@ -196,6 +212,7 @@ impl GspSeqCmdRunner for GspSeqCmd {
196212
GspSeqCmd::RegWrite(cmd) => cmd.run(seq),
197213
GspSeqCmd::RegModify(cmd) => cmd.run(seq),
198214
GspSeqCmd::RegPoll(cmd) => cmd.run(seq),
215+
GspSeqCmd::DelayUs(cmd) => cmd.run(seq),
199216
GspSeqCmd::RegStore(cmd) => cmd.run(seq),
200217
}
201218
}

0 commit comments

Comments
 (0)