simpledrm_device_init_clocks() calls clk_prepare_enable() to avoid clocks
used by the framebuffer getting turned off while in use.

simpledrm_device_release_clocks() then must call clk_disable_unprepare()
to balance the enable count. clk_disable_unprepare() actually turns the
clock off, messing with the hardware state before the real display driver
loads, without any knowledge of the proper display power-off sequence.

Sometimes this leaves the hardware in an undefined state e.g. on some
Qualcomm platforms turning off the DP clocks at simpledrm remove() results
in the following error when the msm display driver tries to re-enable them:

[    2.980181] disp_cc_mdss_dptx3_pixel0_clk_src: rcg didn't update its 
configuration.
[    2.980272] WARNING: drivers/clk/qcom/clk-rcg2.c:136 at 
update_config+0xdc/0x100

Switch to using the new __clk_disable_unprepare_counts_only() function,
which decrements the counts without actually turning off the clocks.

Signed-off-by: Hans de Goede <[email protected]>
---
 drivers/gpu/drm/sysfb/simpledrm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/sysfb/simpledrm.c 
b/drivers/gpu/drm/sysfb/simpledrm.c
index 7a95d2dacd9d..6927a32ed282 100644
--- a/drivers/gpu/drm/sysfb/simpledrm.c
+++ b/drivers/gpu/drm/sysfb/simpledrm.c
@@ -261,7 +261,7 @@ static void simpledrm_device_release_clocks(void *res)
 
        for (i = 0; i < sdev->clk_count; ++i) {
                if (sdev->clks[i]) {
-                       clk_disable_unprepare(sdev->clks[i]);
+                       __clk_disable_unprepare_counts_only(sdev->clks[i]);
                        clk_put(sdev->clks[i]);
                }
        }
@@ -315,7 +315,7 @@ static int simpledrm_device_init_clocks(struct 
simpledrm_device *sdev)
        while (i) {
                --i;
                if (sdev->clks[i]) {
-                       clk_disable_unprepare(sdev->clks[i]);
+                       __clk_disable_unprepare_counts_only(sdev->clks[i]);
                        clk_put(sdev->clks[i]);
                }
        }
-- 
2.54.0

Reply via email to