drm/i915/fbc: Fix FBC for glk+
cover drm/i915/fbc: Fix FBC for glk+
From: Ville Syrjälä <[email protected]>
Implement the missing w/a for back to back FBC disable + plane update on glk+. The scariest part of this is that we now start to use flip nuke so that we can avoid the w/a (as it would cost us one extra frame for every plane update). Hopefully my "can we flip nuke safely?" check is good enough.
There's a bit of cleanup mixed in since there was all kinds of crap in my way. The state of the code is still not pretty but seemed to work well enough in my limited testing.
Entire series availalbe here:git://github.com/vsyrjala/linux.git glk_fbc_wa
Ville Syrjälä (13):
drm/i915/fbc: Disable fbc by default on all glk+ drm/i915/fbc: Nuke bogus single pipe fbc1 restriction drm/i915: Relocate intel_crtc_active() drm/i915/fbc: Remove the FBC_RT_BASE setup for ILK/SNB drm/i915/fbc: Precompute gen9 cfb stride w/a drm/i915/fbc: Track plane visibility drm/i915/fbc: Store fence_id direction in fbc cache/params drm/i915/fbc: Make fence_id optional for i965gm drm/i915/fbc: s/gen9 && !glk/gen9_bc || bxt/ drm/i915/fbc: Nuke fbc.enabled
drm/i915/fbc: Start using flip nuke drm/i915/fbc: Wait for vblank after FBC disable on glk+ drm/i915/fbc: Enable fbc by default on glk+ once again
drivers/gpu/drm/i915/display/intel_display.c | 25 +- drivers/gpu/drm/i915/display/intel_display.h | 1 - drivers/gpu/drm/i915/display/intel_fbc.c | 249 +++++++++---------- drivers/gpu/drm/i915/display/intel_fbc.h | 3 +- drivers/gpu/drm/i915/i915_drv.h | 14 +- drivers/gpu/drm/i915/intel_pm.c | 19 ++ 6 files changed, 150 insertions(+), 161 deletions(-)
Signature · 6 lines
2.23.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/13 drm/i915/fbc: Disable fbc by default on all glk+
From: Ville Syrjälä <[email protected]>
We're missing a workaround in the fbc code for all glk+ platforms which can cause corruption around the top of the screen. So enabling fbc by default is a bad idea. I'm not keen to backport the w/a so let's start by disabling fbc by default on all glk+. We'll lift the restriction once the w/a is in place.
--- drivers/gpu/drm/i915/display/intel_fbc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/display/intel_fbc.c +1 -1
@@ -1284,7 +1284,7 @@ static int intel_sanitize_fbc_option(struct drm_i915_private *dev_priv)return 0 ;/* https://bugs.freedesktop.org/show_bug.cgi?id=108085 */ -if (IS_GEMINILAKE (dev_priv)) +if (INTEL_GEN (dev_priv) >=10 ||IS_GEMINILAKE (dev_priv))return 0 ;if (IS_BROADWELL (dev_priv) ||INTEL_GEN (dev_priv) >=9 )
Signature · 1 line
2.23.0
Sasha Levin
maintainerRe: [PATCH 01/13] drm/i915/fbc: Disable fbc by default on all glk+
Hi,
[This is an automated email]
This commit has been processed because it contains a -stable tag. The stable tag indicates that it's relevant for the following trees: all
The bot has tested the following trees: v5.3.13, v4.19.86, v4.14.156, v4.9.203, v4.4.203.
v5.3.13: Build OK!
v4.19.86: Failed to apply! Possible dependencies:
Unable to calculate
v4.14.156: Failed to apply! Possible dependencies:
Unable to calculate
v4.9.203: Failed to apply! Possible dependencies:
1d25724b41fa ("drm/i915/fbc: disable framebuffer compression on GeminiLake") fd7d6c5c8f3e ("drm/i915: enable FBC on gen9+ too")
v4.4.203: Failed to apply! Possible dependencies:
0e631adc1aef ("drm/i915: introduce is_active/activate/deactivate to the FBC terminology")
128d735606d4 ("drm/i915: use a single intel_fbc_work struct")
1d25724b41fa ("drm/i915/fbc: disable framebuffer compression on GeminiLake")
30c58d5896e5 ("drm/i915: extract crtc_is_valid() on the FBC code")
36dbc4d76918 ("drm/i915/fbc: FBC causes display flicker when VT-d is enabled on Skylake")
45b32a291978 ("drm/i915: use struct intel_crtc *crtc at __intel_fbc_update()")
571050226c5d ("drm/i915: extract fbc_on_pipe_a_only()")
754d113304aa ("drm/i915: pass the crtc as an argument to intel_fbc_update()")
793af070a716 ("drm/i915: remove newline from a no_fbc_reason message")
80788a0fbbdf ("drm/i915/fbc: sanitize i915.enable_fbc during FBC init")
913a3a6acae3 ("drm/i915/fbc: don't print no_fbc_reason to dmesg")
a4dedd5a14a8 ("drm/i915: remove unnecessary check for crtc->primary->fb")
ab34a7e8b55a ("drm/i915/fbc: replace frequent dev_priv->fbc.x with fbc->x")
bf6189c6f062 ("drm/i915: change no_fbc_reason from enum to string")
c68ae339e710 ("drm/i915: don't disable_fbc() if FBC is already disabled")
e9c5fd26ac38 ("drm/i915: set dev_priv->fbc.crtc before scheduling the enable work")NOTE: The patch will not be queued to stable trees until it is upstream.
How should we proceed with this patch?
Signature · 6 lines
Thanks, Sasha _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/13 drm/i915/fbc: Nuke bogus single pipe fbc1 restriction
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Not sure where the single pipe only restriction came for fbc1. Nothing I can see that would prevent this.
v2: Nuke no_fbc_on_multiple_pipes() too
--- drivers/gpu/drm/i915/display/intel_display.c | 2 - drivers/gpu/drm/i915/display/intel_fbc.c | 52 -------------------- drivers/gpu/drm/i915/display/intel_fbc.h | 1 - drivers/gpu/drm/i915/i915_drv.h | 1 - 4 files changed, 56 deletions(-)
drivers/gpu/drm/i915/display/intel_display.c +0 -2
@@ -17869,8 +17869,6 @@ intel_modeset_setup_hw_state(struct drm_device *dev, }intel_display_power_put (dev_priv,POWER_DOMAIN_INIT , wakeref); - -intel_fbc_init_pipe_state (dev_priv); }void intel_display_resume (struct drm_device *dev)
drivers/gpu/drm/i915/display/intel_fbc.c +0 -52
82 lines not on this page · raw message
drivers/gpu/drm/i915/display/intel_fbc.h +0 -1
@@ -24,7 +24,6 @@ void intel_fbc_pre_update(struct intel_crtc *crtc, struct intel_plane_state *plane_state);void intel_fbc_post_update (struct intel_crtc *crtc);void intel_fbc_init (struct drm_i915_private *dev_priv); -void intel_fbc_init_pipe_state (struct drm_i915_private *dev_priv);void intel_fbc_enable (struct intel_crtc *crtc,struct intel_crtc_state *crtc_state,struct intel_plane_state *plane_state);
drivers/gpu/drm/i915/i915_drv.h +0 -1
@@ -366,7 +366,6 @@ struct intel_fbc {unsigned threshold;unsigned int possible_framebuffer_bits;unsigned int busy_bits; -unsigned int visible_pipes_mask;struct intel_crtc *crtc;struct drm_mm_node compressed_fb;
Signature · 6 lines
2.23.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/13 drm/i915: Relocate intel_crtc_active()
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Move intel_crtc_active() next to its only remaining user (pre-g4x wm code).
--- drivers/gpu/drm/i915/display/intel_display.c | 19 ------------------- drivers/gpu/drm/i915/display/intel_display.h | 1 - drivers/gpu/drm/i915/intel_pm.c | 19 +++++++++++++++++++ 3 files changed, 19 insertions(+), 20 deletions(-)
drivers/gpu/drm/i915/display/intel_display.c +0 -19
@@ -1040,25 +1040,6 @@ bool bxt_find_best_dpll(struct intel_crtc_state *crtc_state, NULL, best_clock); } -bool intel_crtc_active (struct intel_crtc *crtc) -{ -/* Be paranoid as we can arrive here with only partial -* state retrieved from the hardware during setup. -* -* We can ditch the adjusted_mode.crtc_clock check as soon -* as Haswell has gained clock readout/fastboot support. -* -* We can ditch the crtc->primary->state->fb check as soon as we can -* properly reconstruct framebuffers. -* -* FIXME: The intel_crtc->active here should be switched to -* crtc->state->active once we have proper CRTC states wired up -* for atomic. -*/ -return crtc->active && crtc->base.primary->state->fb && - crtc->config->hw.adjusted_mode.crtc_clock; -} -enum transcoder intel_pipe_to_cpu_transcoder (struct drm_i915_private *dev_priv,enum pipe pipe) {
drivers/gpu/drm/i915/display/intel_display.h +0 -1
@@ -558,7 +558,6 @@ bool bxt_find_best_dpll(struct intel_crtc_state *crtc_state, struct dpll *best_clock);int chv_calc_dpll_params (int refclk,struct dpll *pll_clock); -bool intel_crtc_active (struct intel_crtc *crtc);bool hsw_crtc_state_ips_capable (const struct intel_crtc_state *crtc_state);void hsw_enable_ips (const struct intel_crtc_state *crtc_state);void hsw_disable_ips (const struct intel_crtc_state *crtc_state);
drivers/gpu/drm/i915/intel_pm.c +19 -0
@@ -814,6 +814,25 @@ static bool intel_wm_plane_visible(const struct intel_crtc_state *crtc_state,return plane_state->uapi.visible; } +static bool intel_crtc_active (struct intel_crtc *crtc) +{ +/* Be paranoid as we can arrive here with only partial +* state retrieved from the hardware during setup. +* +* We can ditch the adjusted_mode.crtc_clock check as soon +* as Haswell has gained clock readout/fastboot support. +* +* We can ditch the crtc->primary->state->fb check as soon as we can +* properly reconstruct framebuffers. +* +* FIXME: The intel_crtc->active here should be switched to +* crtc->state->active once we have proper CRTC states wired up +* for atomic. +*/ +return crtc->active && crtc->base.primary->state->fb && + crtc->config->hw.adjusted_mode.crtc_clock; +} +static struct intel_crtc *single_enabled_crtc (struct drm_i915_private *dev_priv) {struct intel_crtc *crtc, *enabled =NULL ;
Signature · 6 lines
2.23.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/13 drm/i915/fbc: Remove the FBC_RT_BASE setup for ILK/SNB
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
We don't want to use the FBC hardware render tracking so let's not enable it. To use the hw tracking properly we'd anyway need to integrate this into the command submissing path as the register is context saved, and if rendering happens via the ppgtt we'd have to configure it with the ppgtt address instead of the ggtt address. Easier to use software tracking instead.
Note that on pre-ilk we can't actually disable render tracking. However we can't rely on it because it requires that DSPSURF to match the render target address, and since we play tricks with DSPSURF that may not be the case. Hence we shall rely on software render tracking on all platforms.
--- drivers/gpu/drm/i915/display/intel_fbc.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/i915/display/intel_fbc.c +0 -2
@@ -248,8 +248,6 @@ static void ilk_fbc_activate(struct drm_i915_private *dev_priv) }I915_WRITE (ILK_DPFC_FENCE_YOFF , params->crtc.fence_y_offset); -I915_WRITE (ILK_FBC_RT_BASE , -i915_ggtt_offset (params->vma) |ILK_FBC_RT_VALID );/* enable it... */ I915_WRITE (ILK_DPFC_CONTROL , dpfc_ctl |DPFC_CTL_EN );
Signature · 6 lines
2.23.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 5/13 drm/i915/fbc: Precompute gen9 cfb stride w/a
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Precompute the override cfb stride value so that we can check it when determining if flip nuke can be used or not.
The hardware has 13 bits for this, so we can shrink the storage to u16 while at it.
--- drivers/gpu/drm/i915/display/intel_fbc.c | 33 ++++++++++++++---------- drivers/gpu/drm/i915/i915_drv.h | 3 ++- 2 files changed, 21 insertions(+), 15 deletions(-)
drivers/gpu/drm/i915/display/intel_fbc.c +19 -14
@@ -283,8 +283,7 @@ static void gen7_fbc_activate(struct drm_i915_private *dev_priv) val &= ~(FBC_STRIDE_OVERRIDE |FBC_STRIDE_MASK ); -if (i915_gem_object_get_tiling (params->vma->obj) != -I915_TILING_X ) +if (params->gen9_wa_cfb_stride) val |=FBC_STRIDE_OVERRIDE | params->gen9_wa_cfb_stride;I915_WRITE (CHICKEN_MISC_4 , val);
@@ -414,8 +413,8 @@ static void intel_fbc_deactivate(struct drm_i915_private *dev_priv,static int find_compression_threshold (struct drm_i915_private *dev_priv,struct drm_mm_node *node, -int size, -int fb_cpp) +unsigned int size, +unsigned int fb_cpp) {int compression_threshold =1 ;int ret;
@@ -461,18 +460,15 @@ static int find_compression_threshold(struct drm_i915_private *dev_priv, } } -static int intel_fbc_alloc_cfb (struct intel_crtc *crtc) +static int intel_fbc_alloc_cfb (struct drm_i915_private *dev_priv, +unsigned int size,unsigned int fb_cpp) { -struct drm_i915_private *dev_priv =to_i915 (crtc->base.dev);struct intel_fbc *fbc = &dev_priv->fbc;struct drm_mm_node *uninitialized_var (compressed_llb ); -int size, fb_cpp, ret; +int ret;WARN_ON (drm_mm_node_allocated (&fbc->compressed_fb)); - size =intel_fbc_calculate_cfb_size (dev_priv, &fbc->state_cache); - fb_cpp = fbc->state_cache.fb.format->cpp[0 ]; - ret =find_compression_threshold (dev_priv, &fbc->compressed_fb, size, fb_cpp);if (!ret)
@@ -823,9 +819,7 @@ static void intel_fbc_get_reg_params(struct intel_crtc *crtc, params->cfb_size =intel_fbc_calculate_cfb_size (dev_priv, cache); -if (IS_GEN (dev_priv,9 ) && !IS_GEMINILAKE (dev_priv)) - params->gen9_wa_cfb_stride =DIV_ROUND_UP (cache->plane.src_w, -32 * fbc->threshold) *8 ; + params->gen9_wa_cfb_stride = cache->gen9_wa_cfb_stride; } void intel_fbc_pre_update(struct intel_crtc *crtc,
@@ -1054,6 +1048,8 @@ void intel_fbc_enable(struct intel_crtc *crtc, {struct drm_i915_private *dev_priv =to_i915 (crtc->base.dev);struct intel_fbc *fbc = &dev_priv->fbc; +struct intel_fbc_state_cache *cache = &fbc->state_cache; +const struct drm_framebuffer *fb = plane_state->hw.fb;if (!fbc_supported (dev_priv))return ;
@@ -1076,11 +1072,20 @@ void intel_fbc_enable(struct intel_crtc *crtc,WARN_ON (fbc->crtc !=NULL );intel_fbc_update_state_cache (crtc, crtc_state, plane_state); -if (intel_fbc_alloc_cfb (crtc)) { +if (intel_fbc_alloc_cfb (dev_priv, +intel_fbc_calculate_cfb_size (dev_priv, cache), + fb->format->cpp[0 ])) { fbc->no_fbc_reason ="not enough stolen memory" ; goto out; } +if (IS_GEN (dev_priv,9 ) && !IS_GEMINILAKE (dev_priv) && + fb->modifier !=I915_FORMAT_MOD_X_TILED ) + cache->gen9_wa_cfb_stride = +DIV_ROUND_UP (cache->plane.src_w,32 * fbc->threshold) *8 ; +else + cache->gen9_wa_cfb_stride =0 ; +DRM_DEBUG_KMS ("Enabling FBC on pipe %c\n" ,pipe_name (crtc->pipe)); fbc->no_fbc_reason ="FBC enabled but not active yet\n" ;
drivers/gpu/drm/i915/i915_drv.h +2 -1
@@ -417,6 +417,7 @@ struct intel_fbc {const struct drm_format_info *format;unsigned int stride; } fb; +u16 gen9_wa_cfb_stride; } state_cache;/*
@@ -442,7 +443,7 @@ struct intel_fbc { } fb;int cfb_size; -unsigned int gen9_wa_cfb_stride; +u16 gen9_wa_cfb_stride; } params;const char *no_fbc_reason;
Signature · 6 lines
2.23.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 6/14 drm/i915/fbc: Precompute gen9 cfb stride w/a
From: Ville Syrjälä <[email protected]>
Precompute the override cfb stride value so that we can check it when determining if flip nuke can be used or not.
The hardware has 13 bits for this, so we can shrink the storage to u16 while at it.
v2: Don't explode when crtc_state->enable_fbc lies to us
--- drivers/gpu/drm/i915/display/intel_fbc.c | 38 +++++++++++++++--------- drivers/gpu/drm/i915/i915_drv.h | 3 +- 2 files changed, 26 insertions(+), 15 deletions(-)
drivers/gpu/drm/i915/display/intel_fbc.c +24 -14
@@ -283,8 +283,7 @@ static void gen7_fbc_activate(struct drm_i915_private *dev_priv) val &= ~(FBC_STRIDE_OVERRIDE |FBC_STRIDE_MASK ); -if (i915_gem_object_get_tiling (params->vma->obj) != -I915_TILING_X ) +if (params->gen9_wa_cfb_stride) val |=FBC_STRIDE_OVERRIDE | params->gen9_wa_cfb_stride;I915_WRITE (CHICKEN_MISC_4 , val);
@@ -414,8 +413,8 @@ static void intel_fbc_deactivate(struct drm_i915_private *dev_priv,static int find_compression_threshold (struct drm_i915_private *dev_priv,struct drm_mm_node *node, -int size, -int fb_cpp) +unsigned int size, +unsigned int fb_cpp) {int compression_threshold =1 ;int ret;
@@ -461,18 +460,15 @@ static int find_compression_threshold(struct drm_i915_private *dev_priv, } } -static int intel_fbc_alloc_cfb (struct intel_crtc *crtc) +static int intel_fbc_alloc_cfb (struct drm_i915_private *dev_priv, +unsigned int size,unsigned int fb_cpp) { -struct drm_i915_private *dev_priv =to_i915 (crtc->base.dev);struct intel_fbc *fbc = &dev_priv->fbc;struct drm_mm_node *uninitialized_var (compressed_llb ); -int size, fb_cpp, ret; +int ret;WARN_ON (drm_mm_node_allocated (&fbc->compressed_fb)); - size =intel_fbc_calculate_cfb_size (dev_priv, &fbc->state_cache); - fb_cpp = fbc->state_cache.fb.format->cpp[0 ]; - ret =find_compression_threshold (dev_priv, &fbc->compressed_fb, size, fb_cpp);if (!ret)
@@ -823,9 +819,7 @@ static void intel_fbc_get_reg_params(struct intel_crtc *crtc, params->cfb_size =intel_fbc_calculate_cfb_size (dev_priv, cache); -if (IS_GEN (dev_priv,9 ) && !IS_GEMINILAKE (dev_priv)) - params->gen9_wa_cfb_stride =DIV_ROUND_UP (cache->plane.src_w, -32 * fbc->threshold) *8 ; + params->gen9_wa_cfb_stride = cache->gen9_wa_cfb_stride; } void intel_fbc_pre_update(struct intel_crtc *crtc,
@@ -1054,6 +1048,8 @@ void intel_fbc_enable(struct intel_crtc *crtc, {struct drm_i915_private *dev_priv =to_i915 (crtc->base.dev);struct intel_fbc *fbc = &dev_priv->fbc; +struct intel_fbc_state_cache *cache = &fbc->state_cache; +const struct drm_framebuffer *fb = plane_state->hw.fb;if (!fbc_supported (dev_priv))return ;
@@ -1076,11 +1072,25 @@ void intel_fbc_enable(struct intel_crtc *crtc,WARN_ON (fbc->crtc !=NULL );intel_fbc_update_state_cache (crtc, crtc_state, plane_state); -if (intel_fbc_alloc_cfb (crtc)) { + +/* FIXME crtc_state->enable_fbc lies :( */ +if (!cache->plane.visible) + goto out; + +if (intel_fbc_alloc_cfb (dev_priv, +intel_fbc_calculate_cfb_size (dev_priv, cache), + fb->format->cpp[0 ])) { fbc->no_fbc_reason ="not enough stolen memory" ; goto out; } +if (IS_GEN (dev_priv,9 ) && !IS_GEMINILAKE (dev_priv) && + fb->modifier !=I915_FORMAT_MOD_X_TILED ) + cache->gen9_wa_cfb_stride = +DIV_ROUND_UP (cache->plane.src_w,32 * fbc->threshold) *8 ; +else + cache->gen9_wa_cfb_stride =0 ; +DRM_DEBUG_KMS ("Enabling FBC on pipe %c\n" ,pipe_name (crtc->pipe)); fbc->no_fbc_reason ="FBC enabled but not active yet\n" ;
drivers/gpu/drm/i915/i915_drv.h +2 -1
@@ -417,6 +417,7 @@ struct intel_fbc {const struct drm_format_info *format;unsigned int stride; } fb; +u16 gen9_wa_cfb_stride; } state_cache;/*
@@ -442,7 +443,7 @@ struct intel_fbc { } fb;int cfb_size; -unsigned int gen9_wa_cfb_stride; +u16 gen9_wa_cfb_stride; } params;const char *no_fbc_reason;
Signature · 6 lines
2.23.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v3 5/13 drm/i915/fbc: Precompute gen9 cfb stride w/a
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Precompute the override cfb stride value so that we can check it when determining if flip nuke can be used or not.
The hardware has 13 bits for this, so we can shrink the storage to u16 while at it.
v2: Don't explode when crtc_state->enable_fbc lies to us
--- drivers/gpu/drm/i915/display/intel_fbc.c | 38 +++++++++++++++--------- drivers/gpu/drm/i915/i915_drv.h | 3 +- 2 files changed, 26 insertions(+), 15 deletions(-)
drivers/gpu/drm/i915/display/intel_fbc.c +24 -14
@@ -283,8 +283,7 @@ static void gen7_fbc_activate(struct drm_i915_private *dev_priv) val &= ~(FBC_STRIDE_OVERRIDE |FBC_STRIDE_MASK ); -if (i915_gem_object_get_tiling (params->vma->obj) != -I915_TILING_X ) +if (params->gen9_wa_cfb_stride) val |=FBC_STRIDE_OVERRIDE | params->gen9_wa_cfb_stride;I915_WRITE (CHICKEN_MISC_4 , val);
@@ -414,8 +413,8 @@ static void intel_fbc_deactivate(struct drm_i915_private *dev_priv,static int find_compression_threshold (struct drm_i915_private *dev_priv,struct drm_mm_node *node, -int size, -int fb_cpp) +unsigned int size, +unsigned int fb_cpp) {int compression_threshold =1 ;int ret;
@@ -461,18 +460,15 @@ static int find_compression_threshold(struct drm_i915_private *dev_priv, } } -static int intel_fbc_alloc_cfb (struct intel_crtc *crtc) +static int intel_fbc_alloc_cfb (struct drm_i915_private *dev_priv, +unsigned int size,unsigned int fb_cpp) { -struct drm_i915_private *dev_priv =to_i915 (crtc->base.dev);struct intel_fbc *fbc = &dev_priv->fbc;struct drm_mm_node *uninitialized_var (compressed_llb ); -int size, fb_cpp, ret; +int ret;WARN_ON (drm_mm_node_allocated (&fbc->compressed_fb)); - size =intel_fbc_calculate_cfb_size (dev_priv, &fbc->state_cache); - fb_cpp = fbc->state_cache.fb.format->cpp[0 ]; - ret =find_compression_threshold (dev_priv, &fbc->compressed_fb, size, fb_cpp);if (!ret)
@@ -823,9 +819,7 @@ static void intel_fbc_get_reg_params(struct intel_crtc *crtc, params->cfb_size =intel_fbc_calculate_cfb_size (dev_priv, cache); -if (IS_GEN (dev_priv,9 ) && !IS_GEMINILAKE (dev_priv)) - params->gen9_wa_cfb_stride =DIV_ROUND_UP (cache->plane.src_w, -32 * fbc->threshold) *8 ; + params->gen9_wa_cfb_stride = cache->gen9_wa_cfb_stride; } void intel_fbc_pre_update(struct intel_crtc *crtc,
@@ -1054,6 +1048,8 @@ void intel_fbc_enable(struct intel_crtc *crtc, {struct drm_i915_private *dev_priv =to_i915 (crtc->base.dev);struct intel_fbc *fbc = &dev_priv->fbc; +struct intel_fbc_state_cache *cache = &fbc->state_cache; +const struct drm_framebuffer *fb = plane_state->hw.fb;if (!fbc_supported (dev_priv))return ;
@@ -1076,11 +1072,25 @@ void intel_fbc_enable(struct intel_crtc *crtc,WARN_ON (fbc->crtc !=NULL );intel_fbc_update_state_cache (crtc, crtc_state, plane_state); -if (intel_fbc_alloc_cfb (crtc)) { + +/* FIXME crtc_state->enable_fbc lies :( */ +if (!cache->plane.visible) + goto out; + +if (intel_fbc_alloc_cfb (dev_priv, +intel_fbc_calculate_cfb_size (dev_priv, cache), + fb->format->cpp[0 ])) { fbc->no_fbc_reason ="not enough stolen memory" ; goto out; } +if (IS_GEN (dev_priv,9 ) && !IS_GEMINILAKE (dev_priv) && + fb->modifier !=I915_FORMAT_MOD_X_TILED ) + cache->gen9_wa_cfb_stride = +DIV_ROUND_UP (cache->plane.src_w,32 * fbc->threshold) *8 ; +else + cache->gen9_wa_cfb_stride =0 ; +DRM_DEBUG_KMS ("Enabling FBC on pipe %c\n" ,pipe_name (crtc->pipe)); fbc->no_fbc_reason ="FBC enabled but not active yet\n" ;
drivers/gpu/drm/i915/i915_drv.h +2 -1
@@ -417,6 +417,7 @@ struct intel_fbc {const struct drm_format_info *format;unsigned int stride; } fb; +u16 gen9_wa_cfb_stride; } state_cache;/*
@@ -442,7 +443,7 @@ struct intel_fbc { } fb;int cfb_size; -unsigned int gen9_wa_cfb_stride; +u16 gen9_wa_cfb_stride; } params;const char *no_fbc_reason;
Signature · 6 lines
2.23.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 6/13 drm/i915/fbc: Track plane visibility
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Currently the code (ab)uses cache->vma to indicate the plane visibility. I want to nuke that so let's add a dedicated boolean for this.
--- drivers/gpu/drm/i915/display/intel_fbc.c | 21 ++++++++++----------- drivers/gpu/drm/i915/i915_drv.h | 1 + 2 files changed, 11 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/display/intel_fbc.c +10 -11
@@ -634,8 +634,9 @@ static void intel_fbc_update_state_cache(struct intel_crtc *crtc,struct intel_fbc_state_cache *cache = &fbc->state_cache;struct drm_framebuffer *fb = plane_state->hw.fb; - cache->vma =NULL ; - cache->flags =0 ; + cache->plane.visible = plane_state->uapi.visible; +if (!cache->plane.visible) +return ; cache->crtc.mode_flags = crtc_state->hw.adjusted_mode.flags;if (IS_HASWELL (dev_priv) ||IS_BROADWELL (dev_priv))
@@ -649,16 +650,12 @@ static void intel_fbc_update_state_cache(struct intel_crtc *crtc,*/ cache->plane.src_w =drm_rect_width (&plane_state->uapi.src) >>16 ; cache->plane.src_h =drm_rect_height (&plane_state->uapi.src) >>16 ; - cache->plane.visible = plane_state->uapi.visible; cache->plane.adjusted_x = plane_state->color_plane[0 ].x; cache->plane.adjusted_y = plane_state->color_plane[0 ].y; cache->plane.y = plane_state->uapi.src.y1 >>16 ; cache->plane.pixel_blend_mode = plane_state->hw.pixel_blend_mode; -if (!cache->plane.visible) -return ; - cache->fb.format = fb->format; cache->fb.stride = fb->pitches[0 ];
@@ -674,6 +671,11 @@ static bool intel_fbc_can_activate(struct intel_crtc *crtc)struct intel_fbc *fbc = &dev_priv->fbc;struct intel_fbc_state_cache *cache = &fbc->state_cache; +if (!cache->plane.visible) { + fbc->no_fbc_reason ="primary plane not visible" ; +return false; + } +/* We don't need to use a state cache here since this information is * global for all CRTC. */
@@ -682,11 +684,6 @@ static bool intel_fbc_can_activate(struct intel_crtc *crtc)return false; } -if (!cache->vma) { - fbc->no_fbc_reason ="primary plane not visible" ; -return false; - } -if (cache->crtc.mode_flags &DRM_MODE_FLAG_INTERLACE ) { fbc->no_fbc_reason ="incompatible mode" ;return false;
@@ -820,6 +817,8 @@ static void intel_fbc_get_reg_params(struct intel_crtc *crtc, params->cfb_size =intel_fbc_calculate_cfb_size (dev_priv, cache); params->gen9_wa_cfb_stride = cache->gen9_wa_cfb_stride; + + params->plane_visible = cache->plane.visible; } void intel_fbc_pre_update(struct intel_crtc *crtc,
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -444,6 +444,7 @@ struct intel_fbc {int cfb_size;u16 gen9_wa_cfb_stride; +bool plane_visible; } params;const char *no_fbc_reason;
Signature · 6 lines
2.23.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 7/13 drm/i915/fbc: Store fence_id direction in fbc cache/params
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Rather than playing around with vma+flags let's just grab the fence id from within and stash that directly in the fbc cache/params.
--- drivers/gpu/drm/i915/display/intel_fbc.c | 33 +++++++++++++----------- drivers/gpu/drm/i915/i915_drv.h | 8 ++---- 2 files changed, 20 insertions(+), 21 deletions(-)
drivers/gpu/drm/i915/display/intel_fbc.c +18 -15
@@ -151,7 +151,7 @@ static void i8xx_fbc_activate(struct drm_i915_private *dev_priv)if (IS_I945GM (dev_priv)) fbc_ctl |=FBC_CTL_C3_IDLE ;/* 945 needs special SR handling */ fbc_ctl |= (cfb_pitch &0xff ) <<FBC_CTL_STRIDE_SHIFT ; - fbc_ctl |= params->vma->fence->id; + fbc_ctl |= params->fence_id;I915_WRITE (FBC_CONTROL , fbc_ctl); }
@@ -171,8 +171,8 @@ static void g4x_fbc_activate(struct drm_i915_private *dev_priv)else dpfc_ctl |=DPFC_CTL_LIMIT_1X ; -if (params->flags &PLANE_HAS_FENCE ) { - dpfc_ctl |=DPFC_CTL_FENCE_EN | params->vma->fence->id; +if (params->fence_id >=0 ) { + dpfc_ctl |=DPFC_CTL_FENCE_EN | params->fence_id;I915_WRITE (DPFC_FENCE_YOFF , params->crtc.fence_y_offset); }else {I915_WRITE (DPFC_FENCE_YOFF ,0 );
@@ -229,14 +229,14 @@ static void ilk_fbc_activate(struct drm_i915_private *dev_priv)break ; } -if (params->flags &PLANE_HAS_FENCE ) { +if (params->fence_id >=0 ) { dpfc_ctl |=DPFC_CTL_FENCE_EN ;if (IS_GEN (dev_priv,5 )) - dpfc_ctl |= params->vma->fence->id; + dpfc_ctl |= params->fence_id;if (IS_GEN (dev_priv,6 )) {I915_WRITE (SNB_DPFC_CTL_SA ,SNB_CPU_FENCE_ENABLE | - params->vma->fence->id); + params->fence_id);I915_WRITE (DPFC_CPU_FENCE_OFFSET , params->crtc.fence_y_offset); }
@@ -309,11 +309,11 @@ static void gen7_fbc_activate(struct drm_i915_private *dev_priv)break ; } -if (params->flags &PLANE_HAS_FENCE ) { +if (params->fence_id >=0 ) { dpfc_ctl |=IVB_DPFC_CTL_FENCE_EN ;I915_WRITE (SNB_DPFC_CTL_SA ,SNB_CPU_FENCE_ENABLE | - params->vma->fence->id); + params->fence_id);I915_WRITE (DPFC_CPU_FENCE_OFFSET , params->crtc.fence_y_offset); }else {I915_WRITE (SNB_DPFC_CTL_SA ,0 );
@@ -659,10 +659,14 @@ static void intel_fbc_update_state_cache(struct intel_crtc *crtc, cache->fb.format = fb->format; cache->fb.stride = fb->pitches[0 ]; - cache->vma = plane_state->vma; - cache->flags = plane_state->flags; -if (WARN_ON (cache->flags &PLANE_HAS_FENCE && !cache->vma->fence)) - cache->flags &= ~PLANE_HAS_FENCE ; +WARN_ON (plane_state->flags &PLANE_HAS_FENCE && + !plane_state->vma->fence); + +if (plane_state->flags &PLANE_HAS_FENCE && + plane_state->vma->fence) + cache->fence_id = plane_state->vma->fence->id; +else + cache->fence_id =-1 ; }static bool intel_fbc_can_activate (struct intel_crtc *crtc)
@@ -707,7 +711,7 @@ static bool intel_fbc_can_activate(struct intel_crtc *crtc)* For now this will effecively disable FBC with 90/270 degree * rotation. */ -if (!(cache->flags &PLANE_HAS_FENCE )) { +if (cache->fence_id <0 ) { fbc->no_fbc_reason ="framebuffer not tiled or fenced" ;return false; }
@@ -804,8 +808,7 @@ static void intel_fbc_get_reg_params(struct intel_crtc *crtc,* zero. */ memset (params,0 ,sizeof (*params)); - params->vma = cache->vma; - params->flags = cache->flags; + params->fence_id = cache->fence_id; params->crtc.pipe = crtc->pipe; params->crtc.i9xx_plane =to_intel_plane (crtc->base.primary)->i9xx_plane;
drivers/gpu/drm/i915/i915_drv.h +2 -6
@@ -386,9 +386,6 @@ struct intel_fbc {* these problems. */ struct intel_fbc_state_cache { -struct i915_vma *vma; -unsigned long flags; -struct {unsigned int mode_flags;u32 hsw_bdw_pixel_rate;
@@ -418,6 +415,7 @@ struct intel_fbc {unsigned int stride; } fb;u16 gen9_wa_cfb_stride; +s8 fence_id; } state_cache;/*
@@ -428,9 +426,6 @@ struct intel_fbc {* are supposed to read from it in order to program the registers. */ struct intel_fbc_reg_params { -struct i915_vma *vma; -unsigned long flags; -struct {enum pipe pipe;enum i9xx_plane_id i9xx_plane;
@@ -444,6 +439,7 @@ struct intel_fbc {int cfb_size;u16 gen9_wa_cfb_stride; +s8 fence_id;bool plane_visible; } params;
Signature · 6 lines
2.23.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 8/13 drm/i915/fbc: Make fence_id optional for i965gm
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
i965gm no longer needs the fence for scanout so we should be do what we do for ctg+ and only configure a fence for FBC when we have one.
In theory this should do nothing atm on account of intel_fbc_can_activate() requiring the fence, but since we do this for g4x+ let's do it for i965gm as well. We may want to relax the requirements at some point and allow FBC without a fence.
--- drivers/gpu/drm/i915/display/intel_fbc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/display/intel_fbc.c +5 -2
@@ -138,8 +138,10 @@ static void i8xx_fbc_activate(struct drm_i915_private *dev_priv)u32 fbc_ctl2;/* Set it up... */ - fbc_ctl2 =FBC_CTL_FENCE_DBL |FBC_CTL_IDLE_IMM |FBC_CTL_CPU_FENCE ; + fbc_ctl2 =FBC_CTL_FENCE_DBL |FBC_CTL_IDLE_IMM ; fbc_ctl2 |=FBC_CTL_PLANE (params->crtc.i9xx_plane); +if (params->fence_id >=0 ) + fbc_ctl2 |=FBC_CTL_CPU_FENCE ;I915_WRITE (FBC_CONTROL2 , fbc_ctl2);I915_WRITE (FBC_FENCE_OFF , params->crtc.fence_y_offset); }
@@ -151,7 +153,8 @@ static void i8xx_fbc_activate(struct drm_i915_private *dev_priv)if (IS_I945GM (dev_priv)) fbc_ctl |=FBC_CTL_C3_IDLE ;/* 945 needs special SR handling */ fbc_ctl |= (cfb_pitch &0xff ) <<FBC_CTL_STRIDE_SHIFT ; - fbc_ctl |= params->fence_id; +if (params->fence_id >=0 ) + fbc_ctl |= params->fence_id;I915_WRITE (FBC_CONTROL , fbc_ctl); }
Signature · 6 lines
2.23.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 9/13 drm/i915/fbc: s/gen9 && !glk/gen9_bc || bxt/
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Replace the 'gen9 && !glk' with the slightly more obvious 'gen9_bc || bxt'.
--- drivers/gpu/drm/i915/display/intel_fbc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/display/intel_fbc.c +2 -2
@@ -281,7 +281,7 @@ static void gen7_fbc_activate(struct drm_i915_private *dev_priv)int threshold = dev_priv->fbc.threshold;/* Display WA #0529: skl, kbl, bxt. */ -if (IS_GEN (dev_priv,9 ) && !IS_GEMINILAKE (dev_priv)) { +if (IS_GEN9_BC (dev_priv) ||IS_BROXTON (dev_priv)) {u32 val =I915_READ (CHICKEN_MISC_4 ); val &= ~(FBC_STRIDE_OVERRIDE |FBC_STRIDE_MASK );
@@ -1084,7 +1084,7 @@ void intel_fbc_enable(struct intel_crtc *crtc, goto out; } -if (IS_GEN (dev_priv,9 ) && !IS_GEMINILAKE (dev_priv) && +if ((IS_GEN9_BC (dev_priv) ||IS_BROXTON (dev_priv)) && fb->modifier !=I915_FORMAT_MOD_X_TILED ) cache->gen9_wa_cfb_stride =DIV_ROUND_UP (cache->plane.src_w,32 * fbc->threshold) *8 ;
Signature · 6 lines
2.23.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 10/13 drm/i915/fbc: Nuke fbc.enabled
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
fbc.enabled == (fbc.crtc != NULL), so let's just nuke fbc.enabled.
--- drivers/gpu/drm/i915/display/intel_fbc.c | 23 +++++++++-------------- drivers/gpu/drm/i915/i915_drv.h | 1 - 2 files changed, 9 insertions(+), 15 deletions(-)
drivers/gpu/drm/i915/display/intel_fbc.c +9 -14
@@ -840,7 +840,7 @@ void intel_fbc_pre_update(struct intel_crtc *crtc,mutex_lock (&fbc->lock); -if (!fbc->enabled || fbc->crtc != crtc) +if (fbc->crtc != crtc) goto unlock;intel_fbc_update_state_cache (crtc, crtc_state, plane_state);
@@ -864,14 +864,13 @@ static void __intel_fbc_disable(struct drm_i915_private *dev_priv)struct intel_crtc *crtc = fbc->crtc;WARN_ON (!mutex_is_locked (&fbc->lock)); -WARN_ON (!fbc->enabled); +WARN_ON (!fbc->crtc);WARN_ON (fbc->active);DRM_DEBUG_KMS ("Disabling FBC on pipe %c\n" ,pipe_name (crtc->pipe));__intel_fbc_cleanup_cfb (dev_priv); - fbc->enabled = false; fbc->crtc =NULL ; }
@@ -882,7 +881,7 @@ static void __intel_fbc_post_update(struct intel_crtc *crtc)WARN_ON (!mutex_is_locked (&fbc->lock)); -if (!fbc->enabled || fbc->crtc != crtc) +if (fbc->crtc != crtc)return ; fbc->flip_pending = false;
@@ -922,7 +921,7 @@ void intel_fbc_post_update(struct intel_crtc *crtc)static unsigned int intel_fbc_get_frontbuffer_bit (struct intel_fbc *fbc) { -if (fbc->enabled) +if (fbc->crtc)return to_intel_plane (fbc->crtc->base.primary)->frontbuffer_bit;else return fbc->possible_framebuffer_bits;
@@ -944,7 +943,7 @@ void intel_fbc_invalidate(struct drm_i915_private *dev_priv, fbc->busy_bits |=intel_fbc_get_frontbuffer_bit (fbc) & frontbuffer_bits; -if (fbc->enabled && fbc->busy_bits) +if (fbc->crtc && fbc->busy_bits)intel_fbc_deactivate (dev_priv,"frontbuffer write" );mutex_unlock (&fbc->lock);
@@ -965,7 +964,7 @@ void intel_fbc_flush(struct drm_i915_private *dev_priv,if (origin ==ORIGIN_GTT || origin ==ORIGIN_FLIP ) goto out; -if (!fbc->busy_bits && fbc->enabled && +if (!fbc->busy_bits && fbc->crtc && (frontbuffer_bits &intel_fbc_get_frontbuffer_bit (fbc))) {if (fbc->active)intel_fbc_recompress (dev_priv);
@@ -1061,8 +1060,7 @@ void intel_fbc_enable(struct intel_crtc *crtc,mutex_lock (&fbc->lock); -if (fbc->enabled) { -WARN_ON (fbc->crtc ==NULL ); +if (fbc->crtc) {if (fbc->crtc == crtc) {WARN_ON (!crtc_state->enable_fbc);WARN_ON (fbc->active);
@@ -1074,7 +1072,6 @@ void intel_fbc_enable(struct intel_crtc *crtc, goto out;WARN_ON (fbc->active); -WARN_ON (fbc->crtc !=NULL );intel_fbc_update_state_cache (crtc, crtc_state, plane_state); if (intel_fbc_alloc_cfb(dev_priv,
@@ -1094,7 +1091,6 @@ void intel_fbc_enable(struct intel_crtc *crtc,DRM_DEBUG_KMS ("Enabling FBC on pipe %c\n" ,pipe_name (crtc->pipe)); fbc->no_fbc_reason ="FBC enabled but not active yet\n" ; - fbc->enabled = true; fbc->crtc = crtc; out:mutex_unlock (&fbc->lock);
@@ -1134,7 +1130,7 @@ void intel_fbc_global_disable(struct drm_i915_private *dev_priv)return ;mutex_lock (&fbc->lock); -if (fbc->enabled) { +if (fbc->crtc) {WARN_ON (fbc->crtc->active);__intel_fbc_disable (dev_priv); }
@@ -1150,7 +1146,7 @@ static void intel_fbc_underrun_work_fn(struct work_struct *work)mutex_lock (&fbc->lock);/* Maybe we were scheduled twice. */ -if (fbc->underrun_detected || !fbc->enabled) +if (fbc->underrun_detected || !fbc->crtc) goto out;DRM_DEBUG_KMS ("Disabling FBC due to FIFO underrun.\n" );
@@ -1273,7 +1269,6 @@ void intel_fbc_init(struct drm_i915_private *dev_priv)INIT_WORK (&fbc->underrun_work, intel_fbc_underrun_work_fn);mutex_init (&fbc->lock); - fbc->enabled = false; fbc->active = false;if (!drm_mm_initialized (&dev_priv->mm.stolen))
drivers/gpu/drm/i915/i915_drv.h +0 -1
@@ -373,7 +373,6 @@ struct intel_fbc {bool false_color; -bool enabled;bool active;bool flip_pending;
Signature · 6 lines
2.23.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 11/13 drm/i915/fbc: Start using flip nuke
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
The hardware automagically nukes the cfb on flip. We can use that whenever the plane/crtc configuration doesn't change too much. Let's hook that up.
We'll need this for glk+ since we need to introduce an extra vblank wait after FBC disable. As we're currently disabling FBC around all plane updates we'd slow them down by an extra frame. Not a great user experience when your fps is always capped at vrefres/2. With flip nuke we don't need the extra vblank wait.
--- drivers/gpu/drm/i915/display/intel_fbc.c | 50 ++++++++++++++++++------ 1 file changed, 39 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/display/intel_fbc.c +39 -11
@@ -68,7 +68,7 @@ static unsigned int get_crtc_fence_y_offset(struct intel_fbc *fbc)* write to the PLANE_SIZE register. For BDW-, the hardware looks at the value * we wrote to PIPESRC. */ -static void intel_fbc_get_plane_source_size (struct intel_fbc_state_cache *cache, +static void intel_fbc_get_plane_source_size (const struct intel_fbc_state_cache *cache,int *width,int *height) {if (width)
@@ -78,7 +78,7 @@ static void intel_fbc_get_plane_source_size(struct intel_fbc_state_cache *cache, }static int intel_fbc_calculate_cfb_size (struct drm_i915_private *dev_priv, -struct intel_fbc_state_cache *cache) +const struct intel_fbc_state_cache *cache) {int lines;
@@ -827,6 +827,38 @@ static void intel_fbc_get_reg_params(struct intel_crtc *crtc, params->plane_visible = cache->plane.visible; } +static bool intel_fbc_can_flip_nuke (const struct intel_crtc_state *crtc_state) +{ +struct intel_crtc *crtc =to_intel_crtc (crtc_state->uapi.crtc); +struct drm_i915_private *dev_priv =to_i915 (crtc->base.dev); +const struct intel_fbc *fbc = &dev_priv->fbc; +const struct intel_fbc_state_cache *cache = &fbc->state_cache; +const struct intel_fbc_reg_params *params = &fbc->params; + +if (drm_atomic_crtc_needs_modeset (&crtc_state->uapi)) +return false; + +if (!params->plane_visible) +return false; + +if (!intel_fbc_can_activate (crtc)) +return false; + +if (params->fb.format != cache->fb.format) +return false; + +if (params->fb.stride != cache->fb.stride) +return false; + +if (params->cfb_size !=intel_fbc_calculate_cfb_size (dev_priv, cache)) +return false; + +if (params->gen9_wa_cfb_stride != cache->gen9_wa_cfb_stride) +return false; + +return true; +} +void intel_fbc_pre_update (struct intel_crtc *crtc,struct intel_crtc_state *crtc_state,struct intel_plane_state *plane_state)
@@ -846,7 +878,8 @@ void intel_fbc_pre_update(struct intel_crtc *crtc,intel_fbc_update_state_cache (crtc, crtc_state, plane_state); fbc->flip_pending = true; -intel_fbc_deactivate (dev_priv, reason); +if (!intel_fbc_can_flip_nuke (crtc_state)) +intel_fbc_deactivate (dev_priv, reason); unlock:mutex_unlock (&fbc->lock); }
@@ -885,7 +918,6 @@ static void __intel_fbc_post_update(struct intel_crtc *crtc)return ; fbc->flip_pending = false; -WARN_ON (fbc->active);if (!i915_modparams.enable_fbc) {intel_fbc_deactivate (dev_priv,"disabled at runtime per module param" );
@@ -899,10 +931,9 @@ static void __intel_fbc_post_update(struct intel_crtc *crtc)if (!intel_fbc_can_activate (crtc))return ; -if (!fbc->busy_bits) { -intel_fbc_deactivate (dev_priv,"FBC enabled (active or scheduled)" ); +if (!fbc->busy_bits)intel_fbc_hw_activate (dev_priv); - }else +else intel_fbc_deactivate (dev_priv,"frontbuffer write" ); }
@@ -1061,10 +1092,7 @@ void intel_fbc_enable(struct intel_crtc *crtc,mutex_lock (&fbc->lock);if (fbc->crtc) { -if (fbc->crtc == crtc) { -WARN_ON (!crtc_state->enable_fbc); -WARN_ON (fbc->active); - } +WARN_ON (fbc->crtc == crtc && !crtc_state->enable_fbc); goto out; }
Signature · 6 lines
2.23.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 12/13 drm/i915/fbc: Wait for vblank after FBC disable on glk+
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
On glk+ the hardware gets confused if we disable FBC while it's recompressing and we perform a plane update during the same frame. The result is that top of the screen gets corrupted.
We can avoid that by giving the hardware enough time to finish the FBC disable before we touch the plane registers. Ie. we need an extra vblank wait after FBC disable.
--- drivers/gpu/drm/i915/display/intel_display.c | 4 ++- drivers/gpu/drm/i915/display/intel_fbc.c | 26 +++++++++++++++++--- drivers/gpu/drm/i915/display/intel_fbc.h | 2 +- 3 files changed, 27 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/display/intel_display.c +3 -1
@@ -6105,7 +6105,9 @@ static void intel_pre_plane_update(struct intel_crtc_state *old_crtc_state,intel_atomic_get_new_plane_state (intel_state,to_intel_plane (primary)); -intel_fbc_pre_update (crtc, pipe_config, new_primary_state); +if (intel_fbc_pre_update (crtc, pipe_config, new_primary_state)) +intel_wait_for_vblank (dev_priv, crtc->pipe); +/* * Gen2 reports pipe underruns whenever all planes are disabled. * So disable underrun reporting before all the planes get disabled.
drivers/gpu/drm/i915/display/intel_fbc.c +23 -3
@@ -859,16 +859,17 @@ static bool intel_fbc_can_flip_nuke(const struct intel_crtc_state *crtc_state)return true; } -void intel_fbc_pre_update (struct intel_crtc *crtc, +bool intel_fbc_pre_update (struct intel_crtc *crtc,struct intel_crtc_state *crtc_state,struct intel_plane_state *plane_state) {struct drm_i915_private *dev_priv =to_i915 (crtc->base.dev);struct intel_fbc *fbc = &dev_priv->fbc;const char *reason ="update pending" ; +bool need_vblank_wait = false;if (!fbc_supported (dev_priv)) -return ; +return need_vblank_wait;mutex_lock (&fbc->lock);
@@ -878,10 +879,29 @@ void intel_fbc_pre_update(struct intel_crtc *crtc,intel_fbc_update_state_cache (crtc, crtc_state, plane_state); fbc->flip_pending = true; -if (!intel_fbc_can_flip_nuke (crtc_state)) +if (!intel_fbc_can_flip_nuke (crtc_state)) {intel_fbc_deactivate (dev_priv, reason); + +/* +* Display WA #1198: glk+ +* Need an extra vblank wait between FBC disable and most plane +* updates. Bspec says this is only needed for plane disable, but +* that is not true. Touching most plane registers will cause the +* corruption to appear. Also SKL/derivatives do not seem to be +* affected. +* +* TODO: could optimize this a bit by sampling the frame +* counter when we disable FBC (if it was already done earlier) +* and skipping the extra vblank wait before the plane update +* if at least one frame has already passed. +*/ +if (INTEL_GEN (dev_priv) >=10 ||IS_GEMINILAKE (dev_priv)) + need_vblank_wait = true; + } unlock:mutex_unlock (&fbc->lock); + +return need_vblank_wait; }/**
drivers/gpu/drm/i915/display/intel_fbc.h +1 -1
@@ -19,7 +19,7 @@ struct intel_plane_state;void intel_fbc_choose_crtc (struct drm_i915_private *dev_priv,struct intel_atomic_state *state);bool intel_fbc_is_active (struct drm_i915_private *dev_priv); -void intel_fbc_pre_update (struct intel_crtc *crtc, +bool intel_fbc_pre_update (struct intel_crtc *crtc,struct intel_crtc_state *crtc_state,struct intel_plane_state *plane_state);void intel_fbc_post_update (struct intel_crtc *crtc);
Signature · 6 lines
2.23.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 13/13 drm/i915/fbc: Enable fbc by default on glk+ once again
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Now that we have the glk+ w/a for back to back fbc disable + plane update in place we can once more enable fbc on glk+ by default.
--- drivers/gpu/drm/i915/display/intel_fbc.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/gpu/drm/i915/display/intel_fbc.c +0 -4
@@ -1283,10 +1283,6 @@ static int intel_sanitize_fbc_option(struct drm_i915_private *dev_priv)if (!HAS_FBC (dev_priv))return 0 ; -/* https://bugs.freedesktop.org/show_bug.cgi?id=108085 */ -if (INTEL_GEN (dev_priv) >=10 ||IS_GEMINILAKE (dev_priv)) -return 0 ; -if (IS_BROADWELL (dev_priv) ||INTEL_GEN (dev_priv) >=9 )return 1 ;
Signature · 6 lines
2.23.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.BAT: failure for drm/i915/fbc: Fix FBC for glk+
In reply to Ville Syrjala== Series Details ==
== Series Details ==
Series: drm/i915/fbc: Fix FBC for glk+
URL : https://patchwork.freedesktop.org/series/70062/
State : failure
== Summary ==
CI Bug Log - changes from CI_DRM_7426 -> Patchwork_15442
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with Patchwork_15442 absolutely need to be verified manually.
If you think the reported changes have nothing to do with the changes introduced in Patchwork_15442, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15442/index.html
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in Patchwork_15442:
### IGT changes ###
#### Possible regressions ####
* igt@gem_exec_suspend@basic-s3:
- fi-kbl-8809g: [PASS][1] -> [DMESG-WARN][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7426/fi-kbl-8809g/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15442/fi-kbl-8809g/igt@[email protected]
* igt@kms_cursor_legacy@basic-busy-flip-before-cursor-atomic:
- fi-icl-y: [PASS][3] -> [FAIL][4] +7 similar issues
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7426/fi-icl-y/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15442/fi-icl-y/igt@[email protected]
* igt@kms_cursor_legacy@basic-flip-after-cursor-atomic:
- fi-icl-u3: [PASS][5] -> [FAIL][6] +7 similar issues
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7426/fi-icl-u3/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15442/fi-icl-u3/igt@[email protected]
- fi-icl-dsi: [PASS][7] -> [FAIL][8] +7 similar issues
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7426/fi-icl-dsi/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15442/fi-icl-dsi/igt@[email protected]
* igt@kms_cursor_legacy@basic-flip-before-cursor-atomic:
- fi-icl-u2: [PASS][9] -> [FAIL][10] +7 similar issues
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7426/fi-icl-u2/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15442/fi-icl-u2/igt@[email protected]
* igt@kms_cursor_legacy@basic-flip-before-cursor-varying-size:
- fi-glk-dsi: [PASS][11] -> [FAIL][12] +7 similar issues
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7426/fi-glk-dsi/igt@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15442/fi-glk-dsi/igt@[email protected]
Known issues
------------
Here are the changes found in Patchwork_15442 that come from known issues:
### IGT changes ###
#### Possible fixes ####
* igt@i915_selftest@live_gem_contexts:
- fi-skl-lmem: [DMESG-FAIL][13] -> [PASS][14]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7426/fi-skl-lmem/igt@i915_selftest@live_gem_contexts.html
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15442/fi-skl-lmem/igt@i915_selftest@live_gem_contexts.html
#### Warnings ####
* igt@kms_flip@basic-flip-vs-modeset:
- fi-kbl-x1275: [DMESG-WARN][15] ([fdo#103558] / [fdo#105602]) -> [DMESG-WARN][16] ([fdo#103558] / [fdo#105602] / [fdo#105763]) +3 similar issues
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7426/fi-kbl-x1275/igt@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15442/fi-kbl-x1275/igt@[email protected]
* igt@kms_pipe_crc_basic@read-crc-pipe-a:
- fi-kbl-x1275: [DMESG-WARN][17] ([fdo#103558] / [fdo#105602] / [fdo#105763]) -> [DMESG-WARN][18] ([fdo#103558] / [fdo#105602]) +7 similar issues
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7426/fi-kbl-x1275/igt@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15442/fi-kbl-x1275/igt@[email protected]
[fdo#103558]: https://bugs.freedesktop.org/show_bug.cgi?id=103558
[fdo#105602]: https://bugs.freedesktop.org/show_bug.cgi?id=105602
[fdo#105763]: https://bugs.freedesktop.org/show_bug.cgi?id=105763
Participating hosts (49 -> 44)
------------------------------
Additional (1): fi-whl-u
Missing (6): fi-ilk-m540 fi-hsw-4200u fi-bsw-cyan fi-ctg-p8600 fi-byt-clapper fi-bdw-samus
Build changes
-------------
* CI: CI-20190529 -> None
* Linux: CI_DRM_7426 -> Patchwork_15442
CI-20190529: 20190529
CI_DRM_7426: b204d72d3485a148456e2077683974739b675b21 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5310: d1ea62b3f759f10ff6860561ba82e5c4902511d3 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_15442: a34f6796e9f9f53623b5fd1b3e77b9607fe24729 @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
a34f6796e9f9 drm/i915/fbc: Enable fbc by default on glk+ once again a3f7771b0473 drm/i915/fbc: Wait for vblank after FBC disable on glk+ 2519b734bf8c drm/i915/fbc: Start using flip nuke 36d789629601 drm/i915/fbc: Nuke fbc.enabledcff73cbedbde drm/i915/fbc: s/gen9 && !glk/gen9_bc || bxt/ 6ded20c12dae drm/i915/fbc: Make fence_id optional for i965gm 9c533e7eec86 drm/i915/fbc: Store fence_id direction in fbc cache/params 90ad5b5335ff drm/i915/fbc: Track plane visibility b3da3f2c675b drm/i915/fbc: Precompute gen9 cfb stride w/a 64a4197bff28 drm/i915/fbc: Remove the FBC_RT_BASE setup for ILK/SNB 938bbf57ad0e drm/i915: Relocate intel_crtc_active() 2daa6970f04a drm/i915/fbc: Nuke bogus single pipe fbc1 restriction 834c34e40bc9 drm/i915/fbc: Disable fbc by default on all glk+
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15442/index.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Hi Ville,
It's great to see Intel putting attention into this, thanks!
Quoted 5 lines · Ville Syrjala
Implement the missing w/a for back to back FBC disable + plane update on glk+. The scariest part of this is that we now start to use flip nuke so that we can avoid the w/a (as it would cost us one extra frame for every plane update). Hopefully my "can we flip nuke safely?" check is good enough.
I tested on Asus E406MA which is one of the original platforms where we were seeing the corruption at the top of the screen.
I first took your branch *without* your new patches applied, to reconfirm the base case of FBC causing corruption. However this didn't work as desired - FBC did not get enabled and i915_fbc_status reported "no suitable CRTC fo FBC".
This must be a change in behaviour since we originally saw the corruption bug a while back. I checked that skl_plane_has_fbc() correctly marks the right plane (pipe A, primary plane) as has_fbc=1 however the loop inside intel_fbc_choose_crtc() was only considering plane 7 (PLANE_CURSOR) and then deciding that there were no FBC-capable planes.
I then applied your patch series and checked again. FBC still disabled, but this time the reason is "CFB requirements changed".
I then booted with i915.fastboot=0 and now FBC is enabled. I'm unable to reproduce the graphics corruption under this setup, so it looks like your patches may have solved the original issue. However, it's unfortunate that FBC will continue to remain disabled for users of this platform, as fastboot defaults to on (and the fastboot associated boot flicker reduction is very welcome). Do you think this point is worth following up on?
Thanks,
Daniel
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.BUILD: failure for drm/i915/fbc: Fix FBC for glk+ (rev3)
In reply to Ville Syrjala== Series Details ==
== Series Details ==
Series: drm/i915/fbc: Fix FBC for glk+ (rev3)
URL : https://patchwork.freedesktop.org/series/70062/
State : failure
== Summary ==
Applying: drm/i915/fbc: Disable fbc by default on all glk+
Applying: drm/i915/fbc: Nuke bogus single pipe fbc1 restriction
Applying: drm/i915: Relocate intel_crtc_active()
Applying: drm/i915/fbc: Remove the FBC_RT_BASE setup for ILK/SNB
Applying: drm/i915/fbc: Precompute gen9 cfb stride w/a
Applying: drm/i915/fbc: Track plane visibility
Applying: drm/i915/fbc: Store fence_id direction in fbc cache/params
Applying: drm/i915/fbc: Make fence_id optional for i965gm
Applying: drm/i915/fbc: s/gen9 && !glk/gen9_bc || bxt/
Applying: drm/i915/fbc: Nuke fbc.enabled
error: sha1 information is lacking or useless (drivers/gpu/drm/i915/i915_drv.h).
error: could not build fake ancestor
hint: Use 'git am --show-current-patch' to see the failed patch Patch failed at 0010 drm/i915/fbc: Nuke fbc.enabled
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