All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i915] drm/i915/bw: Ignore inactive CRTCs in bandwidth calculation
@ 2026-10-16  1:47 Hanson Wang
  2026-10-16 11:52 ` Ville Syrjälä
  0 siblings, 1 reply; 2+ messages in thread
From: Hanson Wang @ 2026-10-16  1:47 UTC (permalink / raw)
  To: intel-gfx
  Cc: jani.nikula, rodrigo.vivi, joonas.lahtinen, tursulin, dri-devel,
	Hanson Wang

The per-CRTC bandwidth helpers use cached active_planes and data_rate
values without checking whether the CRTC is active. During hardware
state readout an inactive CRTC may retain stale plane state, causing
intel_bw_state to account phantom bandwidth.

This can leave bandwidth and an active plane accounted after an HDMI
disconnect and make the QGV check reject otherwise valid atomic commits.

Return zero from both helpers for inactive CRTCs so hardware readout
and atomic checks cannot propagate stale bandwidth.

Signed-off-by: Hanson Wang <hanson.wang@ugreen.com>
---
 drivers/gpu/drm/i915/display/intel_bw.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/i915/display/intel_bw.c b/drivers/gpu/drm/i915/display/intel_bw.c
index ac6da20d9..62d9ae416 100644
--- a/drivers/gpu/drm/i915/display/intel_bw.c
+++ b/drivers/gpu/drm/i915/display/intel_bw.c
@@ -838,6 +838,9 @@ void intel_bw_init_hw(struct intel_display *display)
 
 static unsigned int intel_bw_crtc_num_active_planes(const struct intel_crtc_state *crtc_state)
 {
+	if (!crtc_state->hw.active)
+		return 0;
+
 	/*
 	 * We assume cursors are small enough
 	 * to not not cause bandwidth problems.
@@ -852,6 +855,9 @@ static unsigned int intel_bw_crtc_data_rate(const struct intel_crtc_state *crtc_
 	unsigned int data_rate = 0;
 	enum plane_id plane_id;
 
+	if (!crtc_state->hw.active)
+		return 0;
+
 	for_each_plane_id_on_crtc(crtc, plane_id) {
 		/*
 		 * We assume cursors are small enough
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH i915] drm/i915/bw: Ignore inactive CRTCs in bandwidth calculation
  2026-10-16  1:47 [PATCH i915] drm/i915/bw: Ignore inactive CRTCs in bandwidth calculation Hanson Wang
@ 2026-10-16 11:52 ` Ville Syrjälä
  0 siblings, 0 replies; 2+ messages in thread
From: Ville Syrjälä @ 2026-10-16 11:52 UTC (permalink / raw)
  To: Hanson Wang
  Cc: intel-gfx, jani.nikula, rodrigo.vivi, joonas.lahtinen, tursulin,
	dri-devel

On Fri, Oct 16, 2026 at 09:47:04AM +0800, Hanson Wang wrote:
> The per-CRTC bandwidth helpers use cached active_planes and data_rate
> values without checking whether the CRTC is active. During hardware
> state readout an inactive CRTC may retain stale plane state, causing
> intel_bw_state to account phantom bandwidth.
> 
> This can leave bandwidth and an active plane accounted after an HDMI
> disconnect and make the QGV check reject otherwise valid atomic commits.

Shouldn't happen. If the CRTC gets disabled it no longer counts. Are you
leaving the CRTC logically enabled but inactive (enable==true &&
active==false)? That we still want to count because 
'enable==true && active==false -> enable==true && active==true'
transition should never fail.

> 
> Return zero from both helpers for inactive CRTCs so hardware readout
> and atomic checks cannot propagate stale bandwidth.
> 
> Signed-off-by: Hanson Wang <hanson.wang@ugreen.com>
> ---
>  drivers/gpu/drm/i915/display/intel_bw.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_bw.c b/drivers/gpu/drm/i915/display/intel_bw.c
> index ac6da20d9..62d9ae416 100644
> --- a/drivers/gpu/drm/i915/display/intel_bw.c
> +++ b/drivers/gpu/drm/i915/display/intel_bw.c
> @@ -838,6 +838,9 @@ void intel_bw_init_hw(struct intel_display *display)
>  
>  static unsigned int intel_bw_crtc_num_active_planes(const struct intel_crtc_state *crtc_state)
>  {
> +	if (!crtc_state->hw.active)
> +		return 0;
> +
>  	/*
>  	 * We assume cursors are small enough
>  	 * to not not cause bandwidth problems.
> @@ -852,6 +855,9 @@ static unsigned int intel_bw_crtc_data_rate(const struct intel_crtc_state *crtc_
>  	unsigned int data_rate = 0;
>  	enum plane_id plane_id;
>  
> +	if (!crtc_state->hw.active)
> +		return 0;
> +
>  	for_each_plane_id_on_crtc(crtc, plane_id) {
>  		/*
>  		 * We assume cursors are small enough
> -- 
> 2.34.1

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-16 11:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-16  1:47 [PATCH i915] drm/i915/bw: Ignore inactive CRTCs in bandwidth calculation Hanson Wang
2026-10-16 11:52 ` Ville Syrjälä

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.