[PATCH] drm/ttm: fix bulk move handling during resource init

Alex Deucher alexdeucher at gmail.com
Thu Jun 2 16:54:26 UTC 2022


On Thu, Jun 2, 2022 at 11:47 AM Christian König
<ckoenig.leichtzumerken at gmail.com> wrote:
>
> The resource must be on the LRU before ttm_lru_bulk_move_add() is called.
>
> Signed-off-by: Christian König <christian.koenig at amd.com>

This should at least fix the null pointer in these bugs:

Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/1992
Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/2034

Alex

> ---
>  drivers/gpu/drm/ttm/ttm_resource.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_resource.c b/drivers/gpu/drm/ttm/ttm_resource.c
> index 65889b3caf50..928b9140f3c5 100644
> --- a/drivers/gpu/drm/ttm/ttm_resource.c
> +++ b/drivers/gpu/drm/ttm/ttm_resource.c
> @@ -169,15 +169,17 @@ void ttm_resource_init(struct ttm_buffer_object *bo,
>         res->bus.is_iomem = false;
>         res->bus.caching = ttm_cached;
>         res->bo = bo;
> -       INIT_LIST_HEAD(&res->lru);
>
>         man = ttm_manager_type(bo->bdev, place->mem_type);
>         spin_lock(&bo->bdev->lru_lock);
>         man->usage += res->num_pages << PAGE_SHIFT;
> -       if (bo->bulk_move)
> +       if (bo->bulk_move) {
> +               list_add_tail(&res->lru, &man->lru[bo->priority]);
>                 ttm_lru_bulk_move_add(bo->bulk_move, res);
> -       else
> +       } else {
> +               INIT_LIST_HEAD(&res->lru);
>                 ttm_resource_move_to_lru_tail(res);
> +       }
>         spin_unlock(&bo->bdev->lru_lock);
>  }
>  EXPORT_SYMBOL(ttm_resource_init);
> --
> 2.25.1
>


More information about the amd-gfx mailing list