[PATCH] drm/tilcdc: conditionally calling drm_atomic_helper_shutdown()

Xulin Sun posted 1 patch 1 month, 1 week ago
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
[PATCH] drm/tilcdc: conditionally calling drm_atomic_helper_shutdown()
Posted by Xulin Sun 1 month, 1 week ago
The `drm_atomic_helper_shutdown(dev)` is called only if
`priv->is_registered` is true, ensuring that it runs only when the device
has been properly registered. Otherwise, if it encounters a defer probe,
the following call trace will appear.

WARNING: CPU: 0 PID: 13 at drivers/gpu/drm/drm_atomic_state_helper.c:174 drm_atomic_helper_crtc_duplicate_state+0x68/0x70
Modules linked in:
CPU: 0 PID: 13 Comm: kworker/u2:1
Hardware name: Generic AM33XX (Flattened Device Tree)
Workqueue: events_unbound deferred_probe_work_func
 unwind_backtrace from show_stack+0x18/0x1c
 show_stack from dump_stack_lvl+0x24/0x2c
 dump_stack_lvl from __warn+0x80/0x134
 __warn from warn_slowpath_fmt+0x19c/0x1a4
 warn_slowpath_fmt from drm_atomic_helper_crtc_duplicate_state+0x68/0x70
 drm_atomic_helper_crtc_duplicate_state from drm_atomic_get_crtc_state+0x70/0x110
 drm_atomic_get_crtc_state from drm_atomic_helper_disable_all+0x98/0x1c8
 drm_atomic_helper_disable_all from drm_atomic_helper_shutdown+0x90/0x144
 drm_atomic_helper_shutdown from tilcdc_fini+0x58/0xe0
 tilcdc_fini from tilcdc_init.constprop.0+0x23c/0x620
 tilcdc_init.constprop.0 from tilcdc_pdev_probe+0x58/0xac
 tilcdc_pdev_probe from platform_probe+0x64/0xb8
 platform_probe from really_probe+0xd0/0x2e0
 really_probe from __driver_probe_device+0x90/0x1a8
 __driver_probe_device from driver_probe_device+0x38/0x10c
 driver_probe_device from __device_attach_driver+0x9c/0x110
 __device_attach_driver from bus_for_each_drv+0x98/0xec
 bus_for_each_drv from __device_attach+0xb0/0x1ac
 __device_attach from bus_probe_device+0x90/0x94
 bus_probe_device from deferred_probe_work_func+0x80/0xac
 deferred_probe_work_func from process_one_work+0x198/0x3f8
 process_one_work from worker_thread+0x35c/0x550
 worker_thread from kthread+0x108/0x124
 kthread from ret_from_fork+0x14/0x28
Exception stack(0xe0039fb0 to 0xe0039ff8)
9fa0:                                     00000000 00000000 00000000 00000000
9fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
9fe0: 00000000 00000000 00000000 00000000 00000013 00000000
---[ end trace 0000000000000000 ]---
tilcdc 4830e000.lcdc: [drm] *ERROR* Disabling all crtc's during unload failed with -12

Signed-off-by: Xulin Sun <xulin.sun@windriver.com>
---
 drivers/gpu/drm/tilcdc/tilcdc_drv.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index cd5eefa06060..9c11ea126b46 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -171,11 +171,12 @@ static void tilcdc_fini(struct drm_device *dev)
 	if (priv->crtc)
 		tilcdc_crtc_shutdown(priv->crtc);
 
-	if (priv->is_registered)
+	if (priv->is_registered) {
 		drm_dev_unregister(dev);
+		drm_atomic_helper_shutdown(dev);
+	}
 
 	drm_kms_helper_poll_fini(dev);
-	drm_atomic_helper_shutdown(dev);
 	tilcdc_irq_uninstall(dev);
 	drm_mode_config_cleanup(dev);
 
-- 
2.34.1