diff options
| author | 2021-06-10 21:32:36 +0300 | |
|---|---|---|
| committer | 2021-06-24 21:49:54 +0300 | |
| commit | 8538d78e26ecaf2c9f0d43526207c643972c2cc1 (patch) | |
| tree | b3786634dddd6270c228f1701d43ef2dc40ea5f1 | |
| parent | drm/i915/fbc: Extract intel_fbc_stolen_end() (diff) | |
drm/i915/fbc: Make the cfb allocation loop a bit more legible
Write the cfb allocation loop as an actual loop instead of some
hard to read goto thing.
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210610183237.3920-9-ville.syrjala@linux.intel.com
Reviewed-by: José Roberto de Souza <jose.souza@intel.com>
| -rw-r--r-- | drivers/gpu/drm/i915/display/intel_fbc.c | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/drivers/gpu/drm/i915/display/intel_fbc.c b/drivers/gpu/drm/i915/display/intel_fbc.c index 6415f2cfd1ac..b6bfb4439a8b 100644 --- a/drivers/gpu/drm/i915/display/intel_fbc.c +++ b/drivers/gpu/drm/i915/display/intel_fbc.c @@ -440,44 +440,45 @@ static u64 intel_fbc_stolen_end(struct drm_i915_private *dev_priv) return min(end, intel_fbc_cfb_base_max(dev_priv)); } +static int intel_fbc_max_limit(struct drm_i915_private *dev_priv, int fb_cpp) +{ + /* + * FIXME: FBC1 can have arbitrary cfb stride, + * so we could support different compression ratios. + */ + if (DISPLAY_VER(dev_priv) < 5 && !IS_G4X(dev_priv)) + return 1; + + /* WaFbcOnly1to1Ratio:ctg */ + if (IS_G4X(dev_priv)) + return 1; + + /* FBC2 can only do 1:1, 1:2, 1:4 */ + return fb_cpp == 2 ? 2 : 4; +} + static int find_compression_limit(struct drm_i915_private *dev_priv, unsigned int size, unsigned int fb_cpp) { struct intel_fbc *fbc = &dev_priv->fbc; u64 end = intel_fbc_stolen_end(dev_priv); - int compression_limit = 1; - int ret; - - /* HACK: This code depends on what we will do in *_enable_fbc. If that - * code changes, this code needs to change as well. - * - * The enable_fbc code will attempt to use one of our 2 compression - * limits, therefore, in that case, we only have 1 resort. - */ + int ret, limit = 1; /* Try to over-allocate to reduce reallocations and fragmentation. */ ret = i915_gem_stolen_insert_node_in_range(dev_priv, &fbc->compressed_fb, size <<= 1, 4096, 0, end); if (ret == 0) - return compression_limit; - -again: - /* HW's ability to limit the CFB is 1:4 */ - if (compression_limit > 4 || - (fb_cpp == 2 && compression_limit == 2)) - return 0; + return limit; - ret = i915_gem_stolen_insert_node_in_range(dev_priv, &fbc->compressed_fb, - size >>= 1, 4096, 0, end); - if (ret && DISPLAY_VER(dev_priv) <= 4) { - return 0; - } else if (ret) { - compression_limit <<= 1; - goto again; - } else { - return compression_limit; + for (; limit <= intel_fbc_max_limit(dev_priv, fb_cpp); limit <<= 1) { + ret = i915_gem_stolen_insert_node_in_range(dev_priv, &fbc->compressed_fb, + size >>= 1, 4096, 0, end); + if (ret == 0) + return limit; } + + return 0; } static int intel_fbc_alloc_cfb(struct drm_i915_private *dev_priv, |
