Skip to content

Commit ac4ba79

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: <stable@vger.kernel.org> # 5.10.x Cc: <stable@vger.kernel.org> # 5.15.x Cc: <stable@vger.kernel.org> # 5.16.x Reported-by: Michael Stapelberg <michael+drm@stapelberg.ch> Signed-off-by: Maxime Ripard <maxime@cerno.tech> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 46f919c commit ac4ba79

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

‎drivers/gpu/drm/vc4/vc4_hdmi.c‎

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

1405-
ret = pm_runtime_resume_and_get(&vc4_hdmi->pdev->dev);
1406-
if (ret)
1407-
return ret;
1405+
if (enable) {
1406+
ret = pm_runtime_resume_and_get(&vc4_hdmi->pdev->dev);
1407+
if (ret)
1408+
return ret;
14081409

1409-
val = HDMI_READ(HDMI_CEC_CNTRL_5);
1410-
val &= ~(VC4_HDMI_CEC_TX_SW_RESET | VC4_HDMI_CEC_RX_SW_RESET |
1411-
VC4_HDMI_CEC_CNT_TO_4700_US_MASK |
1412-
VC4_HDMI_CEC_CNT_TO_4500_US_MASK);
1413-
val |= ((4700 / usecs) << VC4_HDMI_CEC_CNT_TO_4700_US_SHIFT) |
1414-
((4500 / usecs) << VC4_HDMI_CEC_CNT_TO_4500_US_SHIFT);
1410+
val = HDMI_READ(HDMI_CEC_CNTRL_5);
1411+
val &= ~(VC4_HDMI_CEC_TX_SW_RESET | VC4_HDMI_CEC_RX_SW_RESET |
1412+
VC4_HDMI_CEC_CNT_TO_4700_US_MASK |
1413+
VC4_HDMI_CEC_CNT_TO_4500_US_MASK);
1414+
val |= ((4700 / usecs) << VC4_HDMI_CEC_CNT_TO_4700_US_SHIFT) |
1415+
((4500 / usecs) << VC4_HDMI_CEC_CNT_TO_4500_US_SHIFT);
14151416

1416-
if (enable) {
14171417
HDMI_WRITE(HDMI_CEC_CNTRL_5, val |
14181418
VC4_HDMI_CEC_TX_SW_RESET | VC4_HDMI_CEC_RX_SW_RESET);
14191419
HDMI_WRITE(HDMI_CEC_CNTRL_5, val);
@@ -1439,7 +1439,10 @@ static int vc4_hdmi_cec_adap_enable(struct cec_adapter *adap, bool enable)
14391439
HDMI_WRITE(HDMI_CEC_CPU_MASK_SET, VC4_HDMI_CPU_CEC);
14401440
HDMI_WRITE(HDMI_CEC_CNTRL_5, val |
14411441
VC4_HDMI_CEC_TX_SW_RESET | VC4_HDMI_CEC_RX_SW_RESET);
1442+
1443+
pm_runtime_put(&vc4_hdmi->pdev->dev);
14421444
}
1445+
14431446
return 0;
14441447
}
14451448

@@ -1531,8 +1534,6 @@ static int vc4_hdmi_cec_init(struct vc4_hdmi *vc4_hdmi)
15311534
if (ret < 0)
15321535
goto err_delete_cec_adap;
15331536

1534-
pm_runtime_put(&vc4_hdmi->pdev->dev);
1535-
15361537
return 0;
15371538

15381539
err_delete_cec_adap:

0 commit comments

Comments
 (0)