FAILED: patch "[PATCH] drm/i915/migrate: Account for the reserved_space" failed to apply to 5.15-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
Possible dependencies:
31a2e6cbe8a4 ("drm/i915/migrate: Account for the reserved_space") 00e27ad85bc9 ("drm/i915/migrate: add acceleration support for DG2") 31d70749bfe1 ("drm/i915/migrate: fix length calculation") 08c7c122ad90 ("drm/i915/migrate: fix offset calculation") 8eb7fcce34d1 ("drm/i915/migrate: don't check the scratch page")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 31a2e6cbe8a4eb0d1650fff4b77872b744e14a62 Mon Sep 17 00:00:00 2001
From: Chris Wilson <[email protected]>
Date: Fri, 2 Dec 2022 12:28:42 +0000
Subject: [PATCH] drm/i915/migrate: Account for the reserved_space
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
drivers/gpu/drm/i915/gt/intel_migrate.c +12 -4
@@ -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 );