before = kzalloc(sizeof(*before), GFP_KERNEL);
if (!before)
return -ENOMEM;
+ INIT_LIST_HEAD(&before->list);
after = kzalloc(sizeof(*after), GFP_KERNEL);
if (!after) {
kfree(before);
return -ENOMEM;
}
+ INIT_LIST_HEAD(&after->list);
/* Now gather all removed mappings */
it = interval_tree_iter_first(&vm->va, saddr, eaddr);
/* Remember mapping split at the start */
if (tmp->it.start < saddr) {
- before->it.start = tmp->it.start;;
+ before->it.start = tmp->it.start;
before->it.last = saddr - 1;
before->offset = tmp->offset;
before->flags = tmp->flags;
trace_amdgpu_vm_bo_unmap(NULL, tmp);
}
- /* Insert partial mapping before the range*/
- if (before->it.start != before->it.last) {
+ /* Insert partial mapping before the range */
+ if (!list_empty(&before->list)) {
interval_tree_insert(&before->it, &vm->va);
if (before->flags & AMDGPU_PTE_PRT)
amdgpu_vm_prt_get(adev);
}
/* Insert partial mapping after the range */
- if (after->it.start != after->it.last) {
+ if (!list_empty(&after->list)) {
interval_tree_insert(&after->it, &vm->va);
if (after->flags & AMDGPU_PTE_PRT)
amdgpu_vm_prt_get(adev);