diff mbox series

[1/5] drm/ttm: fix eviction valuable range check.

Message ID 20201019222257.1684769-2-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>

This was adding size to start, but pfn and start are in pages,
so it should be using num_pages.

Not sure this fixes anything in the real world, just noticed it
during refactoring.

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

Comments

Christian König Oct. 20, 2020, 8:46 a.m. UTC | #1
Am 20.10.20 um 00:22 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> This was adding size to start, but pfn and start are in pages,
> so it should be using num_pages.
>
> Not sure this fixes anything in the real world, just noticed it
> during refactoring.

Oh, yes it most likely does!

> Signed-off-by: Dave Airlie <airlied@redhat.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

CC stable?

> ---
>   drivers/gpu/drm/ttm/ttm_bo.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index cbc74a320db2..3101650c01b4 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -620,7 +620,7 @@ bool ttm_bo_eviction_valuable(struct ttm_buffer_object *bo,
>   	/* Don't evict this BO if it's outside of the
>   	 * requested placement range
>   	 */
> -	if (place->fpfn >= (bo->mem.start + bo->mem.size) ||
> +	if (place->fpfn >= (bo->mem.start + bo->mem.num_pages) ||
>   	    (place->lpfn && place->lpfn <= bo->mem.start))
>   		return false;
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index cbc74a320db2..3101650c01b4 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -620,7 +620,7 @@  bool ttm_bo_eviction_valuable(struct ttm_buffer_object *bo,
 	/* Don't evict this BO if it's outside of the
 	 * requested placement range
 	 */
-	if (place->fpfn >= (bo->mem.start + bo->mem.size) ||
+	if (place->fpfn >= (bo->mem.start + bo->mem.num_pages) ||
 	    (place->lpfn && place->lpfn <= bo->mem.start))
 		return false;