Skip to content

Commit d5e81e3

Browse files
mripardgregkh
authored andcommitted
drm/vc4: hdmi: Make sure the device is powered with CEC
Commit 20b0dfa upstream. The original commit depended on a rework commit (724fc85 ("drm/vc4: hdmi: Split the CEC disable / enable functions in two")) that (rightfully) didn't reach stable. However, probably because the context changed, when the patch was applied to stable the pm_runtime_put called got moved to the end of the vc4_hdmi_cec_adap_enable function (that would have become vc4_hdmi_cec_disable with the rework) to vc4_hdmi_cec_init. This means that at probe time, we now drop our reference to the clocks and power domains and thus end up with a CPU hang when the CPU tries to access registers. The call to pm_runtime_resume_and_get() is also problematic since the .adap_enable CEC hook is called both to enable and to disable the controller. That means that we'll now call pm_runtime_resume_and_get() at disable time as well, messing with the reference counting. The behaviour we should have though would be to have pm_runtime_resume_and_get() called when the CEC controller is enabled, and pm_runtime_put when it's disabled. We need to move things around a bit to behave that way, but it aligns stable with upstream. Cc: <[email protected]> # 5.10.x Cc: <[email protected]> # 5.15.x Cc: <[email protected]> # 5.16.x Reported-by: Michael Stapelberg <[email protected]> Signed-off-by: Maxime Ripard <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent dffeeca commit d5e81e3

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

drivers/gpu/drm/vc4/vc4_hdmi.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,18 +1738,18 @@ static int vc4_hdmi_cec_adap_enable(struct cec_adapter *adap, bool enable)
17381738
u32 val;
17391739
int ret;
17401740

1741-
ret = pm_runtime_resume_and_get(&vc4_hdmi->pdev->dev);
1742-
if (ret)
1743-
return ret;
1741+
if (enable) {
1742+
ret = pm_runtime_resume_and_get(&vc4_hdmi->pdev->dev);
1743+
if (ret)
1744+
return ret;
17441745

1745-
val = HDMI_READ(HDMI_CEC_CNTRL_5);
1746-
val &= ~(VC4_HDMI_CEC_TX_SW_RESET | VC4_HDMI_CEC_RX_SW_RESET |
1747-
VC4_HDMI_CEC_CNT_TO_4700_US_MASK |
1748-
VC4_HDMI_CEC_CNT_TO_4500_US_MASK);
1749-
val |= ((4700 / usecs) << VC4_HDMI_CEC_CNT_TO_4700_US_SHIFT) |
1750-
((4500 / usecs) << VC4_HDMI_CEC_CNT_TO_4500_US_SHIFT);
1746+
val = HDMI_READ(HDMI_CEC_CNTRL_5);
1747+
val &= ~(VC4_HDMI_CEC_TX_SW_RESET | VC4_HDMI_CEC_RX_SW_RESET |
1748+
VC4_HDMI_CEC_CNT_TO_4700_US_MASK |
1749+
VC4_HDMI_CEC_CNT_TO_4500_US_MASK);
1750+
val |= ((4700 / usecs) << VC4_HDMI_CEC_CNT_TO_4700_US_SHIFT) |
1751+
((4500 / usecs) << VC4_HDMI_CEC_CNT_TO_4500_US_SHIFT);
17511752

1752-
if (enable) {
17531753
HDMI_WRITE(HDMI_CEC_CNTRL_5, val |
17541754
VC4_HDMI_CEC_TX_SW_RESET | VC4_HDMI_CEC_RX_SW_RESET);
17551755
HDMI_WRITE(HDMI_CEC_CNTRL_5, val);
@@ -1777,7 +1777,10 @@ static int vc4_hdmi_cec_adap_enable(struct cec_adapter *adap, bool enable)
17771777
HDMI_WRITE(HDMI_CEC_CPU_MASK_SET, VC4_HDMI_CPU_CEC);
17781778
HDMI_WRITE(HDMI_CEC_CNTRL_5, val |
17791779
VC4_HDMI_CEC_TX_SW_RESET | VC4_HDMI_CEC_RX_SW_RESET);
1780+
1781+
pm_runtime_put(&vc4_hdmi->pdev->dev);
17801782
}
1783+
17811784
return 0;
17821785
}
17831786

@@ -1888,8 +1891,6 @@ static int vc4_hdmi_cec_init(struct vc4_hdmi *vc4_hdmi)
18881891
if (ret < 0)
18891892
goto err_remove_handlers;
18901893

1891-
pm_runtime_put(&vc4_hdmi->pdev->dev);
1892-
18931894
return 0;
18941895

18951896
err_remove_handlers:

0 commit comments

Comments
 (0)