Skip to contentSkip to conversation

drm/i915: Fixup the free space logic in ring_prepare

PATCH In review [email protected] 3 participants 3 messages Mar 11, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915: Fixup the free space logic in ring_prepare

From: Akash Goel <[email protected]>

Currently for the case where there is enough space at the end of Ring buffer for accommodating only the base request, the wrapround is done immediately and as a result the base request gets added at the start of Ring buffer. But there may not be enough free space at the beginning to accommodate the base request, as before the wraparound, the wait was effectively done for the reserved_size free space from the start of Ring buffer. In such a case there is a potential of Ring buffer overflow, the instructions at the head of Ring (ACTHD) can get overwritten.

Since the base request can fit in the remaining space, there is no need to wraparound immediately. The wraparound will anyway happen later when the reserved part starts getting used.

---
 drivers/gpu/drm/i915/intel_lrc.c        | 6 +++---
 drivers/gpu/drm/i915/intel_ringbuffer.c | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +3 -3
index f60d5eb..eae882b 100644
@@ -853,11 +853,11 @@ static int logical_ring_prepare(struct drm_i915_gem_request *req, int bytes)
 		if (unlikely(total_bytes > remain_usable)) {
 			/*
 			 * The base request will fit but the reserved space
-			 * falls off the end. So only need to to wait for the
-			 * reserved size after flushing out the remainder.
+			 * falls off the end. So don't need an immediate wrap
+			 * and only need to effectively wait for the reserved
+			 * size space from the start of ringbuffer.
 			 */
 			wait_bytes = remain_actual + ringbuf->reserved_size;
-			need_wrap = true;
 		} else if (total_bytes > ringbuf->space) {
 			/* No wrapping required, just waiting. */
 			wait_bytes = total_bytes;
drivers/gpu/drm/i915/intel_ringbuffer.c +3 -3
index 45ce45a..c2ea2cd 100644
@@ -2454,11 +2454,11 @@ static int __intel_ring_prepare(struct intel_engine_cs *ring, int bytes)
 		if (unlikely(total_bytes > remain_usable)) {
 			/*
 			 * The base request will fit but the reserved space
-			 * falls off the end. So only need to to wait for the
-			 * reserved size after flushing out the remainder.
+			 * falls off the end. So don't need an immediate wrap
+			 * and only need to effectively wait for the reserved
+			 * size space from the start of ringbuffer.
 			 */
 			wait_bytes = remain_actual + ringbuf->reserved_size;
-			need_wrap = true;
 		} else if (total_bytes > ringbuf->space) {
 			/* No wrapping required, just waiting. */
 			wait_bytes = total_bytes;
Signature · 6 lines
1.9.2

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw
Quoted 11 lines · On Fri, Mar 11, 2016 at 02:56:42PM +0530, [email protected] wrote:

From: Akash Goel <[email protected]>

Currently for the case where there is enough space at the end of Ring buffer for accommodating only the base request, the wrapround is done immediately and as a result the base request gets added at the start of Ring buffer. But there may not be enough free space at the beginning to accommodate the base request, as before the wraparound, the wait was effectively done for the reserved_size free space from the start of Ring buffer. In such a case there is a potential of Ring buffer overflow, the instructions at the head of Ring (ACTHD) can get overwritten.

Quoted 6 lines

Since the base request can fit in the remaining space, there is no need to wraparound immediately. The wraparound will anyway happen later when the reserved part starts getting used.

From an earlier review:

Quoted 10 lines

The benefit (other than that bug fix which could affect ilk in extreme circumstances, though I guess the timing is a little too short for igt/gem_ringfill to hit it - we can fill the ring with ease, but we would have to overwrite after wrap whilst the ACTHD was still in the zone in order for it to actualy fallover. Hmm, if we added a BUG for tail overflow that might have a chance of detecting the issue) should be that we squeeze in perhaps even another whole request before the ring is exhausted and so reserved-space is less wasteful on gen that do not need the full reservation.

Quoted 4 lines

In theory this could be impacting upon Ironlakes in the real-world, so a candidate for stable@

-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

✗ Fi.CI.BAT: failure for drm/i915: Fixup the free space logic in ring_prepare

In reply to [email protected]
== Series Details ==

== Series Details ==

Series: drm/i915: Fixup the free space logic in ring_prepare
URL : https://patchwork.freedesktop.org/series/4346/
State : failure

== Summary ==

Series 4346v1 drm/i915: Fixup the free space logic in ring_prepare
http://patchwork.freedesktop.org/api/1.0/series/4346/revisions/1/mbox/

Test kms_flip:

        Subgroup basic-flip-vs-modeset:
                dmesg-warn -> PASS       (bdw-ultra)
Test kms_pipe_crc_basic:
        Subgroup suspend-read-crc-pipe-b:
                incomplete -> PASS       (hsw-gt2)
Test pm_rpm:
        Subgroup basic-pci-d3-state:
                dmesg-warn -> PASS       (snb-dellxps)
                dmesg-warn -> PASS       (hsw-brixbox)
        Subgroup basic-rte:
                dmesg-warn -> PASS       (bsw-nuc-2)
bdw-nuci7        total:193  pass:181  dwarn:0   dfail:0   fail:0   skip:12 
bdw-ultra        total:193  pass:172  dwarn:0   dfail:0   fail:0   skip:21 
bsw-nuc-2        total:193  pass:156  dwarn:0   dfail:0   fail:0   skip:37 
byt-nuc          total:193  pass:158  dwarn:0   dfail:0   fail:0   skip:35 
hsw-brixbox      total:193  pass:171  dwarn:0   dfail:0   fail:0   skip:22 
hsw-gt2          total:193  pass:176  dwarn:0   dfail:0   fail:0   skip:17 
ilk-hp8440p      total:193  pass:130  dwarn:0   dfail:0   fail:0   skip:63 
ivb-t430s        total:193  pass:168  dwarn:0   dfail:0   fail:0   skip:25 
skl-i5k-2        total:193  pass:170  dwarn:0   dfail:0   fail:0   skip:23 
skl-i7k-2        total:193  pass:170  dwarn:0   dfail:0   fail:0   skip:23 
skl-nuci5        total:193  pass:182  dwarn:0   dfail:0   fail:0   skip:11 
snb-dellxps      total:193  pass:158  dwarn:1   dfail:0   fail:0   skip:34 

Results at /archive/results/CI_IGT_test/Patchwork_1569/

63461ba49f1bc63fe9dcccdbbaa3a5049c57ae37 drm-intel-nightly: 2016y-03m-10d-13h-21m-51s UTC integration manifest 20c3dc0c2392adf40c131feedb8711c9c739336d drm/i915: Fixup the free space logic in ring_prepare

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx