drm/i915: Only pin the fence for primary planes (and gen2/3)
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 21 Feb 2018 18:48:07 +0000 (20:48 +0200)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Thu, 22 Feb 2018 15:41:37 +0000 (17:41 +0200)
Currently we pin a fence on every plane doing tiled scanout. The
number of planes we have available is fast apporaching the number
of fences so we really should stop wasting them. Only FBC needs
the fence on gen4+, so let's use fences only for the primary planes
on those platforms.

v2: drop the tiling check from plane_uses_fence() as the obj is
    NULL during initial_plane_config() and we don't rally need the
    check since i915_vma_pin_fence() does the check anyway

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180221184807.577-1-ville.syrjala@linux.intel.com
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/i915/intel_drv.h
drivers/gpu/drm/i915/intel_fbdev.c

index c96032c0406f11842ec34a2b4ec7c6d92769660f..a991195e53541a3fe9ae4cf03aab5d879f652b25 100644 (file)
@@ -2067,9 +2067,18 @@ static unsigned int intel_surf_alignment(const struct drm_framebuffer *fb,
        }
 }
 
+static bool intel_plane_uses_fence(const struct intel_plane_state *plane_state)
+{
+       struct intel_plane *plane = to_intel_plane(plane_state->base.plane);
+       struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
+
+       return INTEL_GEN(dev_priv) < 4 || plane->id == PLANE_PRIMARY;
+}
+
 struct i915_vma *
 intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
                           unsigned int rotation,
+                          bool uses_fence,
                           unsigned long *out_flags)
 {
        struct drm_device *dev = fb->dev;
@@ -2122,7 +2131,7 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
        if (IS_ERR(vma))
                goto err;
 
-       if (i915_vma_is_map_and_fenceable(vma)) {
+       if (uses_fence && i915_vma_is_map_and_fenceable(vma)) {
                int ret;
 
                /* Install a fence for tiled scan-out. Pre-i965 always needs a
@@ -2836,6 +2845,7 @@ valid_fb:
        intel_state->vma =
                intel_pin_and_fence_fb_obj(fb,
                                           primary->state->rotation,
+                                          intel_plane_uses_fence(intel_state),
                                           &intel_state->flags);
        mutex_unlock(&dev->struct_mutex);
        if (IS_ERR(intel_state->vma)) {
@@ -12730,6 +12740,7 @@ intel_prepare_plane_fb(struct drm_plane *plane,
 
                vma = intel_pin_and_fence_fb_obj(fb,
                                                 new_state->rotation,
+                                                intel_plane_uses_fence(to_intel_plane_state(new_state)),
                                                 &to_intel_plane_state(new_state)->flags);
                if (!IS_ERR(vma))
                        to_intel_plane_state(new_state)->vma = vma;
@@ -13143,6 +13154,7 @@ intel_legacy_cursor_update(struct drm_plane *plane,
        } else {
                vma = intel_pin_and_fence_fb_obj(fb,
                                                 new_plane_state->rotation,
+                                                false,
                                                 &to_intel_plane_state(new_plane_state)->flags);
                if (IS_ERR(vma)) {
                        DRM_DEBUG_KMS("failed to pin object\n");
index 04fc4bd123295b8440ebfb6d718501fadc89b8e8..80881218bfc902c4505e3258fdf1ee76fd75626a 100644 (file)
@@ -1424,6 +1424,7 @@ void intel_release_load_detect_pipe(struct drm_connector *connector,
 struct i915_vma *
 intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
                           unsigned int rotation,
+                          bool uses_fence,
                           unsigned long *out_flags);
 void intel_unpin_fb_vma(struct i915_vma *vma, unsigned long flags);
 struct drm_framebuffer *
index 055f409f8b7587502a7e779bc40d4d53b11e85bc..6f12adc063650c1ad4f696922dee1215a98398c0 100644 (file)
@@ -215,7 +215,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
         */
        vma = intel_pin_and_fence_fb_obj(&ifbdev->fb->base,
                                         DRM_MODE_ROTATE_0,
-                                        &flags);
+                                        false, &flags);
        if (IS_ERR(vma)) {
                ret = PTR_ERR(vma);
                goto out_unlock;