Port Xe to use GPUVA and implement NULL VM binds
Subsystems (5)
Matthew Brost
maintainercover Port Xe to use GPUVA and implement NULL VM binds
GPUVA is common code written primarily by Danilo with the idea being a common place to track GPUVAs (VMAs in Xe) within an address space (VMs in Xe), track all the GPUVAs attached to GEMs, and a common way implement VM binds / unbinds with MMAP / MUNMAP semantics via creating operation lists. All of this adds up to a common way to implement VK sparse bindings.
This series pulls in the GPUVA code written by Danilo plus some small fixes by myself into 1 large patch. Once the GPUVA makes it upstream, we can rebase and drop this patch. I believe what lands upstream should be nearly identical to this patch at least from an API perspective.
The last two patches port Xe to GPUVA and add support for NULL VM binds (writes dropped, read zero, VK sparse support). An example of the semantics of this is below.
MAP 0x0000-0x8000 to NULL - 0x0000-0x8000 writes dropped + read zero
MAP 0x4000-0x5000 to a GEM - 0x0000-0x4000, 0x5000-0x8000 writes dropped + read zero; 0x4000-0x5000 mapped to a GEM
UNMAP 0x3000-0x6000 - 0x0000-0x3000, 0x6000-0x8000 writes dropped + read zero
UNMAP 0x0000-0x8000 - Nothing mapped
No changins to existing behavior, rather just new functionality.
A follow up will optimize REBIND operation to avoid using dma-resv slots for ordering (partial unbinds when not changing page sizes) and prune the xe_vma object data members.
Danilo Krummrich (1):
maple_tree: split up MA_STATE() macro
Matthew Brost (2):
drm/xe: Port Xe to GPUVA
drm/xe: NULL binding implementation
Signed-off-by: Danilo Krummrich (1):
drm: manager to keep track of GPUs VA mappings
Documentation/gpu/drm-mm.rst | 31 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/drm_debugfs.c | 56 + drivers/gpu/drm/drm_gem.c | 3 + drivers/gpu/drm/drm_gpuva_mgr.c | 1891 +++++++++++++++++++ drivers/gpu/drm/xe/xe_bo.c | 10 +- drivers/gpu/drm/xe/xe_bo.h | 1 + drivers/gpu/drm/xe/xe_device.c | 2 +- drivers/gpu/drm/xe/xe_exec.c | 4 +- drivers/gpu/drm/xe/xe_gt_pagefault.c | 27 +- drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c | 14 +- drivers/gpu/drm/xe/xe_guc_ct.c | 6 +- drivers/gpu/drm/xe/xe_migrate.c | 5 +- drivers/gpu/drm/xe/xe_pt.c | 166 +- drivers/gpu/drm/xe/xe_trace.h | 10 +- drivers/gpu/drm/xe/xe_vm.c | 1872 +++++++++--------- drivers/gpu/drm/xe/xe_vm.h | 76 +- drivers/gpu/drm/xe/xe_vm_madvise.c | 87 +- drivers/gpu/drm/xe/xe_vm_types.h | 168 +- include/drm/drm_debugfs.h | 23 + include/drm/drm_drv.h | 7 + include/drm/drm_gem.h | 75 + include/drm/drm_gpuva_mgr.h | 735 +++++++ include/linux/maple_tree.h | 7 +- include/uapi/drm/xe_drm.h | 8 + 25 files changed, 4072 insertions(+), 1213 deletions(-) create mode 100644 drivers/gpu/drm/drm_gpuva_mgr.c create mode 100644 include/drm/drm_gpuva_mgr.h
Signature · 1 line
2.34.1
Matthew Brost
maintainerPATCH 1/4 maple_tree: split up MA_STATE() macro
From: Danilo Krummrich <[email protected]>
Split up the MA_STATE() macro such that components using the maple tree can easily inherit from struct ma_state and build custom tree walk macros to hide their internals from users.
Example:
struct sample_iterator {
struct ma_state mas;
struct sample_mgr *mgr;
};\#define SAMPLE_ITERATOR(name, __mgr, start) \
struct sample_iterator name = { \
.mas = MA_STATE_INIT(&(__mgr)->mt, start, 0), \
.mgr = __mgr, \
}\#define sample_iter_for_each_range(it__, entry__, end__) \ mas_for_each(&(it__).mas, entry__, end__)
--
struct sample *sample;SAMPLE_ITERATOR(si, min);
sample_iter_for_each_range(&si, sample, max) {
frob(mgr, sample);
}--- include/linux/maple_tree.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
include/linux/maple_tree.h +5 -2
@@ -424,8 +424,8 @@ struct ma_wr_state {#define MA_ERROR (err) \ ((struct maple_enode *)(((unsigned long)err << 2) | 2UL)) -#define MA_STATE (name, mt, first, end) \ - struct ma_state name = { \ +#define MA_STATE_INIT (mt, first, end) \ + { \ .tree = mt, \ .index = first, \ .last = end, \
@@ -435,6 +435,9 @@ struct ma_wr_state { .alloc = NULL, \ } +#define MA_STATE (name, mt, first, end) \ + struct ma_state name = MA_STATE_INIT(mt, first, end) +#define MA_WR_STATE (name, ma_state, wr_entry) \ struct ma_wr_state name = { \ .mas = ma_state, \
Signature · 1 line
2.34.1
Matthew Brost
maintainerPATCH 2/4 drm: manager to keep track of GPUs VA mappings
In reply to Matthew BrostFrom: "Signed-off-by: Danilo Krummrich" <[email protected]>
Add infrastructure to keep track of GPU virtual address (VA) mappings with a decicated VA space manager implementation.
New UAPIs, motivated by Vulkan sparse memory bindings graphics drivers start implementing, allow userspace applications to request multiple and arbitrary GPU VA mappings of buffer objects. The DRM GPU VA manager is intended to serve the following purposes in this context.
1) Provide infrastructure to track GPU VA allocations and mappings, making use of the maple_tree.
2) Generically connect GPU VA mappings to their backing buffers, in particular DRM GEM objects.
3) Provide a common implementation to perform more complex mapping operations on the GPU VA space. In particular splitting and merging of GPU VA mappings, e.g. for intersecting mapping requests or partial unmap requests.
--- Documentation/gpu/drm-mm.rst | 31 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/drm_debugfs.c | 56 + drivers/gpu/drm/drm_gem.c | 3 + drivers/gpu/drm/drm_gpuva_mgr.c | 1891 +++++++++++++++++++++++++++++++ include/drm/drm_debugfs.h | 23 + include/drm/drm_drv.h | 7 + include/drm/drm_gem.h | 75 ++ include/drm/drm_gpuva_mgr.h | 735 ++++++++++++ 9 files changed, 2822 insertions(+) create mode 100644 drivers/gpu/drm/drm_gpuva_mgr.c create mode 100644 include/drm/drm_gpuva_mgr.h
Documentation/gpu/drm-mm.rst +31 -0
@@ -466,6 +466,37 @@ DRM MM Range Allocator Function References .. kernel-doc:: drivers/gpu/drm/drm_mm.c :export: +DRM GPU VA Manager +================== + +Overview +-------- + +.. kernel-doc:: drivers/gpu/drm/drm_gpuva_mgr.c + :doc: Overview + +Split and Merge +--------------- + +.. kernel-doc:: drivers/gpu/drm/drm_gpuva_mgr.c + :doc: Split and Merge + +Locking +------- + +.. kernel-doc:: drivers/gpu/drm/drm_gpuva_mgr.c + :doc: Locking + + +DRM GPU VA Manager Function References +-------------------------------------- + +.. kernel-doc:: include/drm/drm_gpuva_mgr.h + :internal: + +.. kernel-doc:: drivers/gpu/drm/drm_gpuva_mgr.c + :export: + DRM Buddy Allocator ===================
drivers/gpu/drm/Makefile +1 -0
@@ -46,6 +46,7 @@ drm-y := \ drm_vblank.o \ drm_vblank_work.o \ drm_vma_manager.o \ + drm_gpuva_mgr.o \ drm_writeback.o drm-$(CONFIG_DRM_LEGACY) += \ drm_agpsupport.o \
drivers/gpu/drm/drm_debugfs.c +56 -0
68 lines not on this page · raw message
drivers/gpu/drm/drm_gem.c +3 -0
@@ -164,6 +164,9 @@ void drm_gem_private_object_init(struct drm_device *dev,if (!obj->resv) obj->resv = &obj->_resv; +if (drm_core_check_feature (dev,DRIVER_GEM_GPUVA )) +drm_gem_gpuva_init (obj); +drm_vma_node_reset (&obj->vma_node);INIT_LIST_HEAD (&obj->lru_node); }
drivers/gpu/drm/drm_gpuva_mgr.c new file +1891 -0
1,891 lines not on this page · raw message
include/drm/drm_debugfs.h +23 -0
@@ -34,6 +34,22 @@#include <linux/types.h> #include <linux/seq_file.h> + +#include <drm/drm_gpuva_mgr.h> + +/** +* DRM_DEBUGFS_GPUVA_INFO - &drm_info_list entry to dump a GPU VA space +* @show: the &drm_info_list's show callback +* @data: driver private data +* +* Drivers should use this macro to define a &drm_info_list entry to provide a +* debugfs file for dumping the GPU VA space regions and mappings. +* +* For each DRM GPU VA space drivers should call drm_debugfs_gpuva_info() from +* their @show callback. +*/ +#define DRM_DEBUGFS_GPUVA_INFO (show, data) {"gpuvas", show, DRIVER_GEM_GPUVA, data} +/** * struct drm_info_list - debugfs info list entry *
@@ -85,6 +101,8 @@ void drm_debugfs_create_files(const struct drm_info_list *files, struct drm_minor *minor);int drm_debugfs_remove_files (const struct drm_info_list *files,int count,struct drm_minor *minor); +int drm_debugfs_gpuva_info (struct seq_file *m, +struct drm_gpuva_manager *mgr);#else static inline void drm_debugfs_create_files(const struct drm_info_list *files, int count, struct dentry *root,
@@ -96,6 +114,11 @@ static inline int drm_debugfs_remove_files(const struct drm_info_list *files, {return 0 ; } +static inline int drm_debugfs_gpuva_info (struct seq_file *m, +struct drm_gpuva_manager *mgr) +{ +return 0 ; +}#endif #endif /* _DRM_DEBUGFS_H_ */
include/drm/drm_drv.h +7 -0
@@ -105,6 +105,13 @@ enum drm_driver_feature {*/ DRIVER_COMPUTE_ACCEL =BIT (7 ), +/** +* @DRIVER_GEM_GPUVA: +* +* Driver supports user defined GPU VA bindings for GEM objects. +*/ + DRIVER_GEM_GPUVA = BIT(8), +/* IMPORTANT: Below are all the legacy flags, add new ones above. */ /**
include/drm/drm_gem.h +75 -0
91 lines not on this page · raw message
include/drm/drm_gpuva_mgr.h new file +735 -0
735 lines not on this page · raw message
Signature · 1 line
2.34.1
Matthew Brost
maintainerPATCH 3/4 drm/xe: Port Xe to GPUVA
In reply to Matthew BrostRather than open coding VM binds and VMA tracking, use the GPUVA library. GPUVA provides a common infrastructure for VM binds to use mmap / munmap semantics and support for VK sparse bindings.
The concepts are:
1) xe_vm inherits from drm_gpuva_manager
2) xe_vma inherits from drm_gpuva
3) xe_vma_op inherits from drm_gpuva_op
4) VM bind operations (MAP, UNMAP, PREFETCH, UNMAP_ALL) call into the GPUVA code to generate an VMA operations list which is parsed, commited, and executed.
--- drivers/gpu/drm/xe/xe_bo.c | 10 +- drivers/gpu/drm/xe/xe_device.c | 2 +- drivers/gpu/drm/xe/xe_exec.c | 2 +- drivers/gpu/drm/xe/xe_gt_pagefault.c | 23 +- drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c | 14 +- drivers/gpu/drm/xe/xe_guc_ct.c | 6 +- drivers/gpu/drm/xe/xe_migrate.c | 5 +- drivers/gpu/drm/xe/xe_pt.c | 105 +- drivers/gpu/drm/xe/xe_trace.h | 10 +- drivers/gpu/drm/xe/xe_vm.c | 1792 +++++++++---------- drivers/gpu/drm/xe/xe_vm.h | 66 +- drivers/gpu/drm/xe/xe_vm_madvise.c | 87 +- drivers/gpu/drm/xe/xe_vm_types.h | 165 +- 13 files changed, 1116 insertions(+), 1171 deletions(-)
drivers/gpu/drm/xe/xe_bo.c +5 -5
@@ -404,7 +404,8 @@ static int xe_bo_trigger_rebind(struct xe_device *xe, struct xe_bo *bo, {struct dma_resv_iter cursor;struct dma_fence *fence; -struct xe_vma *vma; +struct drm_gpuva *gpuva; +struct drm_gem_object *obj = &bo->ttm.base;int ret =0 ;dma_resv_assert_held (bo->ttm.base.resv);
@@ -417,8 +418,9 @@ static int xe_bo_trigger_rebind(struct xe_device *xe, struct xe_bo *bo,dma_resv_iter_end (&cursor); } -list_for_each_entry (vma, &bo->vmas, bo_link) { -struct xe_vm *vm = vma->vm; +drm_gem_for_each_gpuva (gpuva, obj) { +struct xe_vma *vma =gpuva_to_vma (gpuva); +struct xe_vm *vm =xe_vma_vm (vma);trace_xe_vma_evict (vma);
@@ -443,10 +445,8 @@ static int xe_bo_trigger_rebind(struct xe_device *xe, struct xe_bo *bo, }else { ret = timeout; } - }else {bool vm_resv_locked = false; -struct xe_vm *vm = vma->vm;/* * We need to put the vma on the vm's rebind_list,
drivers/gpu/drm/xe/xe_device.c +1 -1
@@ -130,7 +130,7 @@ static struct drm_driver driver = { .driver_features =DRIVER_GEM |DRIVER_RENDER |DRIVER_SYNCOBJ | - DRIVER_SYNCOBJ_TIMELINE, + DRIVER_SYNCOBJ_TIMELINE | DRIVER_GEM_GPUVA, .open = xe_file_open, .postclose = xe_file_close,
drivers/gpu/drm/xe/xe_exec.c +1 -1
@@ -118,7 +118,7 @@ static int xe_exec_begin(struct xe_engine *e, struct ww_acquire_ctx *ww,if (xe_vma_is_userptr (vma))continue ; - err =xe_bo_validate (vma->bo, vm, false); + err =xe_bo_validate (xe_vma_bo (vma), vm, false);if (err) {xe_vm_unlock_dma_resv (vm, tv_onstack, *tv, ww, objs); *tv =NULL ;
drivers/gpu/drm/xe/xe_gt_pagefault.c +9 -14
@@ -75,9 +75,10 @@ static bool vma_is_valid(struct xe_gt *gt, struct xe_vma *vma) !(BIT (gt->info.id) & vma->usm.gt_invalidated); } -static bool vma_matches (struct xe_vma *vma,struct xe_vma *lookup) +static bool vma_matches (struct xe_vma *vma,u64 page_addr) { -if (lookup->start > vma->end || lookup->end < vma->start) +if (page_addr >xe_vma_end (vma) -1 || + page_addr +SZ_4K <xe_vma_start (vma))return false;return true;
@@ -90,16 +91,14 @@ static bool only_needs_bo_lock(struct xe_bo *bo)static struct xe_vma *lookup_vma (struct xe_vm *vm,u64 page_addr) { -struct xe_vma *vma =NULL , lookup; +struct xe_vma *vma =NULL ; - lookup.start = page_addr; - lookup.end = lookup.start +SZ_4K -1 ;if (vm->usm.last_fault_vma) {/* Fast lookup */ -if (vma_matches (vm->usm.last_fault_vma, &lookup)) +if (vma_matches (vm->usm.last_fault_vma, page_addr)) vma = vm->usm.last_fault_vma; }if (!vma) - vma =xe_vm_find_overlapping_vma (vm, &lookup); + vma =xe_vm_find_overlapping_vma (vm, page_addr,SZ_4K );return vma; }
@@ -170,7 +169,7 @@ static int handle_pagefault(struct xe_gt *gt, struct pagefault *pf) }/* Lock VM and BOs dma-resv */ - bo = vma->bo; + bo =xe_vma_bo (vma);if (only_needs_bo_lock (bo)) {/* This path ensures the BO's LRU is updated */ ret =xe_bo_lock (bo, &ww, xe->info.tile_count, false);
@@ -487,12 +486,8 @@ static struct xe_vma *get_acc_vma(struct xe_vm *vm, struct acc *acc) {u64 page_va = acc->va_range_base + (ffs (acc->sub_granularity) -1 ) *sub_granularity_in_byte (acc->granularity); -struct xe_vma lookup; - - lookup.start = page_va; - lookup.end = lookup.start +SZ_4K -1 ; -return xe_vm_find_overlapping_vma (vm, &lookup); +return xe_vm_find_overlapping_vma (vm, page_va,SZ_4K ); }static int handle_acc (struct xe_gt *gt,struct acc *acc)
@@ -536,7 +531,7 @@ static int handle_acc(struct xe_gt *gt, struct acc *acc) goto unlock_vm;/* Lock VM and BOs dma-resv */ - bo = vma->bo; + bo =xe_vma_bo (vma);if (only_needs_bo_lock (bo)) {/* This path ensures the BO's LRU is updated */ ret =xe_bo_lock (bo, &ww, xe->info.tile_count, false);
drivers/gpu/drm/xe/xe_gt_tlb_invalidation.c +7 -7
@@ -201,8 +201,8 @@ int xe_gt_tlb_invalidation_vma(struct xe_gt *gt,if (!xe->info.has_range_tlb_invalidation) { action[len++] =MAKE_INVAL_OP (XE_GUC_TLB_INVAL_FULL ); }else { -u64 start = vma->start; -u64 length = vma->end - vma->start +1 ; +u64 start =xe_vma_start (vma); +u64 length =xe_vma_size (vma);u64 align, end;if (length <SZ_4K )
@@ -215,12 +215,12 @@ int xe_gt_tlb_invalidation_vma(struct xe_gt *gt,* address mask covering the required range. */ align =roundup_pow_of_two (length); - start =ALIGN_DOWN (vma->start, align); - end =ALIGN (vma->start + length, align); + start =ALIGN_DOWN (xe_vma_start (vma), align); + end =ALIGN (xe_vma_start (vma) + length, align); length = align;while (start + length < end) { length <<=1 ; - start =ALIGN_DOWN (vma->start, length); + start =ALIGN_DOWN (xe_vma_start (vma), length); }/*
@@ -229,7 +229,7 @@ int xe_gt_tlb_invalidation_vma(struct xe_gt *gt,*/ if (length >=SZ_2M ) { length =max_t (u64,SZ_16M , length); - start =ALIGN_DOWN (vma->start, length); + start =ALIGN_DOWN (xe_vma_start (vma), length); }XE_BUG_ON (length <SZ_4K );
@@ -238,7 +238,7 @@ int xe_gt_tlb_invalidation_vma(struct xe_gt *gt,XE_BUG_ON (!IS_ALIGNED (start, length)); action[len++] =MAKE_INVAL_OP (XE_GUC_TLB_INVAL_PAGE_SELECTIVE ); - action[len++] = vma->vm->usm.asid; + action[len++] =xe_vma_vm (vma)->usm.asid; action[len++] =lower_32_bits (start); action[len++] =upper_32_bits (start); action[len++] =ilog2 (length) -ilog2 (SZ_4K );
drivers/gpu/drm/xe/xe_guc_ct.c +3 -3
@@ -783,13 +783,13 @@ static int parse_g2h_response(struct xe_guc_ct *ct, u32 *msg, u32 len)if (type ==GUC_HXG_TYPE_RESPONSE_FAILURE ) { g2h_fence->fail = true; g2h_fence->error = -FIELD_GET (GUC_HXG_FAILURE_MSG_0_ERROR , msg[0 ]); +FIELD_GET (GUC_HXG_FAILURE_MSG_0_ERROR , msg[1 ]); g2h_fence->hint = -FIELD_GET (GUC_HXG_FAILURE_MSG_0_HINT , msg[0 ]); +FIELD_GET (GUC_HXG_FAILURE_MSG_0_HINT , msg[1 ]); }else if (type ==GUC_HXG_TYPE_NO_RESPONSE_RETRY ) { g2h_fence->retry = true; g2h_fence->reason = -FIELD_GET (GUC_HXG_RETRY_MSG_0_REASON , msg[0 ]); +FIELD_GET (GUC_HXG_RETRY_MSG_0_REASON , msg[1 ]); }else if (g2h_fence->response_buffer) { g2h_fence->response_len = response_len; memcpy(g2h_fence->response_buffer, msg + GUC_CTB_MSG_MIN_LEN,
drivers/gpu/drm/xe/xe_migrate.c +4 -1
@@ -992,6 +992,7 @@ xe_migrate_update_pgtables_cpu(struct xe_migrate *m,if (wait_vm) {long wait; +vm_dbg (&vm->xe->drm,"wait on VM for munmap" ); wait =dma_resv_wait_timeout (&vm->resv,DMA_RESV_USAGE_BOOKKEEP , true,HZ /100 );
@@ -1089,7 +1090,8 @@ xe_migrate_update_pgtables(struct xe_migrate *m,u64 addr;int err =0 ;bool usm = !eng && xe->info.supports_usm; -bool first_munmap_rebind = vma && vma->first_munmap_rebind; +bool first_munmap_rebind = vma && + vma->gpuva.flags &XE_VMA_FIRST_REBIND ;/* Use the CPU if no in syncs and engine is idle */ if (no_in_syncs (syncs, num_syncs) &&engine_is_idle (eng)) {
@@ -1210,6 +1212,7 @@ xe_migrate_update_pgtables(struct xe_migrate *m,* trigger preempts before moving forward */ if (first_munmap_rebind) { +vm_dbg (&vm->xe->drm,"wait on first_munmap_rebind" ); err =job_add_deps (job, &vm->resv,DMA_RESV_USAGE_BOOKKEEP );if (err)
drivers/gpu/drm/xe/xe_pt.c +54 -51
285 lines not on this page · raw message
drivers/gpu/drm/xe/xe_trace.h +5 -5
@@ -18,7 +18,7 @@#include "xe_gt_types.h" #include "xe_guc_engine_types.h" #include "xe_sched_job.h" -#include "xe_vm_types.h" +#include "xe_vm.h" DECLARE_EVENT_CLASS(xe_gt_tlb_invalidation_fence, TP_PROTO(struct xe_gt_tlb_invalidation_fence *fence),
@@ -368,10 +368,10 @@ DECLARE_EVENT_CLASS(xe_vma,TP_fast_assign ( __entry->vma = (unsigned long)vma; - __entry->asid = vma->vm->usm.asid; - __entry->start = vma->start; - __entry->end = vma->end; - __entry->ptr = (u64 )vma->userptr.ptr; + __entry->asid =xe_vma_vm (vma)->usm.asid; + __entry->start =xe_vma_start (vma); + __entry->end =xe_vma_end (vma) -1 ; + __entry->ptr =xe_vma_userptr (vma); ), TP_printk("vma=0x%016llx, asid=0x%05x, start=0x%012llx, end=0x%012llx, ptr=0x%012llx,",
drivers/gpu/drm/xe/xe_vm.c +833 -959
2,402 lines not on this page · raw message
drivers/gpu/drm/xe/xe_vm.h +63 -3
90 lines not on this page · raw message
drivers/gpu/drm/xe/xe_vm_madvise.c +20 -67
15 lines not on this page · raw message
drivers/gpu/drm/xe/xe_vm_types.h +111 -54
165 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.34.1
Part of the diff is not shown here. View the raw message.
Matthew Brost
maintainerPATCH 4/4 drm/xe: NULL binding implementation
In reply to Matthew BrostAdd uAPI and implementation for NULL bindings. A NULL binding is defined as writes dropped and read zero. A single bit in the uAPI has been added which results in a single bit in the PTEs being set.
NULL bindings are indended to be used to implement VK sparse bindings.
--- drivers/gpu/drm/xe/xe_bo.h | 1 + drivers/gpu/drm/xe/xe_exec.c | 2 + drivers/gpu/drm/xe/xe_gt_pagefault.c | 4 +- drivers/gpu/drm/xe/xe_pt.c | 77 ++++++++++++++++------- drivers/gpu/drm/xe/xe_vm.c | 92 ++++++++++++++++++---------- drivers/gpu/drm/xe/xe_vm.h | 10 +++ drivers/gpu/drm/xe/xe_vm_madvise.c | 2 +- drivers/gpu/drm/xe/xe_vm_types.h | 3 + include/uapi/drm/xe_drm.h | 8 +++ 9 files changed, 144 insertions(+), 55 deletions(-)
drivers/gpu/drm/xe/xe_bo.h +1 -0
@@ -54,6 +54,7 @@#define GEN8_PDE_IPS_64K BIT_ULL(11)#define GEN12_GGTT_PTE_LM BIT_ULL(1) +#define GEN12_PTE_NULL BIT_ULL(9)#define GEN12_USM_PPGTT_PTE_AE BIT_ULL(10)#define GEN12_PPGTT_PTE_LM BIT_ULL(11)#define GEN12_PDE_64K BIT_ULL(6)
drivers/gpu/drm/xe/xe_exec.c +2 -0
@@ -115,6 +115,8 @@ static int xe_exec_begin(struct xe_engine *e, struct ww_acquire_ctx *ww,* to a location where the GPU can access it). */ list_for_each_entry (vma, &vm->rebind_list, rebind_link) { +XE_BUG_ON (xe_vma_is_null (vma)); +if (xe_vma_is_userptr (vma))continue ;
drivers/gpu/drm/xe/xe_gt_pagefault.c +2 -2
@@ -526,8 +526,8 @@ static int handle_acc(struct xe_gt *gt, struct acc *acc)trace_xe_vma_acc (vma); -/* Userptr can't be migrated, nothing to do */ -if (xe_vma_is_userptr (vma)) +/* Userptr or null can't be migrated, nothing to do */ +if (xe_vma_has_no_bo (vma)) goto unlock_vm;/* Lock VM and BOs dma-resv */
drivers/gpu/drm/xe/xe_pt.c +56 -21
157 lines not on this page · raw message
drivers/gpu/drm/xe/xe_vm.c +61 -31
241 lines not on this page · raw message
drivers/gpu/drm/xe/xe_vm.h +10 -0
@@ -158,7 +158,17 @@ extern struct ttm_device_funcs xe_ttm_funcs;struct ttm_buffer_object *xe_vm_ttm_bo (struct xe_vm *vm); +static inline bool xe_vma_is_null (struct xe_vma *vma) +{ +return vma->gpuva.flags &XE_VMA_NULL ; +} +static inline bool xe_vma_is_userptr (struct xe_vma *vma) +{ +return !xe_vma_bo (vma) && !xe_vma_is_null (vma); +} + +static inline bool xe_vma_has_no_bo (struct xe_vma *vma) {return !xe_vma_bo (vma); }
drivers/gpu/drm/xe/xe_vm_madvise.c +1 -1
@@ -226,7 +226,7 @@ get_vmas(struct xe_vm *vm, int *num_vmas, u64 addr, u64 range)drm_gpuva_iter_for_each_range (it, addr + range) {struct xe_vma *vma =gpuva_to_vma (it.va); -if (xe_vma_is_userptr (vma)) +if (xe_vma_has_no_bo (vma))continue ;if (*num_vmas == max_vmas) {
drivers/gpu/drm/xe/xe_vm_types.h +3 -0
@@ -29,6 +29,7 @@ struct xe_vm;#define XE_VMA_ATOMIC_PTE_BIT (DRM_GPUVA_USERBITS << 2)#define XE_VMA_FIRST_REBIND (DRM_GPUVA_USERBITS << 3)#define XE_VMA_LAST_REBIND (DRM_GPUVA_USERBITS << 4) +#define XE_VMA_NULL (DRM_GPUVA_USERBITS << 5)struct xe_vma {/** @gpuva: Base GPUVA object */
@@ -307,6 +308,8 @@ struct xe_vma_op_map {bool immediate;/** @read_only: Read only */ bool read_only; +/** @null: NULL (writes dropped, read zero) */ +bool null; };/** struct xe_vma_op_unmap - VMA unmap operation */
include/uapi/drm/xe_drm.h +8 -0
@@ -446,6 +446,14 @@ struct drm_xe_vm_bind_op {* than differing the MAP to the page fault handler. */ #define XE_VM_BIND_FLAG_IMMEDIATE (0x1 << 18) +/* +* When the NULL flag is set, the page tables are setup with a special +* bit which indicates writes are dropped and all reads return zero. The +* NULL flags is only valid for XE_VM_BIND_OP_MAP operations, the BO +* handle MBZ, and the BO offset MBZ. This flag is intended to implement +* VK sparse bindings. +*/ +#define XE_VM_BIND_FLAG_NULL (0x1 << 19)/** @reserved: Reserved */ __u64 reserved[2 ];
Signature · 1 line
2.34.1
Patchwork
CI[Intel-xe] ✓ CI.Patch_applied: success for Port Xe to use GPUVA and implement NULL VM binds
In reply to Matthew Brost== Series Details ==
== Series Details ==
Series: Port Xe to use GPUVA and implement NULL VM binds
URL : https://patchwork.freedesktop.org/series/115217/
State : success
== Summary ==
=== Applying kernel patches on branch 'drm-xe-next' with base: === commit 8f6c3eaf3f9daab25b31e80c8ba277877fd10547
Author: Mauro Carvalho Chehab <[email protected]> AuthorDate: Fri Mar 10 09:13:39 2023 +0100 Commit: Lucas De Marchi <[email protected]> CommitDate: Wed Mar 15 10:28:56 2023 -0700
drm/xe/xe_uc_fw: Use firmware files from standard locations
The GuC/HuC firmware files used by Xe drivers are the same as used by i915. Use the already-known location to find those firmware files, for a couple of reasons:
1. Avoid having the same firmware placed on two different places on MODULE_FIRMWARE(), if both 915 and xe drivers are compiled;
2. Having firmware files located on different locations may end creating bigger initramfs, as the same files will be copied twice my mkinitrd/dracut/...;
3. this is the place where those firmware files are located at
https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git
Upstream doesn't expect them to have on other places;
4. When built with display support, DMC firmware will be loaded from i915/ directory. It is very confusing to have some firmware files on a different place for the same driver.
[ Mostly agree with the direction of "use the firmware blobs from
upstream at their current location for these platforms". Previous directory was not wrong as the plan was to have it handled in the upstream firmware repo. For future platforms the location can be changed if the support is only in xe ]
=== git am output follows ===
Applying: maple_tree: split up MA_STATE() macro
Applying: drm: manager to keep track of GPUs VA mappings
Applying: drm/xe: Port Xe to GPUVA
Applying: drm/xe: NULL binding implementation
Patchwork
CI[Intel-xe] ✗ CI.KUnit: failure for Port Xe to use GPUVA and implement NULL VM binds
In reply to Matthew Brost== Series Details ==
== Series Details ==
Series: Port Xe to use GPUVA and implement NULL VM binds
URL : https://patchwork.freedesktop.org/series/115217/
State : failure
== Summary ==
+ trap cleanup EXIT
+ /kernel/tools/testing/kunit/kunit.py run --kunitconfig /kernel/drivers/gpu/drm/xe/.kunitconfig ERROR:root:../drivers/gpu/drm/xe/xe_vm.c: In function ‘xe_vma_op_work_func’:../drivers/gpu/drm/xe/xe_vm.c:2722:4: error: label at end of compound statement
2722 | default:
| ^~~~~~~make[6]: *** [../scripts/Makefile.build:250: drivers/gpu/drm/xe/xe_vm.o] Error 1 make[6]: *** Waiting for unfinished jobs....
make[5]: *** [../scripts/Makefile.build:500: drivers/gpu/drm/xe] Error 2 make[4]: *** [../scripts/Makefile.build:500: drivers/gpu/drm] Error 2 make[3]: *** [../scripts/Makefile.build:500: drivers/gpu] Error 2 make[2]: *** [../scripts/Makefile.build:500: drivers] Error 2 make[1]: *** [/kernel/Makefile:1992: .] Error 2
make: *** [Makefile:231: __sub-make] Error 2
[18:27:59] Configuring KUnit Kernel ...
Generating .config ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig [18:28:03] Building KUnit Kernel ... Populating config with: $ make ARCH=um O=.kunit olddefconfig Building with: $ make ARCH=um O=.kunit --jobs=48 + cleanup ++ stat -c %u:%g /kernel + chown -R 1003:1003 /kernel