From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5C96D606A693 for ; Fri, 4 Dec 2026 15:29:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=pixelcluster.dev header.i=@pixelcluster.dev header.a=rsa-sha256 header.s=ovhmo-selector-1 header.b=xP4dPH59 Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2096811301B; Fri, 4 Dec 2026 15:29:54 +0000 (UTC) X-Greylist: delayed 2134 seconds by postgrey-1.36 at gabe; Fri, 04 Dec 2026 15:29:48 UTC Received: from 4.mo2.mail-out.ovh.net (4.mo2.mail-out.ovh.net [46.105.54.237]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2240410EC05 for ; Fri, 4 Dec 2026 15:29:48 +0000 (UTC) Received: from director2.derp.mail-out.ovh.net (director2.derp.mail-out.ovh.net [79.137.60.36]) by mo2.mail-out.ovh.net (Postfix) with ESMTPS id 4jgvdw2k32z431p; Fri, 4 Dec 2026 14:54:12 +0000 (UTC) Received: from director2.derp.mail-out.ovh.net (director2.derp.mail-out.ovh.net. [127.0.0.1]) by director2.derp.mail-out.ovh.net (inspect_sender_mail_agent) with SMTP for ; Fri, 4 Dec 2026 14:54:12 +0000 (UTC) Received: from mta7.priv.ovhmail-u1.ea.mail.ovh.net (unknown [10.109.231.2]) by director2.derp.mail-out.ovh.net (Postfix) with ESMTPS id 4jgvdw1B5Tz1xyM; Fri, 4 Dec 2026 14:54:12 +0000 (UTC) Received: from pixelcluster.dev (unknown [10.1.6.1]) (Authenticated sender: nat@pixelcluster.dev) by mta7.priv.ovhmail-u1.ea.mail.ovh.net (Postfix) with ESMTPSA id BC173B8178D; Fri, 4 Dec 2026 14:54:11 +0000 (UTC) Authentication-Results: garm.ovh; auth=pass (GARM-108S002d85514f2-9491-4f42-864f-bd8aa797ee2a, C72A8C269379148255D259EF506AD3C5C1B61040) smtp.auth=nat@pixelcluster.dev X-OVh-ClientIp: 141.95.41.139 From: Natalie Vock To: intel-xe@lists.freedesktop.org, Thomas =?UTF-8?B?SGVsbHN0csO2bQ==?= Cc: Thomas =?UTF-8?B?SGVsbHN0csO2bQ==?= , Arun Pravin , Matthew Auld , Matthew Brost , 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 Message-ID: In-Reply-To: <20261124190954.47690-1-thomas.hellstrom@linux.intel.com> References: <20261124190954.47690-1-thomas.hellstrom@linux.intel.com> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" x-ovh-tracer-id: 15281839438858314011 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: dmFkZTE4XTwNsxlZKrWijd539zQh02RIfXGwRUOuxJnDPUsjv+2YgwFxiwEVx384n3kU7NyAsNaDBAJs5NCINzchdkLk4GCk+bMb13PxqPcc2RdnKt1+qV3jVYlUezAaC8fqIfCF0KTu90fi09hozwHRZgO2Ih3rDYYU5NeJa2rtYW2CLklDeH4MGqeAcEgE68moQiepdZTbkXTrUCcnWyMkLECPMUKxHpzqcOnZ4JZp9Pb8qW4TluwT2jCgImJtkaiEFKGrFetQ4jPzvWceXNh4roapOYNMnFJ/mu6VTox1Z4hGEeFBrWuI6lBa7n8o/aH8NhVe0+HWgx0PLyOERe8vdvwWdgErkuUqZSJ2D7msb4U37TIhWKGDDWNH8DMaN+BeiOZyMF1pMhSW/HA6taJ/wj/anW6JGjoEDWBpMsmahHEe9RpcFmmwpsHyNFH8yJVRBSZpwFiOKzPL6LjdcfoHOPub9VAjSRREqVeC7HebwJqgS4KjvKbnCUileQIG+gmnjc7aUzP9+tyjdNmsqNgKG+C/RI8InbjhKAcOAO5OQ7vSHg7g/qP4yL563uopC026NXUZ/s9l1igTkqn+aB4+5moUTH+SZ7LSyMqWFSdcHnKmwF+IoAUiPgkWXl72lGOu4oqA9sD7yugGhd3ND9+kkEnLhfSjSlHzfer7ZOIf/w3RZA DKIM-Signature: a=rsa-sha256; bh=eZKs0ucRHZqAn1nx9uAbO5fRYEl6lahusUIF98jrD6c=; c=relaxed/relaxed; d=pixelcluster.dev; h=From; s=ovhmo-selector-1; t=1796396052; v=1; b=xP4dPH59OshFLh15Fu9MZ888d/EMOoFIsgOwz/6cM7oN17Pv/78c46tcSCm1GTBp2V7qcj0n NbdJr9gqHpgjbSbAB/OBGnhEqe5PxxMFLfuItVh3qJDrKCYrBmSHZt7ro5tQg4txLTcVWSxwL8g WZlfBjS/iu1/jGD5C5UKYugrhOn4QIvu/9DEYQY45Wl9HHYVNkBQbNa+GWreR8SXE326MquAkuF lt7fG1xR/4CWyCglkzomKp9LHa3KatL3zV7vD7xMskUNmNSDxz3nXjUphgKWHUwW3zqvFZ1qOXv r3egOdd+dZoaZU3bAqBT2enlxHuJjhkiPyDkcGRntp3Qg== X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Intel-xe" X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Tuesday, 24 November 2026 20:09 Thomas Hellstr=C3=B6m 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. >=20 > 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. >=20 > 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. >=20 > Patch and commit message was drafted using an LLM. >=20 > Fixes: dd08ebf6c352 ("drm/xe: Introduce a new DRM driver for Intel GPUs") > Cc: Natalie Vock > Cc: Arun Pravin > Cc: Matthew Auld > Cc: Matthew Brost > Cc: dri-devel@lists.freedesktop.org > Cc: # v6.8+ > Signed-off-by: Thomas Hellstr=C3=B6m Reviewed-by: Natalie Vock > --- > drivers/gpu/drm/ttm/ttm_bo_util.c | 20 ++++++++++++++++++++ > include/drm/ttm/ttm_bo.h | 15 ++------------- > 2 files changed, 22 insertions(+), 13 deletions(-) >=20 > 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); > =20 > +/** > + * 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_m= em 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_buff= er_object *bo, > bo->resource =3D new_mem; > } > =20 > -/** > - * 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); > =20 > /** > * ttm_bo_unreserve >=20