drm/i915/bw: sync global BW after non-atomic plane disable
Subsystems (3)
PATCH 1/1 drm/i915/bw: sync global BW after non-atomic plane disable
Hardware readout copies the firmware plane configuration into the global bandwidth state. skl_dbuf_sanitize() may then disable those planes through intel_plane_disable_noatomic(), which clears the CRTC-local active_planes, data_rate and DDB entries but does not update the global state.
A later atomic modeset sees both the old and new per-CRTC bandwidth as zero and skips the global update. The sanitized pipe therefore keeps contributing a phantom data rate and an active plane to the QGV check.
Do not force !hw.active to zero. A logically enabled but inactive CRTC must retain its bandwidth reservation so that reactivating it cannot fail due to insufficient bandwidth. After the non-atomic disable, recompute the global intel_bw_state and the separate dbuf bandwidth state from the updated CRTC-local plane and DDB state.
Reproduced on two N5105 systems from different board vendors running 6.18.15. After DBUF sanitization, pipe B retained 196000 kB/s and one plane in the global BW state despite its local plane state being cleared and the pipe subsequently being disabled.
With the corresponding fix backported to 6.18.15 on one system, the same sanitization path updated the global accounting to 0 kB/s and zero planes. Subsequent QGV checks no longer included the stale bandwidth.
---
Testing:
- The corresponding 6.18.15 backport was tested on one N5105 system.
- This mainline version has not been runtime-tested.
- The original high-bandwidth application failure was not replayed.
drivers/gpu/drm/i915/display/intel_bw.c +15 -4
@@ -1444,6 +1444,20 @@ static void intel_bw_crtc_update(struct intel_bw_state *bw_state, bw_state->num_active_planes[crtc->pipe]); } +void intel_bw_crtc_update_noatomic (struct intel_crtc *crtc) +{ +struct intel_display *display =to_intel_display (crtc); +struct intel_bw_state *bw_state = +to_intel_bw_state (display->bw.obj.state); +const struct intel_crtc_state *crtc_state = +to_intel_crtc_state (crtc->base.state); + +if (DISPLAY_VER (display) <11 ) +return ; + +intel_bw_crtc_update (bw_state, crtc_state); +} +void intel_bw_update_hw_state (struct intel_display *display) { struct intel_bw_state *bw_state =
@@ -1456,12 +1470,9 @@ void intel_bw_update_hw_state(struct intel_display *display) bw_state->pipe_sagv_reject =0 ;for_each_intel_crtc (display, crtc) { -const struct intel_crtc_state *crtc_state = -to_intel_crtc_state (crtc->base.state);enum pipe pipe = crtc->pipe; -if (DISPLAY_VER (display) >=11 ) -intel_bw_crtc_update (bw_state, crtc_state); +intel_bw_crtc_update_noatomic (crtc);/* initially SAGV has been forced off */ bw_state->pipe_sagv_reject |=BIT (pipe);
drivers/gpu/drm/i915/display/intel_bw.h +1 -0
@@ -30,6 +30,7 @@ void intel_bw_init_hw(struct intel_display *display);int intel_bw_init (struct intel_display *display);int intel_bw_atomic_check (struct intel_atomic_state *state);void intel_bw_update_hw_state (struct intel_display *display); +void intel_bw_crtc_update_noatomic (struct intel_crtc *crtc);void intel_bw_crtc_disable_noatomic (struct intel_crtc *crtc);bool intel_bw_pmdemand_needs_update (struct intel_atomic_state *state);
drivers/gpu/drm/i915/display/intel_dbuf_bw.c +15 -7
@@ -226,21 +226,29 @@ int intel_dbuf_bw_calc_min_cdclk(struct intel_atomic_state *state,return 0 ; } -void intel_dbuf_bw_update_hw_state (struct intel_display *display) +void intel_dbuf_bw_crtc_update_noatomic (struct intel_crtc *crtc) { +struct intel_display *display =to_intel_display (crtc);struct intel_dbuf_bw_state *dbuf_bw_state =to_intel_dbuf_bw_state (display->dbuf_bw.obj.state); -struct intel_crtc *crtc; +const struct intel_crtc_state *crtc_state = +to_intel_crtc_state (crtc->base.state);if (DISPLAY_VER (display) <9 )return ; -for_each_intel_crtc (display, crtc) { -const struct intel_crtc_state *crtc_state = -to_intel_crtc_state (crtc->base.state); +skl_crtc_calc_dbuf_bw (&dbuf_bw_state->dbuf_bw[crtc->pipe], crtc_state); +} -skl_crtc_calc_dbuf_bw (&dbuf_bw_state->dbuf_bw[crtc->pipe], crtc_state); - } +void intel_dbuf_bw_update_hw_state (struct intel_display *display) +{ +struct intel_crtc *crtc; + +if (DISPLAY_VER (display) <9 ) +return ; + +for_each_intel_crtc (display, crtc) +intel_dbuf_bw_crtc_update_noatomic (crtc); }void intel_dbuf_bw_crtc_disable_noatomic (struct intel_crtc *crtc)
drivers/gpu/drm/i915/display/intel_dbuf_bw.h +1 -0
@@ -32,6 +32,7 @@ int intel_dbuf_bw_calc_min_cdclk(struct intel_atomic_state *state,int intel_dbuf_bw_min_cdclk (struct intel_display *display,const struct intel_dbuf_bw_state *dbuf_bw_state);void intel_dbuf_bw_update_hw_state (struct intel_display *display); +void intel_dbuf_bw_crtc_update_noatomic (struct intel_crtc *crtc);void intel_dbuf_bw_crtc_disable_noatomic (struct intel_crtc *crtc);#endif /* __INTEL_DBUF_BW_H__ */
drivers/gpu/drm/i915/display/intel_display.c +9 -0
@@ -67,6 +67,7 @@#include "intel_cursor.h" #include "intel_cursor_regs.h" #include "intel_cx0_phy.h" +#include "intel_dbuf_bw.h" #include "intel_ddi.h" #include "intel_de.h" #include "intel_dip.h"
@@ -679,6 +680,14 @@ void intel_plane_disable_noatomic(struct intel_crtc *crtc,skl_wm_plane_disable_noatomic (crtc, plane); +/* +* Keep the global bandwidth states in sync with the updated +* CRTC-local plane and DDB state. Otherwise a later atomic check +* may skip the update when its old and new inputs are identical. +*/ +intel_bw_crtc_update_noatomic (crtc); +intel_dbuf_bw_crtc_update_noatomic (crtc); +if ((crtc_state->active_planes & ~BIT (PLANE_CURSOR )) ==0 &&hsw_ips_disable (crtc_state)) { crtc_state->ips_enabled = false;
Signature · 1 line
2.34.1
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] drm/i915/display: stale cdclk state after intel_plane_disable_noatomic() --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] drm/i915/display: stale cdclk state after intel_plane_disable_noatomic()
--
commit cc04b14ee64b615dd833441addacb0b2def5e98d
Author: Hanson Wang <[email protected]>
drm/i915/bw: sync global BW after non-atomic plane disable
This commit updates the global intel_bw_state and intel_dbuf_bw_state when a plane is disabled via intel_plane_disable_noatomic() so that subsequent atomic checks do not retain stale plane bandwidth accounting.
Quoted 4 lines
drivers/gpu/drm/i915/display/intel_display.c +0
-0
[ ... ]
Quoted 5 lines
drivers/gpu/drm/i915/display/intel_display.c +1
-0@@ -679,6 +680,14 @@ void intel_plane_disable_noatomic(struct intel_crtc *crtc,skl_wm_plane_disable_noatomic (crtc, plane); +/*
drivers/gpu/drm/i915/display/intel_display.c void intel_plane_disable_noatomic(struct intel_crtc *crtc, · line 693
Quoted 10 lines
drivers/gpu/drm/i915/display/intel_display.c +7
-0+* Keep the global bandwidth states in sync with the updated +* CRTC-local plane and DDB state. Otherwise a later atomic check +* may skip the update when its old and new inputs are identical. +*/ +intel_bw_crtc_update_noatomic (crtc); +intel_dbuf_bw_crtc_update_noatomic (crtc); +if ((crtc_state->active_planes & ~BIT (PLANE_CURSOR )) ==0 &&hsw_ips_disable (crtc_state)) { crtc_state->ips_enabled = false;
[Severity: Medium]
Does updating display->dbuf_bw.obj.state here without also updating display->cdclk.obj.state and crtc_state->min_cdclk leave cdclk_state->dbuf_bw_min_cdclk and cdclk_state->min_cdclk[pipe] stuck at their pre-sanitization values?
During hardware readout, intel_cdclk_update_hw_state() caches crtc_state->min_cdclk in cdclk_state->min_cdclk[pipe] and caches intel_dbuf_bw_min_cdclk(display, dbuf_bw_state) in cdclk_state->dbuf_bw_min_cdclk. When skl_dbuf_sanitize() then disables the plane through intel_plane_disable_noatomic(), intel_dbuf_bw_crtc_update_noatomic() zeroes the pipe's entry in dbuf_bw_state, so a subsequent atomic modeset on that pipe sees both old_dbuf_bw and new_dbuf_bw as zero and skips intel_cdclk_update_dbuf_bw_min_cdclk() in intel_dbuf_bw_calc_min_cdclk():
drivers/gpu/drm/i915/display/intel_dbuf_bw.c:intel_dbuf_bw_calc_min_cdclk() {
...
for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state) {
struct intel_dbuf_bw old_dbuf_bw, new_dbuf_bw;
skl_crtc_calc_dbuf_bw(&old_dbuf_bw, old_crtc_state);
skl_crtc_calc_dbuf_bw(&new_dbuf_bw, new_crtc_state);
if (!intel_dbuf_bw_changed(display, &old_dbuf_bw, &new_dbuf_bw))
continue;
...
if (!old_dbuf_bw_state)
return 0;
}Similarly, intel_plane_set_invisible() zeroes plane_min_cdclk[plane->id] and hsw_ips_disable() clears ips_enabled without recomputing crtc_state->min_cdclk or cdclk_state->min_cdclk[pipe]; intel_initial_commit() then updates crtc_state->min_cdclk while allow_cdclk_decrease is false, so later modesets where min_cdclk does not change return early in intel_cdclk_update_crtc_min_cdclk() on new_min_cdclk == old_min_cdclk, keeping minimum CDCLK artificially elevated.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Thanks for the review.
I retested the patched mainline kernel on the N5105 with KMS debug logging enabled. The original DBUF sanitization path was
triggered: pipe B initially accounted for 196000 kB/s and one plane, and the patch cleared that accounting after plane disable.
The subsequent full modeset enabled pipe A and disabled pipe B. The KMS log explicitly shows pipe B's minimum CDCLK changing from 24500 kHz to 0 kHz.
Post-boot inspection also confirmed that the per-CRTC and global minima agree, and that dbuf_bw_min_cdclk is 9282 kHz, matching the value recomputed from the current DBUF bandwidth state.
Thus, I did not observe persistent stale CDCLK minima on this boot path. This does not rule out the plane-only disable case where the CRTC remains enabled without a subsequent full modeset; that case remains untested.
Thanks,
Hanson
Patchwork
CI✗ LGCI.VerificationFailed: failure for drm/i915/bw: sync global BW after non-atomic plane disable
In reply to Hanson Wang== Series Details ==
== Series Details ==
Series: drm/i915/bw: sync global BW after non-atomic plane disable
URL : https://patchwork.freedesktop.org/series/178844/
State : failure
== Summary ==
Series author address '[email protected]' is not on the allowlist, which prevents CI from being automatically triggered. If you want CI to run for this series, ask Patchwork project owners to click 'retest' on the series in Patchwork. Exception occurred during validation, bailing out!
Build URL: http://gfx-ci.igk.intel.com:8080/job/CI_PW_kernel/193435/ (on built-in)
Quoted 22 lines · Hanson Wang
Hardware readout copies the firmware plane configuration into the global bandwidth state.
skl_dbuf_sanitize()may then disable those planes throughintel_plane_disable_noatomic(), which clears the CRTC-localactive_planes,data_rateand DDB entries but does not update the global state.A later atomic modeset sees both the old and new per-CRTC bandwidth as zero and skips the global update. The sanitized pipe therefore keeps contributing a phantom data rate and an active plane to the QGV check.
Do not force !hw.active to zero. A logically enabled but inactive CRTC must retain its bandwidth reservation so that reactivating it cannot fail due to insufficient bandwidth. After the non-atomic disable, recompute the global
intel_bw_stateand the separate dbuf bandwidth state from the updated CRTC-local plane and DDB state.Reproduced on two N5105 systems from different board vendors running 6.18.15. After DBUF sanitization, pipe B retained 196000 kB/s and one plane in the global BW state despite its local plane state being cleared and the pipe subsequently being disabled.
Quoted 4 lines
With the corresponding fix backported to 6.18.15 on one system, the same sanitization path updated the global accounting to 0 kB/s and zero planes. Subsequent QGV checks no longer included the stale bandwidth.
I think what we might want to do is add a new intel_display_update_hw_state() wrapper that calls all the intel_foo_update_hw_state() functions. Then we just call that after any disable_noatomic() stuff is done. Not sure if a single call would be sufficient once we've sanitized everything, or if we'd need to do a few extra calls during the sanitization sequence.
And if we're missing any intel_foo_update_hw_state() implementations then we should just add them.
Quoted 143 lines
Signed-off-by Hanson Wang <[email protected]>---
Testing:
- The corresponding 6.18.15 backport was tested on one N5105 system.
- This mainline version has not been runtime-tested.
- The original high-bandwidth application failure was not replayed.drivers/gpu/drm/i915/display/intel_bw.c +15
-4@@ -1444,6 +1444,20 @@ static void intel_bw_crtc_update(struct intel_bw_state *bw_state, bw_state->num_active_planes[crtc->pipe]); } +void intel_bw_crtc_update_noatomic (struct intel_crtc *crtc) +{ +struct intel_display *display =to_intel_display (crtc); +struct intel_bw_state *bw_state = +to_intel_bw_state (display->bw.obj.state); +const struct intel_crtc_state *crtc_state = +to_intel_crtc_state (crtc->base.state); + +if (DISPLAY_VER (display) <11 ) +return ; + +intel_bw_crtc_update (bw_state, crtc_state); +} +void intel_bw_update_hw_state (struct intel_display *display) { struct intel_bw_state *bw_state =@@ -1456,12 +1470,9 @@ void intel_bw_update_hw_state(struct intel_display *display) bw_state->pipe_sagv_reject =0 ;for_each_intel_crtc (display, crtc) { -const struct intel_crtc_state *crtc_state = -to_intel_crtc_state (crtc->base.state);enum pipe pipe = crtc->pipe; -if (DISPLAY_VER (display) >=11 ) -intel_bw_crtc_update (bw_state, crtc_state); +intel_bw_crtc_update_noatomic (crtc);/* initially SAGV has been forced off */ bw_state->pipe_sagv_reject |=BIT (pipe);drivers/gpu/drm/i915/display/intel_bw.h +1
-0@@ -30,6 +30,7 @@ void intel_bw_init_hw(struct intel_display *display);int intel_bw_init (struct intel_display *display);int intel_bw_atomic_check (struct intel_atomic_state *state);void intel_bw_update_hw_state (struct intel_display *display); +void intel_bw_crtc_update_noatomic (struct intel_crtc *crtc);void intel_bw_crtc_disable_noatomic (struct intel_crtc *crtc);bool intel_bw_pmdemand_needs_update (struct intel_atomic_state *state);drivers/gpu/drm/i915/display/intel_dbuf_bw.c +15
-7@@ -226,21 +226,29 @@ int intel_dbuf_bw_calc_min_cdclk(struct intel_atomic_state *state,return 0 ; } -void intel_dbuf_bw_update_hw_state (struct intel_display *display) +void intel_dbuf_bw_crtc_update_noatomic (struct intel_crtc *crtc) { +struct intel_display *display =to_intel_display (crtc);struct intel_dbuf_bw_state *dbuf_bw_state =to_intel_dbuf_bw_state (display->dbuf_bw.obj.state); -struct intel_crtc *crtc; +const struct intel_crtc_state *crtc_state = +to_intel_crtc_state (crtc->base.state);if (DISPLAY_VER (display) <9 )return ; -for_each_intel_crtc (display, crtc) { -const struct intel_crtc_state *crtc_state = -to_intel_crtc_state (crtc->base.state); +skl_crtc_calc_dbuf_bw (&dbuf_bw_state->dbuf_bw[crtc->pipe], crtc_state); +} -skl_crtc_calc_dbuf_bw (&dbuf_bw_state->dbuf_bw[crtc->pipe], crtc_state); - } +void intel_dbuf_bw_update_hw_state (struct intel_display *display) +{ +struct intel_crtc *crtc; + +if (DISPLAY_VER (display) <9 ) +return ; + +for_each_intel_crtc (display, crtc) +intel_dbuf_bw_crtc_update_noatomic (crtc); }void intel_dbuf_bw_crtc_disable_noatomic (struct intel_crtc *crtc)drivers/gpu/drm/i915/display/intel_dbuf_bw.h +1
-0@@ -32,6 +32,7 @@ int intel_dbuf_bw_calc_min_cdclk(struct intel_atomic_state *state,int intel_dbuf_bw_min_cdclk (struct intel_display *display,const struct intel_dbuf_bw_state *dbuf_bw_state);void intel_dbuf_bw_update_hw_state (struct intel_display *display); +void intel_dbuf_bw_crtc_update_noatomic (struct intel_crtc *crtc);void intel_dbuf_bw_crtc_disable_noatomic (struct intel_crtc *crtc);#endif /* __INTEL_DBUF_BW_H__ */ drivers/gpu/drm/i915/display/intel_display.c +9
-0@@ -67,6 +67,7 @@#include "intel_cursor.h" #include "intel_cursor_regs.h" #include "intel_cx0_phy.h" +#include "intel_dbuf_bw.h" #include "intel_ddi.h" #include "intel_de.h" #include "intel_dip.h" @@ -679,6 +680,14 @@ void intel_plane_disable_noatomic(struct intel_crtc *crtc,skl_wm_plane_disable_noatomic (crtc, plane); +/* +* Keep the global bandwidth states in sync with the updated +* CRTC-local plane and DDB state. Otherwise a later atomic check +* may skip the update when its old and new inputs are identical. +*/ +intel_bw_crtc_update_noatomic (crtc); +intel_dbuf_bw_crtc_update_noatomic (crtc); +if ((crtc_state->active_planes & ~BIT (PLANE_CURSOR )) ==0 &&hsw_ips_disable (crtc_state)) { crtc_state->ips_enabled = false;Signature · 1 line
2.34.1
Signature · 2 lines
Ville Syrjälä Intel
Patchwork
CI✗ LGCI.VerificationFailed: failure for drm/i915/bw: sync global BW after non-atomic plane disable
In reply to Hanson Wang== Series Details ==
== Series Details ==
Series: drm/i915/bw: sync global BW after non-atomic plane disable
URL : https://patchwork.freedesktop.org/series/178908/
State : failure
== Summary ==
Series author address '[email protected]' is not on the allowlist, which prevents CI from being automatically triggered. If you want CI to run for this series, ask Patchwork project owners to click 'retest' on the series in Patchwork. Exception occurred during validation, bailing out!
Build URL: http://intel-gfx-ci-public.igk.intel.com:8080/job/xe_pw_trigger/1345677/ (on master)