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 <[email protected]>
>> Reviewed-by: Alexandre Courbot <[email protected]>
>> Signed-off-by: Danilo Krummrich <[email protected]>
>
>> -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.

Reply via email to