Skip to content

Commit 34ebb62

Browse files
committed
drm/xe/vm: Update xe_vma_ops_incr_pt_update_ops to take an increment value
Prefetch for SVM ranges can have more than one operation to increment, hence modify the function to accept an increment value as input. v2: - Call xe_vma_ops_incr_pt_update_ops only once for REMAP (Matthew Brost) - Add check for 0 ops v3: - s/u8/int for inc_val and num_remap_ops (Matthew Brost) Suggested-by: Matthew Brost <matthew.brost@intel.com> Reviewed-by: Matthew Brost <matthew.brost@intel.com> Acked-by: Thomas Hellström <thomas.hellstrom@linux.intel.com> Link: https://lore.kernel.org/r/20250513040228.470682-7-himal.prasad.ghimiray@intel.com Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
1 parent da2eb41 commit 34ebb62

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

drivers/gpu/drm/xe/xe_vm.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -806,13 +806,16 @@ static void xe_vma_ops_fini(struct xe_vma_ops *vops)
806806
kfree(vops->pt_update_ops[i].ops);
807807
}
808808

809-
static void xe_vma_ops_incr_pt_update_ops(struct xe_vma_ops *vops, u8 tile_mask)
809+
static void xe_vma_ops_incr_pt_update_ops(struct xe_vma_ops *vops, u8 tile_mask, int inc_val)
810810
{
811811
int i;
812812

813+
if (!inc_val)
814+
return;
815+
813816
for (i = 0; i < XE_MAX_TILES_PER_DEVICE; ++i)
814817
if (BIT(i) & tile_mask)
815-
++vops->pt_update_ops[i].num_ops;
818+
vops->pt_update_ops[i].num_ops += inc_val;
816819
}
817820

818821
static void xe_vm_populate_rebind(struct xe_vma_op *op, struct xe_vma *vma,
@@ -842,7 +845,7 @@ static int xe_vm_ops_add_rebind(struct xe_vma_ops *vops, struct xe_vma *vma,
842845

843846
xe_vm_populate_rebind(op, vma, tile_mask);
844847
list_add_tail(&op->link, &vops->list);
845-
xe_vma_ops_incr_pt_update_ops(vops, tile_mask);
848+
xe_vma_ops_incr_pt_update_ops(vops, tile_mask, 1);
846849

847850
return 0;
848851
}
@@ -977,7 +980,7 @@ xe_vm_ops_add_range_rebind(struct xe_vma_ops *vops,
977980

978981
xe_vm_populate_range_rebind(op, vma, range, tile_mask);
979982
list_add_tail(&op->link, &vops->list);
980-
xe_vma_ops_incr_pt_update_ops(vops, tile_mask);
983+
xe_vma_ops_incr_pt_update_ops(vops, tile_mask, 1);
981984

982985
return 0;
983986
}
@@ -1062,7 +1065,7 @@ xe_vm_ops_add_range_unbind(struct xe_vma_ops *vops,
10621065

10631066
xe_vm_populate_range_unbind(op, range);
10641067
list_add_tail(&op->link, &vops->list);
1065-
xe_vma_ops_incr_pt_update_ops(vops, range->tile_present);
1068+
xe_vma_ops_incr_pt_update_ops(vops, range->tile_present, 1);
10661069

10671070
return 0;
10681071
}
@@ -2493,7 +2496,7 @@ static int vm_bind_ioctl_ops_parse(struct xe_vm *vm, struct drm_gpuva_ops *ops,
24932496
!op->map.is_cpu_addr_mirror) ||
24942497
op->map.invalidate_on_bind)
24952498
xe_vma_ops_incr_pt_update_ops(vops,
2496-
op->tile_mask);
2499+
op->tile_mask, 1);
24972500
break;
24982501
}
24992502
case DRM_GPUVA_OP_REMAP:
@@ -2502,6 +2505,7 @@ static int vm_bind_ioctl_ops_parse(struct xe_vm *vm, struct drm_gpuva_ops *ops,
25022505
gpuva_to_vma(op->base.remap.unmap->va);
25032506
bool skip = xe_vma_is_cpu_addr_mirror(old);
25042507
u64 start = xe_vma_start(old), end = xe_vma_end(old);
2508+
int num_remap_ops = 0;
25052509

25062510
if (op->base.remap.prev)
25072511
start = op->base.remap.prev->va.addr +
@@ -2554,7 +2558,7 @@ static int vm_bind_ioctl_ops_parse(struct xe_vm *vm, struct drm_gpuva_ops *ops,
25542558
(ULL)op->remap.start,
25552559
(ULL)op->remap.range);
25562560
} else {
2557-
xe_vma_ops_incr_pt_update_ops(vops, op->tile_mask);
2561+
num_remap_ops++;
25582562
}
25592563
}
25602564

@@ -2583,11 +2587,13 @@ static int vm_bind_ioctl_ops_parse(struct xe_vm *vm, struct drm_gpuva_ops *ops,
25832587
(ULL)op->remap.start,
25842588
(ULL)op->remap.range);
25852589
} else {
2586-
xe_vma_ops_incr_pt_update_ops(vops, op->tile_mask);
2590+
num_remap_ops++;
25872591
}
25882592
}
25892593
if (!skip)
2590-
xe_vma_ops_incr_pt_update_ops(vops, op->tile_mask);
2594+
num_remap_ops++;
2595+
2596+
xe_vma_ops_incr_pt_update_ops(vops, op->tile_mask, num_remap_ops);
25912597
break;
25922598
}
25932599
case DRM_GPUVA_OP_UNMAP:
@@ -2599,7 +2605,7 @@ static int vm_bind_ioctl_ops_parse(struct xe_vm *vm, struct drm_gpuva_ops *ops,
25992605
return -EBUSY;
26002606

26012607
if (!xe_vma_is_cpu_addr_mirror(vma))
2602-
xe_vma_ops_incr_pt_update_ops(vops, op->tile_mask);
2608+
xe_vma_ops_incr_pt_update_ops(vops, op->tile_mask, 1);
26032609
break;
26042610
case DRM_GPUVA_OP_PREFETCH:
26052611
vma = gpuva_to_vma(op->base.prefetch.va);
@@ -2611,7 +2617,7 @@ static int vm_bind_ioctl_ops_parse(struct xe_vm *vm, struct drm_gpuva_ops *ops,
26112617
}
26122618

26132619
if (!xe_vma_is_cpu_addr_mirror(vma))
2614-
xe_vma_ops_incr_pt_update_ops(vops, op->tile_mask);
2620+
xe_vma_ops_incr_pt_update_ops(vops, op->tile_mask, 1);
26152621
break;
26162622
default:
26172623
drm_warn(&vm->xe->drm, "NOT POSSIBLE");

0 commit comments

Comments
 (0)