[PATCH 1/2] drm/ttm: add lru notify to bo driver v2
Koenig, Christian
Christian.Koenig at amd.com
Mon Jan 14 13:01:09 UTC 2019
Am 14.01.19 um 08:02 schrieb Chunming Zhou:
> allow driver do somethings when lru changed.
> v2:
> address Michel's comments.
>
> Change-Id: Ie82053da49272881d4b52b1c406f7c221a3fcadf
> Signed-off-by: Chunming Zhou <david1.zhou at amd.com>
Reviewed-by: Christian König <christian.koenig at amd.com>
> ---
> drivers/gpu/drm/ttm/ttm_bo.c | 11 +++++++----
> include/drm/ttm/ttm_bo_driver.h | 9 +++++++++
> 2 files changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 0ec08394e17a..de088c8070fb 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -198,19 +198,22 @@ static void ttm_bo_ref_bug(struct kref *list_kref)
>
> void ttm_bo_del_from_lru(struct ttm_buffer_object *bo)
> {
> + struct ttm_bo_device *bdev = bo->bdev;
> + bool notify = false;
> +
> if (!list_empty(&bo->swap)) {
> list_del_init(&bo->swap);
> kref_put(&bo->list_kref, ttm_bo_ref_bug);
> + notify = true;
> }
> if (!list_empty(&bo->lru)) {
> list_del_init(&bo->lru);
> kref_put(&bo->list_kref, ttm_bo_ref_bug);
> + notify = true;
> }
>
> - /*
> - * TODO: Add a driver hook to delete from
> - * driver-specific LRU's here.
> - */
> + if (notify && bdev->driver->del_from_lru_notify)
> + bdev->driver->del_from_lru_notify(bo);
> }
>
> void ttm_bo_del_sub_from_lru(struct ttm_buffer_object *bo)
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index 1021106438b2..15829b24277c 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -381,6 +381,15 @@ struct ttm_bo_driver {
> */
> int (*access_memory)(struct ttm_buffer_object *bo, unsigned long offset,
> void *buf, int len, int write);
> +
> + /**
> + * struct ttm_bo_driver member del_from_lru_notify
> + *
> + * @bo: the buffer object deleted from lru
> + *
> + * notify driver that a BO was deleted from LRU.
> + */
> + void (*del_from_lru_notify)(struct ttm_buffer_object *bo);
> };
>
> /**
More information about the amd-gfx
mailing list