Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/vc4: crtc: Make sure the HDMI controller is powered when disabling

Since commit 875a4d536842 ("drm/vc4: drv: Disable the CRTC at boot
time"), during the initial setup of the driver we call into the VC4 HDMI
controller hooks to make sure the controller is properly disabled.

However, we were never making sure that the device was properly powered
while doing so. This never resulted in any (reported) issue in practice,
but since the introduction of commit 4209f03fcb8e ("drm/vc4: hdmi: Warn
if we access the controller while disabled") we get a loud complaint
when we do that kind of access.

Let's make sure we have the HDMI controller properly powered while
disabling it.

Fixes: 875a4d536842 ("drm/vc4: drv: Disable the CRTC at boot time")
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Reviewed-by: Nicolas Saenz Julienne <nsaenz@kernel.org>
Tested-by: Nicolas Saenz Julienne <nsaenz@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210923185013.826679-1-maxime@cerno.tech

+18 -1
+18 -1
drivers/gpu/drm/vc4/vc4_crtc.c
··· 32 32 #include <linux/clk.h> 33 33 #include <linux/component.h> 34 34 #include <linux/of_device.h> 35 + #include <linux/pm_runtime.h> 35 36 36 37 #include <drm/drm_atomic.h> 37 38 #include <drm/drm_atomic_helper.h> ··· 43 42 #include <drm/drm_vblank.h> 44 43 45 44 #include "vc4_drv.h" 45 + #include "vc4_hdmi.h" 46 46 #include "vc4_regs.h" 47 47 48 48 #define HVS_FIFO_LATENCY_PIX 6 ··· 498 496 enum vc4_encoder_type encoder_type; 499 497 const struct vc4_pv_data *pv_data; 500 498 struct drm_encoder *encoder; 499 + struct vc4_hdmi *vc4_hdmi; 501 500 unsigned encoder_sel; 502 501 int channel; 502 + int ret; 503 503 504 504 if (!(of_device_is_compatible(vc4_crtc->pdev->dev.of_node, 505 505 "brcm,bcm2711-pixelvalve2") || ··· 529 525 if (WARN_ON(!encoder)) 530 526 return 0; 531 527 532 - return vc4_crtc_disable(crtc, encoder, NULL, channel); 528 + vc4_hdmi = encoder_to_vc4_hdmi(encoder); 529 + ret = pm_runtime_resume_and_get(&vc4_hdmi->pdev->dev); 530 + if (ret) 531 + return ret; 532 + 533 + ret = vc4_crtc_disable(crtc, encoder, NULL, channel); 534 + if (ret) 535 + return ret; 536 + 537 + ret = pm_runtime_put(&vc4_hdmi->pdev->dev); 538 + if (ret) 539 + return ret; 540 + 541 + return 0; 533 542 } 534 543 535 544 static void vc4_crtc_atomic_disable(struct drm_crtc *crtc,