From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=46.105.32.207 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796396063; b=Sxg3zLfRe5yZeJ9cIxNJPY9e8zeg6r95HHP8QqbDirmm4UsutW4GhNDn5YNj+ApJIlYp ZZwM5YkmkICz1a76/PQb7OdsUUUMoJuUHNc8WPEHUG1zIfyiesUM9IhQFzAU6nxvo7bmE BA5IDU/Srg5vwAOcVQ5coDAS5q7Jx4eXomr9KXekE2mkH3QjFcO1gGiICgn1gPrK5Z6tK /RSaLM99p8r4DdlvbUIzhX4jqWgRBxMn01Z8A4Oma0l7aI+Uyta/rE3xPu1JPgsBJfn27 Yc5lUmooPO1X3Gyh5Zg/bbUkQXtteifk9xRNnYRebir2wcPPPqswfcxSFt1QWpa2Wjg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796396063; h=DMARC-Filter:Received:Received:Received:Received:X-OVh-ClientIp:From: To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:Content-Type:x-ovh-tracer-id:X-VR-SPAMSTATE: X-VR-SPAMSCORE:X-VR-SPAMCAUSE:DKIM-Signature; bh=eZKs0ucRHZqAn1nx9uAbO5fRYEl6lahusUIF98jrD6c=; b=3leg/eOoME5xWYEmZ/Kqfl/qbVxpn59LmA/h8PnMvoMFWbG+9Eni7L4u1YKW98aIo1X+ 2nWvMVMUf0a2mCrL2goeGn/bkVPHRKIgMA4QTK1HXssyk4zg0hoUpz0PfxzGGacFrsxoe ncapvaH/tNdzK36yAmlegMla9zF8QKBwMjXbacncHapABW/Z5coQ5njRxNc+xOkMPbt/o F/470sjWNqOj9RXJ/2OFZL9riSexknamJQl9Lv26phqFEOqJRTfWikUgA6yH+Y23pzo+b H7vqUM5CNPFW7SvirvjrwY8Sq8e1qos7ww+5g5OcIrvqSciwKF7O1onQRMFVieqoXJA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=pixelcluster.dev; spf=pass smtp.mailfrom=pixelcluster.dev; dkim=pass header.d=pixelcluster.dev header.i=@pixelcluster.dev header.a=rsa-sha256 header.s=ovhmo-selector-1 header.b=xP4dPH59; arc=none smtp.remote-ip=46.105.32.207 Received: from 8.mo2.mail-out.ovh.net (8.mo2.mail-out.ovh.net [46.105.32.207]) (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 33476606A322 for ; Fri, 4 Dec 2026 14:54:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 33476606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pixelcluster.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pixelcluster.dev 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 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-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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== 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