Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/exynos: Call drm_atomic_helper_shutdown() at shutdown/unbind time

Based on grepping through the source code this driver appears to be
missing a call to drm_atomic_helper_shutdown() at system shutdown time
and at driver unbind time. Among other things, this means that if a
panel is in use that it won't be cleanly powered off at system
shutdown time.

The fact that we should call drm_atomic_helper_shutdown() in the case
of OS shutdown/restart and at driver remove (or unbind) time comes
straight out of the kernel doc "driver instance overview" in
drm_drv.c.

A few notes about this fix:
- When adding drm_atomic_helper_shutdown() to the unbind path, I added
it after drm_kms_helper_poll_fini() since that's when other drivers
seemed to have it.
- Technically with a previous patch, ("drm/atomic-helper:
drm_atomic_helper_shutdown(NULL) should be a noop"), we don't
actually need to check to see if our "drm" pointer is NULL before
calling drm_atomic_helper_shutdown(). We'll leave the "if" test in,
though, so that this patch can land without any dependencies. It
could potentially be removed later.
- This patch also makes sure to set the drvdata to NULL in the case of
bind errors to make sure that shutdown can't access freed data.

Suggested-by: Maxime Ripard <mripard@kernel.org>
Reviewed-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Inki Dae <inki.dae@samsung.com>

authored by

Douglas Anderson and committed by
Inki Dae
16ac5b21 a2f8994c

+11
+11
drivers/gpu/drm/exynos/exynos_drm_drv.c
··· 300 300 drm_mode_config_cleanup(drm); 301 301 exynos_drm_cleanup_dma(drm); 302 302 kfree(private); 303 + dev_set_drvdata(dev, NULL); 303 304 err_free_drm: 304 305 drm_dev_put(drm); 305 306 ··· 314 313 drm_dev_unregister(drm); 315 314 316 315 drm_kms_helper_poll_fini(drm); 316 + drm_atomic_helper_shutdown(drm); 317 317 318 318 component_unbind_all(drm->dev, drm); 319 319 drm_mode_config_cleanup(drm); ··· 352 350 return 0; 353 351 } 354 352 353 + static void exynos_drm_platform_shutdown(struct platform_device *pdev) 354 + { 355 + struct drm_device *drm = platform_get_drvdata(pdev); 356 + 357 + if (drm) 358 + drm_atomic_helper_shutdown(drm); 359 + } 360 + 355 361 static struct platform_driver exynos_drm_platform_driver = { 356 362 .probe = exynos_drm_platform_probe, 357 363 .remove = exynos_drm_platform_remove, 364 + .shutdown = exynos_drm_platform_shutdown, 358 365 .driver = { 359 366 .name = "exynos-drm", 360 367 .pm = &exynos_drm_pm_ops,