drm/ttm: Fix ttm_bo_move_memcpy
All error paths will want to keep the mm node, so handle this at the function exit. This fixes an ioremap failure error path. Also add some comments to make the function a bit easier to understand. Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> Reviewed-by: Jakob Bornecrantz <jakob@vmware.com> Cc: stable@vger.kernel.org
This commit is contained in:
parent
9a0599ddea
commit
da95c788ef
|
@ -343,22 +343,26 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Single TTM move. NOP.
|
||||||
|
*/
|
||||||
if (old_iomap == NULL && new_iomap == NULL)
|
if (old_iomap == NULL && new_iomap == NULL)
|
||||||
goto out2;
|
goto out2;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Move nonexistent data. NOP.
|
||||||
|
*/
|
||||||
if (old_iomap == NULL && ttm == NULL)
|
if (old_iomap == NULL && ttm == NULL)
|
||||||
goto out2;
|
goto out2;
|
||||||
|
|
||||||
/* TTM might be null for moves within the same region.
|
/*
|
||||||
|
* TTM might be null for moves within the same region.
|
||||||
*/
|
*/
|
||||||
if (ttm && ttm->state == tt_unpopulated) {
|
if (ttm && ttm->state == tt_unpopulated) {
|
||||||
ret = ttm->bdev->driver->ttm_tt_populate(ttm);
|
ret = ttm->bdev->driver->ttm_tt_populate(ttm);
|
||||||
if (ret) {
|
if (ret)
|
||||||
/* if we fail here don't nuke the mm node
|
|
||||||
* as the bo still owns it */
|
|
||||||
old_copy.mm_node = NULL;
|
|
||||||
goto out1;
|
goto out1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
add = 0;
|
add = 0;
|
||||||
dir = 1;
|
dir = 1;
|
||||||
|
@ -383,12 +387,9 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
|
||||||
prot);
|
prot);
|
||||||
} else
|
} else
|
||||||
ret = ttm_copy_io_page(new_iomap, old_iomap, page);
|
ret = ttm_copy_io_page(new_iomap, old_iomap, page);
|
||||||
if (ret) {
|
if (ret)
|
||||||
/* failing here, means keep old copy as-is */
|
|
||||||
old_copy.mm_node = NULL;
|
|
||||||
goto out1;
|
goto out1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
mb();
|
mb();
|
||||||
out2:
|
out2:
|
||||||
old_copy = *old_mem;
|
old_copy = *old_mem;
|
||||||
|
@ -405,6 +406,11 @@ out1:
|
||||||
ttm_mem_reg_iounmap(bdev, old_mem, new_iomap);
|
ttm_mem_reg_iounmap(bdev, old_mem, new_iomap);
|
||||||
out:
|
out:
|
||||||
ttm_mem_reg_iounmap(bdev, &old_copy, old_iomap);
|
ttm_mem_reg_iounmap(bdev, &old_copy, old_iomap);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* On error, keep the mm node!
|
||||||
|
*/
|
||||||
|
if (!ret)
|
||||||
ttm_bo_mem_put(bo, &old_copy);
|
ttm_bo_mem_put(bo, &old_copy);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue