From: Beata Michalska <beata.michalska@arm.com>
To: ojeda@kernel.org, dakr@kernel.org, gregkh@linuxfoundation.org,
rafael@kernel.org, aliceryhl@google.com
Cc: boqun@kernel.org, gary@garyguo.net, bjorn3_gh@protonmail.com,
lossin@kernel.org, a.hindborg@kernel.org, tmgross@umich.edu,
daniel.almeida@collabora.com, boris.brezillon@collabora.com,
work@onurozkan.dev, samitolvanen@google.com, acourbot@nvidia.com,
rust-for-linux@vger.kernel.org, driver-core@lists.linux.dev,
linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org
Subject: [PATCH v5 3/3 DO NOT MERGE] drm/tyr: enable runtime PM
Date: Mon, 26 Oct 2026 13:05:08 +0100 [thread overview]
Message-ID: <20261026120523.526942-4-beata.michalska@arm.com> (raw)
In-Reply-To: <20261026120523.526942-1-beata.michalska@arm.com>
Add runtime PM support to the Tyr platform driver. Move the clocks
and regulators used by runtime suspend and resume into the PM
payload, register the PM callbacks, configure autosuspend,
and let DRM paths take a PM usage reference while querying
device state.
Signed-off-by: Beata Michalska <beata.michalska@arm.com>
---
drivers/gpu/drm/tyr/driver.rs | 110 +++++++++++++++++++++++++++-------
drivers/gpu/drm/tyr/file.rs | 3 +
2 files changed, 93 insertions(+), 20 deletions(-)
diff --git a/drivers/gpu/drm/tyr/driver.rs b/drivers/gpu/drm/tyr/driver.rs
index c2b99d67369f..de18470f0bd6 100644
--- a/drivers/gpu/drm/tyr/driver.rs
+++ b/drivers/gpu/drm/tyr/driver.rs
@@ -21,17 +21,15 @@
poll,
Io, //
},
- new_mutex,
of,
platform,
+ pm,
+ pm::*,
prelude::*,
regulator,
regulator::Regulator,
sizes::SZ_2M,
- sync::{
- Arc,
- Mutex, //
- },
+ sync::Arc,
time, //
};
@@ -59,6 +57,9 @@
pub(crate) struct TyrPlatformDriverData<'bound> {
#[pin]
_reg: drm::Registration<'bound, TyrDrmDriver>,
+ // This needs to be dropped after drm::Registration as that one
+ // borrows PMContext.
+ pub(crate) pm: pm::Registration<'bound, TyrPlatformDriver>,
}
/// Data owned by the DRM [`Registration`].
@@ -73,11 +74,8 @@ pub(crate) struct TyrDrmRegistrationData<'drm> {
/// Firmware sections.
pub(crate) fw: Firmware<'drm>,
- #[pin]
- clks: Mutex<Clocks>,
-
- #[pin]
- regulators: Mutex<Regulators>,
+ /// Runtime PM context owned by the PM Registration
+ pub(crate) pm: PMContext<'drm, TyrPlatformDriver>,
/// GPU MMIO register mapping.
pub(crate) iomem: Arc<IoMem<'drm>>,
@@ -113,6 +111,8 @@ impl platform::Driver for TyrPlatformDriver {
type IdInfo = ();
type Data<'bound> = TyrPlatformDriverData<'bound>;
const OF_ID_TABLE: Option<of::IdTable<Self::IdInfo>> = Some(&OF_TABLE);
+ const DEV_PM_OPS: Option<pm::DevPMOpsRef<'static, platform::Adapter<Self>>> =
+ Some(TYR_PM_OPS.pm_ops());
fn probe<'bound>(
pdev: &'bound platform::Device<Core<'_>>,
@@ -130,6 +130,37 @@ fn probe<'bound>(
let mali_regulator = Regulator::<regulator::Enabled>::get(pdev.as_ref(), c"mali")?;
let sram_regulator = Regulator::<regulator::Enabled>::get(pdev.as_ref(), c"sram")?;
+ let runtime_payload = TyrRuntimePMPayload {
+ clks: Clocks {
+ core: core_clk,
+ stacks: stacks_clk,
+ coregroup: coregroup_clk,
+ },
+ _regulators: Regulators {
+ _mali: mali_regulator,
+ _sram: sram_regulator,
+ },
+ };
+
+ let mut pm_configs = KVec::<PMConfig>::with_capacity(2, GFP_KERNEL)?;
+ pm_configs.push(PMConfig::AutoSuspend(true), GFP_KERNEL)?;
+ pm_configs.push(PMConfig::AutoSuspendDelay(300), GFP_KERNEL)?;
+
+ // SAFETY: `pm_registration` is stored in `TyrPlatformDriverData`
+ // and dropped when the driver is
+ // unbound; it is never forgotten.
+ let pm_registration = unsafe {
+ pm::Registration::new(
+ pdev.as_ref(),
+ &TYR_PM_OPS,
+ None,
+ Some(pm_configs),
+ runtime_payload,
+ )
+ }?;
+
+ let pm_context = pm_registration.ctx().clone();
+
let request = pdev.io_request_by_index(0).ok_or(ENODEV)?;
let iomem = Arc::new(request.iomap_sized::<SZ_2M>()?, GFP_KERNEL)?;
@@ -171,20 +202,14 @@ fn probe<'bound>(
pin_init!(TyrDrmRegistrationData {
pdev,
fw: firmware,
- clks <- new_mutex!(Clocks {
- core: core_clk,
- stacks: stacks_clk,
- coregroup: coregroup_clk,
- }),
- regulators <- new_mutex!(Regulators {
- _mali: mali_regulator,
- _sram: sram_regulator,
- }),
+ pm: pm_context,
iomem,
gpu_info,
}),
)},
- _: { dev_dbg!(pdev, "Tyr initialized correctly.") },
+ pm: pm_registration,
+ _: { pm.ctx().enable(RuntimePMState::Resumed)?;
+ dev_dbg!(pdev, "Tyr initialized correctly.") },
}))
})
}
@@ -239,3 +264,48 @@ struct Regulators {
_mali: Regulator<regulator::Enabled>,
_sram: Regulator<regulator::Enabled>,
}
+
+pub(crate) struct TyrRuntimePMPayload {
+ clks: Clocks,
+ _regulators: Regulators,
+}
+
+static TYR_PM_OPS: pm::DevPMOps<TyrPlatformDriver> = pm::DevPMOps::new();
+
+#[vtable]
+impl PMOps for TyrPlatformDriver {
+ type Adapter = platform::Adapter<TyrPlatformDriver>;
+ type DeviceType = platform::Device<kernel::device::Bound>;
+ type RuntimePayloadType = TyrRuntimePMPayload;
+
+ fn runtime_suspend<'a>(
+ _dev: &'a Self::DeviceType,
+ payload: TyrRuntimePMPayload,
+ ) -> Result<TyrRuntimePMPayload, (TyrRuntimePMPayload, Error)> {
+ payload.clks.coregroup.disable_unprepare();
+ payload.clks.stacks.disable_unprepare();
+ payload.clks.core.disable_unprepare();
+ Ok(payload)
+ }
+ fn runtime_resume<'a>(
+ _dev: &'a Self::DeviceType,
+ payload: TyrRuntimePMPayload,
+ ) -> Result<TyrRuntimePMPayload, (TyrRuntimePMPayload, Error)> {
+ if let Err(e) = payload.clks.core.prepare_enable() {
+ return Err((payload, e));
+ }
+
+ if let Err(e) = payload.clks.stacks.prepare_enable() {
+ payload.clks.core.disable_unprepare();
+ return Err((payload, e));
+ }
+
+ if let Err(e) = payload.clks.coregroup.prepare_enable() {
+ payload.clks.stacks.disable_unprepare();
+ payload.clks.core.disable_unprepare();
+ return Err((payload, e));
+ }
+
+ Ok(payload)
+ }
+}
diff --git a/drivers/gpu/drm/tyr/file.rs b/drivers/gpu/drm/tyr/file.rs
index 9f60a90d4948..111cd4ccf87c 100644
--- a/drivers/gpu/drm/tyr/file.rs
+++ b/drivers/gpu/drm/tyr/file.rs
@@ -5,6 +5,7 @@
self,
Registered, //
},
+ pm::PMProfile,
prelude::*,
uaccess::UserSlice,
uapi, //
@@ -37,6 +38,8 @@ pub(crate) fn dev_query(
devquery: &mut uapi::drm_panthor_dev_query,
_file: &TyrDrmFile,
) -> Result<u32> {
+ // Runtime suspend called when pm_scope gets dropped
+ let _pm_scope = reg_data.pm.get(PMProfile::new())?;
if devquery.pointer == 0 {
match devquery.type_ {
uapi::drm_panthor_dev_query_type_DRM_PANTHOR_DEV_QUERY_GPU_INFO => {
--
2.43.0
next prev parent reply other threads:[~2026-10-26 12:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-26 12:05 Request::put_noidleFrom 43bd77ceaa3d6a9f61ae8074be13824a94fa76c1 Mon Sep 17 00:00:00 2001 Beata Michalska
2026-10-26 12:05 ` [PATCH v5 1/3] rust: add runtime PM support Beata Michalska
2026-10-26 12:05 ` [PATCH v5 2/3] rust: platform: wire runtime PM callbacks Beata Michalska
2026-10-26 12:05 ` Beata Michalska [this message]
2026-10-26 12:15 ` Request::put_noidleFrom 43bd77ceaa3d6a9f61ae8074be13824a94fa76c1 Mon Sep 17 00:00:00 2001 Greg KH
2026-10-26 12:28 ` Beata Michalska
2026-10-26 12:25 ` [PATCH v5 0/3] Rust: add runtime PM support Beata Michalska
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=20261026120523.526942-4-beata.michalska@arm.com \
--to=beata.michalska@arm.com \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=boris.brezillon@collabora.com \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=driver-core@lists.linux.dev \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rafael@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=samitolvanen@google.com \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.dev \
/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
all inboxes | Powered by JetHome®