mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
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>
This commit is contained in:
committed by
Alexandre Courbot
parent
2367ce2e9e
commit
e386680e8d
@@ -473,7 +473,6 @@ unsafe impl AsBytes for RegPollPayload {}
|
||||
#[derive(Copy, Clone)]
|
||||
pub(crate) struct DelayUsPayload(r570_144::GSP_SEQ_BUF_PAYLOAD_DELAY_US);
|
||||
|
||||
#[expect(unused)]
|
||||
impl DelayUsPayload {
|
||||
/// Returns the delay value in microseconds.
|
||||
pub(crate) fn val(&self) -> u32 {
|
||||
@@ -515,7 +514,6 @@ unsafe impl AsBytes for RegStorePayload {}
|
||||
#[repr(transparent)]
|
||||
pub(crate) struct SequencerBufferCmd(r570_144::GSP_SEQUENCER_BUFFER_CMD);
|
||||
|
||||
#[expect(unused)]
|
||||
impl SequencerBufferCmd {
|
||||
/// Returns the opcode as a `SeqBufOpcode` enum, or error if invalid.
|
||||
pub(crate) fn opcode(&self) -> Result<SeqBufOpcode> {
|
||||
|
||||
@@ -14,7 +14,10 @@ use kernel::{
|
||||
device,
|
||||
io::poll::read_poll_timeout,
|
||||
prelude::*,
|
||||
time::Delta,
|
||||
time::{
|
||||
delay::fsleep,
|
||||
Delta, //
|
||||
},
|
||||
transmute::FromBytes,
|
||||
types::ARef, //
|
||||
};
|
||||
@@ -71,6 +74,7 @@ pub(crate) enum GspSeqCmd {
|
||||
RegWrite(fw::RegWritePayload),
|
||||
RegModify(fw::RegModifyPayload),
|
||||
RegPoll(fw::RegPollPayload),
|
||||
DelayUs(fw::DelayUsPayload),
|
||||
RegStore(fw::RegStorePayload),
|
||||
}
|
||||
|
||||
@@ -96,6 +100,11 @@ impl GspSeqCmd {
|
||||
let size = opcode_size + size_of_val(&payload);
|
||||
(GspSeqCmd::RegPoll(payload), size)
|
||||
}
|
||||
fw::SeqBufOpcode::DelayUs => {
|
||||
let payload = fw_cmd.delay_us_payload()?;
|
||||
let size = opcode_size + size_of_val(&payload);
|
||||
(GspSeqCmd::DelayUs(payload), size)
|
||||
}
|
||||
fw::SeqBufOpcode::RegStore => {
|
||||
let payload = fw_cmd.reg_store_payload()?;
|
||||
let size = opcode_size + size_of_val(&payload);
|
||||
@@ -182,6 +191,13 @@ impl GspSeqCmdRunner for fw::RegPollPayload {
|
||||
}
|
||||
}
|
||||
|
||||
impl GspSeqCmdRunner for fw::DelayUsPayload {
|
||||
fn run(&self, _sequencer: &GspSequencer<'_>) -> Result {
|
||||
fsleep(Delta::from_micros(i64::from(self.val())));
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl GspSeqCmdRunner for fw::RegStorePayload {
|
||||
fn run(&self, sequencer: &GspSequencer<'_>) -> Result {
|
||||
let addr = usize::from_safe_cast(self.addr());
|
||||
@@ -196,6 +212,7 @@ impl GspSeqCmdRunner for GspSeqCmd {
|
||||
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),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user