diff mbox series

[BACKPORT,4.19.y,3/3] drm/tilcdc: Register cpufreq notifier after we have initialized crtc

Message ID 20190829200001.17092-4-mathieu.poirier@linaro.org
State New
Headers show
Series Candidate from TI 4.19 product kernel | expand

Commit Message

Mathieu Poirier Aug. 29, 2019, 8 p.m. UTC
From: Jyri Sarha <jsarha@ti.com>


commit 432973fd3a20102840d5f7e61af9f1a03c217a4c upstream

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: Mathieu Poirier <mathieu.poirier@linaro.org>

---
 drivers/gpu/drm/tilcdc/tilcdc_drv.c | 34 ++++++++++++++---------------
 1 file changed, 17 insertions(+), 17 deletions(-)

-- 
2.17.1

Comments

Sasha Levin Aug. 29, 2019, 11:11 p.m. UTC | #1
On Thu, Aug 29, 2019 at 02:00:01PM -0600, Mathieu Poirier wrote:
>From: Jyri Sarha <jsarha@ti.com>

>

>commit 432973fd3a20102840d5f7e61af9f1a03c217a4c upstream

>

>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: Mathieu Poirier <mathieu.poirier@linaro.org>


I've queued this one for 4.19 and 4.14, thank you!

--
Thanks,
Sasha
diff mbox series

Patch

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 0fb300d41a09..e1868776da25 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -184,6 +184,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);
 
@@ -198,12 +204,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);
 
@@ -274,17 +274,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;
 
@@ -361,6 +350,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)