-----Original Message----- From: dri-devel [mailto:dri-devel-bounces@xxxxxxxxxxxxxxxxxxxxx] On Behalf Of Thomas Hellstrom Sent: Thursday, December 21, 2017 3:51 PM To: dri-devel@xxxxxxxxxxxxxxxxxxxxx Subject: Re: [PATCH 6/7] drm/ttm: add ttm_bo_evict_swapout_allowable to check bo is allowable to evict or swapout On 12/20/2017 11:35 AM, Roger He wrote: > extract this function since eviction and swapout share same logic But it's only used in eviction? Yes, currently it only used in eviction. And will be used in Swapout. > > Change-Id: I80a475a93fceed8d66d74a1832c815a0756341ac > Signed-off-by: Roger He <Hongbo.He@xxxxxxx> > --- > drivers/gpu/drm/ttm/ttm_bo.c | 29 +++++++++++++++++++---------- > 1 file changed, 19 insertions(+), 10 deletions(-) > > diff --git a/drivers/gpu/drm/ttm/ttm_bo.c > b/drivers/gpu/drm/ttm/ttm_bo.c index e7595b4..313925c 100644 > --- a/drivers/gpu/drm/ttm/ttm_bo.c > +++ b/drivers/gpu/drm/ttm/ttm_bo.c > @@ -706,6 +706,23 @@ bool ttm_bo_eviction_valuable(struct ttm_buffer_object *bo, > } > EXPORT_SYMBOL(ttm_bo_eviction_valuable); > > +static bool ttm_bo_evict_swapout_allowable(struct ttm_buffer_object *bo, > + struct ttm_operation_ctx *ctx, bool *locked) Could we have a description in the code what this function actually does? admittedly it checks whether a swapout or eviction is allowable, but it aso performs a recursive tryreserve(), and that is of value to any future code reader.? Ok. Thanks Roger(Hongbo.He) /Thomas > +{ > + bool ret = false; > + > + *locked = false; > + if (bo->resv == ctx->resv) { > + if (ctx->allow_reserved_eviction || !list_empty(&bo->ddestroy)) > + ret = true; > + } else { > + *locked = reservation_object_trylock(bo->resv); > + ret = *locked; > + } > + > + return ret; > +} > + > static int ttm_mem_evict_first(struct ttm_bo_device *bdev, > uint32_t mem_type, > const struct ttm_place *place, @@ -721,21 +738,13 @@ > static int ttm_mem_evict_first(struct ttm_bo_device *bdev, > spin_lock(&glob->lru_lock); > for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { > list_for_each_entry(bo, &man->lru[i], lru) { > - if (bo->resv == ctx->resv) { > - if (!ctx->allow_reserved_eviction && > - list_empty(&bo->ddestroy)) > - continue; > - } else { > - locked = reservation_object_trylock(bo->resv); > - if (!locked) > - continue; > - } > + if (!ttm_bo_evict_swapout_allowable(bo, ctx, &locked)) > + continue; > > if (place && !bdev->driver->eviction_valuable(bo, > place)) { > if (locked) > reservation_object_unlock(bo->resv); > - locked = false; > continue; > } > break; _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel