summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/nova-core/falcon.rs12
-rw-r--r--drivers/gpu/nova-core/falcon/hal/ga102.rs4
-rw-r--r--drivers/gpu/nova-core/gfw.rs5
-rw-r--r--drivers/gpu/nova-core/util.rs8
4 files changed, 13 insertions, 16 deletions
diff --git a/drivers/gpu/nova-core/falcon.rs b/drivers/gpu/nova-core/falcon.rs
index be4bf59422c6..c2c6f9eb380a 100644
--- a/drivers/gpu/nova-core/falcon.rs
+++ b/drivers/gpu/nova-core/falcon.rs
@@ -3,11 +3,11 @@
//! Falcon microprocessor base support
use core::ops::Deref;
-use core::time::Duration;
use hal::FalconHal;
use kernel::bindings;
use kernel::device;
use kernel::prelude::*;
+use kernel::time::Delta;
use kernel::types::ARef;
use crate::dma::DmaObject;
@@ -353,7 +353,7 @@ impl<E: FalconEngine + 'static> Falcon<E> {
/// Wait for memory scrubbing to complete.
fn reset_wait_mem_scrubbing(&self, bar: &Bar0) -> Result {
// TIMEOUT: memory scrubbing should complete in less than 20ms.
- util::wait_on(Duration::from_millis(20), || {
+ util::wait_on(Delta::from_millis(20), || {
if regs::NV_PFALCON_FALCON_HWCFG2::read(bar, E::BASE).mem_scrubbing_done() {
Some(())
} else {
@@ -368,7 +368,7 @@ impl<E: FalconEngine + 'static> Falcon<E> {
// According to OpenRM's `kflcnPreResetWait_GA102` documentation, HW sometimes does not set
// RESET_READY so a non-failing timeout is used.
- let _ = util::wait_on(Duration::from_micros(150), || {
+ let _ = util::wait_on(Delta::from_micros(150), || {
let r = regs::NV_PFALCON_FALCON_HWCFG2::read(bar, E::BASE);
if r.reset_ready() {
Some(())
@@ -381,7 +381,7 @@ impl<E: FalconEngine + 'static> Falcon<E> {
// TODO[DLAY]: replace with udelay() or equivalent once available.
// TIMEOUT: falcon engine should not take more than 10us to reset.
- let _: Result = util::wait_on(Duration::from_micros(10), || None);
+ let _: Result = util::wait_on(Delta::from_micros(10), || None);
regs::NV_PFALCON_FALCON_ENGINE::alter(bar, E::BASE, |v| v.set_reset(false));
@@ -472,7 +472,7 @@ impl<E: FalconEngine + 'static> Falcon<E> {
// Wait for the transfer to complete.
// TIMEOUT: arbitrarily large value, no DMA transfer to the falcon's small memories
// should ever take that long.
- util::wait_on(Duration::from_secs(2), || {
+ util::wait_on(Delta::from_secs(2), || {
let r = regs::NV_PFALCON_FALCON_DMATRFCMD::read(bar, E::BASE);
if r.idle() {
Some(())
@@ -542,7 +542,7 @@ impl<E: FalconEngine + 'static> Falcon<E> {
}
// TIMEOUT: arbitrarily large value, firmwares should complete in less than 2 seconds.
- util::wait_on(Duration::from_secs(2), || {
+ util::wait_on(Delta::from_secs(2), || {
let r = regs::NV_PFALCON_FALCON_CPUCTL::read(bar, E::BASE);
if r.halted() {
Some(())
diff --git a/drivers/gpu/nova-core/falcon/hal/ga102.rs b/drivers/gpu/nova-core/falcon/hal/ga102.rs
index 0344cd33e6ea..52c33d3f22a8 100644
--- a/drivers/gpu/nova-core/falcon/hal/ga102.rs
+++ b/drivers/gpu/nova-core/falcon/hal/ga102.rs
@@ -1,10 +1,10 @@
// SPDX-License-Identifier: GPL-2.0
use core::marker::PhantomData;
-use core::time::Duration;
use kernel::device;
use kernel::prelude::*;
+use kernel::time::Delta;
use crate::driver::Bar0;
use crate::falcon::{
@@ -23,7 +23,7 @@ fn select_core_ga102<E: FalconEngine>(bar: &Bar0) -> Result {
.write(bar, E::BASE);
// TIMEOUT: falcon core should take less than 10ms to report being enabled.
- util::wait_on(Duration::from_millis(10), || {
+ util::wait_on(Delta::from_millis(10), || {
let r = regs::NV_PRISCV_RISCV_BCR_CTRL::read(bar, E::BASE);
if r.valid() {
Some(())
diff --git a/drivers/gpu/nova-core/gfw.rs b/drivers/gpu/nova-core/gfw.rs
index ce03ac9f4d9d..d5b68e02d405 100644
--- a/drivers/gpu/nova-core/gfw.rs
+++ b/drivers/gpu/nova-core/gfw.rs
@@ -6,10 +6,9 @@
//! the GPU is considered unusable until this step is completed, so we must wait on it before
//! performing driver initialization.
-use core::time::Duration;
-
use kernel::bindings;
use kernel::prelude::*;
+use kernel::time::Delta;
use crate::driver::Bar0;
use crate::regs;
@@ -19,7 +18,7 @@ use crate::util;
pub(crate) fn wait_gfw_boot_completion(bar: &Bar0) -> Result {
// TIMEOUT: arbitrarily large value. GFW starts running immediately after the GPU is put out of
// reset, and should complete in less time than that.
- util::wait_on(Duration::from_secs(4), || {
+ util::wait_on(Delta::from_secs(4), || {
// Check that FWSEC has lowered its protection level before reading the GFW_BOOT
// status.
let gfw_booted = regs::NV_PGC6_AON_SECURE_SCRATCH_GROUP_05_PRIV_LEVEL_MASK::read(bar)
diff --git a/drivers/gpu/nova-core/util.rs b/drivers/gpu/nova-core/util.rs
index 5cafe0797cd6..64fb13760764 100644
--- a/drivers/gpu/nova-core/util.rs
+++ b/drivers/gpu/nova-core/util.rs
@@ -1,9 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
-use core::time::Duration;
-
use kernel::prelude::*;
-use kernel::time::Instant;
+use kernel::time::{Delta, Instant};
pub(crate) const fn to_lowercase_bytes<const N: usize>(s: &str) -> [u8; N] {
let src = s.as_bytes();
@@ -34,7 +32,7 @@ pub(crate) const fn const_bytes_to_str(bytes: &[u8]) -> &str {
///
/// TODO[DLAY]: replace with `read_poll_timeout` once it is available.
/// (https://lore.kernel.org/lkml/20250220070611.214262-8-fujita.tomonori@gmail.com/)
-pub(crate) fn wait_on<R, F: Fn() -> Option<R>>(timeout: Duration, cond: F) -> Result<R> {
+pub(crate) fn wait_on<R, F: Fn() -> Option<R>>(timeout: Delta, cond: F) -> Result<R> {
let start_time = Instant::now();
loop {
@@ -42,7 +40,7 @@ pub(crate) fn wait_on<R, F: Fn() -> Option<R>>(timeout: Duration, cond: F) -> Re
return Ok(ret);
}
- if start_time.elapsed().as_nanos() > timeout.as_nanos() as i64 {
+ if start_time.elapsed().as_nanos() > timeout.as_nanos() {
return Err(ETIMEDOUT);
}
}