drm/tilcdc: Register cpufreq notifier after we have initialized crtc
authorJyri Sarha <jsarha@ti.com>
Wed, 12 Dec 2018 17:26:32 +0000 (19:26 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Sep 2019 08:20:49 +0000 (10:20 +0200)
[ Upstream commit 432973fd3a20102840d5f7e61af9f1a03c217a4c ]

Register cpufreq notifier after we have initialized the crtc and
unregister it before we remove the ctrc. Receiving a cpufreq notify
without crtc causes a crash.

Reported-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Jyri Sarha <jsarha@ti.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/tilcdc/tilcdc_drv.c

index b0d70f943cec56116085f7c3b4740ea30e11e750..56039897607c6bbd1feef8ed8d7b520edc7c3cbb 100644 (file)
@@ -189,6 +189,12 @@ static void tilcdc_fini(struct drm_device *dev)
 {
        struct tilcdc_drm_private *priv = dev->dev_private;
 
+#ifdef CONFIG_CPU_FREQ
+       if (priv->freq_transition.notifier_call)
+               cpufreq_unregister_notifier(&priv->freq_transition,
+                                           CPUFREQ_TRANSITION_NOTIFIER);
+#endif
+
        if (priv->crtc)
                tilcdc_crtc_shutdown(priv->crtc);
 
@@ -204,12 +210,6 @@ static void tilcdc_fini(struct drm_device *dev)
        drm_mode_config_cleanup(dev);
        tilcdc_remove_external_device(dev);
 
-#ifdef CONFIG_CPU_FREQ
-       if (priv->freq_transition.notifier_call)
-               cpufreq_unregister_notifier(&priv->freq_transition,
-                                           CPUFREQ_TRANSITION_NOTIFIER);
-#endif
-
        if (priv->clk)
                clk_put(priv->clk);
 
@@ -282,17 +282,6 @@ static int tilcdc_init(struct drm_driver *ddrv, struct device *dev)
                goto init_failed;
        }
 
-#ifdef CONFIG_CPU_FREQ
-       priv->freq_transition.notifier_call = cpufreq_transition;
-       ret = cpufreq_register_notifier(&priv->freq_transition,
-                       CPUFREQ_TRANSITION_NOTIFIER);
-       if (ret) {
-               dev_err(dev, "failed to register cpufreq notifier\n");
-               priv->freq_transition.notifier_call = NULL;
-               goto init_failed;
-       }
-#endif
-
        if (of_property_read_u32(node, "max-bandwidth", &priv->max_bandwidth))
                priv->max_bandwidth = TILCDC_DEFAULT_MAX_BANDWIDTH;
 
@@ -369,6 +358,17 @@ static int tilcdc_init(struct drm_driver *ddrv, struct device *dev)
        }
        modeset_init(ddev);
 
+#ifdef CONFIG_CPU_FREQ
+       priv->freq_transition.notifier_call = cpufreq_transition;
+       ret = cpufreq_register_notifier(&priv->freq_transition,
+                       CPUFREQ_TRANSITION_NOTIFIER);
+       if (ret) {
+               dev_err(dev, "failed to register cpufreq notifier\n");
+               priv->freq_transition.notifier_call = NULL;
+               goto init_failed;
+       }
+#endif
+
        if (priv->is_componentized) {
                ret = component_bind_all(dev, ddev);
                if (ret < 0)