diff mbox series

[2/5] drm/ttm: fix memcpy move bo size comparison

Message ID 20201019222257.1684769-3-airlied@gmail.com (mailing list archive)
State New, archived
Headers show
Series ttm fix range checks + drop some fields | expand

Commit Message

Dave Airlie Oct. 19, 2020, 10:22 p.m. UTC
From: Dave Airlie <airlied@redhat.com>

start is in page units, so compare with pages.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/ttm/ttm_bo_util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Christian König Oct. 20, 2020, 8:51 a.m. UTC | #1
You can just nuke the whole handling.

As far as I can see ttm_bo_move_memcpy() is never used with overlapping 
memory objects because those are illegal in TTM for other reasons.

Christian.

Am 20.10.20 um 00:22 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> start is in page units, so compare with pages.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
>   drivers/gpu/drm/ttm/ttm_bo_util.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
> index 558e78ad82aa..b31be57884ba 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_util.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
> @@ -268,7 +268,7 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
>   	dir = 1;
>   
>   	if ((old_mem->mem_type == new_mem->mem_type) &&
> -	    (new_mem->start < old_mem->start + old_mem->size)) {
> +	    (new_mem->start < old_mem->start + old_mem->num_pages)) {
>   		dir = -1;
>   		add = new_mem->num_pages - 1;
>   	}
diff mbox series

Patch

diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
index 558e78ad82aa..b31be57884ba 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -268,7 +268,7 @@  int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
 	dir = 1;
 
 	if ((old_mem->mem_type == new_mem->mem_type) &&
-	    (new_mem->start < old_mem->start + old_mem->size)) {
+	    (new_mem->start < old_mem->start + old_mem->num_pages)) {
 		dir = -1;
 		add = new_mem->num_pages - 1;
 	}