Skip to content

drm/vc4: Hold pm_runtime for vc4. #4706

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion arch/arm/boot/dts/bcm2835-common.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
"hd";
interrupts = <2 8>, <2 9>;
ddc = <&i2c2>;
clocks = <&clocks BCM2835_PLLH_PIX>,
clocks = <&firmware_clocks 9>,
<&clocks BCM2835_CLOCK_HSM>;
clock-names = "pixel", "hdmi";
dmas = <&dma (17|(1<<27)|(1<<24))>;
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/boot/dts/overlays/README
Original file line number Diff line number Diff line change
Expand Up @@ -3620,8 +3620,8 @@ Params: cma-512 CMA is 512MB (needs 1GB)
cma-default Use upstream's default value
audio Enable or disable audio over HDMI (default "on")
noaudio Disable all HDMI audio (default "off")
nocomposite Disable the composite video output (default
"off")
composite Enable the composite output (default "off")
N.B. Disables all other outputs on a Pi 4.


Name: vc4-kms-v3d-pi4
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/boot/dts/overlays/upstream-overlay.dts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// redo: ovmerge -c vc4-kms-v3d-overlay.dts,cma-default dwc2-overlay.dts,dr_mode=otg
// redo: ovmerge -c vc4-kms-v3d-overlay.dts,cma-default,composite dwc2-overlay.dts,dr_mode=otg

/dts-v1/;
/plugin/;
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/boot/dts/overlays/vc4-kms-v3d-overlay.dts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@

fragment@11 {
target = <&vec>;
__overlay__ {
__dormant__ {
status = "okay";
};
};
Expand Down Expand Up @@ -118,6 +118,6 @@
__overrides__ {
audio = <0>,"!13";
noaudio = <0>,"=13";
nocomposite = <0>, "!11";
composite = <0>, "=11";
};
};
1 change: 1 addition & 0 deletions drivers/clk/bcm/clk-raspberrypi.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ static int raspberrypi_discover_clocks(struct raspberrypi_clk *rpi,
case RPI_FIRMWARE_HEVC_CLK_ID:
case RPI_FIRMWARE_PIXEL_BVB_CLK_ID:
case RPI_FIRMWARE_VEC_CLK_ID:
case RPI_FIRMWARE_PIXEL_CLK_ID:
hw = raspberrypi_clk_register(rpi, clks->parent,
clks->id);
if (IS_ERR(hw))
Expand Down
61 changes: 39 additions & 22 deletions drivers/gpu/drm/vc4/vc4_hdmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2242,7 +2242,6 @@ static int vc4_hdmi_cec_init(struct vc4_hdmi *vc4_hdmi)
struct platform_device *pdev = vc4_hdmi->pdev;
struct device *dev = &pdev->dev;
unsigned long flags;
u32 value;
int ret;

if (!of_find_property(dev->of_node, "interrupts", NULL)) {
Expand All @@ -2261,15 +2260,6 @@ static int vc4_hdmi_cec_init(struct vc4_hdmi *vc4_hdmi)
cec_fill_conn_info_from_drm(&conn_info, &vc4_hdmi->connector);
cec_s_conn_info(vc4_hdmi->cec_adap, &conn_info);

spin_lock_irqsave(&vc4_hdmi->hw_lock, flags);
value = HDMI_READ(HDMI_CEC_CNTRL_1);
/* Set the logical address to Unregistered */
value |= VC4_HDMI_CEC_ADDR_MASK;
HDMI_WRITE(HDMI_CEC_CNTRL_1, value);
spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags);

vc4_hdmi_cec_update_clk_div(vc4_hdmi);

if (vc4_hdmi->variant->external_irq_controller) {
ret = request_threaded_irq(platform_get_irq_byname(pdev, "cec-rx"),
vc4_cec_irq_handler_rx_bare,
Expand Down Expand Up @@ -2332,6 +2322,29 @@ static void vc4_hdmi_cec_exit(struct vc4_hdmi *vc4_hdmi)

cec_unregister_adapter(vc4_hdmi->cec_adap);
}

static int vc4_hdmi_cec_resume(struct vc4_hdmi *vc4_hdmi)
{
unsigned long flags;
u32 value;

spin_lock_irqsave(&vc4_hdmi->hw_lock, flags);
value = HDMI_READ(HDMI_CEC_CNTRL_1);
/* Set the logical address to Unregistered */
value |= VC4_HDMI_CEC_ADDR_MASK;
HDMI_WRITE(HDMI_CEC_CNTRL_1, value);
spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags);

vc4_hdmi_cec_update_clk_div(vc4_hdmi);

if (!vc4_hdmi->variant->external_irq_controller) {
spin_lock_irqsave(&vc4_hdmi->hw_lock, flags);
HDMI_WRITE(HDMI_CEC_CPU_MASK_SET, 0xffffffff);
spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags);
}

return 0;
}
#else
static int vc4_hdmi_cec_init(struct vc4_hdmi *vc4_hdmi)
{
Expand All @@ -2340,6 +2353,10 @@ static int vc4_hdmi_cec_init(struct vc4_hdmi *vc4_hdmi)

static void vc4_hdmi_cec_exit(struct vc4_hdmi *vc4_hdmi) {};

static void vc4_hdmi_cec_resume(struct vc4_hdmi *vc4_hdmi)
{
return 0;
}
#endif

static int vc4_hdmi_build_regset(struct vc4_hdmi *vc4_hdmi,
Expand Down Expand Up @@ -2575,6 +2592,15 @@ static int vc4_hdmi_runtime_resume(struct device *dev)
if (ret)
return ret;

if (vc4_hdmi->variant->reset)
vc4_hdmi->variant->reset(vc4_hdmi);

ret = vc4_hdmi_cec_resume(vc4_hdmi);
if (ret) {
clk_disable_unprepare(vc4_hdmi->hsm_clock);
return ret;
}

return 0;
}
#endif
Expand Down Expand Up @@ -2688,20 +2714,11 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)
if (ret)
goto err_put_ddc;

/*
* We need to have the device powered up at this point to call
* our reset hook and for the CEC init.
*/
ret = vc4_hdmi_runtime_resume(dev);
if (ret)
goto err_put_ddc;

pm_runtime_get_noresume(dev);
pm_runtime_set_active(dev);
pm_runtime_enable(dev);

if (vc4_hdmi->variant->reset)
vc4_hdmi->variant->reset(vc4_hdmi);
ret = pm_runtime_resume_and_get(dev);
if (ret)
goto err_put_ddc;

if ((of_device_is_compatible(dev->of_node, "brcm,bcm2711-hdmi0") ||
of_device_is_compatible(dev->of_node, "brcm,bcm2711-hdmi1")) &&
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/vc4/vc4_hdmi_regs.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ static inline u32 vc4_hdmi_read(struct vc4_hdmi *hdmi,
const struct vc4_hdmi_variant *variant = hdmi->variant;
void __iomem *base;

WARN_ON(!pm_runtime_active(&hdmi->pdev->dev));
WARN_ON(pm_runtime_status_suspended(&hdmi->pdev->dev));

if (reg >= variant->num_registers) {
dev_warn(&hdmi->pdev->dev,
Expand Down Expand Up @@ -447,7 +447,7 @@ static inline void vc4_hdmi_write(struct vc4_hdmi *hdmi,

lockdep_assert_held(&hdmi->hw_lock);

WARN_ON(!pm_runtime_active(&hdmi->pdev->dev));
WARN_ON(pm_runtime_status_suspended(&hdmi->pdev->dev));

if (reg >= variant->num_registers) {
dev_warn(&hdmi->pdev->dev,
Expand Down