Skip to content

Commit f7a02ad

Browse files
committed
drm/i915: Only pin the fence for primary planes (and gen2/3)
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>
1 parent 85798ac commit f7a02ad

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

drivers/gpu/drm/i915/intel_display.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2067,9 +2067,18 @@ static unsigned int intel_surf_alignment(const struct drm_framebuffer *fb,
20672067
}
20682068
}
20692069

2070+
static bool intel_plane_uses_fence(const struct intel_plane_state *plane_state)
2071+
{
2072+
struct intel_plane *plane = to_intel_plane(plane_state->base.plane);
2073+
struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
2074+
2075+
return INTEL_GEN(dev_priv) < 4 || plane->id == PLANE_PRIMARY;
2076+
}
2077+
20702078
struct i915_vma *
20712079
intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
20722080
unsigned int rotation,
2081+
bool uses_fence,
20732082
unsigned long *out_flags)
20742083
{
20752084
struct drm_device *dev = fb->dev;
@@ -2122,7 +2131,7 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
21222131
if (IS_ERR(vma))
21232132
goto err;
21242133

2125-
if (i915_vma_is_map_and_fenceable(vma)) {
2134+
if (uses_fence && i915_vma_is_map_and_fenceable(vma)) {
21262135
int ret;
21272136

21282137
/* Install a fence for tiled scan-out. Pre-i965 always needs a
@@ -2836,6 +2845,7 @@ intel_find_initial_plane_obj(struct intel_crtc *intel_crtc,
28362845
intel_state->vma =
28372846
intel_pin_and_fence_fb_obj(fb,
28382847
primary->state->rotation,
2848+
intel_plane_uses_fence(intel_state),
28392849
&intel_state->flags);
28402850
mutex_unlock(&dev->struct_mutex);
28412851
if (IS_ERR(intel_state->vma)) {
@@ -12730,6 +12740,7 @@ intel_prepare_plane_fb(struct drm_plane *plane,
1273012740

1273112741
vma = intel_pin_and_fence_fb_obj(fb,
1273212742
new_state->rotation,
12743+
intel_plane_uses_fence(to_intel_plane_state(new_state)),
1273312744
&to_intel_plane_state(new_state)->flags);
1273412745
if (!IS_ERR(vma))
1273512746
to_intel_plane_state(new_state)->vma = vma;
@@ -13143,6 +13154,7 @@ intel_legacy_cursor_update(struct drm_plane *plane,
1314313154
} else {
1314413155
vma = intel_pin_and_fence_fb_obj(fb,
1314513156
new_plane_state->rotation,
13157+
false,
1314613158
&to_intel_plane_state(new_plane_state)->flags);
1314713159
if (IS_ERR(vma)) {
1314813160
DRM_DEBUG_KMS("failed to pin object\n");

drivers/gpu/drm/i915/intel_drv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,6 +1424,7 @@ void intel_release_load_detect_pipe(struct drm_connector *connector,
14241424
struct i915_vma *
14251425
intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
14261426
unsigned int rotation,
1427+
bool uses_fence,
14271428
unsigned long *out_flags);
14281429
void intel_unpin_fb_vma(struct i915_vma *vma, unsigned long flags);
14291430
struct drm_framebuffer *

drivers/gpu/drm/i915/intel_fbdev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
215215
*/
216216
vma = intel_pin_and_fence_fb_obj(&ifbdev->fb->base,
217217
DRM_MODE_ROTATE_0,
218-
&flags);
218+
false, &flags);
219219
if (IS_ERR(vma)) {
220220
ret = PTR_ERR(vma);
221221
goto out_unlock;

0 commit comments

Comments
 (0)