summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorJunwei Zhang <Jerry.Zhang@amd.com>2017-03-16 16:09:24 +0800
committerAlex Deucher <alexander.deucher@amd.com>2017-03-29 23:54:02 -0400
commit27f6d61036a8cb25d144c8bcc6c15e2b54cec566 (patch)
tree6ff3bb71d46dae9798faca9b06ceecda7bfd02ae /drivers
parent80f95c579d800fa22e9e57ecb3d50b9e93bc1f82 (diff)
drm/amdgpu: fix before and after mapping judgement for replace mapping
If the before mapping is 1 page size, so its start and last will be same. Thus below condition will become false, then to free the before mapping. > if (before->it.start != before->it.last) But in this case, we need the before mapping of 1 page size. So does after mapping. Signed-off-by: Junwei Zhang <Jerry.Zhang@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 2da08027ff29..1f811ef44ce7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -1704,12 +1704,14 @@ int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev,
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);
@@ -1719,7 +1721,7 @@ int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev,
/* 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;
@@ -1754,8 +1756,8 @@ int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev,
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);
@@ -1764,7 +1766,7 @@ int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *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);