Skip to content

Commit 4190e8b

Browse files
committed
drm/vc4: hdmi: Check the HSM rate at runtime_resume
If our HSM clock has not been properly initialized, any register access will silently lock up the system. Let's check that this can't happen by adding a check for the rate before any register access, and error out otherwise. Link: https://lore.kernel.org/dri-devel/[email protected]/ Reviewed-by: Javier Martinez Canillas <[email protected]> Tested-by: Stefan Wahren <[email protected]> Signed-off-by: Maxime Ripard <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent ae71ab5 commit 4190e8b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

drivers/gpu/drm/vc4/vc4_hdmi.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2869,6 +2869,7 @@ static int vc4_hdmi_runtime_resume(struct device *dev)
28692869
struct vc4_hdmi *vc4_hdmi = dev_get_drvdata(dev);
28702870
unsigned long __maybe_unused flags;
28712871
u32 __maybe_unused value;
2872+
unsigned long rate;
28722873
int ret;
28732874

28742875
/*
@@ -2884,6 +2885,21 @@ static int vc4_hdmi_runtime_resume(struct device *dev)
28842885
if (ret)
28852886
return ret;
28862887

2888+
/*
2889+
* Whenever the RaspberryPi boots without an HDMI monitor
2890+
* plugged in, the firmware won't have initialized the HSM clock
2891+
* rate and it will be reported as 0.
2892+
*
2893+
* If we try to access a register of the controller in such a
2894+
* case, it will lead to a silent CPU stall. Let's make sure we
2895+
* prevent such a case.
2896+
*/
2897+
rate = clk_get_rate(vc4_hdmi->hsm_clock);
2898+
if (!rate) {
2899+
ret = -EINVAL;
2900+
goto err_disable_clk;
2901+
}
2902+
28872903
if (vc4_hdmi->variant->reset)
28882904
vc4_hdmi->variant->reset(vc4_hdmi);
28892905

@@ -2905,6 +2921,10 @@ static int vc4_hdmi_runtime_resume(struct device *dev)
29052921
#endif
29062922

29072923
return 0;
2924+
2925+
err_disable_clk:
2926+
clk_disable_unprepare(vc4_hdmi->hsm_clock);
2927+
return ret;
29082928
}
29092929

29102930
static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)

0 commit comments

Comments
 (0)