Skip to content

Commit d6c531a

Browse files
Chris WilsonAndi Shyti
authored andcommitted
drm/i915: Invalidate the TLBs on each GT
With multi-GT devices, the object may have been bound on each GT. Invalidate the TLBs across all GT before releasing the pages back to the system. Signed-off-by: Chris Wilson <[email protected]> Cc: Fei Yang <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]> Reviewed-by: Andi Shyti <[email protected]> Signed-off-by: Andi Shyti <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent a79d488 commit d6c531a

File tree

4 files changed

+24
-11
lines changed

4 files changed

+24
-11
lines changed

drivers/gpu/drm/i915/gem/i915_gem_object_types.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include "i915_selftest.h"
1818
#include "i915_vma_resource.h"
1919

20+
#include "gt/intel_gt_defines.h"
21+
2022
struct drm_i915_gem_object;
2123
struct intel_fronbuffer;
2224
struct intel_memory_region;
@@ -675,7 +677,7 @@ struct drm_i915_gem_object {
675677
*/
676678
bool dirty:1;
677679

678-
u32 tlb;
680+
u32 tlb[I915_MAX_GT];
679681
} mm;
680682

681683
struct {

drivers/gpu/drm/i915/gem/i915_gem_pages.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,16 @@ static void unmap_object(struct drm_i915_gem_object *obj, void *ptr)
193193
static void flush_tlb_invalidate(struct drm_i915_gem_object *obj)
194194
{
195195
struct drm_i915_private *i915 = to_i915(obj->base.dev);
196-
struct intel_gt *gt = to_gt(i915);
196+
struct intel_gt *gt;
197+
int id;
197198

198-
if (!obj->mm.tlb)
199-
return;
199+
for_each_gt(gt, i915, id) {
200+
if (!obj->mm.tlb[id])
201+
return;
200202

201-
intel_gt_invalidate_tlb_full(gt, obj->mm.tlb);
202-
obj->mm.tlb = 0;
203+
intel_gt_invalidate_tlb_full(gt, obj->mm.tlb[id]);
204+
obj->mm.tlb[id] = 0;
205+
}
203206
}
204207

205208
struct sg_table *

drivers/gpu/drm/i915/gt/intel_ppgtt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "gem/i915_gem_lmem.h"
99

1010
#include "i915_trace.h"
11+
#include "intel_gt.h"
1112
#include "intel_gtt.h"
1213
#include "gen6_ppgtt.h"
1314
#include "gen8_ppgtt.h"
@@ -210,8 +211,7 @@ void ppgtt_unbind_vma(struct i915_address_space *vm,
210211
return;
211212

212213
vm->clear_range(vm, vma_res->start, vma_res->vma_size);
213-
if (vma_res->tlb)
214-
vma_invalidate_tlb(vm, vma_res->tlb);
214+
vma_invalidate_tlb(vm, vma_res->tlb);
215215
}
216216

217217
static unsigned long pd_count(u64 size, int shift)

drivers/gpu/drm/i915/i915_vma.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,6 +1340,12 @@ I915_SELFTEST_EXPORT int i915_vma_get_pages(struct i915_vma *vma)
13401340

13411341
void vma_invalidate_tlb(struct i915_address_space *vm, u32 *tlb)
13421342
{
1343+
struct intel_gt *gt;
1344+
int id;
1345+
1346+
if (!tlb)
1347+
return;
1348+
13431349
/*
13441350
* Before we release the pages that were bound by this vma, we
13451351
* must invalidate all the TLBs that may still have a reference
@@ -1348,7 +1354,9 @@ void vma_invalidate_tlb(struct i915_address_space *vm, u32 *tlb)
13481354
* the most recent TLB invalidation seqno, and if we have not yet
13491355
* flushed the TLBs upon release, perform a full invalidation.
13501356
*/
1351-
WRITE_ONCE(*tlb, intel_gt_next_invalidate_tlb_full(vm->gt));
1357+
for_each_gt(gt, vm->i915, id)
1358+
WRITE_ONCE(tlb[id],
1359+
intel_gt_next_invalidate_tlb_full(vm->gt));
13521360
}
13531361

13541362
static void __vma_put_pages(struct i915_vma *vma, unsigned int count)
@@ -1993,7 +2001,7 @@ struct dma_fence *__i915_vma_evict(struct i915_vma *vma, bool async)
19932001

19942002
if (async)
19952003
unbind_fence = i915_vma_resource_unbind(vma_res,
1996-
&vma->obj->mm.tlb);
2004+
vma->obj->mm.tlb);
19972005
else
19982006
unbind_fence = i915_vma_resource_unbind(vma_res, NULL);
19992007

@@ -2010,7 +2018,7 @@ struct dma_fence *__i915_vma_evict(struct i915_vma *vma, bool async)
20102018
dma_fence_put(unbind_fence);
20112019
unbind_fence = NULL;
20122020
}
2013-
vma_invalidate_tlb(vma->vm, &vma->obj->mm.tlb);
2021+
vma_invalidate_tlb(vma->vm, vma->obj->mm.tlb);
20142022
}
20152023

20162024
/*

0 commit comments

Comments
 (0)