Remove brownout risks from DPU
cover Remove brownout risks from DPU
Things generally run better when plugged in. That also happens to hold for clocks. To ensure that is the case, remove calls that drop the performance state votes while the clocks are still running.
This helps Glymur devices not crash upon resume when a display (incl. the internal one) is plugged in.
The DSI patch is compile-tested only.
---
Konrad Dybcio (3):
drm/msm/dpu: Drop sneaky dev_pm_opp_set_rate(0) drm/msm/dp: Drop dev_pm_opp_set_rate(0) drm/msm/dsi: Drop dev_pm_opp_set_rate(0)
drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c | 4 ++++ drivers/gpu/drm/msm/dp/dp_ctrl.c | 6 +----- drivers/gpu/drm/msm/dsi/dsi_host.c | 2 -- 3 files changed, 5 insertions(+), 7 deletions(-)
---
base-commit: 0d33d21e47d9dc66f91e44da3fc9220c74d93df7
change-id: 20260728-topic-dpu_power-23f5913b1194
Best regards,
Signature · 1 line
Konrad Dybcio <[email protected]>
PATCH 1/3 drm/msm/dpu: Drop sneaky dev_pm_opp_set_rate(0)
From: Konrad Dybcio <[email protected]>
dev_pm_opp_set_rate(0) removes the vote specified in required-opps but does not actually park the clock, making it run without the necessary power backing. Prevent that from happening when _dpu_core_perf_get_core_clk_rate() returns 0.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c +4 -0
@@ -394,6 +394,10 @@ int dpu_core_perf_crtc_update(struct drm_crtc *crtc,trace_dpu_core_perf_update_clk (kms->dev, !crtc->enabled, clk_rate); +/* If we're going offline, PM callbacks will disable the clocks instead */ +if (!clk_rate) +return 0 ; + clk_rate =min (clk_rate, kms->perf.max_core_clk_rate); ret =dev_pm_opp_set_rate (&kms->pdev->dev, clk_rate);if (ret) {
Signature · 1 line
2.55.0
Re: [PATCH 1/3] drm/msm/dpu: Drop sneaky dev_pm_opp_set_rate(0)
Quoted 18 lines · Konrad Dybcio
From: Konrad Dybcio <[email protected]>
dev_pm_opp_set_rate(0)removes the vote specified in required-opps but does not actually park the clock, making it run without the necessary power backing. Prevent that from happening when_dpu_core_perf_get_core_clk_rate()returns 0.Fixes 25fdd5933e4c ("drm/msm: Add SDM845 DPU support")Signed-off-by Konrad Dybcio <[email protected]>--- drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c +0
-0
drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c int dpu_core_perf_crtc_update(struct drm_crtc *crtc, · line 399
Quoted 6 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c +3
-0@@ -394,6 +394,10 @@ int dpu_core_perf_crtc_update(struct drm_crtc *crtc,trace_dpu_core_perf_update_clk (kms->dev, !crtc->enabled, clk_rate); +/* If we're going offline, PM callbacks will disable the clocks instead */ +if (!clk_rate) +return 0 ;
Is 0 here an actual case? If it is coming from the core_perf, then the next line will handle it.
Quoted 8 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c +1
-0+ clk_rate =min (clk_rate, kms->perf.max_core_clk_rate); ret =dev_pm_opp_set_rate (&kms->pdev->dev, clk_rate);if (ret) {Signature · 2 lines
-- 2.55.0
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH 1/3] drm/msm/dpu: Drop sneaky dev_pm_opp_set_rate(0)
Quoted 20 lines · Dmitry Baryshkov
Quoted 19 lines · Konrad Dybcio
From: Konrad Dybcio <[email protected]>
dev_pm_opp_set_rate(0)removes the vote specified in required-opps but does not actually park the clock, making it run without the necessary power backing. Prevent that from happening when_dpu_core_perf_get_core_clk_rate()returns 0.Fixes 25fdd5933e4c ("drm/msm: Add SDM845 DPU support")Signed-off-by Konrad Dybcio <[email protected]>--- drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c +0
-0@@ -394,6 +394,10 @@ int dpu_core_perf_crtc_update(struct drm_crtc *crtc,
Quoted 8 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c int dpu_core_perf_crtc_update(struct drm_crtc *crtc, · line 399
Quoted 5 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c +3
-0trace_dpu_core_perf_update_clk (kms->dev, !crtc->enabled, clk_rate); +/* If we're going offline, PM callbacks will disable the clocks instead */ +if (!clk_rate) +return 0 ;Is 0 here an actual case? If it is coming from the
core_perf, then the next line will handle it.
Yes it is (upon suspend) and it will not be handled because it's a min() and not a max() below
Konrad
Quoted 10 lines
Quoted 9 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c +1
-0+ clk_rate =min (clk_rate, kms->perf.max_core_clk_rate); ret =dev_pm_opp_set_rate (&kms->pdev->dev, clk_rate);if (ret) {Signature · 2 lines
-- 2.55.0
PATCH 2/3 drm/msm/dp: Drop dev_pm_opp_set_rate(0)
In reply to Konrad DybcioFrom: Konrad Dybcio <[email protected]>
dev_pm_opp_set_rate(0) removes the vote specified in required-opps but does not actually park the clock, making it run without the necessary power backing. Drop the explicit calls to it.
--- drivers/gpu/drm/msm/dp/dp_ctrl.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/gpu/drm/msm/dp/dp_ctrl.c +1 -5
@@ -1950,13 +1950,12 @@ static int msm_dp_ctrl_reinitialize_mainlink(struct msm_dp_ctrl_private *ctrl)msm_dp_ctrl_mainlink_disable (ctrl); ctrl->phy_opts.dp.lanes = ctrl->link->link_params.num_lanes;phy_configure (phy, &ctrl->phy_opts); +/* * Disable and re-enable the mainlink clock since the * link clock might have been adjusted as part of the * link maintenance. */ -dev_pm_opp_set_rate (ctrl->dev,0 ); -msm_dp_ctrl_link_clk_disable (&ctrl->msm_dp_ctrl);phy_power_off (phy);
@@ -1982,7 +1981,6 @@ static int msm_dp_ctrl_deinitialize_mainlink(struct msm_dp_ctrl_private *ctrl)msm_dp_ctrl_reset (&ctrl->msm_dp_ctrl); -dev_pm_opp_set_rate (ctrl->dev,0 );msm_dp_ctrl_link_clk_disable (&ctrl->msm_dp_ctrl);phy_power_off (phy);
@@ -2573,7 +2571,6 @@ void msm_dp_ctrl_off_link_stream(struct msm_dp_ctrl *msm_dp_ctrl) ctrl->stream_clks_on = false; } -dev_pm_opp_set_rate (ctrl->dev,0 );msm_dp_ctrl_link_clk_disable (&ctrl->msm_dp_ctrl);phy_power_off (phy);
@@ -2602,7 +2599,6 @@ void msm_dp_ctrl_off(struct msm_dp_ctrl *msm_dp_ctrl) ctrl->stream_clks_on = false; } -dev_pm_opp_set_rate (ctrl->dev,0 );msm_dp_ctrl_link_clk_disable (&ctrl->msm_dp_ctrl);phy_power_off (phy);
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH 2/3] drm/msm/dp: Drop dev_pm_opp_set_rate(0)
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Removing `dev_pm_opp_set_rate(0)` entirely introduces a permanent performance state (voltage)…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Removing dev_pm_opp_set_rate(0) entirely introduces a permanent performance state (voltage) vote leak when the display is disabled but the monitor remains plugged in. --
--- Patch [2]: [PATCH 2/3] drm/msm/dp: Drop dev_pm_opp_set_rate(0) --- commit bc14685e819772f265842e7901b3f8c5d0779863
Author: Konrad Dybcio <[email protected]>
drm/msm/dp: Drop dev_pm_opp_set_rate(0)
This commit removes explicit calls to dev_pm_opp_set_rate(0) in the DP link disable and deinitialization paths. The commit message notes that it does not actually park the clock and makes it run without the necessary power backing.
Quoted 20 lines
drivers/gpu/drm/msm/dp/dp_ctrl.c +1
-2@@ -1950,13 +1950,12 @@ static int msm_dp_ctrl_reinitialize_mainlink(struct msm_dp_ctrl_private *ctrl)msm_dp_ctrl_mainlink_disable (ctrl); ctrl->phy_opts.dp.lanes = ctrl->link->link_params.num_lanes;phy_configure (phy, &ctrl->phy_opts); +/* * Disable and re-enable the mainlink clock since the * link clock might have been adjusted as part of the * link maintenance. */ -dev_pm_opp_set_rate (ctrl->dev,0 ); -msm_dp_ctrl_link_clk_disable (&ctrl->msm_dp_ctrl);phy_power_off (phy);
drivers/gpu/drm/msm/dp/dp_ctrl.c static int msm_dp_ctrl_deinitialize_mainlink(struct msm_dp_ctrl_private *ctrl) · line 1986
Quoted 7 lines
drivers/gpu/drm/msm/dp/dp_ctrl.c +0
-1@@ -1982,7 +1981,6 @@ static int msm_dp_ctrl_deinitialize_mainlink(struct msm_dp_ctrl_private *ctrl)msm_dp_ctrl_reset (&ctrl->msm_dp_ctrl); -dev_pm_opp_set_rate (ctrl->dev,0 );msm_dp_ctrl_link_clk_disable (&ctrl->msm_dp_ctrl);phy_power_off (phy);
[Severity: Medium]
Does removing this call introduce a permanent performance state (voltage) vote leak when the display is disabled but the monitor remains plugged in?
When a user connects a DP monitor, msm_dp_hpd_plug_handle() holds a runtime PM reference for the duration of the plug. If the link is enabled for display, the clocks are enabled and an OPP rate is set.
Later, if the display is turned off via DRM DPMS or screen timeout, this deinitialization path disables the clocks. However, because the monitor is still physically connected, the runtime PM reference is held. This means the device never runtime suspends and genpd will not automatically drop the performance vote.
Without explicitly dropping the OPP vote here, the SoC power domain might stay in a high performance state indefinitely, causing a continuous power regression.
drivers/gpu/drm/msm/dp/dp_ctrl.c void msm_dp_ctrl_off_link_stream(struct msm_dp_ctrl *msm_dp_ctrl) · line 2576
Quoted 8 lines
drivers/gpu/drm/msm/dp/dp_ctrl.c +0
-1@@ -2573,7 +2571,6 @@ void msm_dp_ctrl_off_link_stream(struct msm_dp_ctrl *msm_dp_ctrl) ctrl->stream_clks_on = false; } -dev_pm_opp_set_rate (ctrl->dev,0 );msm_dp_ctrl_link_clk_disable (&ctrl->msm_dp_ctrl);phy_power_off (phy);
[Severity: Medium]
Similarly, could dropping the OPP vote here in msm_dp_ctrl_off_link_stream() leave the voltage vote active indefinitely while the link stream is off?
drivers/gpu/drm/msm/dp/dp_ctrl.c void msm_dp_ctrl_off(struct msm_dp_ctrl *msm_dp_ctrl) · line 2604
Quoted 8 lines
drivers/gpu/drm/msm/dp/dp_ctrl.c +0
-1@@ -2602,7 +2599,6 @@ void msm_dp_ctrl_off(struct msm_dp_ctrl *msm_dp_ctrl) ctrl->stream_clks_on = false; } -dev_pm_opp_set_rate (ctrl->dev,0 );msm_dp_ctrl_link_clk_disable (&ctrl->msm_dp_ctrl);phy_power_off (phy);
[Severity: Medium]
This removal in msm_dp_ctrl_off() appears to cause the same voltage vote leak when the display is turned off but remains plugged in.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Re: [PATCH 2/3] drm/msm/dp: Drop dev_pm_opp_set_rate(0)
In reply to Konrad DybcioQuoted 6 lines · Konrad Dybcio
From: Konrad Dybcio <[email protected]>
dev_pm_opp_set_rate(0)removes the vote specified in required-opps but does not actually park the clock, making it run without the necessary power backing. Drop the explicit calls to it.
Quoted 6 lines
Fixes c943b4948b58 ("drm/msm/dp: add displayPort driver support")Signed-off-by Konrad Dybcio <[email protected]>--- drivers/gpu/drm/msm/dp/dp_ctrl.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
Signature · 2 lines
With best wishes Dmitry
PATCH 3/3 drm/msm/dsi: Drop dev_pm_opp_set_rate(0)
In reply to Konrad DybcioFrom: Konrad Dybcio <[email protected]>
dev_pm_opp_set_rate(0) removes the vote specified in required-opps but does not actually park the clock, making it run without the necessary power backing. Drop the explicit call to it.
Every call site of ops->link_clk_disable() is followed by pm_runtime_put(), so the power vote will be rescinded if deemed safe.
--- drivers/gpu/drm/msm/dsi/dsi_host.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/msm/dsi/dsi_host.c +0 -2
@@ -550,8 +550,6 @@ int dsi_link_clk_enable_v2(struct msm_dsi_host *msm_host)void dsi_link_clk_disable_6g (struct msm_dsi_host *msm_host) { -/* Drop the performance state vote */ -dev_pm_opp_set_rate (&msm_host->pdev->dev,0 );clk_disable_unprepare (msm_host->esc_clk);clk_disable_unprepare (msm_host->pixel_clk);clk_disable_unprepare (msm_host->byte_intf_clk);
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH 3/3] drm/msm/dsi: Drop dev_pm_opp_set_rate(0)
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
Pre-existing issues:
- [High] Asynchronous pm_runtime_put() in power-off path races with device teardown, leaking bus clocks.
- [High] Ignored return values for clock enablement in msm_dsi_host_xfer_prepare() leading to unclocked register access.
- [High] Unclocked register access crash due to missing cancel_work_sync() for err_work.
- [High] Double put_device() on the PHY device when dsi_get_phy() defers probe.
- [High] Asynchronous pm_runtime_put() causes hardware sequencing violation by disabling regulators while bus clocks are still running. --
--- Patch [3]: [PATCH 3/3] drm/msm/dsi: Drop dev_pm_opp_set_rate(0) --- commit 9d791038937d59c654ef91edf07d2b7ff4432725
Author: Konrad Dybcio <[email protected]>
drm/msm/dsi: Drop dev_pm_opp_set_rate(0)
This commit removes the dev_pm_opp_set_rate(0) call from dsi_link_clk_disable_6g() because it removes the power vote without parking the clock. It relies on the subsequent pm_runtime_put() to rescind the power vote.
Quoted 2 lines
Every call site of
ops->link_clk_disable()is followed bypm_runtime_put(), so the power vote will be rescinded if deemed safe.
[Severity: High]
This isn't a bug introduced by this patch, but does relying on the asynchronous pm_runtime_put() cause a resource leak during teardown?
In msm_dsi_host_power_off(), pm_runtime_put() is called to queue an async suspend. However, if the device is immediately torn down, msm_dsi_host_destroy() cancels any pending async work:
drivers/gpu/drm/msm/dsi/dsi_host.c:msm_dsi_host_destroy() {
...
pm_runtime_disable(&msm_host->pdev->dev);
...
}Because the async suspend is canceled, does this leave the device in the RPM_ACTIVE state and permanently leak the bus clocks? Should pm_runtime_put_sync() be used instead?
[Severity: High]
This is a pre-existing issue, but does this asynchronous pm_runtime_put() also cause a hardware power-sequencing violation?
In msm_dsi_host_power_off(), the regulators are disabled immediately after the async put:
drivers/gpu/drm/msm/dsi/dsi_host.c:msm_dsi_host_power_off() {
...
pm_runtime_put(&msm_host->pdev->dev);
regulator_bulk_disable(msm_host->cfg_hnd->cfg->num_regulators,
msm_host->supplies);
...
}Since pm_runtime_put() returns immediately while bus clocks are still running, does this remove power before the clocks are actually disabled by the asynchronous suspend?
[Severity: High]
This is a pre-existing issue, but is there a risk of an unclocked register access crash during power off?
When the display is turned off in msm_dsi_host_power_off(), hardware clocks are disabled but there is no call to cancel_work_sync() for err_work:
drivers/gpu/drm/msm/dsi/dsi_host.c:msm_dsi_host_power_off() {
...
cfg_hnd->ops->link_clk_disable(msm_host);
pm_runtime_put(&msm_host->pdev->dev);
...
}If err_work executes after clocks are disabled or is flushed during driver teardown:
drivers/gpu/drm/msm/dsi/dsi_host.c:dsi_err_worker() {
...
dsi_sw_reset(msm_host);
...
}Will this unconditional hardware access cause a synchronous external abort?
drivers/gpu/drm/msm/dsi/dsi_host.c int dsi_link_clk_enable_v2(struct msm_dsi_host *msm_host) · line 554
Quoted 10 lines
drivers/gpu/drm/msm/dsi/dsi_host.c +0
-2@@ -550,8 +550,6 @@ int dsi_link_clk_enable_v2(struct msm_dsi_host *msm_host)void dsi_link_clk_disable_6g (struct msm_dsi_host *msm_host) { -/* Drop the performance state vote */ -dev_pm_opp_set_rate (&msm_host->pdev->dev,0 );
[Severity: High]
This is a pre-existing issue, but is it possible for a similar sequence to cause a kernel panic due to ignored return values when enabling clocks?
In msm_dsi_host_xfer_prepare(), the return values for enablement are ignored:
drivers/gpu/drm/msm/dsi/dsi_host.c:msm_dsi_host_xfer_prepare() {
...
pm_runtime_get_sync(&msm_host->pdev->dev);
cfg_hnd->ops->link_clk_set_rate(msm_host);
cfg_hnd->ops->link_clk_enable(msm_host);
...
msm_host->dma_cmd_ctrl_restore = dsi_read(msm_host, REG_DSI_CTRL);
...
}If clock enablement fails, will the unconditional dsi_read() to an unclocked register cause a synchronous external abort?
[Severity: High]
This isn't a bug introduced by this patch, but does dsi_get_phy() double free the PHY device on probe deferral?
If the PHY driver is not ready, dsi_get_phy() drops the reference but leaves a dangling pointer in msm_dsi->phy_dev:
drivers/gpu/drm/msm/dsi/dsi.c:dsi_get_phy() {
...
put_device(&phy_pdev->dev);
DRM_DEV_ERROR(&pdev->dev, "%s: phy driver is not ready\n", __func__);
return -EPROBE_DEFER;
...
}When the error is handled during dsi_init(), it calls dsi_destroy() which drops the reference a second time:
drivers/gpu/drm/msm/dsi/dsi.c:dsi_destroy() {
...
if (msm_dsi->phy_dev) {
put_device(msm_dsi->phy_dev);
...
}Could this lead to a reference count underflow?
Quoted 3 lines
drivers/gpu/drm/msm/dsi/dsi_host.c +0
-0clk_disable_unprepare (msm_host->esc_clk);clk_disable_unprepare (msm_host->pixel_clk);clk_disable_unprepare (msm_host->byte_intf_clk);
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Re: [PATCH 3/3] drm/msm/dsi: Drop dev_pm_opp_set_rate(0)
In reply to Konrad DybcioQuoted 6 lines · Konrad Dybcio
From: Konrad Dybcio <[email protected]>
dev_pm_opp_set_rate(0)removes the vote specified in required-opps but does not actually park the clock, making it run without the necessary power backing. Drop the explicit call to it.
Quoted 9 lines
Every call site of
ops->link_clk_disable()is followed bypm_runtime_put(), so the power vote will be rescinded if deemed safe.Fixes 32d3e0feccfe ("drm/msm: dsi: Use OPP API to set clk/perf state")Signed-off-by Konrad Dybcio <[email protected]>--- drivers/gpu/drm/msm/dsi/dsi_host.c | 2 -- 1 file changed, 2 deletions(-)
Signature · 2 lines
With best wishes Dmitry