Prereqs for TTM accelerated migration
Subsystems (2)
cover Prereqs for TTM accelerated migration
A couple of patches from Chris which implement pipelined migration and clears by atomically writing the PTEs in place before performing the actual blit.
Some ww utilities mainly for the accompanying selftests added by Thomas, as well as modified the above patches for ww locking- and lmem support.
The actual hook up to the i915 ttm backend is being worked on and not included yet, so this is considered to be an early review opportunity.
Chris Wilson (6):
drm/i915/gt: Add an insert_entry for gen8_ppgtt drm/i915/gt: Add a routine to iterate over the pagetables of a GTT drm/i915/gt: Export the pinned context constructor drm/i915/gt: Pipelined page migration
drm/i915/gt: Pipelined clear
drm/i915/gt: Setup a default migration context on the GT
Thomas Hellström (3):
drm/i915: Reference objects on the ww object list drm/i915: Break out dma_resv ww locking utilities to separate files drm/i915: Introduce a ww transaction helper
drivers/gpu/drm/i915/Makefile | 2 + drivers/gpu/drm/i915/gem/i915_gem_object.h | 9 +- drivers/gpu/drm/i915/gt/gen8_ppgtt.c | 68 ++ drivers/gpu/drm/i915/gt/intel_engine.h | 10 + drivers/gpu/drm/i915/gt/intel_engine_cs.c | 21 +- drivers/gpu/drm/i915/gt/intel_gpu_commands.h | 2 + drivers/gpu/drm/i915/gt/intel_gt.c | 4 + drivers/gpu/drm/i915/gt/intel_gt_types.h | 3 + drivers/gpu/drm/i915/gt/intel_gtt.h | 7 + drivers/gpu/drm/i915/gt/intel_migrate.c | 684 ++++++++++++++++++ drivers/gpu/drm/i915/gt/intel_migrate.h | 65 ++ drivers/gpu/drm/i915/gt/intel_migrate_types.h | 15 + drivers/gpu/drm/i915/gt/intel_renderstate.h | 1 + drivers/gpu/drm/i915/gt/intel_ring.h | 1 + drivers/gpu/drm/i915/gt/selftest_migrate.c | 671 +++++++++++++++++ drivers/gpu/drm/i915/i915_gem.c | 52 -- drivers/gpu/drm/i915/i915_gem.h | 12 - drivers/gpu/drm/i915/i915_gem_ww.c | 63 ++ drivers/gpu/drm/i915/i915_gem_ww.h | 50 ++ .../drm/i915/selftests/i915_live_selftests.h | 1 + .../drm/i915/selftests/i915_perf_selftests.h | 1 + 21 files changed, 1669 insertions(+), 73 deletions(-) create mode 100644 drivers/gpu/drm/i915/gt/intel_migrate.c create mode 100644 drivers/gpu/drm/i915/gt/intel_migrate.h create mode 100644 drivers/gpu/drm/i915/gt/intel_migrate_types.h create mode 100644 drivers/gpu/drm/i915/gt/selftest_migrate.c create mode 100644 drivers/gpu/drm/i915/i915_gem_ww.c create mode 100644 drivers/gpu/drm/i915/i915_gem_ww.h
Signature · 6 lines
2.31.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/9 drm/i915: Reference objects on the ww object list
Since the ww transaction endpoint easily end up far out-of-scope of the objects on the ww object list, particularly for contending lock objects, make sure we reference objects on the list so they don't disappear under us.
This comes with a performance penalty so it's been debated whether this is really needed. But I think this is motivated by the fact that locking is typically difficult to get right, and whatever we can do to make it simpler for developers moving forward should be done, unless the performance impact is far too high.
--- drivers/gpu/drm/i915/gem/i915_gem_object.h | 8 ++++++-- drivers/gpu/drm/i915/i915_gem.c | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_object.h +6 -2
@@ -169,13 +169,17 @@ static inline int __i915_gem_object_lock(struct drm_i915_gem_object *obj,else ret =dma_resv_lock (obj->base.resv, ww ? &ww->ctx :NULL ); -if (!ret && ww) +if (!ret && ww) { +i915_gem_object_get (obj);list_add_tail (&obj->obj_link, &ww->obj_list); + }if (ret == -EALREADY ) ret =0 ; -if (ret == -EDEADLK ) +if (ret == -EDEADLK ) { +i915_gem_object_get (obj); ww->contended = obj; + }return ret; }
drivers/gpu/drm/i915/i915_gem.c +4 -0
@@ -1219,6 +1219,7 @@ static void i915_gem_ww_ctx_unlock_all(struct i915_gem_ww_ctx *ww) while ((obj = list_first_entry_or_null(&ww->obj_list, struct drm_i915_gem_object, obj_link))) {list_del (&obj->obj_link);i915_gem_object_unlock (obj); +i915_gem_object_put (obj); } }
@@ -1226,6 +1227,7 @@ void i915_gem_ww_unlock_single(struct drm_i915_gem_object *obj) {list_del (&obj->obj_link);i915_gem_object_unlock (obj); +i915_gem_object_put (obj); }void i915_gem_ww_ctx_fini (struct i915_gem_ww_ctx *ww)
@@ -1250,6 +1252,8 @@ int __must_check i915_gem_ww_ctx_backoff(struct i915_gem_ww_ctx *ww)if (!ret)list_add_tail (&ww->contended->obj_link, &ww->obj_list); +else +i915_gem_object_put (ww->contended); ww->contended =NULL ;
Signature · 1 line
2.31.1
PATCH 2/9 drm/i915: Break out dma_resv ww locking utilities to separate files
In reply to Thomas HellströmAs we're about to add more ww-related functionality, break out the dma_resv ww locking utilities to their own files
--- drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/gem/i915_gem_object.h | 1 + drivers/gpu/drm/i915/gt/intel_renderstate.h | 1 + drivers/gpu/drm/i915/i915_gem.c | 56 ------------------ drivers/gpu/drm/i915/i915_gem.h | 12 ---- drivers/gpu/drm/i915/i915_gem_ww.c | 63 +++++++++++++++++++++ drivers/gpu/drm/i915/i915_gem_ww.h | 21 +++++++ 7 files changed, 87 insertions(+), 68 deletions(-) create mode 100644 drivers/gpu/drm/i915/i915_gem_ww.c create mode 100644 drivers/gpu/drm/i915/i915_gem_ww.h
drivers/gpu/drm/i915/Makefile +1 -0
@@ -45,6 +45,7 @@ i915-y += i915_drv.o \ i915_switcheroo.o \ i915_sysfs.o \ i915_utils.o \ + i915_gem_ww.o \ intel_device_info.o \ intel_dram.o \ intel_memory_region.o \
drivers/gpu/drm/i915/gem/i915_gem_object.h +1 -0
@@ -15,6 +15,7 @@#include "i915_gem_object_types.h" #include "i915_gem_gtt.h" #include "i915_vma_types.h" +#include "i915_gem_ww.h" /* * XXX: There is a prevalence of the assumption that we fit the
drivers/gpu/drm/i915/gt/intel_renderstate.h +1 -0
@@ -8,6 +8,7 @@#include <linux/types.h> #include "i915_gem.h" +#include "i915_gem_ww.h" struct i915_request ;struct intel_context ;
drivers/gpu/drm/i915/i915_gem.c +0 -56
62 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gem.h +0 -12
@@ -123,16 +123,4 @@ static inline bool __tasklet_is_scheduled(struct tasklet_struct *t) return test_bit(TASKLET_STATE_SCHED, &t->state); } -struct i915_gem_ww_ctx { -struct ww_acquire_ctx ctx; -struct list_head obj_list; -bool intr; -struct drm_i915_gem_object *contended; -}; - -void i915_gem_ww_ctx_init (struct i915_gem_ww_ctx *ctx,bool intr); -void i915_gem_ww_ctx_fini (struct i915_gem_ww_ctx *ctx); -int __must_check i915_gem_ww_ctx_backoff (struct i915_gem_ww_ctx *ctx); -void i915_gem_ww_unlock_single (struct drm_i915_gem_object *obj); -#endif /* __I915_GEM_H__ */
drivers/gpu/drm/i915/i915_gem_ww.c new file +63 -0
63 lines not on this page · raw message
drivers/gpu/drm/i915/i915_gem_ww.h new file +21 -0
@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2020 Intel Corporation +*/ +#ifndef __I915_GEM_WW_H__ +#define __I915_GEM_WW_H__ + +#include <drm/drm_drv.h> + +struct i915_gem_ww_ctx { +struct ww_acquire_ctx ctx; +struct list_head obj_list; +struct drm_i915_gem_object *contended; +bool intr; +}; + +void i915_gem_ww_ctx_init (struct i915_gem_ww_ctx *ctx,bool intr); +void i915_gem_ww_ctx_fini (struct i915_gem_ww_ctx *ctx); +int __must_check i915_gem_ww_ctx_backoff (struct i915_gem_ww_ctx *ctx); +void i915_gem_ww_unlock_single (struct drm_i915_gem_object *obj); +#endif
Signature · 1 line
2.31.1
PATCH 3/9 drm/i915: Introduce a ww transaction helper
In reply to Thomas HellströmIntroduce a for_i915_gem_ww(){} utility to help make the code around a ww transaction more readable.
--- drivers/gpu/drm/i915/i915_gem_ww.h | 31 +++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem_ww.h +30 -1
@@ -11,11 +11,40 @@ struct i915_gem_ww_ctx {struct ww_acquire_ctx ctx;struct list_head obj_list;struct drm_i915_gem_object *contended; - bool intr; +unsigned short intr; +unsigned short loop; };void i915_gem_ww_ctx_init (struct i915_gem_ww_ctx *ctx,bool intr);void i915_gem_ww_ctx_fini (struct i915_gem_ww_ctx *ctx);int __must_check i915_gem_ww_ctx_backoff (struct i915_gem_ww_ctx *ctx);void i915_gem_ww_unlock_single (struct drm_i915_gem_object *obj); + +/* Internal functions used by the inlines! Don't use. */ +static inline int __i915_gem_ww_fini (struct i915_gem_ww_ctx *ww,int err) +{ + ww->loop =0 ; +if (err == -EDEADLK ) { + err =i915_gem_ww_ctx_backoff (ww); +if (!err) + ww->loop =1 ; + } + +if (!ww->loop) +i915_gem_ww_ctx_fini (ww); + +return err; +} + +static inline void +__i915_gem_ww_init (struct i915_gem_ww_ctx *ww,bool intr) +{ +i915_gem_ww_ctx_init (ww, intr); + ww->loop =1 ; +} + +#define for_i915_gem_ww (_ww, _err, _intr) \ + for (__i915_gem_ww_init(_ww, _intr); (_ww)->loop; \ + _err = __i915_gem_ww_fini(_ww, _err)) +#endif
Signature · 1 line
2.31.1
PATCH 4/9 drm/i915/gt: Add an insert_entry for gen8_ppgtt
In reply to Thomas HellströmFrom: Chris Wilson <[email protected]>
In the next patch, we will want to write a PTE for an explicit dma address, outside of the usual vma.
--- drivers/gpu/drm/i915/gt/gen8_ppgtt.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/gpu/drm/i915/gt/gen8_ppgtt.c +19 -0
@@ -555,6 +555,24 @@ static void gen8_ppgtt_insert(struct i915_address_space *vm, } } +static void gen8_ppgtt_insert_entry (struct i915_address_space *vm, +dma_addr_t addr, +u64 offset, +enum i915_cache_level level, +u32 flags) +{ +u64 idx = offset >>GEN8_PTE_SHIFT ; +struct i915_page_directory *const pdp = +gen8_pdp_for_page_index (vm, idx); +struct i915_page_directory *pd = +i915_pd_entry (pdp,gen8_pd_index (idx,2 )); +gen8_pte_t *vaddr; + + vaddr =px_vaddr (i915_pt_entry (pd,gen8_pd_index (idx,1 ))); + vaddr[gen8_pd_index (idx,0 )] =gen8_pte_encode (addr, level, flags); +clflush_cache_range (&vaddr[gen8_pd_index (idx,0 )],sizeof (*vaddr)); +} +static int gen8_init_scratch (struct i915_address_space *vm) {u32 pte_flags;
@@ -734,6 +752,7 @@ struct i915_ppgtt *gen8_ppgtt_create(struct intel_gt *gt) ppgtt->vm.bind_async_flags =I915_VMA_LOCAL_BIND ; ppgtt->vm.insert_entries = gen8_ppgtt_insert; + ppgtt->vm.insert_page = gen8_ppgtt_insert_entry; ppgtt->vm.allocate_va_range = gen8_ppgtt_alloc; ppgtt->vm.clear_range = gen8_ppgtt_clear;
Signature · 6 lines
2.31.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 5/9 drm/i915/gt: Add a routine to iterate over the pagetables of a GTT
In reply to Thomas HellströmFrom: Chris Wilson <[email protected]>
In the next patch, we will want to look at the dma addresses of individual page tables, so add a routine to iterate over them.
--- drivers/gpu/drm/i915/gt/gen8_ppgtt.c | 49 ++++++++++++++++++++++++++++ drivers/gpu/drm/i915/gt/intel_gtt.h | 7 ++++ 2 files changed, 56 insertions(+)
drivers/gpu/drm/i915/gt/gen8_ppgtt.c +49 -0
@@ -361,6 +361,54 @@ static void gen8_ppgtt_alloc(struct i915_address_space *vm, &start, start + length, vm->top); } +static void __gen8_ppgtt_foreach (struct i915_address_space *vm, +struct i915_page_directory *pd, +u64 *start,u64 end,int lvl, +void (*fn)(struct i915_address_space *vm, +struct i915_page_table *pt, +void *data), +void *data) +{ +unsigned int idx, len; + + len =gen8_pd_range (*start, end, lvl--, &idx); + +spin_lock (&pd->lock); +do { +struct i915_page_table *pt = pd->entry[idx]; + +atomic_inc (&pt->used); +spin_unlock (&pd->lock); + +if (lvl) { +__gen8_ppgtt_foreach (vm,as_pd (pt), start, end, lvl, + fn, data); + }else { +fn (vm, pt, data); + *start +=gen8_pt_count (*start, end); + } + +spin_lock (&pd->lock); +atomic_dec (&pt->used); + }while (idx++, --len); +spin_unlock (&pd->lock); +} + +static void gen8_ppgtt_foreach (struct i915_address_space *vm, +u64 start,u64 length, +void (*fn)(struct i915_address_space *vm, +struct i915_page_table *pt, +void *data), +void *data) +{ + start >>=GEN8_PTE_SHIFT ; + length >>=GEN8_PTE_SHIFT ; + +__gen8_ppgtt_foreach (vm,i915_vm_to_ppgtt (vm)->pd, + &start, start + length, vm->top, + fn, data); +} + static __always_inline u64 gen8_ppgtt_insert_pte(struct i915_ppgtt *ppgtt, struct i915_page_directory *pdp,
@@ -755,6 +803,7 @@ struct i915_ppgtt *gen8_ppgtt_create(struct intel_gt *gt) ppgtt->vm.insert_page = gen8_ppgtt_insert_entry; ppgtt->vm.allocate_va_range = gen8_ppgtt_alloc; ppgtt->vm.clear_range = gen8_ppgtt_clear; + ppgtt->vm.foreach = gen8_ppgtt_foreach; ppgtt->vm.pte_encode = gen8_pte_encode;
drivers/gpu/drm/i915/gt/intel_gtt.h +7 -0
@@ -296,6 +296,13 @@ struct i915_address_space { u32 flags);void (*cleanup)(struct i915_address_space *vm); +void (*foreach)(struct i915_address_space *vm, +u64 start,u64 length, +void (*fn)(struct i915_address_space *vm, +struct i915_page_table *pt, +void *data), +void *data); +struct i915_vma_ops vma_ops; I915_SELFTEST_DECLARE(struct fault_attr fault_attr);
Signature · 1 line
2.31.1
PATCH 6/9 drm/i915/gt: Export the pinned context constructor
In reply to Thomas HellströmFrom: Chris Wilson <[email protected]>
Allow internal clients to create a pinned context.
--- drivers/gpu/drm/i915/gt/intel_engine.h | 9 +++++++++ drivers/gpu/drm/i915/gt/intel_engine_cs.c | 21 ++++++++++++++------- 2 files changed, 23 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/gt/intel_engine.h +9 -0
@@ -19,7 +19,9 @@#include "intel_workarounds.h" struct drm_printer ; +struct intel_context ;struct intel_gt ; +struct lock_class_key ;/* Early gen2 devices have a cacheline of just 32 bytes, using 64 is overkill, * but keeps the logic simple. Indeed, the whole purpose of this macro is just
@@ -256,6 +258,13 @@ struct i915_request * intel_engine_find_active_request(struct intel_engine_cs *engine);u32 intel_engine_context_size (struct intel_gt *gt,u8 class); +struct intel_context * +intel_engine_create_pinned_context (struct intel_engine_cs *engine, +struct i915_address_space *vm, +unsigned int ring_size, +unsigned int hwsp, +struct lock_class_key *key, +const char *name);void intel_engine_init_active (struct intel_engine_cs *engine,unsigned int subclass);
drivers/gpu/drm/i915/gt/intel_engine_cs.c +14 -7
@@ -810,11 +810,13 @@ intel_engine_init_active(struct intel_engine_cs *engine, unsigned int subclass)#endif } -static struct intel_context * -create_pinned_context (struct intel_engine_cs *engine, -unsigned int hwsp, -struct lock_class_key *key, -const char *name) +struct intel_context * +intel_engine_create_pinned_context (struct intel_engine_cs *engine, +struct i915_address_space *vm, +unsigned int ring_size, +unsigned int hwsp, +struct lock_class_key *key, +const char *name) {struct intel_context *ce;int err;
@@ -825,6 +827,10 @@ create_pinned_context(struct intel_engine_cs *engine,__set_bit (CONTEXT_BARRIER_BIT , &ce->flags); ce->timeline =page_pack_bits (NULL , hwsp); + ce->ring =__intel_context_ring_size (ring_size); + +i915_vm_put (ce->vm); + ce->vm =i915_vm_get (vm); err =intel_context_pin (ce);/* perma-pin so it is always available */ if (err) {
@@ -863,8 +869,9 @@ create_kernel_context(struct intel_engine_cs *engine) {static struct lock_class_key kernel; -return create_pinned_context (engine,I915_GEM_HWS_SEQNO_ADDR , - &kernel,"kernel_context" ); +return intel_engine_create_pinned_context (engine, engine->gt->vm,SZ_4K , +I915_GEM_HWS_SEQNO_ADDR , + &kernel,"kernel_context" ); }/**
Signature · 1 line
2.31.1
PATCH 7/9 drm/i915/gt: Pipelined page migration
In reply to Thomas HellströmFrom: Chris Wilson <[email protected]>
If we pipeline the PTE updates and then do the copy of those pages within a single unpreemptible command packet, we can submit the copies and leave them to be scheduled without having to synchronously wait under a global lock. In order to manage migration, we need to preallocate the page tables (and keep them pinned and available for use at any time), causing a bottleneck for migrations as all clients must contend on the limited resources. By inlining the ppGTT updates and performing the blit atomically, each client only owns the PTE while in use, and so we can reschedule individual operations however we see fit. And most importantly, we do not need to take a global lock on the shared vm, and wait until the operation is complete before releasing the lock for others to claim the PTE for themselves.
--- drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/gt/intel_engine.h | 1 + drivers/gpu/drm/i915/gt/intel_gpu_commands.h | 2 + drivers/gpu/drm/i915/gt/intel_migrate.c | 543 ++++++++++++++++++ drivers/gpu/drm/i915/gt/intel_migrate.h | 45 ++ drivers/gpu/drm/i915/gt/intel_migrate_types.h | 15 + drivers/gpu/drm/i915/gt/intel_ring.h | 1 + drivers/gpu/drm/i915/gt/selftest_migrate.c | 291 ++++++++++ .../drm/i915/selftests/i915_live_selftests.h | 1 + 9 files changed, 900 insertions(+) create mode 100644 drivers/gpu/drm/i915/gt/intel_migrate.c create mode 100644 drivers/gpu/drm/i915/gt/intel_migrate.h create mode 100644 drivers/gpu/drm/i915/gt/intel_migrate_types.h create mode 100644 drivers/gpu/drm/i915/gt/selftest_migrate.c
drivers/gpu/drm/i915/Makefile +1 -0
@@ -109,6 +109,7 @@ gt-y += \ gt/intel_gtt.o \ gt/intel_llc.o \ gt/intel_lrc.o \ + gt/intel_migrate.o \ gt/intel_mocs.o \ gt/intel_ppgtt.o \ gt/intel_rc6.o \
drivers/gpu/drm/i915/gt/intel_engine.h +1 -0
@@ -188,6 +188,7 @@ intel_write_status_page(struct intel_engine_cs *engine, int reg, u32 value)#define I915_GEM_HWS_PREEMPT_ADDR (I915_GEM_HWS_PREEMPT * sizeof(u32))#define I915_GEM_HWS_SEQNO 0x40#define I915_GEM_HWS_SEQNO_ADDR (I915_GEM_HWS_SEQNO * sizeof(u32)) +#define I915_GEM_HWS_MIGRATE (0x42 * sizeof(u32))#define I915_GEM_HWS_SCRATCH 0x80#define I915_HWS_CSB_BUF0_INDEX 0x10
drivers/gpu/drm/i915/gt/intel_gpu_commands.h +2 -0
@@ -123,8 +123,10 @@#define MI_SEMAPHORE_SAD_NEQ_SDD (5 << 12)#define MI_SEMAPHORE_TOKEN_MASK REG_GENMASK(9, 5)#define MI_SEMAPHORE_TOKEN_SHIFT 5 +#define MI_STORE_DATA_IMM MI_INSTR(0x20, 0)#define MI_STORE_DWORD_IMM MI_INSTR(0x20, 1)#define MI_STORE_DWORD_IMM_GEN4 MI_INSTR(0x20, 2) +#define MI_STORE_QWORD_IMM_GEN8 (MI_INSTR(0x20, 3) | REG_BIT(21))#define MI_MEM_VIRTUAL (1 << 22)/* 945,g33,965 */ #define MI_USE_GGTT (1 << 22)/* g4x+ */ #define MI_STORE_DWORD_INDEX MI_INSTR(0x21, 1)
drivers/gpu/drm/i915/gt/intel_migrate.c new file +543 -0
543 lines not on this page · raw message
drivers/gpu/drm/i915/gt/intel_migrate.h new file +45 -0
45 lines not on this page · raw message
drivers/gpu/drm/i915/gt/intel_migrate_types.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2020 Intel Corporation +*/ + +#ifndef __INTEL_MIGRATE_TYPES__ +#define __INTEL_MIGRATE_TYPES__ + +struct intel_context ; + +struct intel_migrate { +struct intel_context *context; +}; + +#endif /* __INTEL_MIGRATE_TYPES__ */
drivers/gpu/drm/i915/gt/intel_ring.h +1 -0
@@ -49,6 +49,7 @@ static inline void intel_ring_advance(struct i915_request *rq, u32 *cs)* intel_ring_begin()). */ GEM_BUG_ON ((rq->ring->vaddr + rq->ring->emit) != cs); +GEM_BUG_ON (!IS_ALIGNED (rq->ring->emit,8 ));/* RING_TAIL qword align */ }static inline u32 intel_ring_wrap (const struct intel_ring *ring,u32 pos)
drivers/gpu/drm/i915/gt/selftest_migrate.c new file +291 -0
291 lines not on this page · raw message
drivers/gpu/drm/i915/selftests/i915_live_selftests.h +1 -0
@@ -26,6 +26,7 @@ selftest(gt_mocs, intel_mocs_live_selftests) selftest(gt_pm, intel_gt_pm_live_selftests) selftest(gt_heartbeat, intel_heartbeat_live_selftests) selftest(requests, i915_request_live_selftests) +selftest(migrate, intel_migrate_live_selftests) selftest(active, i915_active_live_selftests) selftest(objects, i915_gem_object_live_selftests)selftest (mman, i915_gem_mman_live_selftests)
Signature · 1 line
2.31.1
PATCH 8/9 drm/i915/gt: Pipelined clear
In reply to Thomas HellströmFrom: Chris Wilson <[email protected]>
Update the PTE and emit a clear within a single unpreemptible packet such that we can schedule and pipeline clears.
--- drivers/gpu/drm/i915/gt/intel_migrate.c | 141 ++++++++++++++++++ drivers/gpu/drm/i915/gt/intel_migrate.h | 20 +++ drivers/gpu/drm/i915/gt/selftest_migrate.c | 163 +++++++++++++++++++++ 3 files changed, 324 insertions(+)
drivers/gpu/drm/i915/gt/intel_migrate.c +141 -0
@@ -488,6 +488,112 @@ intel_context_migrate_copy(struct intel_context *ce,return err; } +static int emit_clear (struct i915_request *rq,int size,u32 value) +{ +const int gen =INTEL_GEN (rq->engine->i915); +u32 *cs; + +GEM_BUG_ON (size >>PAGE_SHIFT >S16_MAX ); + + cs =intel_ring_begin (rq, gen >=8 ?8 :6 ); +if (IS_ERR (cs)) +return PTR_ERR (cs); + +if (gen >=8 ) { + *cs++ =XY_COLOR_BLT_CMD |BLT_WRITE_RGBA | (7 -2 ); + *cs++ =BLT_DEPTH_32 |BLT_ROP_COLOR_COPY |PAGE_SIZE ; + *cs++ =0 ; + *cs++ = size >>PAGE_SHIFT <<16 |PAGE_SIZE /4 ; + *cs++ =0 ;/* offset */ + *cs++ =0 ; + *cs++ = value; + *cs++ =MI_NOOP ; + }else { + *cs++ =XY_COLOR_BLT_CMD |BLT_WRITE_RGBA | (6 -2 ); + *cs++ =BLT_DEPTH_32 |BLT_ROP_COLOR_COPY |PAGE_SIZE ; + *cs++ =0 ; + *cs++ = size >>PAGE_SHIFT <<16 |PAGE_SIZE /4 ; + *cs++ =0 ; + *cs++ = value; + } + +intel_ring_advance (rq, cs); +return 0 ; +} + +int +intel_context_migrate_clear (struct intel_context *ce, +struct dma_fence *await, +struct scatterlist *sg, +enum i915_cache_level cache_level, +bool is_lmem, +u32 value, +struct i915_request **out) +{ +struct sgt_dma it =sg_sgt (sg); +struct i915_request *rq; +int err; + + *out =NULL ; + +GEM_BUG_ON (ce->ring->size <SZ_64K ); + +do { +int len; + + rq =i915_request_create (ce); +if (IS_ERR (rq)) { + err =PTR_ERR (rq); + goto out_ce; + } + +if (await) { + err =i915_request_await_dma_fence (rq, await); +if (err) + goto out_rq; + +if (rq->engine->emit_init_breadcrumb) { + err = rq->engine->emit_init_breadcrumb (rq); +if (err) + goto out_rq; + } + + await =NULL ; + } + +/* The PTE updates + clear must not be interrupted. */ + err =emit_no_arbitration (rq); +if (err) + goto out_rq; + + len =emit_pte (rq, &it, cache_level, is_lmem,0 ,CHUNK_SZ ); +if (len <=0 ) { + err = len; + goto out_rq; + } + + err = rq->engine->emit_flush (rq,EMIT_INVALIDATE ); +if (err) + goto out_rq; + + err =emit_clear (rq, len, value); + +/* Arbitration is re-enabled between requests. */ +out_rq: +if (*out) +i915_request_put (*out); + *out =i915_request_get (rq); +i915_request_add (rq); +if (err || !it.sg || !sg_dma_len (it.sg)) +break ; + +cond_resched (); + }while (1 ); + +out_ce: +return err; +} + int intel_migrate_copy(struct intel_migrate *m, struct i915_gem_ww_ctx *ww, struct dma_fence *await,
@@ -526,6 +632,41 @@ int intel_migrate_copy(struct intel_migrate *m,return err; } +int +intel_migrate_clear (struct intel_migrate *m, +struct i915_gem_ww_ctx *ww, +struct dma_fence *await, +struct scatterlist *sg, +enum i915_cache_level cache_level, +bool is_lmem, +u32 value, +struct i915_request **out) +{ +struct intel_context *ce; +int err; + + *out =NULL ; +if (!m->context) +return -ENODEV ; + + ce =intel_migrate_create_context (m); +if (IS_ERR (ce)) + ce =intel_context_get (m->context); +GEM_BUG_ON (IS_ERR (ce)); + + err =intel_context_pin_ww (ce, ww); +if (err) + goto out; + + err =intel_context_migrate_clear (ce, await, sg, cache_level, + is_lmem, value, out); + +intel_context_unpin (ce); +out: +intel_context_put (ce); +return err; +} +void intel_migrate_fini (struct intel_migrate *m) {struct intel_context *ce;
drivers/gpu/drm/i915/gt/intel_migrate.h +20 -0
@@ -6,6 +6,8 @@#ifndef __INTEL_MIGRATE__#define __INTEL_MIGRATE__ +#include <linux/types.h> +#include "intel_migrate_types.h" struct dma_fence ;
@@ -40,6 +42,24 @@ int intel_context_migrate_copy(struct intel_context *ce,bool dst_is_lmem, struct i915_request **out); +int +intel_migrate_clear (struct intel_migrate *m, +struct i915_gem_ww_ctx *ww, +struct dma_fence *await, +struct scatterlist *sg, +enum i915_cache_level cache_level, +bool is_lmem, +u32 value, +struct i915_request **out); +int +intel_context_migrate_clear (struct intel_context *ce, +struct dma_fence *await, +struct scatterlist *sg, +enum i915_cache_level cache_level, +bool is_lmem, +u32 value, +struct i915_request **out); +void intel_migrate_fini (struct intel_migrate *m);#endif /* __INTEL_MIGRATE__ */
drivers/gpu/drm/i915/gt/selftest_migrate.c +163 -0
193 lines not on this page · raw message
Signature · 6 lines
2.31.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 9/9 drm/i915/gt: Setup a default migration context on the GT
In reply to Thomas HellströmFrom: Chris Wilson <[email protected]>
Set up a default migration context on the GT and use it from the selftests.
Add a perf selftest and make sure we exercise LMEM if available.
--- drivers/gpu/drm/i915/gt/intel_gt.c | 4 + drivers/gpu/drm/i915/gt/intel_gt_types.h | 3 + drivers/gpu/drm/i915/gt/intel_migrate.c | 4 +- drivers/gpu/drm/i915/gt/selftest_migrate.c | 227 +++++++++++++++++- .../drm/i915/selftests/i915_perf_selftests.h | 1 + 5 files changed, 232 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/gt/intel_gt.c +4 -0
@@ -13,6 +13,7 @@#include "intel_gt_clock_utils.h" #include "intel_gt_pm.h" #include "intel_gt_requests.h" +#include "intel_migrate.h" #include "intel_mocs.h" #include "intel_rc6.h" #include "intel_renderstate.h"
@@ -626,6 +627,8 @@ int intel_gt_init(struct intel_gt *gt)if (err) goto err_gt; +intel_migrate_init (>->migrate, gt); + goto out_fw; err_gt:__intel_gt_disable (gt);
@@ -649,6 +652,7 @@ void intel_gt_driver_remove(struct intel_gt *gt) {__intel_gt_disable (gt); +intel_migrate_fini (>->migrate);intel_uc_driver_remove (>->uc);intel_engines_release (gt);
drivers/gpu/drm/i915/gt/intel_gt_types.h +3 -0
@@ -24,6 +24,7 @@#include "intel_reset_types.h" #include "intel_rc6_types.h" #include "intel_rps_types.h" +#include "intel_migrate_types.h" #include "intel_wakeref.h" struct drm_i915_private ;
@@ -145,6 +146,8 @@ struct intel_gt {struct i915_vma *scratch; +struct intel_migrate migrate; +struct intel_gt_info {intel_engine_mask_t engine_mask;u8 num_engines;
drivers/gpu/drm/i915/gt/intel_migrate.c +2 -2
@@ -416,10 +416,9 @@ intel_context_migrate_copy(struct intel_context *ce,struct i915_request *rq;int err; +GEM_BUG_ON (ce->vm != ce->engine->gt->migrate.context->vm); *out =NULL ; -/* GEM_BUG_ON(ce->vm != migrate_vm); */ -GEM_BUG_ON (ce->ring->size <SZ_64K ); do {
@@ -534,6 +533,7 @@ intel_context_migrate_clear(struct intel_context *ce,struct i915_request *rq;int err; +GEM_BUG_ON (ce->vm != ce->engine->gt->migrate.context->vm); *out =NULL ;GEM_BUG_ON (ce->ring->size <SZ_64K );
drivers/gpu/drm/i915/gt/selftest_migrate.c +222 -5
242 lines not on this page · raw message
drivers/gpu/drm/i915/selftests/i915_perf_selftests.h +1 -0
@@ -17,5 +17,6 @@*/ selftest(engine_cs, intel_engine_cs_perf_selftests) selftest(request, i915_request_perf_selftests) +selftest(migrate, intel_migrate_perf_selftests) selftest(blt, i915_gem_object_blt_perf_selftests)selftest (region, intel_memory_region_perf_selftests)
Signature · 6 lines
2.31.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI[Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for Prereqs for TTM accelerated migration
In reply to Thomas Hellström== Series Details ==
== Series Details ==
Series: Prereqs for TTM accelerated migration
URL : https://patchwork.freedesktop.org/series/91155/
State : warning
== Summary ==
$ dim checkpatch origin/drm-tip 2242ed7d4819 drm/i915: Reference objects on the ww object list 80e16d0ed0bd drm/i915: Break out dma_resv ww locking utilities to separate files -:140: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #140: new file mode 100644
-:165: WARNING:LONG_LINE: line length of 103 exceeds 100 columns #165: FILE: drivers/gpu/drm/i915/i915_gem_ww.c:21:
+ while ((obj = list_first_entry_or_null(&ww->obj_list, struct drm_i915_gem_object, obj_link))) {
total: 0 errors, 2 warnings, 0 checks, 183 lines checked 593821a10769 drm/i915: Introduce a ww transaction helper
-:55: CHECK:MACRO_ARG_REUSE: Macro argument reuse '_ww' - possible side-effects? #55: FILE: drivers/gpu/drm/i915/i915_gem_ww.h:46:
+#define for_i915_gem_ww(_ww, _err, _intr) \
+ for (__i915_gem_ww_init(_ww, _intr); (_ww)->loop; \
+ _err = __i915_gem_ww_fini(_ww, _err))
-:55: CHECK:MACRO_ARG_REUSE: Macro argument reuse '_err' - possible side-effects? #55: FILE: drivers/gpu/drm/i915/i915_gem_ww.h:46:
+#define for_i915_gem_ww(_ww, _err, _intr) \
+ for (__i915_gem_ww_init(_ww, _intr); (_ww)->loop; \
+ _err = __i915_gem_ww_fini(_ww, _err))
total: 0 errors, 0 warnings, 2 checks, 41 lines checkedc7566defcd7c drm/i915/gt: Add an insert_entry for gen8_ppgtt26a16841f182 drm/i915/gt: Add a routine to iterate over the pagetables of a GTT 8e6cf3a8e8b3 drm/i915/gt: Export the pinned context constructor8bd34da39144 drm/i915/gt: Pipelined page migration
-:66: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #66:
new file mode 100644
-:879: WARNING:LINE_SPACING: Missing a blank line after declarations #879: FILE: drivers/gpu/drm/i915/gt/selftest_migrate.c:176:
+ struct drm_i915_private *i915 = migrate->context->engine->i915;
+ I915_RND_STATE(prng);
-:908: WARNING:LINE_SPACING: Missing a blank line after declarations #908: FILE: drivers/gpu/drm/i915/gt/selftest_migrate.c:205:
+ struct threaded_migrate *thread;
+ I915_RND_STATE(prng);
-:933: WARNING:MSLEEP: msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.rst #933: FILE: drivers/gpu/drm/i915/gt/selftest_migrate.c:230:
+ msleep(10); /* start all threads before we kthread_stop() */
total: 0 errors, 4 warnings, 0 checks, 932 lines checked 09387b6a62ee drm/i915/gt: Pipelined clear
-:353: WARNING:LINE_SPACING: Missing a blank line after declarations #353: FILE: drivers/gpu/drm/i915/gt/selftest_migrate.c:311:
+ struct drm_i915_private *i915 = migrate->context->engine->i915;
+ I915_RND_STATE(prng);
total: 0 errors, 1 warnings, 0 checks, 378 lines checked 15bf0f5044d2 drm/i915/gt: Setup a default migration context on the GT
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI[Intel-gfx] ✗ Fi.CI.BAT: failure for Prereqs for TTM accelerated migration
In reply to Thomas Hellström== Series Details ==
== Series Details ==
Series: Prereqs for TTM accelerated migration
URL : https://patchwork.freedesktop.org/series/91155/
State : failure
== Summary ==
CI Bug Log - changes from CI_DRM_10190 -> Patchwork_20309
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with Patchwork_20309 absolutely need to be verified manually.
If you think the reported changes have nothing to do with the changes introduced in Patchwork_20309, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20309/index.html
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in Patchwork_20309:
### IGT changes ###
#### Possible regressions ####
* igt@core_hotunplug@unbind-rebind:
- fi-bsw-nick: [PASS][1] -> [DMESG-WARN][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10190/fi-bsw-nick/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20309/fi-bsw-nick/igt@[email protected]
* igt@i915_selftest@live@gt_heartbeat:
- fi-kbl-soraka: [PASS][3] -> [DMESG-FAIL][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10190/fi-kbl-soraka/igt@i915_selftest@live@gt_heartbeat.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20309/fi-kbl-soraka/igt@i915_selftest@live@gt_heartbeat.html
* igt@i915_selftest@live@uncore:
- fi-bsw-kefka: [PASS][5] -> [DMESG-FAIL][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10190/fi-bsw-kefka/igt@i915_selftest@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20309/fi-bsw-kefka/igt@i915_selftest@[email protected]
New tests
---------
New tests have been introduced between CI_DRM_10190 and Patchwork_20309:
### New IGT tests (1) ###
* igt@i915_selftest@live@migrate:
- Statuses : 2 dmesg-warn(s) 33 pass(s)
- Exec time: [0.52, 7.75] s
Known issues
------------
Here are the changes found in Patchwork_20309 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@gem_huc_copy@huc-copy:
- fi-bxt-dsi: NOTRUN -> [SKIP][7] ([fdo#109271] / [i915#2190])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20309/fi-bxt-dsi/igt@[email protected]
* igt@i915_selftest@live@execlists:
- fi-bxt-dsi: NOTRUN -> [DMESG-FAIL][8] ([i915#3462])
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20309/fi-bxt-dsi/igt@i915_selftest@[email protected]
* {igt@i915_selftest@live@migrate} (NEW):
- {fi-ehl-2}: NOTRUN -> [DMESG-WARN][9] ([i915#1222])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20309/fi-ehl-2/igt@i915_selftest@[email protected]
- {fi-jsl-1}: NOTRUN -> [DMESG-WARN][10] ([i915#1222])
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20309/fi-jsl-1/igt@i915_selftest@[email protected]
* igt@kms_chamelium@common-hpd-after-suspend:
- fi-bxt-dsi: NOTRUN -> [SKIP][11] ([fdo#109271] / [fdo#111827]) +8 similar issues
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20309/fi-bxt-dsi/igt@[email protected]
* igt@kms_force_connector_basic@force-load-detect:
- fi-bxt-dsi: NOTRUN -> [SKIP][12] ([fdo#109271]) +10 similar issues
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20309/fi-bxt-dsi/igt@[email protected]
* igt@kms_pipe_crc_basic@compare-crc-sanitycheck-pipe-d:
- fi-bxt-dsi: NOTRUN -> [SKIP][13] ([fdo#109271] / [i915#533])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20309/fi-bxt-dsi/igt@[email protected]
* igt@runner@aborted:
- fi-bxt-dsi: NOTRUN -> [FAIL][14] ([i915#3363])
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20309/fi-bxt-dsi/igt@[email protected]
#### Possible fixes ####
* igt@i915_pm_rpm@module-reload:
- fi-skl-6600u: [FAIL][15] ([i915#579]) -> [PASS][16]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10190/fi-skl-6600u/igt@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20309/fi-skl-6600u/igt@[email protected]
- {fi-tgl-dsi}: [DMESG-WARN][17] ([i915#1982] / [i915#2411]) -> [PASS][18]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10190/fi-tgl-dsi/igt@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20309/fi-tgl-dsi/igt@[email protected]
#### Warnings ####
* igt@i915_selftest@live@execlists:
- fi-cml-s: [DMESG-FAIL][19] ([i915#3462]) -> [INCOMPLETE][20] ([i915#3462])
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10190/fi-cml-s/igt@i915_selftest@[email protected]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20309/fi-cml-s/igt@i915_selftest@[email protected]
* igt@runner@aborted:
- fi-cfl-8700k: [FAIL][21] ([i915#2426] / [i915#3363]) -> [FAIL][22] ([i915#3363])
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10190/fi-cfl-8700k/igt@[email protected]
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20309/fi-cfl-8700k/igt@[email protected]
- fi-bsw-nick: [FAIL][23] ([fdo#109271] / [i915#1436]) -> [FAIL][24] ([i915#1602])
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10190/fi-bsw-nick/igt@[email protected]
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20309/fi-bsw-nick/igt@[email protected]
- fi-kbl-r: [FAIL][25] ([i915#1436] / [i915#3363]) -> [FAIL][26] ([i915#1436] / [i915#2426] / [i915#3363])
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10190/fi-kbl-r/igt@[email protected]
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20309/fi-kbl-r/igt@[email protected]
- fi-kbl-soraka: [FAIL][27] ([i915#1436] / [i915#2426] / [i915#3363]) -> [FAIL][28] ([i915#1436] / [i915#3363])
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10190/fi-kbl-soraka/igt@[email protected]
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20309/fi-kbl-soraka/igt@[email protected]
- fi-kbl-7500u: [FAIL][29] ([i915#1436] / [i915#2426] / [i915#3363]) -> [FAIL][30] ([i915#1436] / [i915#3363])
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10190/fi-kbl-7500u/igt@[email protected]
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20309/fi-kbl-7500u/igt@[email protected]
- fi-kbl-guc: [FAIL][31] ([i915#1436] / [i915#2426] / [i915#3363]) -> [FAIL][32] ([i915#1436] / [i915#3363])
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10190/fi-kbl-guc/igt@[email protected]
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20309/fi-kbl-guc/igt@[email protected]
- fi-cfl-guc: [FAIL][33] ([i915#3363]) -> [FAIL][34] ([i915#2426] / [i915#3363])
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10190/fi-cfl-guc/igt@[email protected]
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20309/fi-cfl-guc/igt@[email protected]
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#111827]: https://bugs.freedesktop.org/show_bug.cgi?id=111827
[i915#1222]: https://gitlab.freedesktop.org/drm/intel/issues/1222
[i915#1436]: https://gitlab.freedesktop.org/drm/intel/issues/1436
[i915#1602]: https://gitlab.freedesktop.org/drm/intel/issues/1602
[i915#1982]: https://gitlab.freedesktop.org/drm/intel/issues/1982
[i915#2190]: https://gitlab.freedesktop.org/drm/intel/issues/2190
[i915#2411]: https://gitlab.freedesktop.org/drm/intel/issues/2411
[i915#2426]: https://gitlab.freedesktop.org/drm/intel/issues/2426
[i915#2932]: https://gitlab.freedesktop.org/drm/intel/issues/2932
[i915#2966]: https://gitlab.freedesktop.org/drm/intel/issues/2966
[i915#3363]: https://gitlab.freedesktop.org/drm/intel/issues/3363
[i915#3462]: https://gitlab.freedesktop.org/drm/intel/issues/3462
[i915#533]: https://gitlab.freedesktop.org/drm/intel/issues/533
[i915#579]: https://gitlab.freedesktop.org/drm/intel/issues/579
Participating hosts (45 -> 42)
------------------------------
Additional (1): fi-bxt-dsi
Missing (4): fi-ilk-m540 fi-bsw-cyan fi-bdw-samus fi-hsw-4200u
Build changes
-------------
* Linux: CI_DRM_10190 -> Patchwork_20309
CI-20190529: 20190529
CI_DRM_10190: 4503a3efad888d86c2a0c5db101bf2712f90928f @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_6100: 801309d0c245cbf8115c03978d0819f484b477c0 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_20309: 15bf0f5044d29c1be817f05153b76a7b39db2eec @ git://anongit.freedesktop.org/gfx-ci/linux
== Kernel 32bit build ==
Warning: Kernel 32bit buildtest failed:
https://intel-gfx-ci.01.org/Patchwork_20309/build_32bit.log
CALL scripts/checksyscalls.sh CALL scripts/atomic/check-atomics.sh CHK include/generated/compile.h
Kernel: arch/x86/boot/bzImage is ready (#1)
MODPOST modules-only.symvers
ERROR: modpost: "__udivdi3" [drivers/gpu/drm/amd/amdgpu/amdgpu.ko] undefined!
ERROR: modpost: "__divdi3" [drivers/gpu/drm/amd/amdgpu/amdgpu.ko] undefined! scripts/Makefile.modpost:150: recipe for target 'modules-only.symvers' failed make[1]: *** [modules-only.symvers] Error 1
make[1]: *** Deleting file 'modules-only.symvers'
Makefile:1759: recipe for target 'modules' failed
make: *** [modules] Error 2
== Linux commits ==
15bf0f5044d2 drm/i915/gt: Setup a default migration context on the GT 09387b6a62ee drm/i915/gt: Pipelined clear8bd34da39144 drm/i915/gt: Pipelined page migration8e6cf3a8e8b3 drm/i915/gt: Export the pinned context constructor 26a16841f182 drm/i915/gt: Add a routine to iterate over the pagetables of a GTT c7566defcd7c drm/i915/gt: Add an insert_entry for gen8_ppgtt 593821a10769 drm/i915: Introduce a ww transaction helper 80e16d0ed0bd drm/i915: Break out dma_resv ww locking utilities to separate files 2242ed7d4819 drm/i915: Reference objects on the ww object list
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20309/index.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI[Intel-gfx] ✗ Fi.CI.BUILD: warning for Prereqs for TTM accelerated migration
In reply to Thomas Hellström== Series Details ==
== Series Details ==
Series: Prereqs for TTM accelerated migration
URL : https://patchwork.freedesktop.org/series/91155/
State : warning
== Summary ==
CALL scripts/checksyscalls.sh
CALL scripts/atomic/check-atomics.sh
CHK include/generated/compile.h
Kernel: arch/x86/boot/bzImage is ready (#1)
MODPOST modules-only.symvers
ERROR: modpost: "__udivdi3" [drivers/gpu/drm/amd/amdgpu/amdgpu.ko] undefined!
ERROR: modpost: "__divdi3" [drivers/gpu/drm/amd/amdgpu/amdgpu.ko] undefined! scripts/Makefile.modpost:150: recipe for target 'modules-only.symvers' failed make[1]: *** [modules-only.symvers] Error 1
make[1]: *** Deleting file 'modules-only.symvers'
Makefile:1759: recipe for target 'modules' failed
make: *** [modules] Error 2
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20309/build_32bit.log
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH 7/9] drm/i915/gt: Pipelined page migration
In reply to Thomas HellströmQuoted 206 lines · Thomas Hellström
From: Chris Wilson <[email protected]>
If we pipeline the PTE updates and then do the copy of those pages within a single unpreemptible command packet, we can submit the copies and leave them to be scheduled without having to synchronously wait under a global lock. In order to manage migration, we need to preallocate the page tables (and keep them pinned and available for use at any time), causing a bottleneck for migrations as all clients must contend on the limited resources. By inlining the ppGTT updates and performing the blit atomically, each client only owns the PTE while in use, and so we can reschedule individual operations however we see fit. And most importantly, we do not need to take a global lock on the shared vm, and wait until the operation is complete before releasing the lock for others to claim the PTE for themselves.
Signed-off-by Chris Wilson <[email protected]>Co-developed-by Thomas Hellström <[email protected]>Signed-off-by Thomas Hellström <[email protected]>--- drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/gt/intel_engine.h | 1 + drivers/gpu/drm/i915/gt/intel_gpu_commands.h | 2 + drivers/gpu/drm/i915/gt/intel_migrate.c | 543 ++++++++++++++++++ drivers/gpu/drm/i915/gt/intel_migrate.h | 45 ++ drivers/gpu/drm/i915/gt/intel_migrate_types.h | 15 + drivers/gpu/drm/i915/gt/intel_ring.h | 1 + drivers/gpu/drm/i915/gt/selftest_migrate.c | 291 ++++++++++ .../drm/i915/selftests/i915_live_selftests.h | 1 + 9 files changed, 900 insertions(+) create mode 100644 drivers/gpu/drm/i915/gt/intel_migrate.c create mode 100644 drivers/gpu/drm/i915/gt/intel_migrate.h create mode 100644 drivers/gpu/drm/i915/gt/intel_migrate_types.h create mode 100644 drivers/gpu/drm/i915/gt/selftest_migrate.cdrivers/gpu/drm/i915/Makefile +1
-0@@ -109,6 +109,7 @@ gt-y += \ gt/intel_gtt.o \ gt/intel_llc.o \ gt/intel_lrc.o \ + gt/intel_migrate.o \ gt/intel_mocs.o \ gt/intel_ppgtt.o \ gt/intel_rc6.o \drivers/gpu/drm/i915/gt/intel_engine.h +1
-0@@ -188,6 +188,7 @@ intel_write_status_page(struct intel_engine_cs *engine, int reg, u32 value)#define I915_GEM_HWS_PREEMPT_ADDR (I915_GEM_HWS_PREEMPT * sizeof(u32))#define I915_GEM_HWS_SEQNO 0x40#define I915_GEM_HWS_SEQNO_ADDR (I915_GEM_HWS_SEQNO * sizeof(u32)) +#define I915_GEM_HWS_MIGRATE (0x42 * sizeof(u32))#define I915_GEM_HWS_SCRATCH 0x80#define I915_HWS_CSB_BUF0_INDEX 0x10drivers/gpu/drm/i915/gt/intel_gpu_commands.h +2
-0@@ -123,8 +123,10 @@#define MI_SEMAPHORE_SAD_NEQ_SDD (5 << 12)#define MI_SEMAPHORE_TOKEN_MASK REG_GENMASK(9, 5)#define MI_SEMAPHORE_TOKEN_SHIFT 5 +#define MI_STORE_DATA_IMM MI_INSTR(0x20, 0)#define MI_STORE_DWORD_IMM MI_INSTR(0x20, 1)#define MI_STORE_DWORD_IMM_GEN4 MI_INSTR(0x20, 2) +#define MI_STORE_QWORD_IMM_GEN8 (MI_INSTR(0x20, 3) | REG_BIT(21))#define MI_MEM_VIRTUAL (1 << 22)/* 945,g33,965 */ #define MI_USE_GGTT (1 << 22)/* g4x+ */ #define MI_STORE_DWORD_INDEX MI_INSTR(0x21, 1)drivers/gpu/drm/i915/gt/intel_migrate.c new file +126
-0@@ -0,0 +1,543 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2020 Intel Corporation +*/ + +#include "i915_drv.h" +#include "intel_context.h" +#include "intel_gpu_commands.h" +#include "intel_gt.h" +#include "intel_gtt.h" +#include "intel_migrate.h" +#include "intel_ring.h" + +struct insert_pte_data { +u64 offset; +bool is_lmem; +}; + +#define CHUNK_SZ SZ_8M/* ~1ms at 8GiB/s preemption delay */ + +static bool engine_supports_migration (struct intel_engine_cs *engine) +{ +if (!engine) +return false; + +/* +* We need the ability to prevent aribtration (MI_ARB_ON_OFF), +* the ability to write PTE using inline data (MI_STORE_DATA) +* and of course the ability to do the block transfer (blits). +*/ +GEM_BUG_ON (engine->class !=COPY_ENGINE_CLASS ); + +return true; +} + +static void insert_pte (struct i915_address_space *vm, +struct i915_page_table *pt, +void *data) +{ +struct insert_pte_data *d = data; + + vm->insert_page (vm,px_dma (pt), d->offset,I915_CACHE_NONE , + d->is_lmem ?PTE_LM :0 ); + d->offset +=PAGE_SIZE ; +} + +static struct i915_address_space *migrate_vm (struct intel_gt *gt) +{ +struct i915_vm_pt_stash stash = {}; +struct i915_ppgtt *vm; +int err; +int i; + +/* +* We construct a very special VM for use by all migration contexts, +* it is kept pinned so that it can be used at any time. As we need +* to pre-allocate the page directories for the migration VM, this +* limits us to only using a small number of prepared vma. +* +* To be able to pipeline and reschedule migration operations while +* avoiding unnecessary contention on the vm itself, the PTE updates +* are inline with the blits. All the blits use the same fixed +* addresses, with the backing store redirection being updated on the +* fly. Only 2 implicit vma are used for all migration operations. +* +* We lay the ppGTT out as: +* +* [0, CHUNK_SZ) -> first object +* [CHUNK_SZ, 2 * CHUNK_SZ) -> second object +* [2 * CHUNK_SZ, 2 * CHUNK_SZ + 2 * CHUNK_SZ >> 9] -> PTE +* +* By exposing the dma addresses of the page directories themselves +* within the ppGTT, we are then able to rewrite the PTE prior to use. +* But the PTE update and subsequent migration operation must be atomic, +* i.e. within the same non-preemptible window so that we do not switch +* to another migration context that overwrites the PTE. +*/ + + vm =i915_ppgtt_create (gt); +if (IS_ERR (vm)) +return ERR_CAST (vm); + +if (!vm->vm.allocate_va_range || !vm->vm.foreach) { + err = -ENODEV ; + goto err_vm; + } + +/* +* Each engine instance is assigned its own chunk in the VM, so +* that we can run multiple instances concurrently +*/ +for (i =0 ; i <ARRAY_SIZE (gt->engine_class[COPY_ENGINE_CLASS ]); i++) { +struct intel_engine_cs *engine; +u64 base = (u64 )i <<32 ; +struct insert_pte_data d = {}; +struct i915_gem_ww_ctx ww; +u64 sz; + + engine = gt->engine_class[COPY_ENGINE_CLASS ][i]; +if (!engine_supports_migration (engine)) +continue ; + +/* +* We copy in 8MiB chunks. Each PDE covers 2MiB, so we need +* 4x2 page directories for source/destination. +*/ + sz =2 *CHUNK_SZ ; + d.offset = base + sz; + +/* +* We need another page directory setup so that we can write +* the 8x512 PTE in each chunk. +*/ + sz += (sz >>12 ) *sizeof (u64); + + err =i915_vm_alloc_pt_stash (&vm->vm, &stash, sz); +if (err) + goto err_vm; + + for_i915_gem_ww(&ww, err, true) { + err =i915_vm_lock_objects (&vm->vm, &ww); +if (err) +continue ; + err =i915_vm_map_pt_stash (&vm->vm, &stash); +if (err) +continue ;
drivers/gpu/drm/i915/gt/intel_migrate.c line 136
Quoted 10 lines
drivers/gpu/drm/i915/gt/intel_migrate.c new file +10
-0+ + vm->vm.allocate_va_range (&vm->vm, &stash, base, base + sz); + } +i915_vm_free_pt_stash (&vm->vm, &stash); +if (err) + goto err_vm; + +/* Now allow the GPU to rewrite the PTE via its own ppGTT */ + d.is_lmem =i915_gem_object_is_lmem (vm->vm.scratch[0 ]); + vm->vm.foreach (&vm->vm, base, base + sz, insert_pte, &d);
Will this play nice with Xe HP where we have min page size restrictions for the GTT + lmem? The page-table allocations sidestep such restrictions since they were previously never inserted into the GTT. Maybe we need the flat-ppGTT at some point? Perhaps add a TODO or something?
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 1/9] drm/i915: Reference objects on the ww object list
In reply to Thomas HellströmQuoted 6 lines · Thomas Hellström
Since the ww transaction endpoint easily end up far out-of-scope of the objects on the ww object list, particularly for contending lock objects, make sure we reference objects on the list so they don't disappear under us.
Quoted 7 lines
This comes with a performance penalty so it's been debated whether this is really needed. But I think this is motivated by the fact that locking is typically difficult to get right, and whatever we can do to make it simpler for developers moving forward should be done, unless the performance impact is far too high.
Signed-off-by Thomas Hellström <[email protected]>
Re: [PATCH 2/9] drm/i915: Break out dma_resv ww locking utilities to separate files
In reply to Thomas HellströmQuoted 22 lines · Thomas Hellström
As we're about to add more ww-related functionality, break out the
dma_resvww locking utilities to their own filesSigned-off-by Thomas Hellström <[email protected]>--- drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/gem/i915_gem_object.h | 1 + drivers/gpu/drm/i915/gt/intel_renderstate.h | 1 + drivers/gpu/drm/i915/i915_gem.c | 56 ------------------ drivers/gpu/drm/i915/i915_gem.h | 12 ---- drivers/gpu/drm/i915/i915_gem_ww.c | 63 +++++++++++++++++++++ drivers/gpu/drm/i915/i915_gem_ww.h | 21 +++++++ 7 files changed, 87 insertions(+), 68 deletions(-) create mode 100644 drivers/gpu/drm/i915/i915_gem_ww.c create mode 100644 drivers/gpu/drm/i915/i915_gem_ww.hdrivers/gpu/drm/i915/Makefile +0
-0
drivers/gpu/drm/i915/Makefile i915-y += i915_drv.o \ · line 48
Quoted 4 lines
drivers/gpu/drm/i915/Makefile +1
-0@@ -45,6 +45,7 @@ i915-y += i915_drv.o \ i915_switcheroo.o \ i915_sysfs.o \ i915_utils.o \ + i915_gem_ww.o \
Nit: Should be kept sorted.
drivers/gpu/drm/i915/gem/i915_gem_object.h line 18
Quoted 12 lines
drivers/gpu/drm/i915/Makefile +0
-0intel_device_info.o \ intel_dram.o \ intel_memory_region.o \drivers/gpu/drm/i915/gem/i915_gem_object.h +1
-0@@ -15,6 +15,7 @@#include "i915_gem_object_types.h" #include "i915_gem_gtt.h" #include "i915_vma_types.h" +#include "i915_gem_ww.h"
Same here.
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH 3/9] drm/i915: Introduce a ww transaction helper
In reply to Thomas HellströmQuoted 14 lines · Thomas Hellström
Introduce a for_i915_gem_ww(){} utility to help make the code around a ww transaction more readable.
Signed-off-by Thomas Hellström <[email protected]>--- drivers/gpu/drm/i915/i915_gem_ww.h | 31 +++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/i915_gem_ww.h +0
-0
drivers/gpu/drm/i915/i915_gem_ww.h struct i915_gem_ww_ctx { · line 15
Quoted 6 lines
drivers/gpu/drm/i915/i915_gem_ww.h +2
-1@@ -11,11 +11,40 @@ struct i915_gem_ww_ctx {struct ww_acquire_ctx ctx;struct list_head obj_list;struct drm_i915_gem_object *contended; -bool intr; +unsigned short intr; +unsigned short loop;
Why are these now unsigned short?
Quoted 42 lines
drivers/gpu/drm/i915/i915_gem_ww.h +28
-1};void i915_gem_ww_ctx_init (struct i915_gem_ww_ctx *ctx,bool intr);void i915_gem_ww_ctx_fini (struct i915_gem_ww_ctx *ctx);int __must_check i915_gem_ww_ctx_backoff (struct i915_gem_ww_ctx *ctx);void i915_gem_ww_unlock_single (struct drm_i915_gem_object *obj); + +/* Internal functions used by the inlines! Don't use. */ +static inline int __i915_gem_ww_fini (struct i915_gem_ww_ctx *ww,int err) +{ + ww->loop =0 ; +if (err == -EDEADLK ) { + err =i915_gem_ww_ctx_backoff (ww); +if (!err) + ww->loop =1 ; + } + +if (!ww->loop) +i915_gem_ww_ctx_fini (ww); + +return err; +} + +static inline void +__i915_gem_ww_init (struct i915_gem_ww_ctx *ww,bool intr) +{ +i915_gem_ww_ctx_init (ww, intr); + ww->loop =1 ; +} + +#define for_i915_gem_ww (_ww, _err, _intr) \ + for (__i915_gem_ww_init(_ww, _intr); (_ww)->loop; \ + _err = __i915_gem_ww_fini(_ww, _err)) +#endif --2.31.1
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH 3/9] drm/i915: Introduce a ww transaction helper
Quoted 12 lines · Matthew Auld
Quoted 10 lines · Thomas Hellström
Introduce a for_i915_gem_ww(){} utility to help make the code around a ww transaction more readable.
Signed-off-by Thomas Hellström <[email protected]>---
drivers/gpu/drm/i915/i915_gem_ww.h | 31
+++++++++++++++++++++++++++++-1 file changed, 30 insertions(+), 1 deletion(-)
Quoted 15 lines
drivers/gpu/drm/i915/i915_gem_ww.h struct i915_gem_ww_ctx { · line 15
Quoted 12 lines
drivers/gpu/drm/i915/i915_gem_ww.h +2
-1@@ -11,11 +11,40 @@ struct i915_gem_ww_ctx { struct ww_acquire_ctx ctx; struct list_head obj_list; struct drm_i915_gem_object *contended; - bool intr; + unsigned short intr; + unsigned short loop;Why are these now unsigned short?
That's because I once got a harsh comment making some changes to the core mutex code where I happened to stuff bools in the struct ww_mutex, and was told that it was bad style putting bools in compound data types in the linux kernel.
There's no checkpatch.pl checks for that though...
Quoted 46 lines
Reviewed-by Matthew Auld <[email protected]>Quoted 44 lines
drivers/gpu/drm/i915/i915_gem_ww.h +0
-0}; void i915_gem_ww_ctx_init(struct i915_gem_ww_ctx *ctx, bool intr); void i915_gem_ww_ctx_fini(struct i915_gem_ww_ctx *ctx);int
__must_checki915_gem_ww_ctx_backoff(struct i915_gem_ww_ctx *ctx);
voidi915_gem_ww_unlock_single(struct drm_i915_gem_object *obj);drivers/gpu/drm/i915/i915_gem_ww.h +3
-0+ +/* Internal functions used by the inlines! Don't use. */ +static inline int __i915_gem_ww_fini(struct i915_gem_ww_ctx *ww,int err)
drivers/gpu/drm/i915/i915_gem_ww.h +25
-0+{ + ww->loop = 0; + if (err == -EDEADLK) { + err = i915_gem_ww_ctx_backoff(ww); + if (!err) + ww->loop = 1; + } + + if (!ww->loop) + i915_gem_ww_ctx_fini(ww); + + return err; +} + +static inline void +__i915_gem_ww_init (struct i915_gem_ww_ctx *ww,bool intr) +{ + i915_gem_ww_ctx_init(ww, intr); + ww->loop = 1; +} + +#define for_i915_gem_ww (_ww, _err, _intr) \ + for (__i915_gem_ww_init(_ww, _intr); (_ww)->loop; \ + _err = __i915_gem_ww_fini(_ww, _err)) +#endif
--
2.31.1_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH 7/9] drm/i915/gt: Pipelined page migration
In reply to Matthew AuldQuoted 261 lines · Matthew Auld
Quoted 255 lines · Thomas Hellström
From: Chris Wilson <[email protected]>
If we pipeline the PTE updates and then do the copy of those pages within a single unpreemptible command packet, we can submit the copies
and leave them to be scheduled without having to synchronously wait under a global lock. In order to manage migration, we need to preallocate the page tables (and keep them pinned and available for use
at any time), causing a bottleneck for migrations as all clients must
contend on the limited resources. By inlining the ppGTT updates and performing the blit atomically, each client only owns the PTE while in
use, and so we can reschedule individual operations however we see fit.
And most importantly, we do not need to take a global lock on the shared
vm, and wait until the operation is complete before releasing the lock
for others to claim the PTE for themselves.Signed-off-by Chris Wilson <[email protected]>Co-developed-by Thomas HellströmSigned-off-by Thomas Hellström <[email protected]>---
drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/gt/intel_engine.h | 1 + drivers/gpu/drm/i915/gt/intel_gpu_commands.h | 2 + drivers/gpu/drm/i915/gt/intel_migrate.c | 543
++++++++++++++++++
drivers/gpu/drm/i915/gt/intel_migrate.h | 45 ++drivers/gpu/drm/i915/gt/intel_migrate_types.h| 15 + drivers/gpu/drm/i915/gt/intel_ring.h | 1 + drivers/gpu/drm/i915/gt/selftest_migrate.c | 291 ++++++++++ .../drm/i915/selftests/i915_live_selftests.h | 1 +9 files changed, 900 insertions(+)create mode 100644
drivers/gpu/drm/i915/gt/intel_migrate.ccreate mode 100644drivers/gpu/drm/i915/gt/intel_migrate.hcreate mode 100644drivers/gpu/drm/i915/gt/intel_migrate_types.hcreate mode 100644drivers/gpu/drm/i915/gt/selftest_migrate.cdrivers/gpu/drm/i915/Makefile +1
-0@@ -109,6 +109,7 @@ gt-y += \ gt/intel_gtt.o \ gt/intel_llc.o \ gt/intel_lrc.o \ + gt/intel_migrate.o \ gt/intel_mocs.o \ gt/intel_ppgtt.o \ gt/intel_rc6.o \drivers/gpu/drm/i915/gt/intel_engine.h +1
-0@@ -188,6 +188,7 @@ intel_write_status_page(struct intel_engine_cs *engine, int reg, u32 value) #define I915_GEM_HWS_PREEMPT_ADDR (I915_GEM_HWS_PREEMPT * sizeof(u32)) #define I915_GEM_HWS_SEQNO 0x40 #define I915_GEM_HWS_SEQNO_ADDR (I915_GEM_HWS_SEQNO * sizeof(u32)) +#define I915_GEM_HWS_MIGRATE (0x42 * sizeof(u32))#define I915_GEM_HWS_SCRATCH
0x80#define I915_HWS_CSB_BUF0_INDEX
0x10drivers/gpu/drm/i915/gt/intel_gpu_commands.h +2
-0@@ -123,8 +123,10 @@ #define MI_SEMAPHORE_SAD_NEQ_SDD (5 << 12) #define MI_SEMAPHORE_TOKEN_MASK REG_GENMASK(9, 5) #define MI_SEMAPHORE_TOKEN_SHIFT 5 +#define MI_STORE_DATA_IMM MI_INSTR(0x20, 0) #define MI_STORE_DWORD_IMM MI_INSTR(0x20, 1) #define MI_STORE_DWORD_IMM_GEN4 MI_INSTR(0x20, 2) +#define MI_STORE_QWORD_IMM_GEN8 (MI_INSTR(0x20, 3) | REG_BIT(21)) #define MI_MEM_VIRTUAL (1 << 22) /* 945,g33,965 */ #define MI_USE_GGTT (1 << 22) /* g4x+ */ #define MI_STORE_DWORD_INDEX MI_INSTR(0x21, 1)drivers/gpu/drm/i915/gt/intel_migrate.c new file +21
-0@@ -0,0 +1,543 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2020 Intel Corporation +*/ + +#include "i915_drv.h" +#include "intel_context.h" +#include "intel_gpu_commands.h" +#include "intel_gt.h" +#include "intel_gtt.h" +#include "intel_migrate.h" +#include "intel_ring.h" + +struct insert_pte_data { + u64 offset; + bool is_lmem; +}; + +#define CHUNK_SZ SZ_8M/* ~1ms at 8GiB/s preemption delay */ + +static bool engine_supports_migration(struct intel_engine_cs*engine)
drivers/gpu/drm/i915/gt/intel_migrate.c new file +6
-0+{ + if (!engine) + return false; + + /* +* We need the ability to prevent aribtration (
MI_ARB_ON_OFF),
+ * the ability to write PTE using inline data (MI_STORE_DATA)
+ * and of course the ability to do the block transfer (blits).
+ */
+GEM_BUG_ON(engine->class != COPY_ENGINE_CLASS);drivers/gpu/drm/i915/gt/intel_migrate.c new file +24
-0+ + return true; +} + +static void insert_pte (struct i915_address_space *vm, + struct i915_page_table *pt, + void *data) +{ + struct insert_pte_data *d = data; + + vm->insert_page(vm, px_dma(pt), d->offset, I915_CACHE_NONE, + d->is_lmem ? PTE_LM : 0); + d->offset += PAGE_SIZE; +} + +static struct i915_address_space *migrate_vm (struct intel_gt *gt) +{ + struct i915_vm_pt_stash stash = {}; + struct i915_ppgtt *vm; + int err; + int i; + + /* +* We construct a very special VM for use by all migration contexts,
+ * it is kept pinned so that it can be used at any time. As we need
+ * to pre-allocate the page directories for the migration VM, this
+ * limits us to only using a small number of prepared vma. + *
+ * To be able to pipeline and reschedule migration operations while
+ * avoiding unnecessary contention on the vm itself, the PTE updates
+ * are inline with the blits. All the blits use the same fixed
+ * addresses, with the backing store redirection being updated on the
+ * fly. Only 2 implicit vma are used for all migration operations.
+ *
+ * We lay the ppGTT out as:
+ *
+ * [0,CHUNK_SZ) -> first object
+ * [CHUNK_SZ, 2 *CHUNK_SZ) -> second object + * [2 *CHUNK_SZ, 2 *CHUNK_SZ+ 2 *CHUNK_SZ>> 9] -> PTE
+ *
+ * By exposing the dma addresses of the page directories themselves
+ * within the ppGTT, we are then able to rewrite the PTE prior to use.
+ * But the PTE update and subsequent migration operation must be atomic,
+ * i.e. within the same non-preemptible window so that we do not switch
+ * to another migration context that overwrites the PTE. + */drivers/gpu/drm/i915/gt/intel_migrate.c new file +12
-0+ + vm = i915_ppgtt_create(gt); + if (IS_ERR(vm)) + return ERR_CAST(vm); + + if (!vm->vm.allocate_va_range || !vm->vm.foreach) { + err = -ENODEV; + goto err_vm; + } + + /* +* Each engine instance is assigned its own chunk in the VM, so
+ * that we can run multiple instances concurrently + */
+ for (i = 0; i < ARRAY_SIZE(gt-Quoted 1 line
engine_class[COPY_ENGINE_CLASS]); i++) {
+ struct
intel_engine_cs*engine;
+ u64 base = (u64)i << 32;
+ structinsert_pte_datad = {};
+ structi915_gem_ww_ctxww;
+ u64 sz;drivers/gpu/drm/i915/gt/intel_migrate.c new file +7
-0+ + engine = gt->engine_class[COPY_ENGINE_CLASS][i]; + if (!engine_supports_migration(engine)) + continue; + + /* +* We copy in 8MiB chunks. Each PDE covers 2MiB, so we need
+ * 4x2 page directories for source/destination. + */
+ sz = 2 *CHUNK_SZ;
+ d.offset = base + sz;
+
+ /*
+ * We need another page directory setup so that we can write
+ * the 8x512 PTE in each chunk.
+ */
+ sz += (sz >> 12) * sizeof(u64);drivers/gpu/drm/i915/gt/intel_migrate.c new file +10
-0+ + err = i915_vm_alloc_pt_stash(&vm->vm, &stash, sz); + if (err) + goto err_vm; + + for_i915_gem_ww(&ww, err, true) { + err = i915_vm_lock_objects(&vm->vm, &ww); + if (err) + continue; + err = i915_vm_map_pt_stash(&vm->vm,&stash);
+ if (err)
+ continue;
+
+vm->vm.allocate_va_range(&vm->vm, &stash, base, base + sz);
+ }
+i915_vm_free_pt_stash(&vm->vm, &stash); + if (err)
+ gotoerr_vm;
+
+ /* Now allow the GPU to rewrite the PTE via its own ppGTT */
+ d.is_lmem = i915_gem_object_is_lmem(vm-Quoted 3 lines
Quoted 1 line
vm.scratch[0]);
+
vm->vm.foreach(&vm->vm, base, base + sz, insert_pte, &d);
Quoted 6 lines
Will this play nice with Xe HP where we have min page size restrictions for the GTT + lmem? The page-table allocations sidestep such restrictions since they were previously never inserted into the GTT. Maybe we need the flat-ppGTT at some point? Perhaps add a TODO or
something?
I've previously discussed that with Chris, and apparently it should be as easy as adjusting the sz >> 12 above. But yeah, Chris also brought up the flat-ppGTT idea as something we should look into.
Mieanwhile, we should add a TODO.
/Thomas
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 7/9] drm/i915/gt: Pipelined page migration
In reply to Thomas HellströmQuoted 107 lines · Thomas Hellström
From: Chris Wilson <[email protected]>
If we pipeline the PTE updates and then do the copy of those pages within a single unpreemptible command packet, we can submit the copies
and leave them to be scheduled without having to synchronously wait under a global lock. In order to manage migration, we need to preallocate the page tables (and keep them pinned and available for use
at any time), causing a bottleneck for migrations as all clients must contend on the limited resources. By inlining the ppGTT updates and performing the blit atomically, each client only owns the PTE while in
use, and so we can reschedule individual operations however we see fit.
And most importantly, we do not need to take a global lock on the shared
vm, and wait until the operation is complete before releasing the lock
for others to claim the PTE for themselves.Signed-off-by Chris Wilson <[email protected]>Co-developed-by Thomas Hellström <[email protected]>Signed-off-by Thomas Hellström <[email protected]>---
drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/gt/intel_engine.h | 1 + drivers/gpu/drm/i915/gt/intel_gpu_commands.h | 2 + drivers/gpu/drm/i915/gt/intel_migrate.c | 543
++++++++++++++++++
drivers/gpu/drm/i915/gt/intel_migrate.h | 45 ++drivers/gpu/drm/i915/gt/intel_migrate_types.h| 15 + drivers/gpu/drm/i915/gt/intel_ring.h | 1 + drivers/gpu/drm/i915/gt/selftest_migrate.c | 291 ++++++++++ .../drm/i915/selftests/i915_live_selftests.h | 1 +9 files changed, 900 insertions(+)create mode 100644
drivers/gpu/drm/i915/gt/intel_migrate.ccreate mode 100644drivers/gpu/drm/i915/gt/intel_migrate.hcreate mode 100644drivers/gpu/drm/i915/gt/intel_migrate_types.hcreate mode 100644drivers/gpu/drm/i915/gt/selftest_migrate.cdrivers/gpu/drm/i915/Makefile +1
-0@@ -109,6 +109,7 @@ gt-y += \ gt/intel_gtt.o \ gt/intel_llc.o \ gt/intel_lrc.o \ + gt/intel_migrate.o \ gt/intel_mocs.o \ gt/intel_ppgtt.o \ gt/intel_rc6.o \drivers/gpu/drm/i915/gt/intel_engine.h +1
-0@@ -188,6 +188,7 @@ intel_write_status_page(struct intel_engine_cs *engine, int reg, u32 value) #define I915_GEM_HWS_PREEMPT_ADDR (I915_GEM_HWS_PREEMPT * sizeof(u32)) #define I915_GEM_HWS_SEQNO 0x40 #define I915_GEM_HWS_SEQNO_ADDR (I915_GEM_HWS_SEQNO * sizeof(u32)) +#define I915_GEM_HWS_MIGRATE (0x42 * sizeof(u32))#define I915_GEM_HWS_SCRATCH 0x80
#define I915_HWS_CSB_BUF0_INDEX 0x10drivers/gpu/drm/i915/gt/intel_gpu_commands.h +2
-0@@ -123,8 +123,10 @@ #define MI_SEMAPHORE_SAD_NEQ_SDD (5 << 12) #define MI_SEMAPHORE_TOKEN_MASK REG_GENMASK(9, 5) #define MI_SEMAPHORE_TOKEN_SHIFT 5 +#define MI_STORE_DATA_IMM MI_INSTR(0x20, 0) #define MI_STORE_DWORD_IMM MI_INSTR(0x20, 1) #define MI_STORE_DWORD_IMM_GEN4 MI_INSTR(0x20, 2) +#define MI_STORE_QWORD_IMM_GEN8 (MI_INSTR(0x20, 3) | REG_BIT(21)) #define MI_MEM_VIRTUAL (1 << 22) /* 945,g33,965 */ #define MI_USE_GGTT (1 << 22) /* g4x+ */ #define MI_STORE_DWORD_INDEX MI_INSTR(0x21, 1)drivers/gpu/drm/i915/gt/intel_migrate.c new file +13
-0@@ -0,0 +1,543 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2020 Intel Corporation +*/ + +#include "i915_drv.h" +#include "intel_context.h" +#include "intel_gpu_commands.h" +#include "intel_gt.h" +#include "intel_gtt.h" +#include "intel_migrate.h" +#include "intel_ring.h" +
...
drivers/gpu/drm/i915/gt/intel_migrate.c line 539
Quoted 12 lines
drivers/gpu/drm/i915/gt/intel_migrate.c new file +12
-0+ +void intel_migrate_fini (struct intel_migrate *m) +{ + struct intel_context *ce; + + ce = fetch_and_zero(&m->context); + if (!ce) + return; + + intel_context_unpin(ce); + intel_context_put(ce); +}
Hmm, CI hints at we should be exporting and using an intel_engine_destroy_pinned_context() here...
/Thomas
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx