MLK-19017-7 drm/imx: sec-dsim_imx: add rpm status check for suspend/resume
authorFancy Fang <chen.fang@nxp.com>
Wed, 25 Jul 2018 07:42:51 +0000 (15:42 +0800)
committerLeonard Crestez <leonard.crestez@nxp.com>
Wed, 17 Apr 2019 23:51:34 +0000 (02:51 +0300)
Add runtime PM status check during runtime suspend and resume
to avoid unnecessary jobs if it is already in that state which
can avoid possible kernel warnings of clock disable/unprepare
mismatch during system suspend if it is alreay in runtime
suspended state.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
(cherry picked from commit 6f95c6fdc0de2fd4fe1d835c164f5e3cfb23e17d)
(cherry picked from commit b6f7433f5b795fa16c15ef9cb3551a371f42f25e)

drivers/gpu/drm/imx/sec_mipi_dsim-imx.c

index e57451d..bc985dd 100644 (file)
@@ -49,6 +49,8 @@ struct imx_sec_dsim_device {
        struct device *dev;
        struct drm_encoder encoder;
        struct regmap *gpr;
+
+       bool rpm_suspended;
 };
 
 #define enc_to_dsim(enc) container_of(enc, struct imx_sec_dsim_device, encoder)
@@ -229,6 +231,7 @@ static int imx_sec_dsim_bind(struct device *dev, struct device *master,
        }
 
        pm_runtime_enable(dev);
+       dsim_dev->rpm_suspended = true;
 
        dev_dbg(dev, "%s: dsim bind end\n", __func__);
 
@@ -288,15 +291,23 @@ static int imx_sec_dsim_resume(struct device *dev)
 #ifdef CONFIG_PM
 static int imx_sec_dsim_runtime_suspend(struct device *dev)
 {
+       if (dsim_dev->rpm_suspended == true)
+               return 0;
+
        sec_mipi_dsim_suspend(dev);
 
        release_bus_freq(BUS_FREQ_HIGH);
 
+       dsim_dev->rpm_suspended = true;
+
        return 0;
 }
 
 static int imx_sec_dsim_runtime_resume(struct device *dev)
 {
+       if (dsim_dev->rpm_suspended == false)
+               return 0;
+
        request_bus_freq(BUS_FREQ_HIGH);
 
        /* Pull dsim out of reset */
@@ -306,6 +317,8 @@ static int imx_sec_dsim_runtime_resume(struct device *dev)
 
        sec_mipi_dsim_resume(dev);
 
+       dsim_dev->rpm_suspended = false;
+
        return 0;
 }
 #endif