From: Matthew Brost <matthew.brost@intel.com>
To: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Cc: <intel-xe@lists.freedesktop.org>,
Natalie Vock <nat@pixelcluster.dev>,
Arun Pravin <arunpravin.paneerselvam@amd.com>,
Matthew Auld <matthew.auld@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: Tue, 24 Nov 2026 11:53:57 -0800 [thread overview]
Message-ID: <awXrVdQKNToiLtmE@gsse-cloud1.jf.intel.com> (raw)
In-Reply-To: <20261124190954.47690-1-thomas.hellstrom@linux.intel.com>
On Tue, Nov 24, 2026 at 08:09:54PM +0100, 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
I'm wondering if other drivers which use TTM + support VRAM (amdgpu,
Nouveau) have a similar problem or this really just an issue in Xe.
Either way I think this is safe and correct for any driver.
> 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>
Reviewed-by: 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>
> ---
> 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
> --
> 2.56.1
>
next prev parent reply other threads:[~2026-11-24 19:54 UTC|newest]
Thread overview: 8+ 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 [this message]
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
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=awXrVdQKNToiLtmE@gsse-cloud1.jf.intel.com \
--to=matthew.brost@intel.com \
--cc=arunpravin.paneerselvam@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.auld@intel.com \
--cc=nat@pixelcluster.dev \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.