There's no point re-enabling the reset work before the DRM device
registration succeeds, so move the enable_work() after the point where
nothing can fail anymore, and in the unlikely event where a reset was
pending, reschedule it.

Fixes: 1b8d771fb214 ("drm/panthor: Keep the reset work disabled until 
everything is initialized")
Closes: 
https://sashiko.dev/#/patchset/[email protected]?part=2
Signed-off-by: Boris Brezillon <[email protected]>
---
 drivers/gpu/drm/panthor/panthor_device.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/panthor/panthor_device.c 
b/drivers/gpu/drm/panthor/panthor_device.c
index c41de1b61533..5355c4074f1f 100644
--- a/drivers/gpu/drm/panthor/panthor_device.c
+++ b/drivers/gpu/drm/panthor/panthor_device.c
@@ -305,9 +305,6 @@ int panthor_device_init(struct panthor_device *ptdev)
 
        panthor_gem_init(ptdev);
 
-       /* Now that everything is initialized, we can enable the reset work. */
-       enable_work(&ptdev->reset.work);
-
        /* ~3 frames */
        pm_runtime_set_autosuspend_delay(ptdev->base.dev, 50);
        pm_runtime_use_autosuspend(ptdev->base.dev);
@@ -316,6 +313,14 @@ int panthor_device_init(struct panthor_device *ptdev)
        if (ret)
                goto err_disable_autosuspend;
 
+       /* Now that everything is initialized, we can enable the reset work.
+        * If there was a reset pending, clear and reschedule, otherwise the
+        * reset.pending bit is stuck.
+        */
+       enable_work(&ptdev->reset.work);
+       if (atomic_read(&ptdev->reset.pending))
+               queue_work(ptdev->reset.wq, &ptdev->reset.work);
+
        pm_runtime_put_autosuspend(ptdev->base.dev);
        return 0;
 

-- 
2.55.0

Reply via email to