]> Git Repo - linux.git/commitdiff
drm/i915/migrate: Account for the reserved_space
authorChris Wilson <[email protected]>
Fri, 2 Dec 2022 12:28:42 +0000 (12:28 +0000)
committerRodrigo Vivi <[email protected]>
Tue, 13 Dec 2022 18:22:26 +0000 (13:22 -0500)
If the ring is nearly full when calling into emit_pte(), we might
incorrectly trample the reserved_space when constructing the packet to
emit the PTEs. This then triggers the GEM_BUG_ON(rq->reserved_space >
ring->space) when later submitting the request, since the request itself
doesn't have enough space left in the ring to emit things like
workarounds, breadcrumbs etc.

v2: Fix the whitespace errors

Testcase: igt@i915_selftests@live_emit_pte_full_ring
Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/7535
Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/6889
Fixes: cf586021642d ("drm/i915/gt: Pipelined page migration")
Signed-off-by: Chris Wilson <[email protected]>
Signed-off-by: Matthew Auld <[email protected]>
Cc: Andrzej Hajda <[email protected]>
Cc: Andi Shyti <[email protected]>
Cc: Nirmoy Das <[email protected]>
Cc: <[email protected]> # v5.15+
Tested-by: Nirmoy Das <[email protected]>
Reviewed-by: Nirmoy Das <[email protected]>
Reviewed-by: Andrzej Hajda <[email protected]>
Reviewed-by: Andi Shyti <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
(cherry picked from commit 35168a6c4ed53db4f786858bac23b1474fd7d0dc)
Signed-off-by: Rodrigo Vivi <[email protected]>
drivers/gpu/drm/i915/gt/intel_migrate.c

index b405a04135ca2178692284b8f743d9d6cb0246bd..b783f6f740c8b980822aa6ac6aee40dbdac98177 100644 (file)
@@ -342,6 +342,16 @@ static int emit_no_arbitration(struct i915_request *rq)
        return 0;
 }
 
+static int max_pte_pkt_size(struct i915_request *rq, int pkt)
+{
+       struct intel_ring *ring = rq->ring;
+
+       pkt = min_t(int, pkt, (ring->space - rq->reserved_space) / sizeof(u32) + 5);
+       pkt = min_t(int, pkt, (ring->size - ring->emit) / sizeof(u32) + 5);
+
+       return pkt;
+}
+
 static int emit_pte(struct i915_request *rq,
                    struct sgt_dma *it,
                    enum i915_cache_level cache_level,
@@ -388,8 +398,7 @@ static int emit_pte(struct i915_request *rq,
                return PTR_ERR(cs);
 
        /* Pack as many PTE updates as possible into a single MI command */
-       pkt = min_t(int, dword_length, ring->space / sizeof(u32) + 5);
-       pkt = min_t(int, pkt, (ring->size - ring->emit) / sizeof(u32) + 5);
+       pkt = max_pte_pkt_size(rq, dword_length);
 
        hdr = cs;
        *cs++ = MI_STORE_DATA_IMM | REG_BIT(21); /* as qword elements */
@@ -422,8 +431,7 @@ static int emit_pte(struct i915_request *rq,
                                }
                        }
 
-                       pkt = min_t(int, dword_rem, ring->space / sizeof(u32) + 5);
-                       pkt = min_t(int, pkt, (ring->size - ring->emit) / sizeof(u32) + 5);
+                       pkt = max_pte_pkt_size(rq, dword_rem);
 
                        hdr = cs;
                        *cs++ = MI_STORE_DATA_IMM | REG_BIT(21);
This page took 0.060687 seconds and 4 git commands to generate.