Consider DBuf bandwidth when calculating CDCLK
Subsystems (3)
v3 cover Consider DBuf bandwidth when calculating CDCLK
We need to calculate cdclk after watermarks/ddb has been calculated as with recent hw CDCLK needs to be adjusted accordingly to DBuf requirements, which is not possible with current code organization.
Setting CDCLK according to DBuf BW requirements and not just rejecting if it doesn't satisfy BW requirements, will allow us to save power when it is possible and gain additional bandwidth when it's needed - i.e boosting both our power management and perfomance capabilities.
This patch is preparation for that, first we now extract modeset calculation from modeset checks, in order to call it after wm/ddb has been calculated.
Stanislav Lisovskiy (5):
drm/i915: Decouple cdclk calculation from modeset checks drm/i915: Force recalculate min_cdclk if planes config changed drm/i915: Introduce for_each_dbuf_slice_in_mask macro drm/i915: Adjust CDCLK accordingly to our DBuf bw needs drm/i915: Remove unneeded hack now for CDCLK
drivers/gpu/drm/i915/display/intel_bw.c | 61 ++++++++++++++++++- drivers/gpu/drm/i915/display/intel_bw.h | 8 +++ drivers/gpu/drm/i915/display/intel_cdclk.c | 31 +++++++--- drivers/gpu/drm/i915/display/intel_display.c | 36 ++++++++--- drivers/gpu/drm/i915/display/intel_display.h | 7 +++ .../drm/i915/display/intel_display_power.h | 5 ++ drivers/gpu/drm/i915/intel_pm.c | 34 ++++++++++- drivers/gpu/drm/i915/intel_pm.h | 3 + 8 files changed, 163 insertions(+), 22 deletions(-)
Signature · 6 lines
2.24.1.485.gad05a3d8e5 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v3 1/5 drm/i915: Decouple cdclk calculation from modeset checks
We need to calculate cdclk after watermarks/ddb has been calculated as with recent hw CDCLK needs to be adjusted accordingly to DBuf requirements, which is not possible with current code organization.
Setting CDCLK according to DBuf BW requirements and not just rejecting if it doesn't satisfy BW requirements, will allow us to save power when it is possible and gain additional bandwidth when it's needed - i.e boosting both our power management and perfomance capabilities.
This patch is preparation for that, first we now extract modeset calculation from modeset checks, in order to call it after wm/ddb has been calculated.
v2: - Extract only intel_modeset_calc_cdclk from intel_modeset_checks
(Ville Syrjälä)
--- drivers/gpu/drm/i915/display/intel_display.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/display/intel_display.c +10 -8
@@ -14545,10 +14545,6 @@ static int intel_modeset_checks(struct intel_atomic_state *state)return ret; } - ret =intel_modeset_calc_cdclk (state); -if (ret) -return ret; -intel_modeset_clear_plls (state);if (IS_HASWELL (dev_priv))
@@ -14882,10 +14878,6 @@ static int intel_atomic_check(struct drm_device *dev, goto fail; } - ret =intel_atomic_check_crtcs (state); -if (ret) - goto fail; -intel_fbc_choose_crtc (dev_priv, state); ret =calc_watermark_data (state);if (ret)
@@ -14895,6 +14887,16 @@ static int intel_atomic_check(struct drm_device *dev,if (ret) goto fail; +if (any_ms) { + ret =intel_modeset_calc_cdclk (state); +if (ret) +return ret; + } + + ret =intel_atomic_check_crtcs (state); +if (ret) + goto fail; +for_each_oldnew_intel_crtc_in_state (state, crtc, old_crtc_state, new_crtc_state, i) { if (!needs_modeset(new_crtc_state) &&
Signature · 6 lines
2.24.1.485.gad05a3d8e5 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH v3 1/5] drm/i915: Decouple cdclk calculation from modeset checks
Quoted 50 lines · Stanislav Lisovskiy
We need to calculate cdclk after watermarks/ddb has been calculated as with recent hw CDCLK needs to be adjusted accordingly to DBuf requirements, which is not possible with current code organization.
Setting CDCLK according to DBuf BW requirements and not just rejecting if it doesn't satisfy BW requirements, will allow us to save power when it is possible and gain additional bandwidth when it's needed - i.e boosting both our power management and perfomance capabilities.
This patch is preparation for that, first we now extract modeset calculation from modeset checks, in order to call it after wm/ddb has been calculated.
v2: - Extract only
intel_modeset_calc_cdclkfromintel_modeset_checks
(Ville Syrjälä)Signed-off-by Stanislav Lisovskiy <[email protected]>--- drivers/gpu/drm/i915/display/intel_display.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)drivers/gpu/drm/i915/display/intel_display.c +0
-8@@ -14545,10 +14545,6 @@ static int intel_modeset_checks(struct intel_atomic_state *state)return ret; } - ret =intel_modeset_calc_cdclk (state); -if (ret) -return ret; -intel_modeset_clear_plls (state);if (IS_HASWELL (dev_priv))@@ -14882,10 +14878,6 @@ static int intel_atomic_check(struct drm_device *dev, goto fail; } - ret =intel_atomic_check_crtcs (state); -if (ret) - goto fail; -intel_fbc_choose_crtc (dev_priv, state); ret =calc_watermark_data (state);if (ret)@@ -14895,6 +14887,16 @@ static int intel_atomic_check(struct drm_device *dev,if (ret) goto fail;
drivers/gpu/drm/i915/display/intel_display.c static int intel_atomic_check(struct drm_device *dev, · line 14898
Quoted 10 lines
drivers/gpu/drm/i915/display/intel_display.c +9
-0+if (any_ms) { + ret =intel_modeset_calc_cdclk (state); +if (ret) +return ret; + } + + ret =intel_atomic_check_crtcs (state); +if (ret) + goto fail;
I was thinking we'd do this as two patches. One with just the extraction, and another one with the bigger reordering. But I think I convinced myself that it should be safe, so maybe a single patch is fine.
Quoted 6 lines
drivers/gpu/drm/i915/display/intel_display.c +1
-0+for_each_oldnew_intel_crtc_in_state (state, crtc, old_crtc_state, new_crtc_state, i) { if (!needs_modeset(new_crtc_state) &&Signature · 1 line
2.24.1.485.gad05a3d8e5
Signature · 6 lines
Ville Syrjälä Intel _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 1/5 drm/i915: Decouple cdclk calculation from modeset checks
In reply to Stanislav LisovskiyWe need to calculate cdclk after watermarks/ddb has been calculated as with recent hw CDCLK needs to be adjusted accordingly to DBuf requirements, which is not possible with current code organization.
Setting CDCLK according to DBuf BW requirements and not just rejecting if it doesn't satisfy BW requirements, will allow us to save power when it is possible and gain additional bandwidth when it's needed - i.e boosting both our power management and perfomance capabilities.
This patch is preparation for that, first we now extract modeset calculation from modeset checks, in order to call it after wm/ddb has been calculated.
v2: - Extract only intel_modeset_calc_cdclk from intel_modeset_checks
(Ville Syrjälä)
v3: - Clear plls after intel_modeset_calc_cdclk
--- drivers/gpu/drm/i915/display/intel_display.c | 22 +++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/display/intel_display.c +12 -10
@@ -14464,12 +14464,6 @@ static int intel_modeset_checks(struct intel_atomic_state *state)return ret; } - ret =intel_modeset_calc_cdclk (state); -if (ret) -return ret; - -intel_modeset_clear_plls (state); -if (IS_HASWELL (dev_priv))return hsw_mode_set_planes_workaround (state);
@@ -14801,10 +14795,6 @@ static int intel_atomic_check(struct drm_device *dev, goto fail; } - ret =intel_atomic_check_crtcs (state); -if (ret) - goto fail; -intel_fbc_choose_crtc (dev_priv, state); ret =calc_watermark_data (state);if (ret)
@@ -14814,6 +14804,18 @@ static int intel_atomic_check(struct drm_device *dev,if (ret) goto fail; +if (any_ms) { + ret =intel_modeset_calc_cdclk (state); +if (ret) +return ret; + +intel_modeset_clear_plls (state); + } + + ret =intel_atomic_check_crtcs (state); +if (ret) + goto fail; +for_each_oldnew_intel_crtc_in_state (state, crtc, old_crtc_state, new_crtc_state, i) { if (!needs_modeset(new_crtc_state) &&
Signature · 6 lines
2.24.1.485.gad05a3d8e5 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH v4 1/5] drm/i915: Decouple cdclk calculation from modeset checks
Quoted 9 lines · Stanislav Lisovskiy
We need to calculate cdclk after watermarks/ddb has been calculated as with recent hw CDCLK needs to be adjusted accordingly to DBuf requirements, which is not possible with current code organization.
Setting CDCLK according to DBuf BW requirements and not just rejecting if it doesn't satisfy BW requirements, will allow us to save power when it is possible and gain additional bandwidth when it's needed - i.e boosting both our power management and perfomance capabilities.
Quoted 8 lines
This patch is preparation for that, first we now extract modeset calculation from modeset checks, in order to call it after wm/ddb has been calculated.
v2: - Extract only
intel_modeset_calc_cdclkfromintel_modeset_checks
(Ville Syrjälä)v3: - Clear plls after
intel_modeset_calc_cdclk
Why did we change this now?
Quoted 55 lines
Signed-off-by Stanislav Lisovskiy <[email protected]>--- drivers/gpu/drm/i915/display/intel_display.c | 22 +++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-)drivers/gpu/drm/i915/display/intel_display.c +12
-10@@ -14464,12 +14464,6 @@ static int intel_modeset_checks(struct intel_atomic_state *state)return ret; } - ret =intel_modeset_calc_cdclk (state); -if (ret) -return ret; - -intel_modeset_clear_plls (state); -if (IS_HASWELL (dev_priv))return hsw_mode_set_planes_workaround (state);@@ -14801,10 +14795,6 @@ static int intel_atomic_check(struct drm_device *dev, goto fail; } - ret =intel_atomic_check_crtcs (state); -if (ret) - goto fail; -intel_fbc_choose_crtc (dev_priv, state); ret =calc_watermark_data (state);if (ret)@@ -14814,6 +14804,18 @@ static int intel_atomic_check(struct drm_device *dev,if (ret) goto fail; +if (any_ms) { + ret =intel_modeset_calc_cdclk (state); +if (ret) +return ret; + +intel_modeset_clear_plls (state); + } + + ret =intel_atomic_check_crtcs (state); +if (ret) + goto fail; +for_each_oldnew_intel_crtc_in_state (state, crtc, old_crtc_state, new_crtc_state, i) { if (!needs_modeset(new_crtc_state) &&Signature · 1 line
2.24.1.485.gad05a3d8e5
Signature · 6 lines
Ville Syrjälä Intel _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v3 2/5 drm/i915: Force recalculate min_cdclk if planes config changed
In reply to Stanislav LisovskiyIn Gen11+ whenever we might exceed DBuf bandwidth we might need to recalculate CDCLK which DBuf bandwidth is scaled with. Total Dbuf bw used might change based on particular plane needs.
--- drivers/gpu/drm/i915/display/intel_display.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/display/intel_display.c +8 -2
@@ -14623,7 +14623,7 @@ static bool active_planes_affects_min_cdclk(struct drm_i915_private *dev_priv)/* See {hsw,vlv,ivb}_plane_ratio() */ return IS_BROADWELL (dev_priv) ||IS_HASWELL (dev_priv) ||IS_CHERRYVIEW (dev_priv) ||IS_VALLEYVIEW (dev_priv) || -IS_IVYBRIDGE (dev_priv); +IS_IVYBRIDGE (dev_priv) || (INTEL_GEN (dev_priv) >=11 ); } static int intel_atomic_check_planes(struct intel_atomic_state *state,
@@ -14669,7 +14669,13 @@ static int intel_atomic_check_planes(struct intel_atomic_state *state, old_active_planes = old_crtc_state->active_planes & ~BIT (PLANE_CURSOR ); new_active_planes = new_crtc_state->active_planes & ~BIT (PLANE_CURSOR ); -if (hweight8 (old_active_planes) ==hweight8 (new_active_planes)) +/* +* Not only the number of planes, but if the plane configuration had +* changed might already mean we need to recompute min CDCLK, +* because different planes might consume different amount of Dbuf bandwidth +* according to formula: Bw per plane = Pixel rate * bpp * pipe/plane scale factor +*/ +if (old_active_planes == new_active_planes)continue ; ret =intel_crtc_add_planes_to_state (state, crtc, new_active_planes);
Signature · 6 lines
2.24.1.485.gad05a3d8e5 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH v3 2/5] drm/i915: Force recalculate min_cdclk if planes config changed
Quoted 23 lines · Stanislav Lisovskiy
In Gen11+ whenever we might exceed DBuf bandwidth we might need to recalculate CDCLK which DBuf bandwidth is scaled with. Total Dbuf bw used might change based on particular plane needs.
Signed-off-by Stanislav Lisovskiy <[email protected]>--- drivers/gpu/drm/i915/display/intel_display.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/display/intel_display.c +1
-1@@ -14623,7 +14623,7 @@ static bool active_planes_affects_min_cdclk(struct drm_i915_private *dev_priv)/* See {hsw,vlv,ivb}_plane_ratio() */ return IS_BROADWELL (dev_priv) ||IS_HASWELL (dev_priv) ||IS_CHERRYVIEW (dev_priv) ||IS_VALLEYVIEW (dev_priv) || -IS_IVYBRIDGE (dev_priv); +IS_IVYBRIDGE (dev_priv) || (INTEL_GEN (dev_priv) >=11 ); } static int intel_atomic_check_planes(struct intel_atomic_state *state,
drivers/gpu/drm/i915/display/intel_display.c static int intel_atomic_check_planes(struct intel_atomic_state *state, · line 14677
Quoted 10 lines
drivers/gpu/drm/i915/display/intel_display.c +6
-1@@ -14669,7 +14669,13 @@ static int intel_atomic_check_planes(struct intel_atomic_state *state, old_active_planes = old_crtc_state->active_planes & ~BIT (PLANE_CURSOR ); new_active_planes = new_crtc_state->active_planes & ~BIT (PLANE_CURSOR ); -if (hweight8 (old_active_planes) ==hweight8 (new_active_planes)) +/* +* Not only the number of planes, but if the plane configuration had +* changed might already mean we need to recompute min CDCLK, +* because different planes might consume different amount of Dbuf bandwidth +* according to formula: Bw per plane = Pixel rate * bpp * pipe/plane scale factor +*/
The set of of active planes doesn't dictate the bandwidth since it doesn't consider most of the parameters you listed above. Ie. doesn't seem to be the right place for this stuff.
The decision to bump the cdclk should really come from the dbuf code not from some totally distinct piece of code. But to get this right I have a feeling we'll need the dbuf state and totally decouple cdclk from any_ms.
Quoted 6 lines
drivers/gpu/drm/i915/display/intel_display.c +1
-0+if (old_active_planes == new_active_planes)continue ; ret =intel_crtc_add_planes_to_state (state, crtc, new_active_planes);Signature · 1 line
2.24.1.485.gad05a3d8e5
Signature · 6 lines
Ville Syrjälä Intel _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH v3 2/5] drm/i915: Force recalculate min_cdclk if planes config changed
Quoted 39 lines · Ville Syrjälä
Quoted 23 lines · Stanislav Lisovskiy
In Gen11+ whenever we might exceed DBuf bandwidth we might need to recalculate CDCLK which DBuf bandwidth is scaled with. Total Dbuf bw used might change based on particular plane needs.
Signed-off-by Stanislav Lisovskiy <[email protected]>--- drivers/gpu/drm/i915/display/intel_display.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/display/intel_display.c +1
-1@@ -14623,7 +14623,7 @@ static bool active_planes_affects_min_cdclk(struct drm_i915_private *dev_priv)/* See {hsw,vlv,ivb}_plane_ratio() */ return IS_BROADWELL (dev_priv) ||IS_HASWELL (dev_priv) ||IS_CHERRYVIEW (dev_priv) ||IS_VALLEYVIEW (dev_priv) || -IS_IVYBRIDGE (dev_priv); +IS_IVYBRIDGE (dev_priv) || (INTEL_GEN (dev_priv) >=11 ); } static int intel_atomic_check_planes(struct intel_atomic_state *state,drivers/gpu/drm/i915/display/intel_display.c static int intel_atomic_check_planes(struct intel_atomic_state *state, · line 14677
Quoted 10 lines
drivers/gpu/drm/i915/display/intel_display.c +6
-1@@ -14669,7 +14669,13 @@ static int intel_atomic_check_planes(struct intel_atomic_state *state, old_active_planes = old_crtc_state->active_planes & ~BIT (PLANE_CURSOR ); new_active_planes = new_crtc_state->active_planes & ~BIT (PLANE_CURSOR ); -if (hweight8 (old_active_planes) ==hweight8 (new_active_planes)) +/* +* Not only the number of planes, but if the plane configuration had +* changed might already mean we need to recompute min CDCLK, +* because different planes might consume different amount of Dbuf bandwidth +* according to formula: Bw per plane = Pixel rate * bpp * pipe/plane scale factor +*/ The set of of active planes doesn't dictate the bandwidth since it doesn't consider most of the parameters you listed above. Ie. doesn't seem to be the right place for this stuff.
Quoted 4 lines
The decision to bump the cdclk should really come from the dbuf code not from some totally distinct piece of code. But to get this right I have a feeling we'll need the dbuf state and totally decouple cdclk from
any_ms.
My idea was that if active plane configuration had changed - it means that we need to recalculate bandwidth used by those. Once we now the bandwidth used per slice/per pipe stored in bw_state - so we recalculate only those in state and that should be fine. if recalculated bandwidth results in a different CDCLK - then we need to change it.
Or do you mean we need to recalculate bandwidth constantly as part of DBuf state? I kind of don't like recalculating it everytime, so filtering the case when it will obviously be the same seems to a good idea, may be this check is not correct but I would prefer to recalc used bw only if the planes had changed.
Also I'm fine with tracking it in DBuf state, we first need to land DBuf state patches (need to look at those again), but meanwhile we could store it in a bw_state.
Quoted 11 lines
Quoted 7 lines
drivers/gpu/drm/i915/display/intel_display.c +1
-0+if (old_active_planes == new_active_planes)continue ; ret =intel_crtc_add_planes_to_state (state, crtc, new_active_planes);Signature · 1 line
2.24.1.485.gad05a3d8e5Signature · 2 lines
Ville Syrjälä Intel
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 2/5 drm/i915: Force recalculate min_cdclk if planes config changed
In reply to Stanislav LisovskiyIn Gen11+ whenever we might exceed DBuf bandwidth we might need to recalculate CDCLK which DBuf bandwidth is scaled with. Total Dbuf bw used might change based on particular plane needs.
In intel_atomic_check_planes we try to filter out the cases when we definitely don't need to recalculate required bandwidth/CDCLK. In current code we compare amount of planes and skip recalculating if those are equal.
This seems being too relaxed requirement and might be even wrong because plane combination might become different despite amount of planes is same - that requires recalculating min cdclk and consumed bandwidth.
v2: - Changed commit message to properly reflect the need why,
we might want to change from hamming weight comparison to actual plane combination checking.
--- drivers/gpu/drm/i915/display/intel_display.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/display/intel_display.c +8 -2
@@ -14540,7 +14540,7 @@ static bool active_planes_affects_min_cdclk(struct drm_i915_private *dev_priv)/* See {hsw,vlv,ivb}_plane_ratio() */ return IS_BROADWELL (dev_priv) ||IS_HASWELL (dev_priv) ||IS_CHERRYVIEW (dev_priv) ||IS_VALLEYVIEW (dev_priv) || -IS_IVYBRIDGE (dev_priv); +IS_IVYBRIDGE (dev_priv) || (INTEL_GEN (dev_priv) >=11 ); } static int intel_atomic_check_planes(struct intel_atomic_state *state,
@@ -14586,7 +14586,13 @@ static int intel_atomic_check_planes(struct intel_atomic_state *state, old_active_planes = old_crtc_state->active_planes & ~BIT (PLANE_CURSOR ); new_active_planes = new_crtc_state->active_planes & ~BIT (PLANE_CURSOR ); -if (hweight8 (old_active_planes) ==hweight8 (new_active_planes)) +/* +* Not only the number of planes, but if the plane configuration had +* changed might already mean we need to recompute min CDCLK, +* because different planes might consume different amount of Dbuf bandwidth +* according to formula: Bw per plane = Pixel rate * bpp * pipe/plane scale factor +*/ +if (old_active_planes == new_active_planes)continue ; ret =intel_crtc_add_planes_to_state (state, crtc, new_active_planes);
Signature · 6 lines
2.24.1.485.gad05a3d8e5 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v3 3/5 drm/i915: Introduce for_each_dbuf_slice_in_mask macro
In reply to Stanislav LisovskiyWe quite often need now to iterate only particular dbuf slices in mask, whether they are active or related to particular crtc.
Let's make our life a bit easier and use a macro for that.
--- drivers/gpu/drm/i915/display/intel_display.h | 7 +++++++ drivers/gpu/drm/i915/display/intel_display_power.h | 3 +++ 2 files changed, 10 insertions(+)
drivers/gpu/drm/i915/display/intel_display.h +7 -0
@@ -187,6 +187,13 @@ enum plane_id {for ((__p) =PLANE_PRIMARY ; (__p) <I915_MAX_PLANES ; (__p)++) \ for_each_if((__crtc)->plane_ids_mask & BIT(__p)) +#define for_each_dbuf_slice_in_mask (__slice, __mask) \ + for ((__slice) = 0; (__slice) < I915_MAX_DBUF_SLICES; (__slice)++) \ + for_each_if((1 << (__slice)) & (__mask)) + +#define for_each_dbuf_slice (__slice) \ + for_each_dbuf_slice_in_mask(__slice, (1 << I915_MAX_DBUF_SLICES) - 1) +enum port {PORT_NONE =-1 ,
drivers/gpu/drm/i915/display/intel_display_power.h +3 -0
@@ -311,8 +311,11 @@ intel_display_power_put_async(struct drm_i915_private *i915,enum dbuf_slice {DBUF_S1 ,DBUF_S2 , +DBUF_SLICE_MAX }; +#define I915_DBUF_MAX_SLICES DBUF_SLICE_MAX +#define with_intel_display_power (i915, domain, wf) \ for ((wf) = intel_display_power_get((i915), (domain)); (wf); \ intel_display_power_put_async((i915), (domain), (wf)), (wf) = 0)
Signature · 6 lines
2.24.1.485.gad05a3d8e5 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH v3 3/5] drm/i915: Introduce for_each_dbuf_slice_in_mask macro
Quoted 16 lines · Stanislav Lisovskiy
We quite often need now to iterate only particular dbuf slices in mask, whether they are active or related to particular crtc.
Let's make our life a bit easier and use a macro for that.
Signed-off-by Stanislav Lisovskiy <[email protected]>--- drivers/gpu/drm/i915/display/intel_display.h | 7 +++++++ drivers/gpu/drm/i915/display/intel_display_power.h | 3 +++ 2 files changed, 10 insertions(+)drivers/gpu/drm/i915/display/intel_display.h +0
-0
drivers/gpu/drm/i915/display/intel_display.h enum plane_id { · line 190
Quoted 4 lines
drivers/gpu/drm/i915/display/intel_display.h +1
-0@@ -187,6 +187,13 @@ enum plane_id {for ((__p) =PLANE_PRIMARY ; (__p) <I915_MAX_PLANES ; (__p)++) \ for_each_if((__crtc)->plane_ids_mask & BIT(__p)) +#define for_each_dbuf_slice_in_mask (__slice, __mask) \
Please stick to established conventions.
Quoted 14 lines
drivers/gpu/drm/i915/display/intel_display.h +6
-0+for ((__slice) =0 ; (__slice) <I915_MAX_DBUF_SLICES ; (__slice)++) \ + for_each_if((1 << (__slice)) & (__mask)) + +#define for_each_dbuf_slice (__slice) \ + for_each_dbuf_slice_in_mask(__slice, (1 << I915_MAX_DBUF_SLICES) - 1) +enum port {PORT_NONE =-1 ,drivers/gpu/drm/i915/display/intel_display_power.h +0
-0
drivers/gpu/drm/i915/display/intel_display_power.h intel_display_power_put_async(struct drm_i915_private *i915, · line 318
Quoted 8 lines
drivers/gpu/drm/i915/display/intel_display_power.h +3
-0@@ -311,8 +311,11 @@ intel_display_power_put_async(struct drm_i915_private *i915,enum dbuf_slice {DBUF_S1 ,DBUF_S2 , +DBUF_SLICE_MAX }; +#define I915_DBUF_MAX_SLICES DBUF_SLICE_MAX +
Huh?
Quoted 5 lines
drivers/gpu/drm/i915/display/intel_display_power.h +0
-0#define with_intel_display_power (i915, domain, wf) \ for ((wf) = intel_display_power_get((i915), (domain)); (wf); \ intel_display_power_put_async((i915), (domain), (wf)), (wf) = 0)Signature · 1 line
2.24.1.485.gad05a3d8e5
Signature · 6 lines
Ville Syrjälä Intel _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 3/5 drm/i915: Introduce for_each_dbuf_slice_in_mask macro
In reply to Stanislav LisovskiyWe quite often need now to iterate only particular dbuf slices in mask, whether they are active or related to particular crtc.
v2: - Minor code refactoring
Let's make our life a bit easier and use a macro for that.
--- drivers/gpu/drm/i915/display/intel_display.h | 7 +++++++ drivers/gpu/drm/i915/display/intel_display_power.h | 1 + 2 files changed, 8 insertions(+)
drivers/gpu/drm/i915/display/intel_display.h +7 -0
@@ -187,6 +187,13 @@ enum plane_id {for ((__p) =PLANE_PRIMARY ; (__p) <I915_MAX_PLANES ; (__p)++) \ for_each_if((__crtc)->plane_ids_mask & BIT(__p)) +#define for_each_dbuf_slice_in_mask (__slice, __mask) \ + for ((__slice) = DBUF_S1; (__slice) < I915_MAX_DBUF_SLICES; (__slice)++) \ + for_each_if((BIT(__slice)) & (__mask)) + +#define for_each_dbuf_slice (__slice) \ + for_each_dbuf_slice_in_mask(__slice, BIT(I915_MAX_DBUF_SLICES) - 1) +enum port {PORT_NONE =-1 ,
drivers/gpu/drm/i915/display/intel_display_power.h +1 -0
@@ -311,6 +311,7 @@ intel_display_power_put_async(struct drm_i915_private *i915,enum dbuf_slice {DBUF_S1 ,DBUF_S2 , +I915_DBUF_MAX_SLICES };#define with_intel_display_power (i915, domain, wf) \
Signature · 6 lines
2.24.1.485.gad05a3d8e5 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v3 4/5 drm/i915: Adjust CDCLK accordingly to our DBuf bw needs
In reply to Stanislav LisovskiyAccording to BSpec max BW per slice is calculated using formula Max BW = CDCLK * 64. Currently when calculating min CDCLK we account only per plane requirements, however in order to avoid FIFO underruns we need to estimate accumulated BW consumed by all planes(ddb entries basically) residing on that particular DBuf slice. This will allow us to put CDCLK lower and save power when we don't need that much bandwidth or gain additional performance once plane consumption grows.
v2: - Fix long line warning
- Limited new DBuf bw checks to only gens >= 11
v3: - Lets track used Dbuf bw per slice and per crtc in bw state
(or may be in DBuf state in future), that way we don't need to have all crtcs in state and those only if we detect if are actually going to change cdclk, just same way as we do with other stuff, i.e intel_atomic_serialize_global_state and co. Just as per Ville's paradigm.
- Made dbuf bw calculation procedure look nicer by introducing for_each_dbuf_slice_in_mask - we often will now need to iterate slices using mask.
- According to experimental results CDCLK * 64 accounts for overall bandwidth across all dbufs, not per dbuf.
--- drivers/gpu/drm/i915/display/intel_bw.c | 61 ++++++++++++++++++- drivers/gpu/drm/i915/display/intel_bw.h | 8 +++ drivers/gpu/drm/i915/display/intel_cdclk.c | 25 ++++++++ drivers/gpu/drm/i915/display/intel_display.c | 8 +++ .../drm/i915/display/intel_display_power.h | 2 + drivers/gpu/drm/i915/intel_pm.c | 34 ++++++++++- drivers/gpu/drm/i915/intel_pm.h | 3 + 7 files changed, 138 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/display/intel_bw.c +60 -1
@@ -6,6 +6,7 @@#include <drm/drm_atomic_state_helper.h> #include "intel_bw.h" +#include "intel_pm.h" #include "intel_display_types.h" #include "intel_sideband.h" #include "intel_atomic.h"
@@ -338,7 +339,6 @@ static unsigned int intel_bw_crtc_data_rate(const struct intel_crtc_state *crtc_return data_rate; } -void intel_bw_crtc_update (struct intel_bw_state *bw_state,const struct intel_crtc_state *crtc_state) {
@@ -419,6 +419,65 @@ intel_atomic_bw_get_state(struct intel_atomic_state *state)return to_intel_bw_state (bw_state); } +int intel_bw_calc_min_cdclk (struct intel_atomic_state *state) +{ +struct drm_i915_private *dev_priv =to_i915 (state->base.dev); +int i =0 ; +enum plane_id plane_id; +struct intel_crtc_state *crtc_state; +struct intel_crtc *crtc; +int max_bw =0 ; +int min_cdclk; +enum pipe pipe; +struct intel_bw_state *bw_state; +int slice_id =0 ; + + bw_state =intel_atomic_bw_get_state (state); + +if (IS_ERR (bw_state)) +return PTR_ERR (bw_state); + +for_each_new_intel_crtc_in_state (state, crtc, crtc_state, i) { +struct intel_crtc_bw *crtc_bw = &bw_state->dbuf_bw_used[crtc->pipe]; + +memset (&crtc_bw->dbuf_bw,0 ,sizeof (crtc_bw->dbuf_bw)); + +for_each_plane_id_on_crtc (crtc, plane_id) { +struct skl_ddb_entry *plane_alloc = + &crtc_state->wm.skl.plane_ddb_y[plane_id]; +struct skl_ddb_entry *uv_plane_alloc = + &crtc_state->wm.skl.plane_ddb_uv[plane_id]; +unsigned int data_rate = crtc_state->data_rate[plane_id]; + +unsigned int dbuf_mask =skl_ddb_dbuf_slice_mask (dev_priv, plane_alloc); + + dbuf_mask |=skl_ddb_dbuf_slice_mask (dev_priv, uv_plane_alloc); + +DRM_DEBUG_KMS ("Got dbuf mask %x for pipe %c ddb %d-%d plane %d data rate %d\n" , + dbuf_mask,pipe_name (crtc->pipe), plane_alloc->start, + plane_alloc->end, plane_id, data_rate); + +for_each_dbuf_slice_in_mask (slice_id, dbuf_mask) + crtc_bw->dbuf_bw[slice_id] += data_rate; + } + } + +for_each_dbuf_slice (slice_id) { +int total_bw_per_slice =0 ; + +for_each_pipe (dev_priv, pipe) { +struct intel_crtc_bw *crtc_bw = &bw_state->dbuf_bw_used[pipe]; + + total_bw_per_slice += crtc_bw->dbuf_bw[slice_id]; + } + max_bw += total_bw_per_slice; + } + + min_cdclk = max_bw /64 ; + +return min_cdclk; +} +int intel_bw_atomic_check (struct intel_atomic_state *state) {struct drm_i915_private *dev_priv =to_i915 (state->base.dev);
drivers/gpu/drm/i915/display/intel_bw.h +8 -0
@@ -10,11 +10,16 @@#include "intel_display.h" #include "intel_global_state.h" +#include "intel_display_power.h" struct drm_i915_private ;struct intel_atomic_state ;struct intel_crtc_state ; +struct intel_crtc_bw { +int dbuf_bw[I915_MAX_DBUF_SLICES ]; +}; +struct intel_bw_state {struct intel_global_state base;
@@ -31,6 +36,8 @@ struct intel_bw_state {*/ u8 qgv_points_mask; +struct intel_crtc_bw dbuf_bw_used[I915_MAX_PIPES ]; +unsigned int data_rate[I915_MAX_PIPES ];u8 num_active_planes[I915_MAX_PIPES ]; };
@@ -53,5 +60,6 @@ void intel_bw_crtc_update(struct intel_bw_state *bw_state, const struct intel_crtc_state *crtc_state);int icl_pcode_restrict_qgv_points (struct drm_i915_private *dev_priv,u32 points_mask); +int intel_bw_calc_min_cdclk (struct intel_atomic_state *state);#endif /* __INTEL_BW_H__ */
drivers/gpu/drm/i915/display/intel_cdclk.c +25 -0
@@ -25,6 +25,7 @@#include "intel_cdclk.h" #include "intel_display_types.h" #include "intel_sideband.h" +#include "intel_bw.h" /** * DOC: CDCLK / RAWCLK
@@ -2001,11 +2002,19 @@ int intel_crtc_compute_min_cdclk(const struct intel_crtc_state *crtc_state) {struct drm_i915_private *dev_priv =to_i915 (crtc_state->uapi.crtc->dev); +struct intel_atomic_state *state =NULL ;int min_cdclk;if (!crtc_state->hw.enable)return 0 ; +/* +* FIXME: Unfortunately when this gets called from intel_modeset_setup_hw_state +* there is no intel_atomic_state at all. So lets not then use it. +*/ +if (crtc_state->uapi.state) + state =to_intel_atomic_state (crtc_state->uapi.state); + min_cdclk =intel_pixel_rate_to_cdclk (crtc_state);/* pixel rate mustn't exceed 95% of cdclk with IPS on BDW */
@@ -2080,6 +2089,22 @@ int intel_crtc_compute_min_cdclk(const struct intel_crtc_state *crtc_state)if (IS_TIGERLAKE (dev_priv)) min_cdclk =max (min_cdclk, (int )crtc_state->pixel_rate); +/* +* Similar story as with skl_write_plane_wm and intel_enable_sagv +* - in some certain driver parts, we don't have any guarantee that +* parent exists. So we might be having a crtc_state without +* parent state. +*/ +if (INTEL_GEN (dev_priv) >=11 ) { +if (state) { +int dbuf_bw_cdclk =intel_bw_calc_min_cdclk (state); + +DRM_DEBUG_KMS ("DBuf bw min cdclk %d current min_cdclk %d\n" , + dbuf_bw_cdclk, min_cdclk); + min_cdclk =max (min_cdclk, dbuf_bw_cdclk); + } + } +if (min_cdclk > dev_priv->max_cdclk_freq) { drm_dbg_kms(&dev_priv->drm, "required cdclk (%d kHz) exceeds max (%d kHz)\n",
drivers/gpu/drm/i915/display/intel_display.c +8 -0
@@ -14678,6 +14678,14 @@ static int intel_atomic_check_planes(struct intel_atomic_state *state,if (old_active_planes == new_active_planes)continue ; +/* +* active_planes bitmask has been updated, whenever amount +* of active planes had changed we need to recalculate CDCLK +* as it depends on total bandwidth now, not only min_cdclk +* per plane. +*/ + *need_cdclk_calc = true; + ret =intel_crtc_add_planes_to_state (state, crtc, new_active_planes);if (ret)return ret;
drivers/gpu/drm/i915/display/intel_display_power.h +2 -0
@@ -308,6 +308,8 @@ intel_display_power_put_async(struct drm_i915_private *i915, }#endif +#define I915_MAX_DBUF_SLICES 2 +enum dbuf_slice {DBUF_S1 ,DBUF_S2 ,
drivers/gpu/drm/i915/intel_pm.c +32 -2
@@ -4055,10 +4055,9 @@ icl_get_first_dbuf_slice_offset(u32 dbuf_slice_mask,return offset; } -static u16 intel_get_ddb_size (struct drm_i915_private *dev_priv) +u16 intel_get_ddb_size (struct drm_i915_private *dev_priv) {u16 ddb_size =INTEL_INFO (dev_priv)->ddb_size; -drm_WARN_ON (&dev_priv->drm, ddb_size ==0 );if (INTEL_GEN (dev_priv) <11 )
@@ -4067,6 +4066,37 @@ static u16 intel_get_ddb_size(struct drm_i915_private *dev_priv)return ddb_size; } +u32 skl_ddb_dbuf_slice_mask (struct drm_i915_private *dev_priv, +const struct skl_ddb_entry *entry) +{ +u32 slice_mask =0 ; +u16 ddb_size =intel_get_ddb_size (dev_priv); +u16 num_supported_slices =INTEL_INFO (dev_priv)->num_supported_dbuf_slices; +u16 slice_size = ddb_size / num_supported_slices; +u16 start_slice; +u16 end_slice; + +if (!skl_ddb_entry_size (entry)) +return 0 ; + + start_slice = entry->start / slice_size; + end_slice = (entry->end -1 ) / slice_size; + +DRM_DEBUG_KMS ("ddb size %d slices %d slice size %d start slice %d end slice %d\n" , + ddb_size, num_supported_slices, slice_size, start_slice, end_slice); + +/* +* Per plane DDB entry can in a really worst case be on multiple slices +* but single entry is anyway contigious. +*/ +while (start_slice <= end_slice) { + slice_mask |=1 << start_slice; + start_slice++; + } + +return slice_mask; +} +static u8 skl_compute_dbuf_slices (const struct intel_crtc_state *crtc_state,u8 active_pipes);
drivers/gpu/drm/i915/intel_pm.h +3 -0
@@ -37,6 +37,9 @@ void skl_pipe_ddb_get_hw_state(struct intel_crtc *crtc,struct skl_ddb_entry *ddb_y, struct skl_ddb_entry *ddb_uv);void skl_ddb_get_hw_state (struct drm_i915_private *dev_priv); +u16 intel_get_ddb_size (struct drm_i915_private *dev_priv); +u32 skl_ddb_dbuf_slice_mask (struct drm_i915_private *dev_priv, +const struct skl_ddb_entry *entry);void skl_pipe_wm_get_hw_state (struct intel_crtc *crtc,struct skl_pipe_wm *out);void g4x_wm_sanitize (struct drm_i915_private *dev_priv);
Signature · 6 lines
2.24.1.485.gad05a3d8e5 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH v3 4/5] drm/i915: Adjust CDCLK accordingly to our DBuf bw needs
Quoted 56 lines · Stanislav Lisovskiy
According to BSpec max BW per slice is calculated using formula Max BW = CDCLK * 64. Currently when calculating min CDCLK we account only per plane requirements, however in order to avoid FIFO underruns we need to estimate accumulated BW consumed by all planes(ddb entries basically) residing on that particular DBuf slice. This will allow us to put CDCLK lower and save power when we don't need that much bandwidth or gain additional performance once plane consumption grows.
v2: - Fix long line warning
- Limited new DBuf bw checks to only gens >= 11v3: - Lets track used Dbuf bw per slice and per crtc in bw state
(or may be in DBuf state in future), that way we don't need to have all crtcs in state and those only if we detect if are actually going to change cdclk, just same way as we do with other stuff, i.eintel_atomic_serialize_global_stateand co. Just as per Ville's paradigm.
- Made dbuf bw calculation procedure look nicer by introducingfor_each_dbuf_slice_in_mask- we often will now need to iterate slices using mask.
- According to experimental results CDCLK * 64 accounts for overall bandwidth across all dbufs, not per dbuf.Signed-off-by Stanislav Lisovskiy <[email protected]>--- drivers/gpu/drm/i915/display/intel_bw.c | 61 ++++++++++++++++++- drivers/gpu/drm/i915/display/intel_bw.h | 8 +++ drivers/gpu/drm/i915/display/intel_cdclk.c | 25 ++++++++ drivers/gpu/drm/i915/display/intel_display.c | 8 +++ .../drm/i915/display/intel_display_power.h | 2 + drivers/gpu/drm/i915/intel_pm.c | 34 ++++++++++- drivers/gpu/drm/i915/intel_pm.h | 3 + 7 files changed, 138 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/display/intel_bw.c +1
-1@@ -6,6 +6,7 @@#include <drm/drm_atomic_state_helper.h> #include "intel_bw.h" +#include "intel_pm.h" #include "intel_display_types.h" #include "intel_sideband.h" #include "intel_atomic.h" @@ -338,7 +339,6 @@ static unsigned int intel_bw_crtc_data_rate(const struct intel_crtc_state *crtc_return data_rate; } -void intel_bw_crtc_update (struct intel_bw_state *bw_state,const struct intel_crtc_state *crtc_state) {
drivers/gpu/drm/i915/display/intel_bw.c intel_atomic_bw_get_state(struct intel_atomic_state *state) · line 427
Quoted 9 lines
drivers/gpu/drm/i915/display/intel_bw.c +6
-0@@ -419,6 +419,65 @@ intel_atomic_bw_get_state(struct intel_atomic_state *state)return to_intel_bw_state (bw_state); } +int intel_bw_calc_min_cdclk (struct intel_atomic_state *state) +{ +struct drm_i915_private *dev_priv =to_i915 (state->base.dev); +int i =0 ; +enum plane_id plane_id; +struct intel_crtc_state *crtc_state;
const
drivers/gpu/drm/i915/display/intel_bw.c intel_atomic_bw_get_state(struct intel_atomic_state *state) · line 433
Quoted 6 lines
drivers/gpu/drm/i915/display/intel_bw.c +6
-0+struct intel_crtc *crtc; +int max_bw =0 ; +int min_cdclk; +enum pipe pipe; +struct intel_bw_state *bw_state; +int slice_id =0 ;
Bunch of needless intiialization, needlessly wide scope, etc.
drivers/gpu/drm/i915/display/intel_bw.c intel_atomic_bw_get_state(struct intel_atomic_state *state) · line 436
Quoted 3 lines
drivers/gpu/drm/i915/display/intel_bw.c +3
-0+ + bw_state =intel_atomic_bw_get_state (state); +
Spurious whitespace.
drivers/gpu/drm/i915/display/intel_bw.c intel_atomic_bw_get_state(struct intel_atomic_state *state) · line 449
Quoted 13 lines
drivers/gpu/drm/i915/display/intel_bw.c +13
-0+if (IS_ERR (bw_state)) +return PTR_ERR (bw_state); + +for_each_new_intel_crtc_in_state (state, crtc, crtc_state, i) { +struct intel_crtc_bw *crtc_bw = &bw_state->dbuf_bw_used[crtc->pipe]; + +memset (&crtc_bw->dbuf_bw,0 ,sizeof (crtc_bw->dbuf_bw)); + +for_each_plane_id_on_crtc (crtc, plane_id) { +struct skl_ddb_entry *plane_alloc = + &crtc_state->wm.skl.plane_ddb_y[plane_id]; +struct skl_ddb_entry *uv_plane_alloc = + &crtc_state->wm.skl.plane_ddb_uv[plane_id];
const
drivers/gpu/drm/i915/display/intel_bw.c intel_atomic_bw_get_state(struct intel_atomic_state *state) · line 451
Quoted 2 lines
drivers/gpu/drm/i915/display/intel_bw.c +2
-0+unsigned int data_rate = crtc_state->data_rate[plane_id]; +
more strange whitespace
drivers/gpu/drm/i915/display/intel_bw.c intel_atomic_bw_get_state(struct intel_atomic_state *state) · line 454
Quoted 3 lines
drivers/gpu/drm/i915/display/intel_bw.c +3
-0+unsigned int dbuf_mask =skl_ddb_dbuf_slice_mask (dev_priv, plane_alloc); + + dbuf_mask |=skl_ddb_dbuf_slice_mask (dev_priv, uv_plane_alloc);
Looks bad when you initialize part of it in declaration and the rest later.
drivers/gpu/drm/i915/display/intel_bw.c intel_atomic_bw_get_state(struct intel_atomic_state *state) · line 461
Quoted 7 lines
drivers/gpu/drm/i915/display/intel_bw.c +7
-0+ +DRM_DEBUG_KMS ("Got dbuf mask %x for pipe %c ddb %d-%d plane %d data rate %d\n" , + dbuf_mask,pipe_name (crtc->pipe), plane_alloc->start, + plane_alloc->end, plane_id, data_rate); + +for_each_dbuf_slice_in_mask (slice_id, dbuf_mask) + crtc_bw->dbuf_bw[slice_id] += data_rate;
This doesn't feel quite right for planar formats.
For pre-icl it works by accident since we only have the one slice so we don't end up accounting for the full bandwidth from both color planes to multiple slices. If we had multiple slices and chroma and luma had been allocated to different slices we'd count the same thing multiple times.
For icl+ we seem to assign the full data rate to the UV plane's slice(s) since only the UV plane has data_rate[] != 0.
drivers/gpu/drm/i915/display/intel_bw.c intel_atomic_bw_get_state(struct intel_atomic_state *state) · line 473
Quoted 12 lines
drivers/gpu/drm/i915/display/intel_bw.c +12
-0+ } + } + +for_each_dbuf_slice (slice_id) { +int total_bw_per_slice =0 ; + +for_each_pipe (dev_priv, pipe) { +struct intel_crtc_bw *crtc_bw = &bw_state->dbuf_bw_used[pipe]; + + total_bw_per_slice += crtc_bw->dbuf_bw[slice_id]; + } + max_bw += total_bw_per_slice;
So we're aggregating all the bw instead of per-slice? Is this based on the other mail you sent? Deserves a comment explaining why we do such odd things.
Quoted 32 lines
drivers/gpu/drm/i915/display/intel_bw.c +7
-0+ } + + min_cdclk = max_bw /64 ; + +return min_cdclk; +} +int intel_bw_atomic_check (struct intel_atomic_state *state) {struct drm_i915_private *dev_priv =to_i915 (state->base.dev);drivers/gpu/drm/i915/display/intel_bw.h +5
-0@@ -10,11 +10,16 @@#include "intel_display.h" #include "intel_global_state.h" +#include "intel_display_power.h" struct drm_i915_private ;struct intel_atomic_state ;struct intel_crtc_state ; +struct intel_crtc_bw { +int dbuf_bw[I915_MAX_DBUF_SLICES ]; +}; +struct intel_bw_state {struct intel_global_state base;
drivers/gpu/drm/i915/display/intel_bw.h struct intel_bw_state { · line 39
Quoted 4 lines
drivers/gpu/drm/i915/display/intel_bw.h +1
-0@@ -31,6 +36,8 @@ struct intel_bw_state {*/ u8 qgv_points_mask; +struct intel_crtc_bw dbuf_bw_used[I915_MAX_PIPES ];
The name of the struct isn't very good if it just contains the dbuf bw numbers.
drivers/gpu/drm/i915/display/intel_bw.h struct intel_bw_state { · line 42
Quoted 3 lines
drivers/gpu/drm/i915/display/intel_bw.h +1
-0+unsigned int data_rate[I915_MAX_PIPES ];u8 num_active_planes[I915_MAX_PIPES ];
Maybe collect all this to the per-crtc struct?
Quoted 26 lines
drivers/gpu/drm/i915/display/intel_bw.h +1
-0};@@ -53,5 +60,6 @@ void intel_bw_crtc_update(struct intel_bw_state *bw_state, const struct intel_crtc_state *crtc_state);int icl_pcode_restrict_qgv_points (struct drm_i915_private *dev_priv,u32 points_mask); +int intel_bw_calc_min_cdclk (struct intel_atomic_state *state);#endif /* __INTEL_BW_H__ */ drivers/gpu/drm/i915/display/intel_cdclk.c +2
-0@@ -25,6 +25,7 @@#include "intel_cdclk.h" #include "intel_display_types.h" #include "intel_sideband.h" +#include "intel_bw.h" /** * DOC: CDCLK / RAWCLK @@ -2001,11 +2002,19 @@ int intel_crtc_compute_min_cdclk(const struct intel_crtc_state *crtc_state) {struct drm_i915_private *dev_priv =to_i915 (crtc_state->uapi.crtc->dev); +struct intel_atomic_state *state =NULL ;int min_cdclk;
drivers/gpu/drm/i915/display/intel_cdclk.c int intel_crtc_compute_min_cdclk(const struct intel_crtc_state *crtc_state) · line 2016
Quoted 10 lines
drivers/gpu/drm/i915/display/intel_cdclk.c +6
-0if (!crtc_state->hw.enable)return 0 ; +/* +* FIXME: Unfortunately when this gets called from intel_modeset_setup_hw_state +* there is no intel_atomic_state at all. So lets not then use it. +*/ +if (crtc_state->uapi.state) + state =to_intel_atomic_state (crtc_state->uapi.state);
This still indicates that either this isn't the right place to call this or we have the state stored in the wrong place.
I think I'd just move the thing into intel_compute_min_cdclk() as a start.
Quoted 96 lines
drivers/gpu/drm/i915/display/intel_cdclk.c +17
-0+ min_cdclk =intel_pixel_rate_to_cdclk (crtc_state);/* pixel rate mustn't exceed 95% of cdclk with IPS on BDW */ @@ -2080,6 +2089,22 @@ int intel_crtc_compute_min_cdclk(const struct intel_crtc_state *crtc_state)if (IS_TIGERLAKE (dev_priv)) min_cdclk =max (min_cdclk, (int )crtc_state->pixel_rate); +/* +* Similar story as with skl_write_plane_wm and intel_enable_sagv +* - in some certain driver parts, we don't have any guarantee that +* parent exists. So we might be having a crtc_state without +* parent state. +*/ +if (INTEL_GEN (dev_priv) >=11 ) { +if (state) { +int dbuf_bw_cdclk =intel_bw_calc_min_cdclk (state); + +DRM_DEBUG_KMS ("DBuf bw min cdclk %d current min_cdclk %d\n" , + dbuf_bw_cdclk, min_cdclk); + min_cdclk =max (min_cdclk, dbuf_bw_cdclk); + } + } +if (min_cdclk > dev_priv->max_cdclk_freq) { drm_dbg_kms(&dev_priv->drm, "required cdclk (%d kHz) exceeds max (%d kHz)\n",drivers/gpu/drm/i915/display/intel_display.c +8
-0@@ -14678,6 +14678,14 @@ static int intel_atomic_check_planes(struct intel_atomic_state *state,if (old_active_planes == new_active_planes)continue ; +/* +* active_planes bitmask has been updated, whenever amount +* of active planes had changed we need to recalculate CDCLK +* as it depends on total bandwidth now, not only min_cdclk +* per plane. +*/ + *need_cdclk_calc = true; + ret =intel_crtc_add_planes_to_state (state, crtc, new_active_planes);if (ret)return ret;drivers/gpu/drm/i915/display/intel_display_power.h +2
-0@@ -308,6 +308,8 @@ intel_display_power_put_async(struct drm_i915_private *i915, }#endif +#define I915_MAX_DBUF_SLICES 2 +enum dbuf_slice {DBUF_S1 ,DBUF_S2 ,drivers/gpu/drm/i915/intel_pm.c +18
-2@@ -4055,10 +4055,9 @@ icl_get_first_dbuf_slice_offset(u32 dbuf_slice_mask,return offset; } -static u16 intel_get_ddb_size (struct drm_i915_private *dev_priv) +u16 intel_get_ddb_size (struct drm_i915_private *dev_priv) {u16 ddb_size =INTEL_INFO (dev_priv)->ddb_size; -drm_WARN_ON (&dev_priv->drm, ddb_size ==0 );if (INTEL_GEN (dev_priv) <11 )@@ -4067,6 +4066,37 @@ static u16 intel_get_ddb_size(struct drm_i915_private *dev_priv)return ddb_size; } +u32 skl_ddb_dbuf_slice_mask (struct drm_i915_private *dev_priv, +const struct skl_ddb_entry *entry) +{ +u32 slice_mask =0 ; +u16 ddb_size =intel_get_ddb_size (dev_priv); +u16 num_supported_slices =INTEL_INFO (dev_priv)->num_supported_dbuf_slices; +u16 slice_size = ddb_size / num_supported_slices; +u16 start_slice; +u16 end_slice; + +if (!skl_ddb_entry_size (entry)) +return 0 ; + + start_slice = entry->start / slice_size; + end_slice = (entry->end -1 ) / slice_size; + + DRM_DEBUG_KMS("ddb size %d slices %d slice size %d start slice %d end slice %d\n",
drivers/gpu/drm/i915/intel_pm.c static u16 intel_get_ddb_size(struct drm_i915_private *dev_priv) · line 4095
Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +10
-0+ ddb_size, num_supported_slices, slice_size, start_slice, end_slice); + +/* +* Per plane DDB entry can in a really worst case be on multiple slices +* but single entry is anyway contigious. +*/ +while (start_slice <= end_slice) { + slice_mask |=1 << start_slice; + start_slice++; + }
GENMASK() or somehting?
Quoted 23 lines
drivers/gpu/drm/i915/intel_pm.c +4
-0+ +return slice_mask; +} +static u8 skl_compute_dbuf_slices (const struct intel_crtc_state *crtc_state,u8 active_pipes);drivers/gpu/drm/i915/intel_pm.h +3
-0@@ -37,6 +37,9 @@ void skl_pipe_ddb_get_hw_state(struct intel_crtc *crtc,struct skl_ddb_entry *ddb_y, struct skl_ddb_entry *ddb_uv);void skl_ddb_get_hw_state (struct drm_i915_private *dev_priv); +u16 intel_get_ddb_size (struct drm_i915_private *dev_priv); +u32 skl_ddb_dbuf_slice_mask (struct drm_i915_private *dev_priv, +const struct skl_ddb_entry *entry);void skl_pipe_wm_get_hw_state (struct intel_crtc *crtc,struct skl_pipe_wm *out);void g4x_wm_sanitize (struct drm_i915_private *dev_priv);Signature · 1 line
2.24.1.485.gad05a3d8e5
Signature · 6 lines
Ville Syrjälä Intel _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH v3 4/5] drm/i915: Adjust CDCLK accordingly to our DBuf bw needs
Quoted 60 lines · Ville Syrjälä
Quoted 59 lines · Stanislav Lisovskiy
According to BSpec max BW per slice is calculated using formula Max BW = CDCLK * 64. Currently when calculating min CDCLK we account only per plane requirements, however in order to avoid FIFO underruns we need to estimate accumulated BW consumed by all planes(ddb entries basically) residing on that particular DBuf slice. This will allow us to put CDCLK lower and save power when we don't need that much bandwidth or gain additional performance once plane consumption grows.
v2: - Fix long line warning
- Limited new DBuf bw checks to only gens >= 11v3: - Lets track used Dbuf bw per slice and per crtc in bw state
(or may be in DBuf state in future), that way we don't need to have all crtcs in state and those only if we detect if are actually going to change cdclk, just same way as we do with other stuff, i.eintel_atomic_serialize_global_stateand co. Just as per Ville's paradigm.
- Made dbuf bw calculation procedure look nicer by introducingfor_each_dbuf_slice_in_mask- we often will now need to iterate slices using mask.
- According to experimental results CDCLK * 64 accounts for overall bandwidth across all dbufs, not per dbuf.Signed-off-by Stanislav Lisovskiy <[email protected]>--- drivers/gpu/drm/i915/display/intel_bw.c | 61 ++++++++++++++++++- drivers/gpu/drm/i915/display/intel_bw.h | 8 +++ drivers/gpu/drm/i915/display/intel_cdclk.c | 25 ++++++++ drivers/gpu/drm/i915/display/intel_display.c | 8 +++ .../drm/i915/display/intel_display_power.h | 2 + drivers/gpu/drm/i915/intel_pm.c | 34 ++++++++++- drivers/gpu/drm/i915/intel_pm.h | 3 + 7 files changed, 138 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/display/intel_bw.c +1
-1@@ -6,6 +6,7 @@#include <drm/drm_atomic_state_helper.h> #include "intel_bw.h" +#include "intel_pm.h" #include "intel_display_types.h" #include "intel_sideband.h" #include "intel_atomic.h" @@ -338,7 +339,6 @@ static unsigned int intel_bw_crtc_data_rate(const struct intel_crtc_state *crtc_return data_rate; } -void intel_bw_crtc_update (struct intel_bw_state *bw_state,const struct intel_crtc_state *crtc_state) {@@ -419,6 +419,65 @@ intel_atomic_bw_get_state(struct intel_atomic_state *state)return to_intel_bw_state (bw_state); }
Quoted 8 lines
drivers/gpu/drm/i915/display/intel_bw.c intel_atomic_bw_get_state(struct intel_atomic_state *state) · line 427
Quoted 6 lines
drivers/gpu/drm/i915/display/intel_bw.c +6
-0+int intel_bw_calc_min_cdclk (struct intel_atomic_state *state) +{ +struct drm_i915_private *dev_priv =to_i915 (state->base.dev); +int i =0 ; +enum plane_id plane_id; +struct intel_crtc_state *crtc_state;const
Why? There are lots of places where we use it that way. Even in intel_compute_min_cdclk:
struct intel_crtc_state *crtc_state;
int min_cdclk, i;
enum pipe pipe;
for_each_new_intel_crtc_in_state(state, crtc, crtc_state, i) {
Also I grepped - almost every place in intel_display.c
which has for_each_new_intel_crtc_in_state uses crtc_state as non-const.
It is called that way intel_calc_active_pipes, intel_atomic_check_crtcs,... almost everywhere in intel_display.c
So can you please explain what do you mean?..
Quoted 9 lines
drivers/gpu/drm/i915/display/intel_bw.c intel_atomic_bw_get_state(struct intel_atomic_state *state) · line 433
Quoted 7 lines
drivers/gpu/drm/i915/display/intel_bw.c +6
-0+struct intel_crtc *crtc; +int max_bw =0 ; +int min_cdclk; +enum pipe pipe; +struct intel_bw_state *bw_state; +int slice_id =0 ;Bunch of needless intiialization, needlessly wide scope, etc.
max_bw needs to be accumulated so I guess it should be init to 0.
Agree regarding slice_id - just a leftover after I started to use for_each_dbuf_slice macro.
Quoted 28 lines
drivers/gpu/drm/i915/display/intel_bw.c intel_atomic_bw_get_state(struct intel_atomic_state *state) · line 436
Quoted 4 lines
drivers/gpu/drm/i915/display/intel_bw.c +3
-0+ + bw_state =intel_atomic_bw_get_state (state); +Spurious whitespace.
drivers/gpu/drm/i915/display/intel_bw.c intel_atomic_bw_get_state(struct intel_atomic_state *state) · line 449
Quoted 13 lines
drivers/gpu/drm/i915/display/intel_bw.c +13
-0+if (IS_ERR (bw_state)) +return PTR_ERR (bw_state); + +for_each_new_intel_crtc_in_state (state, crtc, crtc_state, i) { +struct intel_crtc_bw *crtc_bw = &bw_state->dbuf_bw_used[crtc->pipe]; + +memset (&crtc_bw->dbuf_bw,0 ,sizeof (crtc_bw->dbuf_bw)); + +for_each_plane_id_on_crtc (crtc, plane_id) { +struct skl_ddb_entry *plane_alloc = + &crtc_state->wm.skl.plane_ddb_y[plane_id]; +struct skl_ddb_entry *uv_plane_alloc = + &crtc_state->wm.skl.plane_ddb_uv[plane_id];const
drivers/gpu/drm/i915/display/intel_bw.c intel_atomic_bw_get_state(struct intel_atomic_state *state) · line 451
Quoted 2 lines
drivers/gpu/drm/i915/display/intel_bw.c +2
-0+unsigned int data_rate = crtc_state->data_rate[plane_id]; +more strange whitespace
Quoted 6 lines
drivers/gpu/drm/i915/display/intel_bw.c intel_atomic_bw_get_state(struct intel_atomic_state *state) · line 454
Quoted 3 lines
drivers/gpu/drm/i915/display/intel_bw.c +3
-0+unsigned int dbuf_mask =skl_ddb_dbuf_slice_mask (dev_priv, plane_alloc); + + dbuf_mask |=skl_ddb_dbuf_slice_mask (dev_priv, uv_plane_alloc);Looks bad when you initialize part of it in declaration and the rest later.
Didn't want to have a long time here, will have to make a separate function then.
Quoted 11 lines
drivers/gpu/drm/i915/display/intel_bw.c intel_atomic_bw_get_state(struct intel_atomic_state *state) · line 461
Quoted 8 lines
drivers/gpu/drm/i915/display/intel_bw.c +7
-0+ +DRM_DEBUG_KMS ("Got dbuf mask %x for pipe %c ddb %d-%d plane %d data rate %d\n" , + dbuf_mask,pipe_name (crtc->pipe), plane_alloc->start, + plane_alloc->end, plane_id, data_rate); + +for_each_dbuf_slice_in_mask (slice_id, dbuf_mask) + crtc_bw->dbuf_bw[slice_id] += data_rate;This doesn't feel quite right for planar formats.
Quoted 8 lines
For pre-icl it works by accident since we only have the one slice so we don't end up accounting for the full bandwidth from both color planes to multiple slices. If we had multiple slices and chroma and luma had been allocated to different slices we'd count the same thing multiple times.
For icl+ we seem to assign the full data rate to the UV plane's slice(s) since only the UV plane has data_rate[] != 0.
This sounds interesting, so do you mean that we need something like data_rate and data_rate_uv?
My logic here is that we just get a set of slices used by uv and y planes in total and then account for data_rate for those.
We probably then need another patch to split data rate then.
I was aware of that actually but anyway being pessimistic here is better. Also same about if plane would be sitting on 2 slices at the same time.
Quoted 17 lines
drivers/gpu/drm/i915/display/intel_bw.c intel_atomic_bw_get_state(struct intel_atomic_state *state) · line 473
Quoted 13 lines
drivers/gpu/drm/i915/display/intel_bw.c +12
-0+ } + } + +for_each_dbuf_slice (slice_id) { +int total_bw_per_slice =0 ; + +for_each_pipe (dev_priv, pipe) { +struct intel_crtc_bw *crtc_bw = &bw_state->dbuf_bw_used[pipe]; + + total_bw_per_slice += crtc_bw->dbuf_bw[slice_id]; + } + max_bw += total_bw_per_slice;So we're aggregating all the bw instead of per-slice? Is this based on the other mail you sent? Deserves a comment explaining why we do such odd things.
Agree need to add a comment. Currently it seems the only way to make it work without either having underruns or 8K not usable with bumped CDCLK.
Quoted 87 lines
Quoted 33 lines
drivers/gpu/drm/i915/display/intel_bw.c +7
-0+ } + + min_cdclk = max_bw /64 ; + +return min_cdclk; +} +int intel_bw_atomic_check (struct intel_atomic_state *state) {struct drm_i915_private *dev_priv =to_i915 (state->base.dev);drivers/gpu/drm/i915/display/intel_bw.h +5
-0@@ -10,11 +10,16 @@#include "intel_display.h" #include "intel_global_state.h" +#include "intel_display_power.h" struct drm_i915_private ;struct intel_atomic_state ;struct intel_crtc_state ; +struct intel_crtc_bw { +int dbuf_bw[I915_MAX_DBUF_SLICES ]; +}; +struct intel_bw_state {struct intel_global_state base;drivers/gpu/drm/i915/display/intel_bw.h struct intel_bw_state { · line 39
Quoted 4 lines
drivers/gpu/drm/i915/display/intel_bw.h +1
-0@@ -31,6 +36,8 @@ struct intel_bw_state {*/ u8 qgv_points_mask; +struct intel_crtc_bw dbuf_bw_used[I915_MAX_PIPES ];The name of the struct isn't very good if it just contains the dbuf bw numbers.
drivers/gpu/drm/i915/display/intel_bw.h struct intel_bw_state { · line 42
Quoted 3 lines
drivers/gpu/drm/i915/display/intel_bw.h +1
-0+unsigned int data_rate[I915_MAX_PIPES ];u8 num_active_planes[I915_MAX_PIPES ];Maybe collect all this to the per-crtc struct?
Quoted 26 lines
drivers/gpu/drm/i915/display/intel_bw.h +1
-0};@@ -53,5 +60,6 @@ void intel_bw_crtc_update(struct intel_bw_state *bw_state, const struct intel_crtc_state *crtc_state);int icl_pcode_restrict_qgv_points (struct drm_i915_private *dev_priv,u32 points_mask); +int intel_bw_calc_min_cdclk (struct intel_atomic_state *state);#endif /* __INTEL_BW_H__ */ drivers/gpu/drm/i915/display/intel_cdclk.c +2
-0@@ -25,6 +25,7 @@#include "intel_cdclk.h" #include "intel_display_types.h" #include "intel_sideband.h" +#include "intel_bw.h" /** * DOC: CDCLK / RAWCLK @@ -2001,11 +2002,19 @@ int intel_crtc_compute_min_cdclk(const struct intel_crtc_state *crtc_state) {struct drm_i915_private *dev_priv =to_i915 (crtc_state->uapi.crtc->dev); +struct intel_atomic_state *state =NULL ;int min_cdclk;drivers/gpu/drm/i915/display/intel_cdclk.c int intel_crtc_compute_min_cdclk(const struct intel_crtc_state *crtc_state) · line 2016
Quoted 10 lines
drivers/gpu/drm/i915/display/intel_cdclk.c +6
-0if (!crtc_state->hw.enable)return 0 ; +/* +* FIXME: Unfortunately when this gets called from intel_modeset_setup_hw_state +* there is no intel_atomic_state at all. So lets not then use it. +*/ +if (crtc_state->uapi.state) + state =to_intel_atomic_state (crtc_state->uapi.state);This still indicates that either this isn't the right place to call this or we have the state stored in the wrong place.
Quoted 1 line
I think I'd just move the thing into
intel_compute_min_cdclk()as a start.
Was thinking about this, why I didn't put it here is because just wanted to keep all cdclk regulating logic in this function, because intel_compute_min_cdclk is kind of higher level already which is supposed to call that one per crtc_state. Otherwise CDCLK regulating logic will be kind of spread across those two.
Quoted 101 lines
Quoted 101 lines
drivers/gpu/drm/i915/display/intel_cdclk.c +17
-0+ min_cdclk =intel_pixel_rate_to_cdclk (crtc_state);/* pixel rate mustn't exceed 95% of cdclk with IPS on BDW */ @@ -2080,6 +2089,22 @@ int intel_crtc_compute_min_cdclk(const struct intel_crtc_state *crtc_state)if (IS_TIGERLAKE (dev_priv)) min_cdclk =max (min_cdclk, (int )crtc_state->pixel_rate); +/* +* Similar story as with skl_write_plane_wm and intel_enable_sagv +* - in some certain driver parts, we don't have any guarantee that +* parent exists. So we might be having a crtc_state without +* parent state. +*/ +if (INTEL_GEN (dev_priv) >=11 ) { +if (state) { +int dbuf_bw_cdclk =intel_bw_calc_min_cdclk (state); + +DRM_DEBUG_KMS ("DBuf bw min cdclk %d current min_cdclk %d\n" , + dbuf_bw_cdclk, min_cdclk); + min_cdclk =max (min_cdclk, dbuf_bw_cdclk); + } + } +if (min_cdclk > dev_priv->max_cdclk_freq) { drm_dbg_kms(&dev_priv->drm, "required cdclk (%d kHz) exceeds max (%d kHz)\n",drivers/gpu/drm/i915/display/intel_display.c +8
-0@@ -14678,6 +14678,14 @@ static int intel_atomic_check_planes(struct intel_atomic_state *state,if (old_active_planes == new_active_planes)continue ; +/* +* active_planes bitmask has been updated, whenever amount +* of active planes had changed we need to recalculate CDCLK +* as it depends on total bandwidth now, not only min_cdclk +* per plane. +*/ + *need_cdclk_calc = true; + ret =intel_crtc_add_planes_to_state (state, crtc, new_active_planes);if (ret)return ret;drivers/gpu/drm/i915/display/intel_display_power.h +2
-0@@ -308,6 +308,8 @@ intel_display_power_put_async(struct drm_i915_private *i915, }#endif +#define I915_MAX_DBUF_SLICES 2 +enum dbuf_slice {DBUF_S1 ,DBUF_S2 ,drivers/gpu/drm/i915/intel_pm.c +22
-2@@ -4055,10 +4055,9 @@ icl_get_first_dbuf_slice_offset(u32 dbuf_slice_mask,return offset; } -static u16 intel_get_ddb_size (struct drm_i915_private *dev_priv) +u16 intel_get_ddb_size (struct drm_i915_private *dev_priv) {u16 ddb_size =INTEL_INFO (dev_priv)->ddb_size; -drm_WARN_ON (&dev_priv->drm, ddb_size ==0 );if (INTEL_GEN (dev_priv) <11 )@@ -4067,6 +4066,37 @@ static u16 intel_get_ddb_size(struct drm_i915_private *dev_priv)return ddb_size; } +u32 skl_ddb_dbuf_slice_mask (struct drm_i915_private *dev_priv, +const struct skl_ddb_entry *entry) +{ +u32 slice_mask =0 ; +u16 ddb_size =intel_get_ddb_size (dev_priv); +u16 num_supported_slices =INTEL_INFO (dev_priv)->num_supported_dbuf_slices; +u16 slice_size = ddb_size / num_supported_slices; +u16 start_slice; +u16 end_slice; + +if (!skl_ddb_entry_size (entry)) +return 0 ; + + start_slice = entry->start / slice_size; + end_slice = (entry->end -1 ) / slice_size; + +DRM_DEBUG_KMS ("ddb size %d slices %d slice size %d start slice %d end slice %d\n" , + ddb_size, num_supported_slices, slice_size, start_slice, end_slice); + +/* +* Per plane DDB entry can in a really worst case be on multiple slices
Quoted 8 lines
drivers/gpu/drm/i915/intel_pm.c static u16 intel_get_ddb_size(struct drm_i915_private *dev_priv) · line 4095
Quoted 6 lines
drivers/gpu/drm/i915/intel_pm.c +6
-0+* but single entry is anyway contigious. +*/ +while (start_slice <= end_slice) { + slice_mask |=1 << start_slice; + start_slice++; + }
GENMASK()or somehting?
Will fix, thanks for proposal.
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_pm.c +4
-0+ +return slice_mask; +} +static u8 skl_compute_dbuf_slices (const struct intel_crtc_state *crtc_state,u8 active_pipes);
Quoted 20 lines
Quoted 16 lines
drivers/gpu/drm/i915/intel_pm.h +3
-0@@ -37,6 +37,9 @@ void skl_pipe_ddb_get_hw_state(struct intel_crtc *crtc,struct skl_ddb_entry *ddb_y, struct skl_ddb_entry *ddb_uv);void skl_ddb_get_hw_state (struct drm_i915_private *dev_priv); +u16 intel_get_ddb_size (struct drm_i915_private *dev_priv); +u32 skl_ddb_dbuf_slice_mask (struct drm_i915_private *dev_priv, +const struct skl_ddb_entry *entry);void skl_pipe_wm_get_hw_state (struct intel_crtc *crtc,struct skl_pipe_wm *out);void g4x_wm_sanitize (struct drm_i915_private *dev_priv);Signature · 1 line
2.24.1.485.gad05a3d8e5Signature · 2 lines
Ville Syrjälä Intel
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH v3 4/5] drm/i915: Adjust CDCLK accordingly to our DBuf bw needs
Quoted 70 lines · Stanislav
Quoted 60 lines · Ville Syrjälä
Quoted 59 lines · Stanislav Lisovskiy
According to BSpec max BW per slice is calculated using formula Max BW = CDCLK * 64. Currently when calculating min CDCLK we account only per plane requirements, however in order to avoid FIFO underruns we need to estimate accumulated BW consumed by all planes(ddb entries basically) residing on that particular DBuf slice. This will allow us to put CDCLK lower and save power when we don't need that much bandwidth or gain additional performance once plane consumption grows.
v2: - Fix long line warning
- Limited new DBuf bw checks to only gens >= 11v3: - Lets track used Dbuf bw per slice and per crtc in bw state
(or may be in DBuf state in future), that way we don't need to have all crtcs in state and those only if we detect if are actually going to change cdclk, just same way as we do with other stuff, i.eintel_atomic_serialize_global_stateand co. Just as per Ville's paradigm.
- Made dbuf bw calculation procedure look nicer by introducingfor_each_dbuf_slice_in_mask- we often will now need to iterate slices using mask.
- According to experimental results CDCLK * 64 accounts for overall bandwidth across all dbufs, not per dbuf.Signed-off-by Stanislav Lisovskiy <[email protected]>--- drivers/gpu/drm/i915/display/intel_bw.c | 61 ++++++++++++++++++- drivers/gpu/drm/i915/display/intel_bw.h | 8 +++ drivers/gpu/drm/i915/display/intel_cdclk.c | 25 ++++++++ drivers/gpu/drm/i915/display/intel_display.c | 8 +++ .../drm/i915/display/intel_display_power.h | 2 + drivers/gpu/drm/i915/intel_pm.c | 34 ++++++++++- drivers/gpu/drm/i915/intel_pm.h | 3 + 7 files changed, 138 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/display/intel_bw.c +1
-1@@ -6,6 +6,7 @@#include <drm/drm_atomic_state_helper.h> #include "intel_bw.h" +#include "intel_pm.h" #include "intel_display_types.h" #include "intel_sideband.h" #include "intel_atomic.h" @@ -338,7 +339,6 @@ static unsigned int intel_bw_crtc_data_rate(const struct intel_crtc_state *crtc_return data_rate; } -void intel_bw_crtc_update (struct intel_bw_state *bw_state,const struct intel_crtc_state *crtc_state) {@@ -419,6 +419,65 @@ intel_atomic_bw_get_state(struct intel_atomic_state *state)return to_intel_bw_state (bw_state); }Quoted 8 lines
drivers/gpu/drm/i915/display/intel_bw.c intel_atomic_bw_get_state(struct intel_atomic_state *state) · line 427
Quoted 6 lines
drivers/gpu/drm/i915/display/intel_bw.c +6
-0+int intel_bw_calc_min_cdclk (struct intel_atomic_state *state) +{ +struct drm_i915_private *dev_priv =to_i915 (state->base.dev); +int i =0 ; +enum plane_id plane_id; +struct intel_crtc_state *crtc_state;const
Quoted 1 line
Why? There are lots of places where we use it that way.
Always make it const if you don't have to change it. Makes life a lot easier when you immediately see that it can't mutate when you're not looking. Which is also why pure functions are preferrable to those with side effects.
Quoted 59 lines
Even in
intel_compute_min_cdclk:struct
intel_crtc_state*crtc_state;
intmin_cdclk, i;
enum pipe pipe;
for_each_new_intel_crtc_in_state(state, crtc, crtc_state, i){Also I grepped - almost every place in
intel_display.c
which hasfor_each_new_intel_crtc_in_stateusescrtc_stateas non-const.It is called that way
intel_calc_active_pipes,intel_atomic_check_crtcs,... almost everywhere inintel_display.cSo can you please explain what do you mean?..
Quoted 9 lines
drivers/gpu/drm/i915/display/intel_bw.c intel_atomic_bw_get_state(struct intel_atomic_state *state) · line 433
Quoted 7 lines
drivers/gpu/drm/i915/display/intel_bw.c +6
-0+struct intel_crtc *crtc; +int max_bw =0 ; +int min_cdclk; +enum pipe pipe; +struct intel_bw_state *bw_state; +int slice_id =0 ;Bunch of needless intiialization, needlessly wide scope, etc.
max_bwneeds to be accumulated so I guess it should be init to 0.Agree regarding
slice_id- just a leftover after I started to usefor_each_dbuf_slicemacro.Quoted 28 lines
drivers/gpu/drm/i915/display/intel_bw.c intel_atomic_bw_get_state(struct intel_atomic_state *state) · line 436
Quoted 4 lines
drivers/gpu/drm/i915/display/intel_bw.c +3
-0+ + bw_state =intel_atomic_bw_get_state (state); +Spurious whitespace.
drivers/gpu/drm/i915/display/intel_bw.c intel_atomic_bw_get_state(struct intel_atomic_state *state) · line 449
Quoted 13 lines
drivers/gpu/drm/i915/display/intel_bw.c +13
-0+if (IS_ERR (bw_state)) +return PTR_ERR (bw_state); + +for_each_new_intel_crtc_in_state (state, crtc, crtc_state, i) { +struct intel_crtc_bw *crtc_bw = &bw_state->dbuf_bw_used[crtc->pipe]; + +memset (&crtc_bw->dbuf_bw,0 ,sizeof (crtc_bw->dbuf_bw)); + +for_each_plane_id_on_crtc (crtc, plane_id) { +struct skl_ddb_entry *plane_alloc = + &crtc_state->wm.skl.plane_ddb_y[plane_id]; +struct skl_ddb_entry *uv_plane_alloc = + &crtc_state->wm.skl.plane_ddb_uv[plane_id];const
drivers/gpu/drm/i915/display/intel_bw.c intel_atomic_bw_get_state(struct intel_atomic_state *state) · line 451
Quoted 2 lines
drivers/gpu/drm/i915/display/intel_bw.c +2
-0+unsigned int data_rate = crtc_state->data_rate[plane_id]; +more strange whitespace
Quoted 8 lines
Quoted 6 lines
drivers/gpu/drm/i915/display/intel_bw.c intel_atomic_bw_get_state(struct intel_atomic_state *state) · line 454
Quoted 3 lines
drivers/gpu/drm/i915/display/intel_bw.c +3
-0+unsigned int dbuf_mask =skl_ddb_dbuf_slice_mask (dev_priv, plane_alloc); + + dbuf_mask |=skl_ddb_dbuf_slice_mask (dev_priv, uv_plane_alloc);Looks bad when you initialize part of it in declaration and the rest later.
Didn't want to have a long time here, will have to make a separate function then.
Not sure why you want a separate function.
foo = a | b ?
Quoted 18 lines
Quoted 18 lines
drivers/gpu/drm/i915/display/intel_bw.c intel_atomic_bw_get_state(struct intel_atomic_state *state) · line 461
Quoted 9 lines
drivers/gpu/drm/i915/display/intel_bw.c +7
-0+ +DRM_DEBUG_KMS ("Got dbuf mask %x for pipe %c ddb %d-%d plane %d data rate %d\n" , + dbuf_mask,pipe_name (crtc->pipe), plane_alloc->start, + plane_alloc->end, plane_id, data_rate); + +for_each_dbuf_slice_in_mask (slice_id, dbuf_mask) + crtc_bw->dbuf_bw[slice_id] += data_rate;This doesn't feel quite right for planar formats.
For pre-icl it works by accident since we only have the one slice so we don't end up accounting for the full bandwidth from both color planes to multiple slices. If we had multiple slices and chroma and luma had been allocated to different slices we'd count the same thing multiple times.
Quoted 5 lines
Quoted 2 lines
For icl+ we seem to assign the full data rate to the UV plane's slice(s) since only the UV plane has data_rate[] != 0.
This sounds interesting, so do you mean that we need something like
data_rateanddata_rate_uv?
Perhaps. Or maybe we just start tracking the data rate separately for the master and slave planes on icl+. No real issue on pre-icl so that would actually work AFAICS.
Quoted 115 lines
My logic here is that we just get a set of slices used by uv and y planes in total and then account for
data_ratefor those.
We probably then need another patch to split data rate then.I was aware of that actually but anyway being pessimistic here is better. Also same about if plane would be sitting on 2 slices at the same time.
Quoted 17 lines
drivers/gpu/drm/i915/display/intel_bw.c intel_atomic_bw_get_state(struct intel_atomic_state *state) · line 473
Quoted 13 lines
drivers/gpu/drm/i915/display/intel_bw.c +12
-0+ } + } + +for_each_dbuf_slice (slice_id) { +int total_bw_per_slice =0 ; + +for_each_pipe (dev_priv, pipe) { +struct intel_crtc_bw *crtc_bw = &bw_state->dbuf_bw_used[pipe]; + + total_bw_per_slice += crtc_bw->dbuf_bw[slice_id]; + } + max_bw += total_bw_per_slice;So we're aggregating all the bw instead of per-slice? Is this based on the other mail you sent? Deserves a comment explaining why we do such odd things.
Agree need to add a comment. Currently it seems the only way to make it work without either having underruns or 8K not usable with bumped CDCLK.
Quoted 87 lines
Quoted 33 lines
drivers/gpu/drm/i915/display/intel_bw.c +7
-0+ } + + min_cdclk = max_bw /64 ; + +return min_cdclk; +} +int intel_bw_atomic_check (struct intel_atomic_state *state) {struct drm_i915_private *dev_priv =to_i915 (state->base.dev);drivers/gpu/drm/i915/display/intel_bw.h +5
-0@@ -10,11 +10,16 @@#include "intel_display.h" #include "intel_global_state.h" +#include "intel_display_power.h" struct drm_i915_private ;struct intel_atomic_state ;struct intel_crtc_state ; +struct intel_crtc_bw { +int dbuf_bw[I915_MAX_DBUF_SLICES ]; +}; +struct intel_bw_state {struct intel_global_state base;drivers/gpu/drm/i915/display/intel_bw.h struct intel_bw_state { · line 39
Quoted 4 lines
drivers/gpu/drm/i915/display/intel_bw.h +1
-0@@ -31,6 +36,8 @@ struct intel_bw_state {*/ u8 qgv_points_mask; +struct intel_crtc_bw dbuf_bw_used[I915_MAX_PIPES ];The name of the struct isn't very good if it just contains the dbuf bw numbers.
drivers/gpu/drm/i915/display/intel_bw.h struct intel_bw_state { · line 42
Quoted 3 lines
drivers/gpu/drm/i915/display/intel_bw.h +1
-0+unsigned int data_rate[I915_MAX_PIPES ];u8 num_active_planes[I915_MAX_PIPES ];Maybe collect all this to the per-crtc struct?
Quoted 26 lines
drivers/gpu/drm/i915/display/intel_bw.h +1
-0};@@ -53,5 +60,6 @@ void intel_bw_crtc_update(struct intel_bw_state *bw_state, const struct intel_crtc_state *crtc_state);int icl_pcode_restrict_qgv_points (struct drm_i915_private *dev_priv,u32 points_mask); +int intel_bw_calc_min_cdclk (struct intel_atomic_state *state);#endif /* __INTEL_BW_H__ */ drivers/gpu/drm/i915/display/intel_cdclk.c +2
-0@@ -25,6 +25,7 @@#include "intel_cdclk.h" #include "intel_display_types.h" #include "intel_sideband.h" +#include "intel_bw.h" /** * DOC: CDCLK / RAWCLK @@ -2001,11 +2002,19 @@ int intel_crtc_compute_min_cdclk(const struct intel_crtc_state *crtc_state) {struct drm_i915_private *dev_priv =to_i915 (crtc_state->uapi.crtc->dev); +struct intel_atomic_state *state =NULL ;int min_cdclk;drivers/gpu/drm/i915/display/intel_cdclk.c int intel_crtc_compute_min_cdclk(const struct intel_crtc_state *crtc_state) · line 2016
Quoted 10 lines
drivers/gpu/drm/i915/display/intel_cdclk.c +6
-0if (!crtc_state->hw.enable)return 0 ; +/* +* FIXME: Unfortunately when this gets called from intel_modeset_setup_hw_state +* there is no intel_atomic_state at all. So lets not then use it. +*/ +if (crtc_state->uapi.state) + state =to_intel_atomic_state (crtc_state->uapi.state);This still indicates that either this isn't the right place to call this or we have the state stored in the wrong place.
Quoted 6 lines
Quoted 1 line
I think I'd just move the thing into
intel_compute_min_cdclk()as a start.Was thinking about this, why I didn't put it here is because just wanted to keep all cdclk regulating logic in this function, because
intel_compute_min_cdclkis kind of higher level already which is supposed to call that one percrtc_state. Otherwise CDCLK regulating logic will be kind of spread across those two.
This is not a per-crtc limit so having it in the per-crtc function seems wrong anyway to me.
Quoted 141 lines
Quoted 102 lines
Quoted 102 lines
drivers/gpu/drm/i915/display/intel_cdclk.c +17
-0+ min_cdclk =intel_pixel_rate_to_cdclk (crtc_state);/* pixel rate mustn't exceed 95% of cdclk with IPS on BDW */ @@ -2080,6 +2089,22 @@ int intel_crtc_compute_min_cdclk(const struct intel_crtc_state *crtc_state)if (IS_TIGERLAKE (dev_priv)) min_cdclk =max (min_cdclk, (int )crtc_state->pixel_rate); +/* +* Similar story as with skl_write_plane_wm and intel_enable_sagv +* - in some certain driver parts, we don't have any guarantee that +* parent exists. So we might be having a crtc_state without +* parent state. +*/ +if (INTEL_GEN (dev_priv) >=11 ) { +if (state) { +int dbuf_bw_cdclk =intel_bw_calc_min_cdclk (state); + +DRM_DEBUG_KMS ("DBuf bw min cdclk %d current min_cdclk %d\n" , + dbuf_bw_cdclk, min_cdclk); + min_cdclk =max (min_cdclk, dbuf_bw_cdclk); + } + } +if (min_cdclk > dev_priv->max_cdclk_freq) { drm_dbg_kms(&dev_priv->drm, "required cdclk (%d kHz) exceeds max (%d kHz)\n",drivers/gpu/drm/i915/display/intel_display.c +8
-0@@ -14678,6 +14678,14 @@ static int intel_atomic_check_planes(struct intel_atomic_state *state,if (old_active_planes == new_active_planes)continue ; +/* +* active_planes bitmask has been updated, whenever amount +* of active planes had changed we need to recalculate CDCLK +* as it depends on total bandwidth now, not only min_cdclk +* per plane. +*/ + *need_cdclk_calc = true; + ret =intel_crtc_add_planes_to_state (state, crtc, new_active_planes);if (ret)return ret;drivers/gpu/drm/i915/display/intel_display_power.h +2
-0@@ -308,6 +308,8 @@ intel_display_power_put_async(struct drm_i915_private *i915, }#endif +#define I915_MAX_DBUF_SLICES 2 +enum dbuf_slice {DBUF_S1 ,DBUF_S2 ,drivers/gpu/drm/i915/intel_pm.c +22
-2@@ -4055,10 +4055,9 @@ icl_get_first_dbuf_slice_offset(u32 dbuf_slice_mask,return offset; } -static u16 intel_get_ddb_size (struct drm_i915_private *dev_priv) +u16 intel_get_ddb_size (struct drm_i915_private *dev_priv) {u16 ddb_size =INTEL_INFO (dev_priv)->ddb_size; -drm_WARN_ON (&dev_priv->drm, ddb_size ==0 );if (INTEL_GEN (dev_priv) <11 )@@ -4067,6 +4066,37 @@ static u16 intel_get_ddb_size(struct drm_i915_private *dev_priv)return ddb_size; } +u32 skl_ddb_dbuf_slice_mask (struct drm_i915_private *dev_priv, +const struct skl_ddb_entry *entry) +{ +u32 slice_mask =0 ; +u16 ddb_size =intel_get_ddb_size (dev_priv); +u16 num_supported_slices =INTEL_INFO (dev_priv)->num_supported_dbuf_slices; +u16 slice_size = ddb_size / num_supported_slices; +u16 start_slice; +u16 end_slice; + +if (!skl_ddb_entry_size (entry)) +return 0 ; + + start_slice = entry->start / slice_size; + end_slice = (entry->end -1 ) / slice_size; + +DRM_DEBUG_KMS ("ddb size %d slices %d slice size %d start slice %d end slice %d\n" , + ddb_size, num_supported_slices, slice_size, start_slice, end_slice); + +/* +* Per plane DDB entry can in a really worst case be on multiple slices Quoted 8 lines
drivers/gpu/drm/i915/intel_pm.c static u16 intel_get_ddb_size(struct drm_i915_private *dev_priv) · line 4095
Quoted 6 lines
drivers/gpu/drm/i915/intel_pm.c +6
-0+* but single entry is anyway contigious. +*/ +while (start_slice <= end_slice) { + slice_mask |=1 << start_slice; + start_slice++; + }
GENMASK()or somehting?Will fix, thanks for proposal.
Quoted 28 lines
Quoted 24 lines
drivers/gpu/drm/i915/intel_pm.c +4
-0+ +return slice_mask; +} +static u8 skl_compute_dbuf_slices (const struct intel_crtc_state *crtc_state,u8 active_pipes);drivers/gpu/drm/i915/intel_pm.h +3
-0@@ -37,6 +37,9 @@ void skl_pipe_ddb_get_hw_state(struct intel_crtc *crtc,struct skl_ddb_entry *ddb_y, struct skl_ddb_entry *ddb_uv);void skl_ddb_get_hw_state (struct drm_i915_private *dev_priv); +u16 intel_get_ddb_size (struct drm_i915_private *dev_priv); +u32 skl_ddb_dbuf_slice_mask (struct drm_i915_private *dev_priv, +const struct skl_ddb_entry *entry);void skl_pipe_wm_get_hw_state (struct intel_crtc *crtc,struct skl_pipe_wm *out);void g4x_wm_sanitize (struct drm_i915_private *dev_priv);Signature · 1 line
2.24.1.485.gad05a3d8e5Signature · 2 lines
Ville Syrjälä Intel
Signature · 6 lines
Ville Syrjälä Intel _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 4/5 drm/i915: Adjust CDCLK accordingly to our DBuf bw needs
In reply to Stanislav LisovskiyAccording to BSpec max BW per slice is calculated using formula Max BW = CDCLK * 64. Currently when calculating min CDCLK we account only per plane requirements, however in order to avoid FIFO underruns we need to estimate accumulated BW consumed by all planes(ddb entries basically) residing on that particular DBuf slice. This will allow us to put CDCLK lower and save power when we don't need that much bandwidth or gain additional performance once plane consumption grows.
v2: - Fix long line warning
- Limited new DBuf bw checks to only gens >= 11
v3: - Lets track used Dbuf bw per slice and per crtc in bw state
(or may be in DBuf state in future), that way we don't need to have all crtcs in state and those only if we detect if are actually going to change cdclk, just same way as we do with other stuff, i.e intel_atomic_serialize_global_state and co. Just as per Ville's paradigm.
- Made dbuf bw calculation procedure look nicer by introducing for_each_dbuf_slice_in_mask - we often will now need to iterate slices using mask.
- According to experimental results CDCLK * 64 accounts for overall bandwidth across all dbufs, not per dbuf.
v4: - Fixed missing const(Ville)
- Removed spurious whitespaces(Ville)
- Fixed local variable init(reduced scope where not needed)
- Added some comments about data rate for planar formats
- Changed struct intel_crtc_bw to intel_dbuf_bw
- Moved dbuf bw calculation to intel_compute_min_cdclk(Ville)
--- drivers/gpu/drm/i915/display/intel_bw.c | 73 ++++++++++++++++++- drivers/gpu/drm/i915/display/intel_bw.h | 7 ++ drivers/gpu/drm/i915/display/intel_cdclk.c | 27 +++++++ drivers/gpu/drm/i915/display/intel_display.c | 8 ++ .../drm/i915/display/intel_display_power.h | 2 + drivers/gpu/drm/i915/intel_pm.c | 31 +++++++- drivers/gpu/drm/i915/intel_pm.h | 3 + 7 files changed, 148 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/display/intel_bw.c +72 -1
@@ -6,6 +6,7 @@#include <drm/drm_atomic_state_helper.h> #include "intel_bw.h" +#include "intel_pm.h" #include "intel_display_types.h" #include "intel_sideband.h"
@@ -333,7 +334,6 @@ static unsigned int intel_bw_crtc_data_rate(const struct intel_crtc_state *crtc_return data_rate; } -void intel_bw_crtc_update (struct intel_bw_state *bw_state,const struct intel_crtc_state *crtc_state) {
@@ -387,6 +387,77 @@ intel_atomic_get_bw_state(struct intel_atomic_state *state)return to_intel_bw_state (bw_state); } +int intel_bw_calc_min_cdclk (struct intel_atomic_state *state) +{ +struct drm_i915_private *dev_priv =to_i915 (state->base.dev); +int i; +const struct intel_crtc_state *crtc_state; +struct intel_crtc *crtc; +int max_bw =0 ; +int min_cdclk; +struct intel_bw_state *bw_state; +int slice_id; + + bw_state =intel_atomic_get_bw_state (state); +if (IS_ERR (bw_state)) +return PTR_ERR (bw_state); + +for_each_new_intel_crtc_in_state (state, crtc, crtc_state, i) { +enum plane_id plane_id; +struct intel_dbuf_bw *crtc_bw = &bw_state->dbuf_bw[crtc->pipe]; + +memset (&crtc_bw->used_bw,0 ,sizeof (crtc_bw->used_bw)); + +for_each_plane_id_on_crtc (crtc, plane_id) { +const struct skl_ddb_entry *plane_alloc = + &crtc_state->wm.skl.plane_ddb_y[plane_id]; +const struct skl_ddb_entry *uv_plane_alloc = + &crtc_state->wm.skl.plane_ddb_uv[plane_id]; +unsigned int data_rate = crtc_state->data_rate[plane_id]; +unsigned int dbuf_mask =0 ; + + dbuf_mask |=skl_ddb_dbuf_slice_mask (dev_priv, plane_alloc); + dbuf_mask |=skl_ddb_dbuf_slice_mask (dev_priv, uv_plane_alloc); + +/* +* FIXME: To calculate that more properly we probably need to +* to split per plane data_rate into data_rate_y and data_rate_uv +* for multiplanar formats in order not to get accounted those twice +* if they happen to reside on different slices. +* However for pre-icl this would work anyway because we have only single +* slice and for icl+ uv plane has non-zero data rate. +* So in worst case those calculation are a bit pessimistic, which +* shouldn't pose any significant problem anyway. +*/ +for_each_dbuf_slice_in_mask (slice_id, dbuf_mask) + crtc_bw->used_bw[slice_id] += data_rate; + } + } + +for_each_dbuf_slice (slice_id) { +int total_bw_per_slice =0 ; +enum pipe pipe; + +/* +* Current experimental observations show that contrary to BSpec +* we get underruns once we exceed 64 * CDCLK for slices in total. +* As a temporary measure in order not to keep CDCLK bumped up all the +* time we calculate CDCLK according to this formula for overall bw +* consumed by slices. +*/ +for_each_pipe (dev_priv, pipe) { +struct intel_dbuf_bw *crtc_bw = &bw_state->dbuf_bw[pipe]; + + total_bw_per_slice += crtc_bw->used_bw[slice_id]; + } + max_bw += total_bw_per_slice; + } + + min_cdclk = max_bw /64 ; + +return min_cdclk; +} +int intel_bw_atomic_check (struct intel_atomic_state *state) {struct drm_i915_private *dev_priv =to_i915 (state->base.dev);
drivers/gpu/drm/i915/display/intel_bw.h +7 -0
@@ -10,13 +10,19 @@#include "intel_display.h" #include "intel_global_state.h" +#include "intel_display_power.h" struct drm_i915_private ;struct intel_atomic_state ;struct intel_crtc_state ; +struct intel_dbuf_bw { +int used_bw[I915_MAX_DBUF_SLICES ]; +}; +struct intel_bw_state {struct intel_global_state base; +struct intel_dbuf_bw dbuf_bw[I915_MAX_PIPES ];unsigned int data_rate[I915_MAX_PIPES ];u8 num_active_planes[I915_MAX_PIPES ];
@@ -29,5 +35,6 @@ int intel_bw_init(struct drm_i915_private *dev_priv);int intel_bw_atomic_check (struct intel_atomic_state *state);void intel_bw_crtc_update (struct intel_bw_state *bw_state,const struct intel_crtc_state *crtc_state); +int intel_bw_calc_min_cdclk (struct intel_atomic_state *state);#endif /* __INTEL_BW_H__ */
drivers/gpu/drm/i915/display/intel_cdclk.c +27 -0
@@ -25,6 +25,7 @@#include "intel_cdclk.h" #include "intel_display_types.h" #include "intel_sideband.h" +#include "intel_bw.h" /** * DOC: CDCLK / RAWCLK
@@ -2090,6 +2091,23 @@ int intel_crtc_compute_min_cdclk(const struct intel_crtc_state *crtc_state)return min_cdclk; } +static int intel_compute_dbuf_min_cdclk (struct intel_atomic_state *state) +{ +struct drm_i915_private *dev_priv =to_i915 (state->base.dev); +int min_cdclk =intel_bw_calc_min_cdclk (state); + +DRM_DEBUG_KMS ("DBuf bw min cdclk %d\n" , min_cdclk); + +if (min_cdclk > dev_priv->max_cdclk_freq) { +drm_dbg_kms (&dev_priv->drm, +"required cdclk (%d kHz) exceeds max (%d kHz)\n" , + min_cdclk, dev_priv->max_cdclk_freq); +return -EINVAL ; + } + +return min_cdclk; +} +static int intel_compute_min_cdclk (struct intel_cdclk_state *cdclk_state) {struct intel_atomic_state *state = cdclk_state->base.state;
@@ -2098,6 +2116,13 @@ static int intel_compute_min_cdclk(struct intel_cdclk_state *cdclk_state)struct intel_crtc_state *crtc_state;int min_cdclk, i;enum pipe pipe; +int dbuf_bw_min_cdclk =0 ; + +if (INTEL_GEN (dev_priv) >=11 ) { + dbuf_bw_min_cdclk =intel_compute_dbuf_min_cdclk (state); +if (dbuf_bw_min_cdclk <0 ) +return dbuf_bw_min_cdclk; + }for_each_new_intel_crtc_in_state (state, crtc, crtc_state, i) {int ret;
@@ -2106,6 +2131,8 @@ static int intel_compute_min_cdclk(struct intel_cdclk_state *cdclk_state)if (min_cdclk <0 )return min_cdclk; + min_cdclk =max (min_cdclk, dbuf_bw_min_cdclk); +if (cdclk_state->min_cdclk[i] == min_cdclk)continue ;
drivers/gpu/drm/i915/display/intel_display.c +8 -0
@@ -14595,6 +14595,14 @@ static int intel_atomic_check_planes(struct intel_atomic_state *state,if (old_active_planes == new_active_planes)continue ; +/* +* active_planes bitmask has been updated, whenever amount +* of active planes had changed we need to recalculate CDCLK +* as it depends on total bandwidth now, not only min_cdclk +* per plane. +*/ + *need_cdclk_calc = true; + ret =intel_crtc_add_planes_to_state (state, crtc, new_active_planes);if (ret)return ret;
drivers/gpu/drm/i915/display/intel_display_power.h +2 -0
@@ -308,6 +308,8 @@ intel_display_power_put_async(struct drm_i915_private *i915, }#endif +#define I915_MAX_DBUF_SLICES 2 +enum dbuf_slice {DBUF_S1 ,DBUF_S2 ,
drivers/gpu/drm/i915/intel_pm.c +29 -2
@@ -3844,10 +3844,9 @@ icl_get_first_dbuf_slice_offset(u32 dbuf_slice_mask,return offset; } -static u16 intel_get_ddb_size (struct drm_i915_private *dev_priv) +u16 intel_get_ddb_size (struct drm_i915_private *dev_priv) {u16 ddb_size =INTEL_INFO (dev_priv)->ddb_size; -drm_WARN_ON (&dev_priv->drm, ddb_size ==0 );if (INTEL_GEN (dev_priv) <11 )
@@ -3856,6 +3855,34 @@ static u16 intel_get_ddb_size(struct drm_i915_private *dev_priv)return ddb_size; } +u32 skl_ddb_dbuf_slice_mask (struct drm_i915_private *dev_priv, +const struct skl_ddb_entry *entry) +{ +u32 slice_mask =0 ; +u16 ddb_size =intel_get_ddb_size (dev_priv); +u16 num_supported_slices =INTEL_INFO (dev_priv)->num_supported_dbuf_slices; +u16 slice_size = ddb_size / num_supported_slices; +u16 start_slice; +u16 end_slice; + +if (!skl_ddb_entry_size (entry)) +return 0 ; + + start_slice = entry->start / slice_size; + end_slice = (entry->end -1 ) / slice_size; + +/* +* Per plane DDB entry can in a really worst case be on multiple slices +* but single entry is anyway contigious. +*/ +while (start_slice <= end_slice) { + slice_mask |=BIT (start_slice); + start_slice++; + } + +return slice_mask; +} +static u8 skl_compute_dbuf_slices (const struct intel_crtc_state *crtc_state,u8 active_pipes);
drivers/gpu/drm/i915/intel_pm.h +3 -0
@@ -37,6 +37,9 @@ void skl_pipe_ddb_get_hw_state(struct intel_crtc *crtc,struct skl_ddb_entry *ddb_y, struct skl_ddb_entry *ddb_uv);void skl_ddb_get_hw_state (struct drm_i915_private *dev_priv); +u16 intel_get_ddb_size (struct drm_i915_private *dev_priv); +u32 skl_ddb_dbuf_slice_mask (struct drm_i915_private *dev_priv, +const struct skl_ddb_entry *entry);void skl_pipe_wm_get_hw_state (struct intel_crtc *crtc,struct skl_pipe_wm *out);void g4x_wm_sanitize (struct drm_i915_private *dev_priv);
Signature · 6 lines
2.24.1.485.gad05a3d8e5 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v3 5/5 drm/i915: Remove unneeded hack now for CDCLK
In reply to Stanislav LisovskiyNo need to bump up CDCLK now, as it is now correctly calculated, accounting for DBuf BW as BSpec says.
--- drivers/gpu/drm/i915/display/intel_cdclk.c | 12 ------------ 1 file changed, 12 deletions(-)
drivers/gpu/drm/i915/display/intel_cdclk.c +0 -12
@@ -2077,18 +2077,6 @@ int intel_crtc_compute_min_cdclk(const struct intel_crtc_state *crtc_state)/* Account for additional needs from the planes */ min_cdclk =max (intel_planes_min_cdclk (crtc_state), min_cdclk); -/* -* HACK. Currently for TGL platforms we calculate -* min_cdclk initially based on pixel_rate divided -* by 2, accounting for also plane requirements, -* however in some cases the lowest possible CDCLK -* doesn't work and causing the underruns. -* Explicitly stating here that this seems to be currently -* rather a Hack, than final solution. -*/ -if (IS_TIGERLAKE (dev_priv)) - min_cdclk =max (min_cdclk, (int )crtc_state->pixel_rate); -/* * Similar story as with skl_write_plane_wm and intel_enable_sagv * - in some certain driver parts, we don't have any guarantee that
Signature · 6 lines
2.24.1.485.gad05a3d8e5 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI[Intel-gfx] ✗ Fi.CI.BUILD: failure for Consider DBuf bandwidth when calculating CDCLK (rev3)
In reply to Stanislav Lisovskiy== Series Details ==
== Series Details ==
Series: Consider DBuf bandwidth when calculating CDCLK (rev3)
URL : https://patchwork.freedesktop.org/series/74739/
State : failure
== Summary ==
Applying: drm/i915: Decouple cdclk calculation from modeset checks
Applying: drm/i915: Force recalculate min_cdclk if planes config changed
Applying: drm/i915: Introduce for_each_dbuf_slice_in_mask macro
Applying: drm/i915: Adjust CDCLK accordingly to our DBuf bw needs
error: sha1 information is lacking or useless (drivers/gpu/drm/i915/display/intel_bw.c).
error: could not build fake ancestor
hint: Use 'git am --show-current-patch' to see the failed patch
Patch failed at 0004 drm/i915: Adjust CDCLK accordingly to our DBuf bw needs When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI[Intel-gfx] ✗ Fi.CI.BUILD: failure for Consider DBuf bandwidth when calculating CDCLK (rev7)
In reply to Stanislav Lisovskiy== Series Details ==
== Series Details ==
Series: Consider DBuf bandwidth when calculating CDCLK (rev7)
URL : https://patchwork.freedesktop.org/series/74739/
State : failure
== Summary ==
Applying: drm/i915: Decouple cdclk calculation from modeset checks
Applying: drm/i915: Force recalculate min_cdclk if planes config changed
Applying: drm/i915: Introduce for_each_dbuf_slice_in_mask macro
Applying: drm/i915: Adjust CDCLK accordingly to our DBuf bw needs
Applying: drm/i915: Remove unneeded hack now for CDCLK
Using index info to reconstruct a base tree...
M drivers/gpu/drm/i915/display/intel_cdclk.c
Falling back to patching base and 3-way merge...
Auto-merging drivers/gpu/drm/i915/display/intel_cdclk.c
CONFLICT (content): Merge conflict in drivers/gpu/drm/i915/display/intel_cdclk.c
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch Patch failed at 0005 drm/i915: Remove unneeded hack now for CDCLK When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx