From: jsg Date: Mon, 9 Jan 2023 04:24:23 +0000 (+0000) Subject: drm/i915/migrate: Account for the reserved_space X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=cba7b6c0f68ecf1dd94576d955235b9818d6a080;p=openbsd drm/i915/migrate: Account for the reserved_space From Chris Wilson 6e6d577cd90b27a98ce9f06ed96bca7b59d210f0 in linux-6.1.y/6.1.4 31a2e6cbe8a4eb0d1650fff4b77872b744e14a62 in mainline linux --- diff --git a/sys/dev/pci/drm/i915/gt/intel_migrate.c b/sys/dev/pci/drm/i915/gt/intel_migrate.c index aaaf1906026..ee072c7d62e 100644 --- a/sys/dev/pci/drm/i915/gt/intel_migrate.c +++ b/sys/dev/pci/drm/i915/gt/intel_migrate.c @@ -341,6 +341,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, @@ -387,8 +397,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 */ @@ -421,8 +430,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);