drm/i915: Fix the frame buffer fence starvation
Subsystems (2)
PATCH 1/1 drm/i915: Fix the frame buffer fence starvation
Currently a tiled frame buffer to be scanned out is always installed with a fence, leading to fence starvation on gen9lp virtualization use case where graphics stacks of service and guest OSes compete for fences.
By design, this fence is always needed by i965-(GEN4-) platforms. For GEN4 and above, the fence is only required when the frame buffer compression is enabled.
Changes are made to follow graphics hardware design principles.
--- drivers/gpu/drm/i915/intel_display.c | 44 +++++++++++++++++++++++++++--------- drivers/gpu/drm/i915/intel_drv.h | 4 +++- drivers/gpu/drm/i915/intel_fbc.c | 2 +- drivers/gpu/drm/i915/intel_fbdev.c | 3 ++- 4 files changed, 39 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/intel_display.c +33 -11
@@ -2068,7 +2068,8 @@ static unsigned int intel_surf_alignment(const struct drm_framebuffer *fb, }struct i915_vma * -intel_pin_and_fence_fb_obj (struct drm_framebuffer *fb,unsigned int rotation) +intel_pin_and_fence_fb_obj (struct drm_framebuffer *fb,unsigned int rotation, +struct drm_plane *plane,enum pipe pipe) {struct drm_device *dev = fb->dev;struct drm_i915_private *dev_priv =to_i915 (dev);
@@ -2076,6 +2077,8 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb, unsigned int rotation)struct i915_ggtt_view view;struct i915_vma *vma;u32 alignment; +bool needs_fence = false; +struct intel_plane *intel_plane;WARN_ON (!mutex_is_locked (&dev->struct_mutex));
@@ -2105,13 +2108,19 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb, unsigned int rotation) vma =i915_gem_object_pin_to_display_plane (obj, alignment, &view);if (IS_ERR (vma)) goto err; +/* +* Install the fence for pre-i965(GEN4-) tiled frame buffers all the +* time but only do it for i965(GEN4) and beyond when the frame buffer +* compression is enabled during boot up or runtime. +*/ + intel_plane =to_intel_plane (plane); +if (INTEL_GEN (dev_priv) <4 || (intel_fbc_can_enable (dev_priv) && + (pipe ==PIPE_A ) && intel_plane && + (intel_plane->id ==PLANE_PRIMARY ))) + needs_fence = true;if (i915_vma_is_map_and_fenceable (vma)) { -/* Install a fence for tiled scan-out. Pre-i965 always needs a -* fence, whereas 965+ only requires a fence if using -* framebuffer compression. For simplicity, we always, when -* possible, install a fence as the cost is not that onerous. -* +/* * If we fail to fence the tiled scanout, then either the * modeset will reject the change (which is highly unlikely as * the affected systems, all but one, do not have unmappable
@@ -2123,7 +2132,16 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb, unsigned int rotation)* something and try to run the system in a "less than optimal" * mode that matches the user configuration. */ -i915_vma_pin_fence (vma); +if (needs_fence) +i915_vma_pin_fence (vma); +else if (vma->fence) +/* +* For a reused fence, increase its ref count even if +* it's not pinned to maintain the count consistancy. +* This is because the count is unconditionally +* decreased when the fence is unpinned. +*/ + vma->fence->pin_count++; }i915_vma_get (vma);
@@ -2808,7 +2826,8 @@ intel_find_initial_plane_obj(struct intel_crtc *intel_crtc, valid_fb:mutex_lock (&dev->struct_mutex); intel_state->vma = -intel_pin_and_fence_fb_obj (fb, primary->state->rotation); +intel_pin_and_fence_fb_obj (fb, primary->state->rotation, + primary, intel_crtc->pipe);mutex_unlock (&dev->struct_mutex);if (IS_ERR (intel_state->vma)) { DRM_ERROR("failed to pin boot fb on pipe %d: %li\n",
@@ -12711,8 +12730,9 @@ intel_prepare_plane_fb(struct drm_plane *plane, ret =i915_gem_object_attach_phys (obj, align); }else {struct i915_vma *vma; - - vma =intel_pin_and_fence_fb_obj (fb, new_state->rotation); +struct intel_crtc *temp_crtc =to_intel_crtc (new_state->crtc); + vma =intel_pin_and_fence_fb_obj (fb, new_state->rotation, + plane, temp_crtc->pipe);if (!IS_ERR (vma))to_intel_plane_state (new_state)->vma = vma;else
@@ -13128,7 +13148,9 @@ intel_legacy_cursor_update(struct drm_plane *plane, goto out_unlock; } }else { - vma =intel_pin_and_fence_fb_obj (fb, new_plane_state->rotation); +struct intel_crtc *temp_crtc =to_intel_crtc (crtc); + vma =intel_pin_and_fence_fb_obj (fb, new_plane_state->rotation, + plane, temp_crtc->pipe);if (IS_ERR (vma)) {DRM_DEBUG_KMS ("failed to pin object\n" );
drivers/gpu/drm/i915/intel_drv.h +3 -1
@@ -1503,7 +1503,8 @@ void intel_release_load_detect_pipe(struct drm_connector *connector,struct intel_load_detect_pipe *old, struct drm_modeset_acquire_ctx *ctx);struct i915_vma * -intel_pin_and_fence_fb_obj (struct drm_framebuffer *fb,unsigned int rotation); +intel_pin_and_fence_fb_obj (struct drm_framebuffer *fb,unsigned int rotation, +struct drm_plane *plane,enum pipe pipe);void intel_unpin_fb_vma (struct i915_vma *vma);struct drm_framebuffer * intel_framebuffer_create(struct drm_i915_gem_object *obj,
@@ -1759,6 +1760,7 @@ void intel_fbc_flush(struct drm_i915_private *dev_priv, unsigned int frontbuffer_bits, enum fb_op_origin origin);void intel_fbc_cleanup_cfb (struct drm_i915_private *dev_priv);void intel_fbc_handle_fifo_underrun_irq (struct drm_i915_private *dev_priv); +bool intel_fbc_can_enable (struct drm_i915_private *dev_priv);/* intel_hdmi.c */ void intel_hdmi_init(struct drm_i915_private *dev_priv, i915_reg_t hdmi_reg,
drivers/gpu/drm/i915/intel_fbc.c +1 -1
@@ -862,7 +862,7 @@ static bool intel_fbc_can_activate(struct intel_crtc *crtc)return true; } -static bool intel_fbc_can_enable (struct drm_i915_private *dev_priv) +bool intel_fbc_can_enable (struct drm_i915_private *dev_priv) {struct intel_fbc *fbc = &dev_priv->fbc;
drivers/gpu/drm/i915/intel_fbdev.c +2 -1
@@ -211,7 +211,8 @@ static int intelfb_create(struct drm_fb_helper *helper,* This also validates that any existing fb inherited from the * BIOS is suitable for own access. */ - vma =intel_pin_and_fence_fb_obj (&ifbdev->fb->base,DRM_MODE_ROTATE_0 ); + vma =intel_pin_and_fence_fb_obj (&ifbdev->fb->base,DRM_MODE_ROTATE_0 , +NULL ,INVALID_PIPE );if (IS_ERR (vma)) { ret =PTR_ERR (vma); goto out_unlock;
Signature · 6 lines
2.7.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.CHECKPATCH: warning for drm/i915: Fix the frame buffer fence starvation
== Series Details ==
== Series Details ==
Series: drm/i915: Fix the frame buffer fence starvation
URL : https://patchwork.freedesktop.org/series/38626/
State : warning
== Summary ==
$ dim checkpatch origin/drm-tip f9fb22a0f4c9 drm/i915: Fix the frame buffer fence starvation -:29: CHECK: Alignment should match open parenthesis #29: FILE: drivers/gpu/drm/i915/intel_display.c:2072: +intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb, unsigned int rotation, + struct drm_plane *plane, enum pipe pipe)
-:52: CHECK: Unnecessary parentheses around 'pipe == PIPE_A' #52: FILE: drivers/gpu/drm/i915/intel_display.c:2117:
+ if (INTEL_GEN(dev_priv) < 4 || (intel_fbc_can_enable(dev_priv) &&
+ (pipe == PIPE_A) && intel_plane &&
+ (intel_plane->id == PLANE_PRIMARY)))
-:52: CHECK: Unnecessary parentheses around 'intel_plane->id == PLANE_PRIMARY' #52: FILE: drivers/gpu/drm/i915/intel_display.c:2117:
+ if (INTEL_GEN(dev_priv) < 4 || (intel_fbc_can_enable(dev_priv) &&
+ (pipe == PIPE_A) && intel_plane &&
+ (intel_plane->id == PLANE_PRIMARY)))
-:53: CHECK: Alignment should match open parenthesis #53: FILE: drivers/gpu/drm/i915/intel_display.c:2118:
+ if (INTEL_GEN(dev_priv) < 4 || (intel_fbc_can_enable(dev_priv) &&
+ (pipe == PIPE_A) && intel_plane &&
-:77: WARNING: 'consistancy' may be misspelled - perhaps 'consistency'? #77: FILE: drivers/gpu/drm/i915/intel_display.c:2140:
+ * it's not pinned to maintain the count consistancy.
-:78: ERROR: trailing whitespace
#78: FILE: drivers/gpu/drm/i915/intel_display.c:2141:
+^I^I^I * This is because the count is unconditionally $
-:91: CHECK: Alignment should match open parenthesis #91: FILE: drivers/gpu/drm/i915/intel_display.c:2830:
+ intel_pin_and_fence_fb_obj(fb, primary->state->rotation,
+ primary, intel_crtc->pipe);
-:102: WARNING: Missing a blank line after declarations #102: FILE: drivers/gpu/drm/i915/intel_display.c:12736:
+ struct intel_crtc *temp_crtc = to_intel_crtc(new_state->crtc);
+ vma = intel_pin_and_fence_fb_obj(fb, new_state->rotation,
-:103: CHECK: Alignment should match open parenthesis #103: FILE: drivers/gpu/drm/i915/intel_display.c:12737:
+ vma = intel_pin_and_fence_fb_obj(fb, new_state->rotation,
+ plane, temp_crtc->pipe);
-:113: WARNING: Missing a blank line after declarations #113: FILE: drivers/gpu/drm/i915/intel_display.c:13154:
+ struct intel_crtc *temp_crtc = to_intel_crtc(crtc);
+ vma = intel_pin_and_fence_fb_obj(fb, new_plane_state->rotation,
-:114: CHECK: Alignment should match open parenthesis #114: FILE: drivers/gpu/drm/i915/intel_display.c:13155:
+ vma = intel_pin_and_fence_fb_obj(fb, new_plane_state->rotation,
+ plane, temp_crtc->pipe);
total: 1 errors, 3 warnings, 7 checks, 121 lines checked
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for drm/i915: Fix the frame buffer fence starvation
In reply to Guang Bai== Series Details ==
== Series Details ==
Series: drm/i915: Fix the frame buffer fence starvation
URL : https://patchwork.freedesktop.org/series/38626/
State : success
== Summary ==
Series 38626v1 drm/i915: Fix the frame buffer fence starvation
https://patchwork.freedesktop.org/api/1.0/series/38626/revisions/1/mbox/
Test kms_pipe_crc_basic:
Subgroup suspend-read-crc-pipe-a:
pass -> INCOMPLETE (fi-bdw-5557u) fdo#104944
Subgroup suspend-read-crc-pipe-b:
pass -> INCOMPLETE (fi-snb-2520m) fdo#103713fdo#104944 https://bugs.freedesktop.org/show_bug.cgi?id=104944
fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713
fi-bdw-5557u total:244 pass:226 dwarn:0 dfail:0 fail:0 skip:17 fi-bdw-gvtdvm total:288 pass:264 dwarn:0 dfail:0 fail:0 skip:24 time:424s fi-blb-e6850 total:288 pass:223 dwarn:1 dfail:0 fail:0 skip:64 time:371s fi-bsw-n3050 total:288 pass:242 dwarn:0 dfail:0 fail:0 skip:46 time:490s fi-bwr-2160 total:288 pass:183 dwarn:0 dfail:0 fail:0 skip:105 time:284s fi-bxt-dsi total:288 pass:258 dwarn:0 dfail:0 fail:0 skip:30 time:479s fi-bxt-j4205 total:288 pass:259 dwarn:0 dfail:0 fail:0 skip:29 time:476s fi-byt-j1900 total:288 pass:253 dwarn:0 dfail:0 fail:0 skip:35 time:463s fi-byt-n2820 total:288 pass:249 dwarn:0 dfail:0 fail:0 skip:39 time:452s fi-cfl-s2 total:288 pass:262 dwarn:0 dfail:0 fail:0 skip:26 time:553s fi-elk-e7500 total:288 pass:229 dwarn:0 dfail:0 fail:0 skip:59 time:413s fi-gdg-551 total:288 pass:179 dwarn:0 dfail:0 fail:1 skip:108 time:280s fi-glk-1 total:288 pass:260 dwarn:0 dfail:0 fail:0 skip:28 time:506s fi-hsw-4770 total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:386s fi-ilk-650 total:288 pass:228 dwarn:0 dfail:0 fail:0 skip:60 time:409s fi-ivb-3520m total:288 pass:259 dwarn:0 dfail:0 fail:0 skip:29 time:454s fi-ivb-3770 total:288 pass:255 dwarn:0 dfail:0 fail:0 skip:33 time:409s fi-kbl-7500u total:288 pass:263 dwarn:1 dfail:0 fail:0 skip:24 time:452s fi-kbl-7560u total:288 pass:269 dwarn:0 dfail:0 fail:0 skip:19 time:488s fi-kbl-7567u total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:444s fi-kbl-r total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:493s fi-pnv-d510 total:288 pass:222 dwarn:1 dfail:0 fail:0 skip:65 time:583s fi-skl-6260u total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:427s fi-skl-6600u total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:502s fi-skl-6700hq total:288 pass:262 dwarn:0 dfail:0 fail:0 skip:26 time:515s fi-skl-6700k2 total:288 pass:264 dwarn:0 dfail:0 fail:0 skip:24 time:485s fi-skl-6770hq total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:470s fi-skl-guc total:288 pass:260 dwarn:0 dfail:0 fail:0 skip:28 time:409s fi-skl-gvtdvm total:288 pass:265 dwarn:0 dfail:0 fail:0 skip:23 time:426s fi-snb-2520m total:245 pass:211 dwarn:0 dfail:0 fail:0 skip:33 fi-snb-2600 total:288 pass:248 dwarn:0 dfail:0 fail:0 skip:40 time:397s
924528430cb0e1468d5412decc269e09445391f5 drm-tip: 2018y-02m-20d-18h-55m-55s UTC integration manifest f9fb22a0f4c9 drm/i915: Fix the frame buffer fence starvation
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8088/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoting Guang Bai (2018-02-20 11:41:03)
Quoted 17 lines
Currently a tiled frame buffer to be scanned out is always installed with a fence, leading to fence starvation on gen9lp virtualization use case where graphics stacks of service and guest OSes compete for fences.
By design, this fence is always needed by i965-(GEN4-) platforms. For GEN4 and above, the fence is only required when the frame buffer compression is enabled.
Changes are made to follow graphics hardware design principles.
Signed-off-by Guang Bai <[email protected]>---
drivers/gpu/drm/i915/intel_display.c +0
-0@@ -2105,13 +2108,19 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb, unsigned int rotation) vma =i915_gem_object_pin_to_display_plane (obj, alignment, &view);if (IS_ERR (vma)) goto err;
drivers/gpu/drm/i915/intel_display.c intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb, unsigned int rotation) · line 2120
Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +10
-0+/* +* Install the fence for pre-i965(GEN4-) tiled frame buffers all the +* time but only do it for i965(GEN4) and beyond when the frame buffer +* compression is enabled during boot up or runtime. +*/ + intel_plane =to_intel_plane (plane); +if (INTEL_GEN (dev_priv) <4 || (intel_fbc_can_enable (dev_priv) && + (pipe ==PIPE_A ) && intel_plane && + (intel_plane->id ==PLANE_PRIMARY ))) + needs_fence = true;
It is a bit more complicated than this. If the same vma is shared between multiple pipes, then it needs the compound requirements of all. Push this decision out to the caller. (When policy is difficult, punt.)
Quoted 15 lines
drivers/gpu/drm/i915/intel_display.c +1
-6if (i915_vma_is_map_and_fenceable (vma)) { -/* Install a fence for tiled scan-out. Pre-i965 always needs a -* fence, whereas 965+ only requires a fence if using -* framebuffer compression. For simplicity, we always, when -* possible, install a fence as the cost is not that onerous. -* +/* * If we fail to fence the tiled scanout, then either the * modeset will reject the change (which is highly unlikely as * the affected systems, all but one, do not have unmappable @@ -2123,7 +2132,16 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb, unsigned int rotation)* something and try to run the system in a "less than optimal" * mode that matches the user configuration. */ -i915_vma_pin_fence (vma);
drivers/gpu/drm/i915/intel_display.c intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb, unsigned int rotation) · line 2144
Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +10
-0+if (needs_fence) +i915_vma_pin_fence (vma); +else if (vma->fence) +/* +* For a reused fence, increase its ref count even if +* it's not pinned to maintain the count consistancy. +* This is because the count is unconditionally +* decreased when the fence is unpinned. +*/ + vma->fence->pin_count++;
Fixed in tip.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.IGT: success for drm/i915: Fix the frame buffer fence starvation
In reply to Guang Bai== Series Details ==
== Series Details ==
Series: drm/i915: Fix the frame buffer fence starvation
URL : https://patchwork.freedesktop.org/series/38626/
State : success
== Summary ==
Test perf:
Subgroup enable-disable:
pass -> FAIL (shard-apl) fdo#103715
Test kms_cursor_legacy:
Subgroup flip-vs-cursor-legacy:
pass -> FAIL (shard-hsw) fdo#102670
Subgroup 2x-long-flip-vs-cursor-atomic:
fail -> PASS (shard-hsw) fdo#104873 +1
Test kms_frontbuffer_tracking:
Subgroup fbc-1p-primscrn-spr-indfb-draw-mmap-gtt:
pass -> INCOMPLETE (shard-apl) fdo#101623
Test kms_plane_multiple:
Subgroup atomic-pipe-c-tiling-y:
pass -> FAIL (shard-apl) fdo#103166fdo#103715 https://bugs.freedesktop.org/show_bug.cgi?id=103715
fdo#102670 https://bugs.freedesktop.org/show_bug.cgi?id=102670
fdo#104873 https://bugs.freedesktop.org/show_bug.cgi?id=104873
fdo#101623 https://bugs.freedesktop.org/show_bug.cgi?id=101623
fdo#103166 https://bugs.freedesktop.org/show_bug.cgi?id=103166
shard-apl total:3335 pass:1742 dwarn:1 dfail:0 fail:11 skip:1579 time:11596s shard-hsw total:3429 pass:1758 dwarn:1 dfail:0 fail:4 skip:1665 time:11699s shard-snb total:3429 pass:1350 dwarn:1 dfail:0 fail:2 skip:2076 time:6537s
Blacklisted hosts:
shard-kbl total:3379 pass:1886 dwarn:1 dfail:0 fail:9 skip:1481 time:9125s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8088/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx