* Re: [PATCH v2 2/2] drm/tyr: use IoMem directly instead of Devres
2026-05-29 0:00 ` [PATCH v2 2/2] drm/tyr: use IoMem directly instead of Devres Danilo Krummrich
@ 2026-06-01 9:35 ` Alice Ryhl
2026-06-01 9:54 ` Danilo Krummrich
2026-06-02 1:12 ` Deborah Brouwer
2026-06-02 0:50 ` Deborah Brouwer
2026-06-02 6:40 ` Boris Brezillon
2 siblings, 2 replies; 13+ messages in thread
From: Alice Ryhl @ 2026-06-01 9:35 UTC (permalink / raw)
To: Danilo Krummrich
Cc: daniel.almeida, boris.brezillon, deborah.brouwer, gary, dri-devel,
rust-for-linux, Eliot Courtney, Alexandre Courbot
On Fri, May 29, 2026 at 02:00:54AM +0200, Danilo Krummrich wrote:
> 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>
> -pub(crate) type IoMem = kernel::io::mem::IoMem<'static, SZ_2M>;
> +pub(crate) type IoMem<'a> = kernel::io::mem::IoMem<'a, SZ_2M>;
It'd make more sense for me to put 'b or 'bound here.
> let sram_regulator = Regulator::<regulator::Enabled>::get(pdev.as_ref(), c"sram")?;
>
> let request = pdev.io_request_by_index(0).ok_or(ENODEV)?;
> - let iomem = Arc::new(request.iomap_sized::<SZ_2M>()?.into_devres()?, GFP_KERNEL)?;
> + let iomem = request.iomap_sized::<SZ_2M>()?;
>
> issue_soft_reset(pdev.as_ref(), &iomem)?;
> gpu::l2_power_on(pdev.as_ref(), &iomem)?;
>
> - let gpu_info = GpuInfo::new(pdev.as_ref(), &iomem)?;
> + let gpu_info = GpuInfo::new(&iomem);
While this change is fine, I notice that we don't actually keep the
iomem alive past the probe method. I assume we're going to need that,
which leads to the question of whether we can store the iomem in the
places we need it.
As far as I can tell, we can store it in TyrPlatformDriverData but not
in TyrDrmDeviceData, is that right?
I guess it does make sense because the io memory goes away if the
underlying platform device (the bus) goes away, even if the drm device
still exists due to open fds from userspace.
Alice
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 2/2] drm/tyr: use IoMem directly instead of Devres
2026-06-01 9:35 ` Alice Ryhl
@ 2026-06-01 9:54 ` Danilo Krummrich
2026-06-02 1:12 ` Deborah Brouwer
1 sibling, 0 replies; 13+ messages in thread
From: Danilo Krummrich @ 2026-06-01 9:54 UTC (permalink / raw)
To: Alice Ryhl
Cc: daniel.almeida, boris.brezillon, deborah.brouwer, gary, dri-devel,
rust-for-linux, Eliot Courtney, Alexandre Courbot
On Mon Jun 1, 2026 at 11:35 AM CEST, Alice Ryhl wrote:
> On Fri, May 29, 2026 at 02:00:54AM +0200, Danilo Krummrich wrote:
>> 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>
>
>> -pub(crate) type IoMem = kernel::io::mem::IoMem<'static, SZ_2M>;
>> +pub(crate) type IoMem<'a> = kernel::io::mem::IoMem<'a, SZ_2M>;
>
> It'd make more sense for me to put 'b or 'bound here.
You can name it 'b of course, but the semantics for 'bound has been agreed to
describe the lifetime of something actually being in place for the entire
duration of a device being bound to a driver, which isn't the case here.
>> let sram_regulator = Regulator::<regulator::Enabled>::get(pdev.as_ref(), c"sram")?;
>>
>> let request = pdev.io_request_by_index(0).ok_or(ENODEV)?;
>> - let iomem = Arc::new(request.iomap_sized::<SZ_2M>()?.into_devres()?, GFP_KERNEL)?;
>> + let iomem = request.iomap_sized::<SZ_2M>()?;
>>
>> issue_soft_reset(pdev.as_ref(), &iomem)?;
>> gpu::l2_power_on(pdev.as_ref(), &iomem)?;
>>
>> - let gpu_info = GpuInfo::new(pdev.as_ref(), &iomem)?;
>> + let gpu_info = GpuInfo::new(&iomem);
>
>
> While this change is fine, I notice that we don't actually keep the
> iomem alive past the probe method. I assume we're going to need that,
> which leads to the question of whether we can store the iomem in the
> places we need it.
>
> As far as I can tell, we can store it in TyrPlatformDriverData but not
> in TyrDrmDeviceData, is that right?
TyrDrmDeviceData will eventually become the drm::Registration data, so it will
be a ForLt type as well and IoMem<'a> can directly be stored in there.
The DRM device private data being tied to the lifetime of the DRM device itself
doesn't seem to be useful anymore after IOCTLs won't potentially reach into the
driver after device unbind anymore.
In the meantime (or even after this change, although I wouldn't recommend that),
you can call into_devres() before storing it in TyrDrmDeviceData.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 2/2] drm/tyr: use IoMem directly instead of Devres
2026-06-01 9:35 ` Alice Ryhl
2026-06-01 9:54 ` Danilo Krummrich
@ 2026-06-02 1:12 ` Deborah Brouwer
2026-06-02 10:35 ` Gary Guo
1 sibling, 1 reply; 13+ messages in thread
From: Deborah Brouwer @ 2026-06-02 1:12 UTC (permalink / raw)
To: Alice Ryhl
Cc: Danilo Krummrich, daniel.almeida, boris.brezillon, gary,
dri-devel, rust-for-linux, Eliot Courtney, Alexandre Courbot
On Mon, Jun 01, 2026 at 09:35:04AM +0000, Alice Ryhl wrote:
> On Fri, May 29, 2026 at 02:00:54AM +0200, Danilo Krummrich wrote:
> > 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>
>
> > -pub(crate) type IoMem = kernel::io::mem::IoMem<'static, SZ_2M>;
> > +pub(crate) type IoMem<'a> = kernel::io::mem::IoMem<'a, SZ_2M>;
>
> It'd make more sense for me to put 'b or 'bound here.
>
> > let sram_regulator = Regulator::<regulator::Enabled>::get(pdev.as_ref(), c"sram")?;
> >
> > let request = pdev.io_request_by_index(0).ok_or(ENODEV)?;
> > - let iomem = Arc::new(request.iomap_sized::<SZ_2M>()?.into_devres()?, GFP_KERNEL)?;
> > + let iomem = request.iomap_sized::<SZ_2M>()?;
> >
> > issue_soft_reset(pdev.as_ref(), &iomem)?;
> > gpu::l2_power_on(pdev.as_ref(), &iomem)?;
> >
> > - let gpu_info = GpuInfo::new(pdev.as_ref(), &iomem)?;
> > + let gpu_info = GpuInfo::new(&iomem);
>
>
> While this change is fine, I notice that we don't actually keep the
> iomem alive past the probe method. I assume we're going to need that,
> which leads to the question of whether we can store the iomem in the
> places we need it.
>
> As far as I can tell, we can store it in TyrPlatformDriverData but not
> in TyrDrmDeviceData, is that right?
I'm still getting my head around how this applies to tyr's firmware
series, but yes we stop storing iomem in TyrDrmDeviceData, but we won't
store it in TyrPlatformDriverData.
Instead there is a new struct "RegistrationData" that will store the iomem
like this:
#[vtable]
impl drm::Driver for TyrDrmDriver {
type Data = TyrDrmDeviceData;
type RegistrationData = TyrDrmRegistrationData<'static>;
And then in probe something like:
let reg_data = try_pin_init!(TyrDrmRegistrationData {
pdev: platform.clone(),
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,
}),
iomem,
gpu_info,
});
drm::driver::Registration::new_foreign_owned(ddev, pdev.as_ref(), reg_data, 0)?;
>
> I guess it does make sense because the io memory goes away if the
> underlying platform device (the bus) goes away, even if the drm device
> still exists due to open fds from userspace.
>
> Alice
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH v2 2/2] drm/tyr: use IoMem directly instead of Devres
2026-06-02 1:12 ` Deborah Brouwer
@ 2026-06-02 10:35 ` Gary Guo
2026-06-02 10:49 ` Danilo Krummrich
0 siblings, 1 reply; 13+ messages in thread
From: Gary Guo @ 2026-06-02 10:35 UTC (permalink / raw)
To: Deborah Brouwer, Alice Ryhl
Cc: Danilo Krummrich, daniel.almeida, boris.brezillon, gary,
dri-devel, rust-for-linux, Eliot Courtney, Alexandre Courbot
On Tue Jun 2, 2026 at 2:12 AM BST, Deborah Brouwer wrote:
> On Mon, Jun 01, 2026 at 09:35:04AM +0000, Alice Ryhl wrote:
>> On Fri, May 29, 2026 at 02:00:54AM +0200, Danilo Krummrich wrote:
>> > 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>
>>
>> > -pub(crate) type IoMem = kernel::io::mem::IoMem<'static, SZ_2M>;
>> > +pub(crate) type IoMem<'a> = kernel::io::mem::IoMem<'a, SZ_2M>;
>>
>> It'd make more sense for me to put 'b or 'bound here.
>>
>> > let sram_regulator = Regulator::<regulator::Enabled>::get(pdev.as_ref(), c"sram")?;
>> >
>> > let request = pdev.io_request_by_index(0).ok_or(ENODEV)?;
>> > - let iomem = Arc::new(request.iomap_sized::<SZ_2M>()?.into_devres()?, GFP_KERNEL)?;
>> > + let iomem = request.iomap_sized::<SZ_2M>()?;
>> >
>> > issue_soft_reset(pdev.as_ref(), &iomem)?;
>> > gpu::l2_power_on(pdev.as_ref(), &iomem)?;
>> >
>> > - let gpu_info = GpuInfo::new(pdev.as_ref(), &iomem)?;
>> > + let gpu_info = GpuInfo::new(&iomem);
>>
>>
>> While this change is fine, I notice that we don't actually keep the
>> iomem alive past the probe method. I assume we're going to need that,
>> which leads to the question of whether we can store the iomem in the
>> places we need it.
>>
>> As far as I can tell, we can store it in TyrPlatformDriverData but not
>> in TyrDrmDeviceData, is that right?
>
> I'm still getting my head around how this applies to tyr's firmware
> series, but yes we stop storing iomem in TyrDrmDeviceData, but we won't
> store it in TyrPlatformDriverData.
> Instead there is a new struct "RegistrationData" that will store the iomem
> like this:
>
> #[vtable]
> impl drm::Driver for TyrDrmDriver {
> type Data = TyrDrmDeviceData;
> type RegistrationData = TyrDrmRegistrationData<'static>;
>
I am not sure what the distinction even mean for a class device?
There's 1 device per registration, so they're equal. Am I missing something?
Best,
Gary
> And then in probe something like:
>
> let reg_data = try_pin_init!(TyrDrmRegistrationData {
> pdev: platform.clone(),
> 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,
> }),
> iomem,
> gpu_info,
> });
>
> drm::driver::Registration::new_foreign_owned(ddev, pdev.as_ref(), reg_data, 0)?;
>
>
>>
>> I guess it does make sense because the io memory goes away if the
>> underlying platform device (the bus) goes away, even if the drm device
>> still exists due to open fds from userspace.
>>
>> Alice
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH v2 2/2] drm/tyr: use IoMem directly instead of Devres
2026-06-02 10:35 ` Gary Guo
@ 2026-06-02 10:49 ` Danilo Krummrich
0 siblings, 0 replies; 13+ messages in thread
From: Danilo Krummrich @ 2026-06-02 10:49 UTC (permalink / raw)
To: Gary Guo
Cc: Deborah Brouwer, Alice Ryhl, daniel.almeida, boris.brezillon,
dri-devel, rust-for-linux, Eliot Courtney, Alexandre Courbot
On Tue Jun 2, 2026 at 12:35 PM CEST, Gary Guo wrote:
> I am not sure what the distinction even mean for a class device?
>
> There's 1 device per registration, so they're equal. Am I missing something?
The existing DRM device private data's lifetime is tied to the lifetime of the
DRM device itself, which makes sense as long as IOCTLs are not guarded against
driver unbind and can still reach into the driver after driver unbind.
Once that is changed, this doesn't make sense anymore, the driver structures are
then tied to the lifetime of the Registration.
Any handles that userspace may keep open beyond this should be handled by the
subsystem; at this point there is no more HW state the driver would need to take
care of.
Thus, the private data tied to the lifetime of the DRM device won't be needed
anymore, see also [1].
[1] https://lore.kernel.org/dri-devel/DIXMEKSYML5D.1JUXO9CW10RY8@kernel.org/
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 2/2] drm/tyr: use IoMem directly instead of Devres
2026-05-29 0:00 ` [PATCH v2 2/2] drm/tyr: use IoMem directly instead of Devres Danilo Krummrich
2026-06-01 9:35 ` Alice Ryhl
@ 2026-06-02 0:50 ` Deborah Brouwer
2026-06-02 6:40 ` Boris Brezillon
2 siblings, 0 replies; 13+ messages in thread
From: Deborah Brouwer @ 2026-06-02 0:50 UTC (permalink / raw)
To: Danilo Krummrich
Cc: aliceryhl, daniel.almeida, boris.brezillon, gary, dri-devel,
rust-for-linux, Eliot Courtney, Alexandre Courbot
On Fri, May 29, 2026 at 02:00:54AM +0200, Danilo Krummrich wrote:
> 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>
> ---
> drivers/gpu/drm/tyr/driver.rs | 19 ++++++-------------
> drivers/gpu/drm/tyr/gpu.rs | 17 +++++------------
> 2 files changed, 11 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/gpu/drm/tyr/driver.rs b/drivers/gpu/drm/tyr/driver.rs
> index 6276e9743c32..227ea2adccea 100644
> --- a/drivers/gpu/drm/tyr/driver.rs
> +++ b/drivers/gpu/drm/tyr/driver.rs
> @@ -6,11 +6,9 @@
> OptionalClk, //
> },
> device::{
> - Bound,
> Core,
> Device, //
> },
> - devres::Devres,
> dma::{
> Device as DmaDevice,
> DmaMask, //
> @@ -30,7 +28,6 @@
> sizes::SZ_2M,
> sync::{
> aref::ARef,
> - Arc,
> Mutex, //
> },
> time, //
> @@ -44,7 +41,7 @@
> regs::gpu_control::*, //
> };
>
> -pub(crate) type IoMem = kernel::io::mem::IoMem<'static, SZ_2M>;
> +pub(crate) type IoMem<'a> = kernel::io::mem::IoMem<'a, SZ_2M>;
>
> pub(crate) struct TyrDrmDriver;
>
> @@ -74,15 +71,11 @@ pub(crate) struct TyrDrmDeviceData {
> pub(crate) gpu_info: GpuInfo,
> }
>
> -fn issue_soft_reset(dev: &Device<Bound>, iomem: &Devres<IoMem>) -> Result {
> - let io = (*iomem).access(dev)?;
> - io.write_reg(GPU_COMMAND::reset(ResetMode::SoftReset));
> +fn issue_soft_reset(dev: &Device, iomem: &IoMem<'_>) -> Result {
> + iomem.write_reg(GPU_COMMAND::reset(ResetMode::SoftReset));
>
> poll::read_poll_timeout(
> - || {
> - let io = (*iomem).access(dev)?;
> - Ok(io.read(GPU_IRQ_RAWSTAT))
> - },
> + || Ok(iomem.read(GPU_IRQ_RAWSTAT)),
> |status| status.reset_completed(),
> time::Delta::from_millis(1),
> time::Delta::from_millis(100),
> @@ -123,12 +116,12 @@ fn probe<'bound>(
> let sram_regulator = Regulator::<regulator::Enabled>::get(pdev.as_ref(), c"sram")?;
>
> let request = pdev.io_request_by_index(0).ok_or(ENODEV)?;
> - let iomem = Arc::new(request.iomap_sized::<SZ_2M>()?.into_devres()?, GFP_KERNEL)?;
> + let iomem = request.iomap_sized::<SZ_2M>()?;
>
> issue_soft_reset(pdev.as_ref(), &iomem)?;
> gpu::l2_power_on(pdev.as_ref(), &iomem)?;
>
> - let gpu_info = GpuInfo::new(pdev.as_ref(), &iomem)?;
> + let gpu_info = GpuInfo::new(&iomem);
> gpu_info.log(pdev.as_ref());
>
> let pa_bits = MMU_FEATURES::from_raw(gpu_info.mmu_features)
> diff --git a/drivers/gpu/drm/tyr/gpu.rs b/drivers/gpu/drm/tyr/gpu.rs
> index 652556026f50..592b8bb16eba 100644
> --- a/drivers/gpu/drm/tyr/gpu.rs
> +++ b/drivers/gpu/drm/tyr/gpu.rs
> @@ -9,7 +9,6 @@
> Bound,
> Device, //
> },
> - devres::Devres,
> io::{
> poll,
> register::Array,
> @@ -40,10 +39,8 @@
> pub(crate) struct GpuInfo(pub(crate) uapi::drm_panthor_gpu_info);
>
> impl GpuInfo {
> - pub(crate) fn new(dev: &Device<Bound>, iomem: &Devres<IoMem>) -> Result<Self> {
> - let io = (*iomem).access(dev)?;
> -
> - Ok(Self(uapi::drm_panthor_gpu_info {
> + pub(crate) fn new(io: &IoMem<'_>) -> Self {
> + Self(uapi::drm_panthor_gpu_info {
> gpu_id: io.read(GPU_ID).into_raw(),
> gpu_rev: io.read(REVIDR).into_raw(),
> csf_id: io.read(CSF_ID).into_raw(),
> @@ -81,7 +78,7 @@ pub(crate) fn new(dev: &Device<Bound>, iomem: &Devres<IoMem>) -> Result<Self> {
> pad: 0,
> //GPU_FEATURES register is not available; it was introduced in arch 11.x.
> gpu_features: 0,
> - }))
> + })
> }
>
> pub(crate) fn log(&self, dev: &Device<Bound>) {
> @@ -163,15 +160,11 @@ struct GpuModels {
> }];
>
> /// Powers on the l2 block.
> -pub(crate) fn l2_power_on(dev: &Device<Bound>, iomem: &Devres<IoMem>) -> Result {
> - let io = (*iomem).access(dev)?;
> +pub(crate) fn l2_power_on(dev: &Device, io: &IoMem<'_>) -> Result {
> io.write_reg(L2_PWRON_LO::zeroed().with_const_request::<1>());
>
> poll::read_poll_timeout(
> - || {
> - let io = (*iomem).access(dev)?;
> - Ok(io.read(L2_READY_LO))
> - },
> + || Ok(io.read(L2_READY_LO)),
> |status| status.ready() == 1,
> Delta::from_millis(1),
> Delta::from_millis(100),
> --
> 2.54.0
>
Looks good to me!
Tested-by: Deborah Brouwer <deborah.brouwer@collabora.com>
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH v2 2/2] drm/tyr: use IoMem directly instead of Devres
2026-05-29 0:00 ` [PATCH v2 2/2] drm/tyr: use IoMem directly instead of Devres Danilo Krummrich
2026-06-01 9:35 ` Alice Ryhl
2026-06-02 0:50 ` Deborah Brouwer
@ 2026-06-02 6:40 ` Boris Brezillon
2 siblings, 0 replies; 13+ messages in thread
From: Boris Brezillon @ 2026-06-02 6:40 UTC (permalink / raw)
To: Danilo Krummrich
Cc: aliceryhl, daniel.almeida, deborah.brouwer, gary, dri-devel,
rust-for-linux, Eliot Courtney, Alexandre Courbot
On Fri, 29 May 2026 02:00:54 +0200
Danilo Krummrich <dakr@kernel.org> wrote:
> 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>
> ---
> drivers/gpu/drm/tyr/driver.rs | 19 ++++++-------------
> drivers/gpu/drm/tyr/gpu.rs | 17 +++++------------
> 2 files changed, 11 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/gpu/drm/tyr/driver.rs b/drivers/gpu/drm/tyr/driver.rs
> index 6276e9743c32..227ea2adccea 100644
> --- a/drivers/gpu/drm/tyr/driver.rs
> +++ b/drivers/gpu/drm/tyr/driver.rs
> @@ -6,11 +6,9 @@
> OptionalClk, //
> },
> device::{
> - Bound,
> Core,
> Device, //
> },
> - devres::Devres,
> dma::{
> Device as DmaDevice,
> DmaMask, //
> @@ -30,7 +28,6 @@
> sizes::SZ_2M,
> sync::{
> aref::ARef,
> - Arc,
> Mutex, //
> },
> time, //
> @@ -44,7 +41,7 @@
> regs::gpu_control::*, //
> };
>
> -pub(crate) type IoMem = kernel::io::mem::IoMem<'static, SZ_2M>;
> +pub(crate) type IoMem<'a> = kernel::io::mem::IoMem<'a, SZ_2M>;
>
> pub(crate) struct TyrDrmDriver;
>
> @@ -74,15 +71,11 @@ pub(crate) struct TyrDrmDeviceData {
> pub(crate) gpu_info: GpuInfo,
> }
>
> -fn issue_soft_reset(dev: &Device<Bound>, iomem: &Devres<IoMem>) -> Result {
> - let io = (*iomem).access(dev)?;
> - io.write_reg(GPU_COMMAND::reset(ResetMode::SoftReset));
> +fn issue_soft_reset(dev: &Device, iomem: &IoMem<'_>) -> Result {
> + iomem.write_reg(GPU_COMMAND::reset(ResetMode::SoftReset));
>
> poll::read_poll_timeout(
> - || {
> - let io = (*iomem).access(dev)?;
> - Ok(io.read(GPU_IRQ_RAWSTAT))
> - },
> + || Ok(iomem.read(GPU_IRQ_RAWSTAT)),
> |status| status.reset_completed(),
> time::Delta::from_millis(1),
> time::Delta::from_millis(100),
> @@ -123,12 +116,12 @@ fn probe<'bound>(
> let sram_regulator = Regulator::<regulator::Enabled>::get(pdev.as_ref(), c"sram")?;
>
> let request = pdev.io_request_by_index(0).ok_or(ENODEV)?;
> - let iomem = Arc::new(request.iomap_sized::<SZ_2M>()?.into_devres()?, GFP_KERNEL)?;
> + let iomem = request.iomap_sized::<SZ_2M>()?;
>
> issue_soft_reset(pdev.as_ref(), &iomem)?;
> gpu::l2_power_on(pdev.as_ref(), &iomem)?;
>
> - let gpu_info = GpuInfo::new(pdev.as_ref(), &iomem)?;
> + let gpu_info = GpuInfo::new(&iomem);
> gpu_info.log(pdev.as_ref());
>
> let pa_bits = MMU_FEATURES::from_raw(gpu_info.mmu_features)
> diff --git a/drivers/gpu/drm/tyr/gpu.rs b/drivers/gpu/drm/tyr/gpu.rs
> index 652556026f50..592b8bb16eba 100644
> --- a/drivers/gpu/drm/tyr/gpu.rs
> +++ b/drivers/gpu/drm/tyr/gpu.rs
> @@ -9,7 +9,6 @@
> Bound,
> Device, //
> },
> - devres::Devres,
> io::{
> poll,
> register::Array,
> @@ -40,10 +39,8 @@
> pub(crate) struct GpuInfo(pub(crate) uapi::drm_panthor_gpu_info);
>
> impl GpuInfo {
> - pub(crate) fn new(dev: &Device<Bound>, iomem: &Devres<IoMem>) -> Result<Self> {
> - let io = (*iomem).access(dev)?;
> -
> - Ok(Self(uapi::drm_panthor_gpu_info {
> + pub(crate) fn new(io: &IoMem<'_>) -> Self {
> + Self(uapi::drm_panthor_gpu_info {
> gpu_id: io.read(GPU_ID).into_raw(),
> gpu_rev: io.read(REVIDR).into_raw(),
> csf_id: io.read(CSF_ID).into_raw(),
> @@ -81,7 +78,7 @@ pub(crate) fn new(dev: &Device<Bound>, iomem: &Devres<IoMem>) -> Result<Self> {
> pad: 0,
> //GPU_FEATURES register is not available; it was introduced in arch 11.x.
> gpu_features: 0,
> - }))
> + })
> }
>
> pub(crate) fn log(&self, dev: &Device<Bound>) {
> @@ -163,15 +160,11 @@ struct GpuModels {
> }];
>
> /// Powers on the l2 block.
> -pub(crate) fn l2_power_on(dev: &Device<Bound>, iomem: &Devres<IoMem>) -> Result {
> - let io = (*iomem).access(dev)?;
> +pub(crate) fn l2_power_on(dev: &Device, io: &IoMem<'_>) -> Result {
> io.write_reg(L2_PWRON_LO::zeroed().with_const_request::<1>());
>
> poll::read_poll_timeout(
> - || {
> - let io = (*iomem).access(dev)?;
> - Ok(io.read(L2_READY_LO))
> - },
> + || Ok(io.read(L2_READY_LO)),
> |status| status.ready() == 1,
> Delta::from_millis(1),
> Delta::from_millis(100),
^ permalink raw reply [flat|nested] 13+ messages in thread