[PATCH] drm/msm: Make .remove and .shutdown HW shutdown consistent
Javier Martinez Canillas
javierm at redhat.com
Sun Jul 24 09:06:23 UTC 2022
On 7/24/22 10:53, Dmitry Baryshkov wrote:
> On Sun, 24 Jul 2022 at 00:09, Javier Martinez Canillas
[...]
>> -
>> /*
>> * Shutdown the hw if we're far enough along where things might be on.
>> * If we run this too early, we'll end up panicking in any variety of
>> @@ -205,10 +199,21 @@ static int msm_drm_uninit(struct device *dev)
>> * msm_drm_init, drm_dev->registered is used as an indicator that the
>> * shutdown will be successful.
>> */
>> - if (ddev->registered) {
>> + if (dev->registered)
>> + drm_atomic_helper_shutdown(dev);
>> +}
>> +
>> +static int msm_drm_uninit(struct device *dev)
>> +{
>> + struct platform_device *pdev = to_platform_device(dev);
>> + struct msm_drm_private *priv = platform_get_drvdata(pdev);
>> + struct drm_device *ddev = priv->dev;
>> + struct msm_kms *kms = priv->kms;
>> + int i;
>> +
>> + if (ddev->registered)
>> drm_dev_unregister(ddev);
>
> No. The drm_dev_unregister() should come before drm_atomic_helper_shutdown().
>
I'm not sure to understand what you meant here, since drm_dev_unregister() is
called before drm_atomic_helper_shutdown() that's called in msm_shutdown_hw().
> Also drm_dev_unregister() should not be a part of .shutdown callback.
> See the documentation in the drm_drv.c
>
It is not right now, msm_shutdown_hw() only calls drm_atomic_helper_shutdown()
but drm_dev_unregister() is still called from the msm_drm_uninit() function.
Now, your comment made me realize that there's a bug in this patch since after
the drm_dev_unregister(), dev->registered will be set to false and so in the
.remove -> .unbind path drm_atomic_helper_shutdown() will never be executed.
I guess one option is to do the if (dev->registered) check in the callers but
then it won't really be worth it to have a helper and we could just add that
check in msm_drv_shutdown() to conditionally call drm_atomic_helper_shutdown().
--
Best regards,
Javier Martinez Canillas
Linux Engineering
Red Hat
More information about the dri-devel
mailing list