Skip to content

Commit f97525b

Browse files
Danilo KrummrichDarksonn
authored andcommitted
drm/tyr: use IoMem directly instead of Devres
Now that IoMem is lifetime-parameterized, use it directly in probe rather than wrapping it in Devres and Arc. The I/O memory mapping is only used during probe and not stored in driver data, so device-managed revocation is unnecessary. This removes the Devres access(dev) pattern from issue_soft_reset(), GpuInfo::new(), and l2_power_on(), simplifying register access. Reviewed-by: Eliot Courtney <ecourtney@nvidia.com> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Signed-off-by: Danilo Krummrich <dakr@kernel.org> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com> Tested-by: Deborah Brouwer <deborah.brouwer@collabora.com> Link: https://patch.msgid.link/20260529000106.2257996-3-dakr@kernel.org Signed-off-by: Alice Ryhl <aliceryhl@google.com>
1 parent ba47c46 commit f97525b

2 files changed

Lines changed: 11 additions & 25 deletions

File tree

drivers/gpu/drm/tyr/driver.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ use kernel::{
66
OptionalClk, //
77
},
88
device::{
9-
Bound,
109
Core,
1110
Device, //
1211
},
13-
devres::Devres,
1412
dma::{
1513
Device as DmaDevice,
1614
DmaMask, //
@@ -30,7 +28,6 @@ use kernel::{
3028
sizes::SZ_2M,
3129
sync::{
3230
aref::ARef,
33-
Arc,
3431
Mutex, //
3532
},
3633
time, //
@@ -44,7 +41,7 @@ use crate::{
4441
regs::gpu_control::*, //
4542
};
4643

47-
pub(crate) type IoMem = kernel::io::mem::IoMem<'static, SZ_2M>;
44+
pub(crate) type IoMem<'a> = kernel::io::mem::IoMem<'a, SZ_2M>;
4845

4946
pub(crate) struct TyrDrmDriver;
5047

@@ -74,15 +71,11 @@ pub(crate) struct TyrDrmDeviceData {
7471
pub(crate) gpu_info: GpuInfo,
7572
}
7673

77-
fn issue_soft_reset(dev: &Device<Bound>, iomem: &Devres<IoMem>) -> Result {
78-
let io = (*iomem).access(dev)?;
79-
io.write_reg(GPU_COMMAND::reset(ResetMode::SoftReset));
74+
fn issue_soft_reset(dev: &Device, iomem: &IoMem<'_>) -> Result {
75+
iomem.write_reg(GPU_COMMAND::reset(ResetMode::SoftReset));
8076

8177
poll::read_poll_timeout(
82-
|| {
83-
let io = (*iomem).access(dev)?;
84-
Ok(io.read(GPU_IRQ_RAWSTAT))
85-
},
78+
|| Ok(iomem.read(GPU_IRQ_RAWSTAT)),
8679
|status| status.reset_completed(),
8780
time::Delta::from_millis(1),
8881
time::Delta::from_millis(100),
@@ -123,12 +116,12 @@ impl platform::Driver for TyrPlatformDriver {
123116
let sram_regulator = Regulator::<regulator::Enabled>::get(pdev.as_ref(), c"sram")?;
124117

125118
let request = pdev.io_request_by_index(0).ok_or(ENODEV)?;
126-
let iomem = Arc::new(request.iomap_sized::<SZ_2M>()?.into_devres()?, GFP_KERNEL)?;
119+
let iomem = request.iomap_sized::<SZ_2M>()?;
127120

128121
issue_soft_reset(pdev.as_ref(), &iomem)?;
129122
gpu::l2_power_on(pdev.as_ref(), &iomem)?;
130123

131-
let gpu_info = GpuInfo::new(pdev.as_ref(), &iomem)?;
124+
let gpu_info = GpuInfo::new(&iomem);
132125
gpu_info.log(pdev.as_ref());
133126

134127
let pa_bits = MMU_FEATURES::from_raw(gpu_info.mmu_features)

drivers/gpu/drm/tyr/gpu.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use kernel::{
99
Bound,
1010
Device, //
1111
},
12-
devres::Devres,
1312
io::{
1413
poll,
1514
register::Array,
@@ -40,10 +39,8 @@ use crate::{
4039
pub(crate) struct GpuInfo(pub(crate) uapi::drm_panthor_gpu_info);
4140

4241
impl GpuInfo {
43-
pub(crate) fn new(dev: &Device<Bound>, iomem: &Devres<IoMem>) -> Result<Self> {
44-
let io = (*iomem).access(dev)?;
45-
46-
Ok(Self(uapi::drm_panthor_gpu_info {
42+
pub(crate) fn new(io: &IoMem<'_>) -> Self {
43+
Self(uapi::drm_panthor_gpu_info {
4744
gpu_id: io.read(GPU_ID).into_raw(),
4845
gpu_rev: io.read(REVIDR).into_raw(),
4946
csf_id: io.read(CSF_ID).into_raw(),
@@ -81,7 +78,7 @@ impl GpuInfo {
8178
pad: 0,
8279
//GPU_FEATURES register is not available; it was introduced in arch 11.x.
8380
gpu_features: 0,
84-
}))
81+
})
8582
}
8683

8784
pub(crate) fn log(&self, dev: &Device<Bound>) {
@@ -163,15 +160,11 @@ const GPU_MODELS: [GpuModels; 1] = [GpuModels {
163160
}];
164161

165162
/// Powers on the l2 block.
166-
pub(crate) fn l2_power_on(dev: &Device<Bound>, iomem: &Devres<IoMem>) -> Result {
167-
let io = (*iomem).access(dev)?;
163+
pub(crate) fn l2_power_on(dev: &Device, io: &IoMem<'_>) -> Result {
168164
io.write_reg(L2_PWRON_LO::zeroed().with_const_request::<1>());
169165

170166
poll::read_poll_timeout(
171-
|| {
172-
let io = (*iomem).access(dev)?;
173-
Ok(io.read(L2_READY_LO))
174-
},
167+
|| Ok(io.read(L2_READY_LO)),
175168
|status| status.ready() == 1,
176169
Delta::from_millis(1),
177170
Delta::from_millis(100),

0 commit comments

Comments
 (0)