On Fri, Nov 13, 2026 at 05:32:27PM +0300, Onur Özkan wrote:
> +    /// Processes one scheduled reset request.
> +    ///
> +    /// If the pending reset cannot be claimed, the worker returns 
> immediately.
> +    ///
> +    /// It first claims [`ResetState::Pending`], then waits for earlier 
> hardware
> +    /// accesses to complete before issuing the reset and returning the 
> worker
> +    /// state to [`ResetState::Idle`].
> +    ///
> +    /// Panthor reference:
> +    /// - 
> drivers/gpu/drm/panthor/panthor_device.c::panthor_device_reset_work()
> +    fn reset_work(&self) {
> +        if !self.try_transition(ResetState::Pending, ResetState::InProgress) 
> {
> +            return;
> +        }
> +
> +        dev_dbg!(self.pdev, "Starting GPU reset.\n");
> +
> +        // Wait for current hardware accesses to finish before resetting.
> +        let reset_guard = self.hw.close();
> +        let reset_result = run_reset(self.pdev.as_ref(), &self.iomem);
> +        drop(reset_guard);
> +
> +        if let Err(e) = reset_result {
> +            dev_err!(self.pdev, "GPU reset failed: {:?}\n", e);
> +
> +            // TODO: Unplug the GPU.
> +            // There is no API for unplugging the GPU and this is unreachable
> +            // for now since there are no hardware users for reset API.
> +        } else {
> +            dev_dbg!(self.pdev, "GPU reset completed.\n");
> +        }
> +
> +        let _ = self.try_transition(ResetState::InProgress, 
> ResetState::Idle);

I'm pretty sure this needs to happen before drop(reset_guard).

> +    /// Creates [`ResetHandle`].
> +    ///
> +    /// # Safety
> +    ///
> +    /// The returned handle must not be leaked or otherwise prevented from
> +    /// running [`Drop`], since it owns work that may borrow from `'reset`.
> +    pub(crate) unsafe fn new(
> +        pdev: &'reset platform::Device<Bound>,
> +        iomem: ArcBorrow<'_, IoMem<'reset>>,
> +    ) -> Result<impl PinInit<Self, Error>> {
> +        let iomem = iomem.into();
> +
> +        Ok(try_pin_init!(Self {
> +            // SAFETY: The caller guarantees the handle is dropped.
> +            controller <- unsafe {
> +                kernel::new_scoped_work!("tyr::reset", Controller::new(pdev, 
> iomem))
> +            },
> +            wq: Queue::new_ordered().build(c"tyr-reset-wq")?,
> +        }))

The Result is not needed. This can simplify to:

        ) -> impl PinInit<Self, Error> {
            let iomem = iomem.into();
        
            try_pin_init!(Self {
                // SAFETY: The caller guarantees the handle is dropped.
                controller <- unsafe {
                    kernel::new_scoped_work!("tyr::reset", 
Controller::new(pdev, iomem))
                },
                wq: Queue::new_ordered().build(c"tyr-reset-wq")?,
            })

> +    }
> +
> +    /// Schedules a GPU reset on the dedicated workqueue.
> +    ///
> +    /// If a reset is already pending or in progress the call is a no-op.
> +    #[expect(dead_code)]
> +    pub(crate) fn schedule(&'reset self) {
> +        // TODO: Similar to `panthor_device_schedule_reset()` in Panthor, 
> add a
> +        // power management check once Tyr supports it.
> +
> +        if self
> +            .controller
> +            .try_transition(ResetState::Idle, ResetState::Pending)
> +        {
> +            let _ = self.wq.enqueue_scoped(&self.controller);
> +        }

Because this type is invariant over 'reset, it's impossible to call a
method that takes &'reset self.

I think you can just change this to &self.

Alice

Reply via email to