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 C10A7606A323 for ; Wed, 2 Dec 2026 00:17:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SBqGjSOu Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 30B8C10E47B; Wed, 2 Dec 2026 00:16:58 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5713810EA6A; Wed, 2 Dec 2026 00:16:52 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 13DF34527E; Wed, 2 Dec 2026 00:16:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B45D1F0089A; Wed, 2 Dec 2026 00:16:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796170611; bh=CPcL2TpH3AjeWLZDMl6pEH/ZsdkaB8R4n/a17M+BqDI=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=SBqGjSOuxYucy+zOliBbWKVQfATBFsw3xCMzv5RSWyZG08mpv2qZHju/aK0tHaJhb o0sA8QVNp20QDVUpk+Tgum7G04UFMOg9PsJrP65nsrVXi0i/u7V4+j4vPI0SuATig3 tyU+lmszK6L2TkWKmM0+tvCyq1mB8x4biJ9eVi9fzP778+JjyPyLipxCbitH7NMPX9 LGrQPXRBEK7k4l33qlPb9oIat7xrhCzlRhySiIwfeFsk+RpUuZ7k5tOO5Nr22AyijP 9B8wuC4QwO6G65oRkoReHfHNHGOSgCzMsmNQpvKgGaCnKTOO7aZW0ihRK2jbHV8vFb Hs1SdVyMMlx3w== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v4 17/33] drm/xe: Skip self-copies for borrowed pages on defrag moves To: "Matthew Brost" , intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org In-Reply-To: <20261201234915.3305331-18-matthew.brost@intel.com> References: <20261201234915.3305331-1-matthew.brost@intel.com> <20261201234915.3305331-18-matthew.brost@intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 00:16:50 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "dri-devel" X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, 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 X-Archived-By: Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] drm/xe: premature DMA unmap of defrag_old_tt in __xe_migrate_copy() -- commit 79dbefec79082a8241c1d487779c045062f2a820 Author: Matthew Brost drm/xe: Skip self-copies for borrowed pages on defrag moves This commit passes the old ttm_tt into __xe_migrate_copy() on defrag moves so that pages borrowed from the old tt can be skipped instead of blitted to themselves, returning a signaled stub fence when every chunk is borrowed. > diff --git a/drivers/gpu/drm/xe/xe_migrate.c b/drivers/gpu/drm/xe/xe_migr= ate.c > index 0f469942ae6e0..03e9164e28957 100644 > --- a/drivers/gpu/drm/xe/xe_migrate.c > +++ b/drivers/gpu/drm/xe/xe_migrate.c [ ... ] > @@ -1529,6 +1624,14 @@ static struct dma_fence *__xe_migrate_copy(struct = xe_migrate *m, > return ERR_PTR(err); > } > =20 > + /* > + * Every chunk of a defrag data pass may have been borrowed (nothing > + * copied), leaving no job and a NULL fence. Hand back a signaled stub > + * so callers always get a valid fence to wait on. > + */ > + if (!fence) > + return dma_fence_get_stub(); > + > return fence; > } [Severity: High] Can returning an already-signaled stub fence here cause ttm_bo_move_to_ghos= t() to unmap defrag_old_tt's scatter-gather table while GPU work is still in flight? When at least one migration job is emitted, __xe_migrate_copy() chains the first job behind src_bo->ttm.base.resv (DMA_RESV_USAGE_BOOKKEEP), so the returned fence does not signal until pre-existing GPU jobs and any async TLB/L2 flushes queued by xe_bo_trigger_rebind() have completed. When every chunk is borrowed (for example, if the preallocation bag is already empty at the start of the move so the pool allocator harvests the whole tt) and need_ccs is false, no job is emitted and this stub fence is passed straight to ttm_bo_move_accel_cleanup() -> ttm_bo_move_to_ghost(). Because ghost_obj->base._resv is initialized empty and only receives the passed-in fence, ttm_bo_put(ghost_obj) sees an already-signaled reservation and immediately destroys defrag_old_tt, calling xe_tt_unmap_sg() while user GPU jobs or async TLB flushes on non-fault-mode VMs are still accessing the old DMA mappings. Should the !fence path capture src_bo->ttm.base.resv (DMA_RESV_USAGE_BOOKKEEP) via dma_resv_get_singleton() before falling back = to dma_fence_get_stub()? --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201234915.3305= 331-1-matthew.brost@intel.com?part=3D17