From: Deborah Brouwer <deborah.brouwer@collabora.com>
To: dri-devel@lists.freedesktop.org, rust-for-linux@vger.kernel.org
Cc: daniel.almeida@collabora.com, aliceryhl@google.com,
boris.brezillon@collabora.com,
Deborah Brouwer <deborah.brouwer@collabora.com>
Subject: [PATCH] rust: drm: tyr: use read_poll_timeout
Date: Thu, 15 Jan 2026 13:23:55 -0800 [thread overview]
Message-ID: <20260115212355.201628-1-deborah.brouwer@collabora.com> (raw)
The L2 power-on sequence and soft reset in Tyr previously relied on fixed
sleeps followed by a single register check, since polling helpers were not
available in Rust at the time.
Now that read_poll_timeout() is available, poll the relevant registers
until the hardware reports readiness or a timeout is reached.
This avoids unnecessary delays on start-up.
Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
---
drivers/gpu/drm/tyr/driver.rs | 18 +++++++++---------
drivers/gpu/drm/tyr/gpu.rs | 16 +++++++++-------
2 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/drivers/gpu/drm/tyr/driver.rs b/drivers/gpu/drm/tyr/driver.rs
index f0da58932702..60d01e3f101b 100644
--- a/drivers/gpu/drm/tyr/driver.rs
+++ b/drivers/gpu/drm/tyr/driver.rs
@@ -8,6 +8,7 @@
use kernel::devres::Devres;
use kernel::drm;
use kernel::drm::ioctl;
+use kernel::io::poll;
use kernel::new_mutex;
use kernel::of;
use kernel::platform;
@@ -67,19 +68,18 @@ unsafe impl Sync for TyrData {}
fn issue_soft_reset(dev: &Device<Bound>, iomem: &Devres<IoMem>) -> Result {
regs::GPU_CMD.write(dev, iomem, regs::GPU_CMD_SOFT_RESET)?;
- // TODO: We cannot poll, as there is no support in Rust currently, so we
- // sleep. Change this when read_poll_timeout() is implemented in Rust.
- kernel::time::delay::fsleep(time::Delta::from_millis(100));
-
- if regs::GPU_IRQ_RAWSTAT.read(dev, iomem)? & regs::GPU_IRQ_RAWSTAT_RESET_COMPLETED == 0 {
- dev_err!(dev, "GPU reset failed with errno\n");
+ if let Err(e) = poll::read_poll_timeout(
+ || regs::GPU_IRQ_RAWSTAT.read(dev, iomem),
+ |status| *status & regs::GPU_IRQ_RAWSTAT_RESET_COMPLETED != 0,
+ time::Delta::from_millis(1),
+ time::Delta::from_millis(100),
+ ) {
dev_err!(
dev,
- "GPU_INT_RAWSTAT is {}\n",
+ "GPU reset failed, GPU_IRQ_RAWSTAT is {}\n",
regs::GPU_IRQ_RAWSTAT.read(dev, iomem)?
);
-
- return Err(EIO);
+ return Err(e);
}
Ok(())
diff --git a/drivers/gpu/drm/tyr/gpu.rs b/drivers/gpu/drm/tyr/gpu.rs
index 6c582910dd5d..2ec56f763cc6 100644
--- a/drivers/gpu/drm/tyr/gpu.rs
+++ b/drivers/gpu/drm/tyr/gpu.rs
@@ -4,9 +4,10 @@
use kernel::device::Bound;
use kernel::device::Device;
use kernel::devres::Devres;
+use kernel::io::poll;
use kernel::platform;
use kernel::prelude::*;
-use kernel::time;
+use kernel::time::Delta;
use kernel::transmute::AsBytes;
use crate::driver::IoMem;
@@ -206,13 +207,14 @@ fn from(value: u32) -> Self {
pub(crate) fn l2_power_on(dev: &Device<Bound>, iomem: &Devres<IoMem>) -> Result {
regs::L2_PWRON_LO.write(dev, iomem, 1)?;
- // TODO: We cannot poll, as there is no support in Rust currently, so we
- // sleep. Change this when read_poll_timeout() is implemented in Rust.
- kernel::time::delay::fsleep(time::Delta::from_millis(100));
-
- if regs::L2_READY_LO.read(dev, iomem)? != 1 {
+ if let Err(e) = poll::read_poll_timeout(
+ || regs::L2_READY_LO.read(dev, iomem),
+ |status| *status == 1,
+ Delta::from_millis(1),
+ Delta::from_millis(100),
+ ) {
dev_err!(dev, "Failed to power on the GPU\n");
- return Err(EIO);
+ return Err(e);
}
Ok(())
--
2.52.0
next reply other threads:[~2026-01-15 21:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-15 21:23 Deborah Brouwer [this message]
2026-01-16 7:30 ` [PATCH] rust: drm: tyr: use read_poll_timeout Alice Ryhl
2026-01-16 9:52 ` Gary Guo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260115212355.201628-1-deborah.brouwer@collabora.com \
--to=deborah.brouwer@collabora.com \
--cc=aliceryhl@google.com \
--cc=boris.brezillon@collabora.com \
--cc=daniel.almeida@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=rust-for-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox