Skip to content

Commit 60c1620

Browse files
committed
Merge tag 'drm-xe-fixes-2024-02-08' of https://gitlab.freedesktop.org/drm/xe/kernel into drm-fixes
Driver Changes: - Fix a loop in an error path - Fix a missing dma-fence reference - Fix a retry path on userptr REMAP - Workaround for a false gcc warning - Fix missing map of the usm batch buffer in the migrate vm. - Fix a memory leak. - Fix a bad assumption of used page size - Fix hitting a BUG() due to zero pages to map. - Remove some leftover async bind queue relics Signed-off-by: Dave Airlie <[email protected]> From: Thomas Hellstrom <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/ZcS2LllawGifubsk@fedora
2 parents 6c2bf9c + bf4c27b commit 60c1620

File tree

9 files changed

+57
-65
lines changed

9 files changed

+57
-65
lines changed

drivers/gpu/drm/xe/xe_display.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,6 @@ static void xe_display_fini_nommio(struct drm_device *dev, void *dummy)
134134

135135
int xe_display_init_nommio(struct xe_device *xe)
136136
{
137-
int err;
138-
139137
if (!xe->info.enable_display)
140138
return 0;
141139

@@ -145,10 +143,6 @@ int xe_display_init_nommio(struct xe_device *xe)
145143
/* This must be called before any calls to HAS_PCH_* */
146144
intel_detect_pch(xe);
147145

148-
err = intel_power_domains_init(xe);
149-
if (err)
150-
return err;
151-
152146
return drmm_add_action_or_reset(&xe->drm, xe_display_fini_nommio, xe);
153147
}
154148

drivers/gpu/drm/xe/xe_exec_queue.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -926,20 +926,24 @@ void xe_exec_queue_last_fence_put_unlocked(struct xe_exec_queue *q)
926926
* @q: The exec queue
927927
* @vm: The VM the engine does a bind or exec for
928928
*
929-
* Get last fence, does not take a ref
929+
* Get last fence, takes a ref
930930
*
931931
* Returns: last fence if not signaled, dma fence stub if signaled
932932
*/
933933
struct dma_fence *xe_exec_queue_last_fence_get(struct xe_exec_queue *q,
934934
struct xe_vm *vm)
935935
{
936+
struct dma_fence *fence;
937+
936938
xe_exec_queue_last_fence_lockdep_assert(q, vm);
937939

938940
if (q->last_fence &&
939941
test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &q->last_fence->flags))
940942
xe_exec_queue_last_fence_put(q, vm);
941943

942-
return q->last_fence ? q->last_fence : dma_fence_get_stub();
944+
fence = q->last_fence ? q->last_fence : dma_fence_get_stub();
945+
dma_fence_get(fence);
946+
return fence;
943947
}
944948

945949
/**

drivers/gpu/drm/xe/xe_gt.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,10 @@ static int all_fw_domain_init(struct xe_gt *gt)
437437
* USM has its only SA pool to non-block behind user operations
438438
*/
439439
if (gt_to_xe(gt)->info.has_usm) {
440-
gt->usm.bb_pool = xe_sa_bo_manager_init(gt_to_tile(gt), SZ_1M, 16);
440+
struct xe_device *xe = gt_to_xe(gt);
441+
442+
gt->usm.bb_pool = xe_sa_bo_manager_init(gt_to_tile(gt),
443+
IS_DGFX(xe) ? SZ_1M : SZ_512K, 16);
441444
if (IS_ERR(gt->usm.bb_pool)) {
442445
err = PTR_ERR(gt->usm.bb_pool);
443446
goto err_force_wake;

drivers/gpu/drm/xe/xe_gt_pagefault.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ int xe_guc_pagefault_handler(struct xe_guc *guc, u32 *msg, u32 len)
335335
return -EPROTO;
336336

337337
asid = FIELD_GET(PFD_ASID, msg[1]);
338-
pf_queue = &gt->usm.pf_queue[asid % NUM_PF_QUEUE];
338+
pf_queue = gt->usm.pf_queue + (asid % NUM_PF_QUEUE);
339339

340340
spin_lock_irqsave(&pf_queue->lock, flags);
341341
full = pf_queue_full(pf_queue);

drivers/gpu/drm/xe/xe_migrate.c

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,6 @@ static int xe_migrate_prepare_vm(struct xe_tile *tile, struct xe_migrate *m,
170170
if (!IS_DGFX(xe)) {
171171
/* Write out batch too */
172172
m->batch_base_ofs = NUM_PT_SLOTS * XE_PAGE_SIZE;
173-
if (xe->info.has_usm) {
174-
batch = tile->primary_gt->usm.bb_pool->bo;
175-
m->usm_batch_base_ofs = m->batch_base_ofs;
176-
}
177-
178173
for (i = 0; i < batch->size;
179174
i += vm->flags & XE_VM_FLAG_64K ? XE_64K_PAGE_SIZE :
180175
XE_PAGE_SIZE) {
@@ -185,6 +180,24 @@ static int xe_migrate_prepare_vm(struct xe_tile *tile, struct xe_migrate *m,
185180
entry);
186181
level++;
187182
}
183+
if (xe->info.has_usm) {
184+
xe_tile_assert(tile, batch->size == SZ_1M);
185+
186+
batch = tile->primary_gt->usm.bb_pool->bo;
187+
m->usm_batch_base_ofs = m->batch_base_ofs + SZ_1M;
188+
xe_tile_assert(tile, batch->size == SZ_512K);
189+
190+
for (i = 0; i < batch->size;
191+
i += vm->flags & XE_VM_FLAG_64K ? XE_64K_PAGE_SIZE :
192+
XE_PAGE_SIZE) {
193+
entry = vm->pt_ops->pte_encode_bo(batch, i,
194+
pat_index, 0);
195+
196+
xe_map_wr(xe, &bo->vmap, map_ofs + level * 8, u64,
197+
entry);
198+
level++;
199+
}
200+
}
188201
} else {
189202
u64 batch_addr = xe_bo_addr(batch, 0, XE_PAGE_SIZE);
190203

@@ -1204,8 +1217,11 @@ static bool no_in_syncs(struct xe_vm *vm, struct xe_exec_queue *q,
12041217
}
12051218
if (q) {
12061219
fence = xe_exec_queue_last_fence_get(q, vm);
1207-
if (!test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags))
1220+
if (!test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) {
1221+
dma_fence_put(fence);
12081222
return false;
1223+
}
1224+
dma_fence_put(fence);
12091225
}
12101226

12111227
return true;

drivers/gpu/drm/xe/xe_sched_job.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,6 @@ int xe_sched_job_last_fence_add_dep(struct xe_sched_job *job, struct xe_vm *vm)
274274
struct dma_fence *fence;
275275

276276
fence = xe_exec_queue_last_fence_get(job->q, vm);
277-
dma_fence_get(fence);
278277

279278
return drm_sched_job_add_dependency(&job->drm, fence);
280279
}

drivers/gpu/drm/xe/xe_sync.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,6 @@ xe_sync_in_fence_get(struct xe_sync_entry *sync, int num_sync,
307307
/* Easy case... */
308308
if (!num_in_fence) {
309309
fence = xe_exec_queue_last_fence_get(q, vm);
310-
dma_fence_get(fence);
311310
return fence;
312311
}
313312

@@ -322,7 +321,6 @@ xe_sync_in_fence_get(struct xe_sync_entry *sync, int num_sync,
322321
}
323322
}
324323
fences[current_fence++] = xe_exec_queue_last_fence_get(q, vm);
325-
dma_fence_get(fences[current_fence - 1]);
326324
cf = dma_fence_array_create(num_in_fence, fences,
327325
vm->composite_fence_ctx,
328326
vm->composite_fence_seqno++,

drivers/gpu/drm/xe/xe_vm.c

Lines changed: 24 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737
#include "generated/xe_wa_oob.h"
3838
#include "xe_wa.h"
3939

40-
#define TEST_VM_ASYNC_OPS_ERROR
41-
4240
static struct drm_gem_object *xe_vm_obj(struct xe_vm *vm)
4341
{
4442
return vm->gpuvm.r_obj;
@@ -114,11 +112,8 @@ int xe_vma_userptr_pin_pages(struct xe_userptr_vma *uvma)
114112
num_pages - pinned,
115113
read_only ? 0 : FOLL_WRITE,
116114
&pages[pinned]);
117-
if (ret < 0) {
118-
if (in_kthread)
119-
ret = 0;
115+
if (ret < 0)
120116
break;
121-
}
122117

123118
pinned += ret;
124119
ret = 0;
@@ -1984,6 +1979,7 @@ static int xe_vm_prefetch(struct xe_vm *vm, struct xe_vma *vma,
19841979
xe_exec_queue_last_fence_get(wait_exec_queue, vm);
19851980

19861981
xe_sync_entry_signal(&syncs[i], NULL, fence);
1982+
dma_fence_put(fence);
19871983
}
19881984
}
19891985

@@ -2064,7 +2060,6 @@ vm_bind_ioctl_ops_create(struct xe_vm *vm, struct xe_bo *bo,
20642060
struct drm_gem_object *obj = bo ? &bo->ttm.base : NULL;
20652061
struct drm_gpuva_ops *ops;
20662062
struct drm_gpuva_op *__op;
2067-
struct xe_vma_op *op;
20682063
struct drm_gpuvm_bo *vm_bo;
20692064
int err;
20702065

@@ -2111,15 +2106,6 @@ vm_bind_ioctl_ops_create(struct xe_vm *vm, struct xe_bo *bo,
21112106
if (IS_ERR(ops))
21122107
return ops;
21132108

2114-
#ifdef TEST_VM_ASYNC_OPS_ERROR
2115-
if (operation & FORCE_ASYNC_OP_ERROR) {
2116-
op = list_first_entry_or_null(&ops->list, struct xe_vma_op,
2117-
base.entry);
2118-
if (op)
2119-
op->inject_error = true;
2120-
}
2121-
#endif
2122-
21232109
drm_gpuva_for_each_op(__op, ops) {
21242110
struct xe_vma_op *op = gpuva_op_to_vma_op(__op);
21252111

@@ -2199,8 +2185,10 @@ static u64 xe_vma_max_pte_size(struct xe_vma *vma)
21992185
return SZ_1G;
22002186
else if (vma->gpuva.flags & XE_VMA_PTE_2M)
22012187
return SZ_2M;
2188+
else if (vma->gpuva.flags & XE_VMA_PTE_4K)
2189+
return SZ_4K;
22022190

2203-
return SZ_4K;
2191+
return SZ_1G; /* Uninitialized, used max size */
22042192
}
22052193

22062194
static u64 xe_vma_set_pte_size(struct xe_vma *vma, u64 size)
@@ -2530,13 +2518,25 @@ static int __xe_vma_op_execute(struct xe_vm *vm, struct xe_vma *vma,
25302518
}
25312519
drm_exec_fini(&exec);
25322520

2533-
if (err == -EAGAIN && xe_vma_is_userptr(vma)) {
2521+
if (err == -EAGAIN) {
25342522
lockdep_assert_held_write(&vm->lock);
2535-
err = xe_vma_userptr_pin_pages(to_userptr_vma(vma));
2536-
if (!err)
2537-
goto retry_userptr;
25382523

2539-
trace_xe_vma_fail(vma);
2524+
if (op->base.op == DRM_GPUVA_OP_REMAP) {
2525+
if (!op->remap.unmap_done)
2526+
vma = gpuva_to_vma(op->base.remap.unmap->va);
2527+
else if (op->remap.prev)
2528+
vma = op->remap.prev;
2529+
else
2530+
vma = op->remap.next;
2531+
}
2532+
2533+
if (xe_vma_is_userptr(vma)) {
2534+
err = xe_vma_userptr_pin_pages(to_userptr_vma(vma));
2535+
if (!err)
2536+
goto retry_userptr;
2537+
2538+
trace_xe_vma_fail(vma);
2539+
}
25402540
}
25412541

25422542
return err;
@@ -2548,13 +2548,6 @@ static int xe_vma_op_execute(struct xe_vm *vm, struct xe_vma_op *op)
25482548

25492549
lockdep_assert_held_write(&vm->lock);
25502550

2551-
#ifdef TEST_VM_ASYNC_OPS_ERROR
2552-
if (op->inject_error) {
2553-
op->inject_error = false;
2554-
return -ENOMEM;
2555-
}
2556-
#endif
2557-
25582551
switch (op->base.op) {
25592552
case DRM_GPUVA_OP_MAP:
25602553
ret = __xe_vma_op_execute(vm, op->map.vma, op);
@@ -2669,7 +2662,7 @@ static void vm_bind_ioctl_ops_unwind(struct xe_vm *vm,
26692662
{
26702663
int i;
26712664

2672-
for (i = num_ops_list - 1; i; ++i) {
2665+
for (i = num_ops_list - 1; i >= 0; --i) {
26732666
struct drm_gpuva_ops *__ops = ops[i];
26742667
struct drm_gpuva_op *__op;
26752668

@@ -2714,16 +2707,9 @@ static int vm_bind_ioctl_ops_execute(struct xe_vm *vm,
27142707
return 0;
27152708
}
27162709

2717-
#ifdef TEST_VM_ASYNC_OPS_ERROR
2718-
#define SUPPORTED_FLAGS \
2719-
(FORCE_ASYNC_OP_ERROR | DRM_XE_VM_BIND_FLAG_READONLY | \
2720-
DRM_XE_VM_BIND_FLAG_IMMEDIATE | DRM_XE_VM_BIND_FLAG_NULL | 0xffff)
2721-
#else
27222710
#define SUPPORTED_FLAGS \
27232711
(DRM_XE_VM_BIND_FLAG_READONLY | \
2724-
DRM_XE_VM_BIND_FLAG_IMMEDIATE | DRM_XE_VM_BIND_FLAG_NULL | \
2725-
0xffff)
2726-
#endif
2712+
DRM_XE_VM_BIND_FLAG_IMMEDIATE | DRM_XE_VM_BIND_FLAG_NULL)
27272713
#define XE_64K_PAGE_MASK 0xffffull
27282714
#define ALL_DRM_XE_SYNCS_FLAGS (DRM_XE_SYNCS_FLAG_WAIT_FOR_OP)
27292715

drivers/gpu/drm/xe/xe_vm_types.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ struct xe_bo;
2121
struct xe_sync_entry;
2222
struct xe_vm;
2323

24-
#define TEST_VM_ASYNC_OPS_ERROR
25-
#define FORCE_ASYNC_OP_ERROR BIT(31)
26-
2724
#define XE_VMA_READ_ONLY DRM_GPUVA_USERBITS
2825
#define XE_VMA_DESTROYED (DRM_GPUVA_USERBITS << 1)
2926
#define XE_VMA_ATOMIC_PTE_BIT (DRM_GPUVA_USERBITS << 2)
@@ -360,11 +357,6 @@ struct xe_vma_op {
360357
/** @flags: operation flags */
361358
enum xe_vma_op_flags flags;
362359

363-
#ifdef TEST_VM_ASYNC_OPS_ERROR
364-
/** @inject_error: inject error to test async op error handling */
365-
bool inject_error;
366-
#endif
367-
368360
union {
369361
/** @map: VMA map operation specific data */
370362
struct xe_vma_op_map map;

0 commit comments

Comments
 (0)