Re: [PATCH v3 05/25] drm/xe: Update xe_bo_put_deferred arguments to include writeback flag

Matthew Brost
2026-04-01T22:39:34Z

On Wed, Apr 01, 2026 at 02:20:06PM +0200, Francois Dugast wrote:
> On Fri, Feb 27, 2026 at 05:34:41PM -0800, Matthew Brost wrote:
> > Update the xe_bo_put_deferred arguments to include a writeback flag,
> > which indicates whether the BO was added to the deferred list. This is
> > useful when the caller needs to take additional actions after the BO has
> > been queued for deferred release.
> >
> > Signed-off-by: Matthew Brost <matthew.brost@intel.com>
> > ---
> > drivers/gpu/drm/xe/xe_bo.h | 10 ++++++++--
> > drivers/gpu/drm/xe/xe_drm_client.c | 2 +-
> > drivers/gpu/drm/xe/xe_pt.c | 2 +-
> > 3 files changed, 10 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/xe/xe_bo.h b/drivers/gpu/drm/xe/xe_bo.h
> > index c914ab719f20..bf284ed47325 100644
> > --- a/drivers/gpu/drm/xe/xe_bo.h
> > +++ b/drivers/gpu/drm/xe/xe_bo.h
> > @@ -348,6 +348,8 @@ void __xe_bo_release_dummy(struct kref *kref);
> > * @bo: The bo to put.
> > * @deferred: List to which to add the buffer object if we cannot put, or
> > * NULL if the function is to put unconditionally.
> > + * @added: BO was added to deferred list, written back to caller, can be NULL if
> > + * writeback is not needed.
>
> We should add in this comment that if set by the caller then it must be
> false, because this function only sets it to true. With that:
>

Yes, or I could just change this sematic as it is kinda goofy.

Matt

> Reviewed-by: Francois Dugast <francois.dugast@intel.com>
>
> > *
> > * Since the final freeing of an object includes both sleeping and (!)
> > * memory allocation in the dma_resv individualization, it's not ok
> > @@ -367,7 +369,8 @@ void __xe_bo_release_dummy(struct kref *kref);
> > * false otherwise.
> > */
> > static inline bool
> > -xe_bo_put_deferred(struct xe_bo *bo, struct llist_head *deferred)
> > +xe_bo_put_deferred(struct xe_bo *bo, struct llist_head *deferred,
> > + bool *added)
> > {
> > if (!deferred) {
> > xe_bo_put(bo);
> > @@ -377,6 +380,9 @@ xe_bo_put_deferred(struct xe_bo *bo, struct llist_head *deferred)
> > if (!kref_put(&bo->ttm.base.refcount, __xe_bo_release_dummy))
> > return false;
> >
> > + if (added)
> > + *added = true;
> > +
> > return llist_add(&bo->freed, deferred);
> > }
> >
> > @@ -393,7 +399,7 @@ xe_bo_put_async(struct xe_bo *bo)
> > {
> > struct xe_bo_dev *bo_device = &xe_bo_device(bo)->bo_device;
> >
> > - if (xe_bo_put_deferred(bo, &bo_device->async_list))
> > + if (xe_bo_put_deferred(bo, &bo_device->async_list, NULL))
> > schedule_work(&bo_device->async_free);
> > }
> >
> > diff --git a/drivers/gpu/drm/xe/xe_drm_client.c b/drivers/gpu/drm/xe/xe_drm_client.c
> > index 84b66147bf49..45efe7a55427 100644
> > --- a/drivers/gpu/drm/xe/xe_drm_client.c
> > +++ b/drivers/gpu/drm/xe/xe_drm_client.c
> > @@ -246,7 +246,7 @@ static void show_meminfo(struct drm_printer *p, struct drm_file *file)
> > xe_assert(xef->xe, !list_empty(&bo->client_link));
> > }
> >
> > - xe_bo_put_deferred(bo, &deferred);
> > + xe_bo_put_deferred(bo, &deferred, NULL);
> > }
> > spin_unlock(&client->bos_lock);
> >
> > diff --git a/drivers/gpu/drm/xe/xe_pt.c b/drivers/gpu/drm/xe/xe_pt.c
> > index 99b15d37267f..83dacc91b7b3 100644
> > --- a/drivers/gpu/drm/xe/xe_pt.c
> > +++ b/drivers/gpu/drm/xe/xe_pt.c
> > @@ -212,7 +212,7 @@ void xe_pt_destroy(struct xe_pt *pt, u32 flags, struct llist_head *deferred)
> >
> > XE_WARN_ON(!list_empty(&pt->bo->ttm.base.gpuva.list));
> > xe_bo_unpin(pt->bo);
> > - xe_bo_put_deferred(pt->bo, deferred);
> > + xe_bo_put_deferred(pt->bo, deferred, NULL);
> >
> > if (pt->level > 0 && pt->num_live) {
> > struct xe_pt_dir *pt_dir = as_xe_pt_dir(pt);
> > --
> > 2.34.1
> >