Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Natalie Vock <nat@pixelcluster.dev>
To: intel-xe@lists.freedesktop.org,
	"Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Cc: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	"Arun Pravin" <arunpravin.paneerselvam@amd.com>,
	"Matthew Auld" <matthew.auld@intel.com>,
	"Matthew Brost" <matthew.brost@intel.com>,
	dri-devel@lists.freedesktop.org, stable@vger.kernel.org
Subject: Re: [PATCH] drm/ttm: Destroy the ttm_tt in ttm_bo_move_null() when it's no longer needed
Date: Fri, 04 Dec 2026 15:54:11 +0100	[thread overview]
Message-ID: <XCxCL68CSaedPpfBDvs9nQ@pixelcluster.dev> (raw)
In-Reply-To: <20261124190954.47690-1-thomas.hellstrom@linux.intel.com>

On Tuesday, 24 November 2026 20:09 Thomas Hellström wrote:
> The xe kmd uses ttm_bo_move_null() when moving an unpopulated bo to
> VRAM. In that case the bo may still carry a ttm_tt that was created
> for its deferred placement, and it is left dangling on a bo whose new
> resource doesn't use a ttm_tt.
> 
> Make ttm_bo_move_null() destroy the bo's ttm_tt when @new_mem is NULL
> or its memory type manager doesn't use a ttm_tt.
> 
> ttm_bo_tt_destroy() is internal to TTM and not exported. Rather than
> exporting it, move ttm_bo_move_null() out to ttm_bo_util.c and
> export that instead.
> 
> Patch and commit message was drafted using an LLM.
> 
> Fixes: dd08ebf6c352 ("drm/xe: Introduce a new DRM driver for Intel GPUs")
> Cc: Natalie Vock <nat@pixelcluster.dev>
> Cc: Arun Pravin <arunpravin.paneerselvam@amd.com>
> Cc: Matthew Auld <matthew.auld@intel.com>
> Cc: Matthew Brost <matthew.brost@intel.com>
> Cc: dri-devel@lists.freedesktop.org
> Cc: <stable@vger.kernel.org> # v6.8+
> Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>

Reviewed-by: Natalie Vock <nat@pixelcluster.dev>

> ---
>  drivers/gpu/drm/ttm/ttm_bo_util.c | 20 ++++++++++++++++++++
>  include/drm/ttm/ttm_bo.h          | 15 ++-------------
>  2 files changed, 22 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
> index f9458a4d5a09..7f3459db596a 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_util.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
> @@ -202,6 +202,26 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
>  }
>  EXPORT_SYMBOL(ttm_bo_move_memcpy);
>  
> +/**
> + * ttm_bo_move_null() - assign memory for a buffer object.
> + * @bo: The bo to assign the memory to.
> + * @new_mem: The memory to be assigned, or NULL.
> + *
> + * Free the current resource of @bo and assign @new_mem to it. If @new_mem is
> + * NULL or its memory type manager doesn't use a &struct ttm_tt, the bo's
> + * &struct ttm_tt, if any, is unpopulated and destroyed.
> + */
> +void ttm_bo_move_null(struct ttm_buffer_object *bo,
> +		      struct ttm_resource *new_mem)
> +{
> +	if (!new_mem || !ttm_manager_type(bo->bdev, new_mem->mem_type)->use_tt)
> +		ttm_bo_tt_destroy(bo);
> +
> +	ttm_resource_free(bo, &bo->resource);
> +	ttm_bo_assign_mem(bo, new_mem);
> +}
> +EXPORT_SYMBOL(ttm_bo_move_null);
> +
>  static void ttm_transfered_destroy(struct ttm_buffer_object *bo)
>  {
>  	struct ttm_transfer_obj *fbo;
> diff --git a/include/drm/ttm/ttm_bo.h b/include/drm/ttm/ttm_bo.h
> index 32791c4db2a9..d525e04893ed 100644
> --- a/include/drm/ttm/ttm_bo.h
> +++ b/include/drm/ttm/ttm_bo.h
> @@ -356,19 +356,8 @@ static inline void ttm_bo_assign_mem(struct ttm_buffer_object *bo,
>  	bo->resource = new_mem;
>  }
>  
> -/**
> - * ttm_bo_move_null - assign memory for a buffer object.
> - * @bo: The bo to assign the memory to
> - * @new_mem: The memory to be assigned.
> - *
> - * Assign the memory from new_mem to the memory of the buffer object bo.
> - */
> -static inline void ttm_bo_move_null(struct ttm_buffer_object *bo,
> -				    struct ttm_resource *new_mem)
> -{
> -	ttm_resource_free(bo, &bo->resource);
> -	ttm_bo_assign_mem(bo, new_mem);
> -}
> +void ttm_bo_move_null(struct ttm_buffer_object *bo,
> +		      struct ttm_resource *new_mem);
>  
>  /**
>   * ttm_bo_unreserve
> 





      parent reply	other threads:[~2026-12-04 15:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 19:09 [PATCH] drm/ttm: Destroy the ttm_tt in ttm_bo_move_null() when it's no longer needed Thomas Hellström
2026-11-24 19:53 ` Matthew Brost
2026-11-25  9:30   ` Thomas Hellström
2026-11-24 19:58 ` ✓ CI.KUnit: success for " Patchwork
2026-11-24 20:42 ` ✓ Xe.CI.BAT: " Patchwork
2026-11-24 22:09 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-11-25  9:33   ` Thomas Hellström
2026-11-25  9:55 ` [PATCH] " Matthew Auld
2026-12-04 14:54 ` Natalie Vock [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=XCxCL68CSaedPpfBDvs9nQ@pixelcluster.dev \
    --to=nat@pixelcluster.dev \
    --cc=arunpravin.paneerselvam@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.auld@intel.com \
    --cc=matthew.brost@intel.com \
    --cc=stable@vger.kernel.org \
    --cc=thomas.hellstrom@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox