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 86C64606A322 for ; Thu, 3 Dec 2026 00:18:56 +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=V2N19Nng Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E90501126C6; Thu, 3 Dec 2026 00:18:50 +0000 (UTC) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by gabe.freedesktop.org (Postfix) with ESMTPS id BFB7A1126C6; Thu, 3 Dec 2026 00:18:44 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id E7DAB60DEC; Thu, 3 Dec 2026 00:18:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 843C71F00893; Thu, 3 Dec 2026 00:18:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796257123; bh=6UYph0eFu2HFuUl/A0FsxnNHU5GicVeQpUF6aUVIksA=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=V2N19NngPWneivfTU+XgGuOWfeybwXi9pUUF0UfEbeU0655uABfaUqN2RZ1lk+BHe 5/PCUGQAJ9HTXK6GPdA5VoTsMF4YlkzNg1SgvV0uAxUrWies5AKp+p87Qr7D+eT/oK lcIVj+2pxBBtBryQvlYTazyxJWlBfQbYklqdiUZEZ3mYz5qCufxa2RtfhYTkXo/Uod iTZWnqriTylE9FDlGtolaJeBe70iH5GIbnU80DHSWgtZbUDsfGExIwkWKv5kzeLABR O9zEmpC8dsn7Ikle7B//gJYViibVZVEa9imoa6r0etCSvM9LSyJINjkQoytiR2b6uW QcOBlTNXuibYA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v5 33/36] drm/xe: Finalize defrag-IOVA moves with post-copy job To: "Matthew Brost" , intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org In-Reply-To: <20261202233323.3743190-34-matthew.brost@intel.com> References: <20261202233323.3743190-1-matthew.brost@intel.com> <20261202233323.3743190-34-matthew.brost@intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 00:18:43 +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=ham 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: - [Medium] drm/xe: page range mismatch in xe_bo_defrag_iova_copy() with CCS extra_pages -- commit d43bc6ca2ee8e9ea06f7417aee36a16ea7bf5ca3 Author: Matthew Brost drm/xe: Finalize defrag-IOVA moves with post-copy job This commit wires up IOVA defragmentation moves using a packed temporary copy mapping and a post-copy dependency job to transfer the IOVA reservation and relink changed pages. > diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c > index 9f216a7d115ea..65ab974c56acc 100644 > --- a/drivers/gpu/drm/xe/xe_bo.c > +++ b/drivers/gpu/drm/xe/xe_bo.c [ ... ] > @@ -1191,6 +1308,157 @@ static void xe_tt_iova_transfer(struct xe_device = *xe, > old_tt->use_iova =3D false; > } > =20 > +/* > + * xe_bo_defrag_iova_copy - Run an IOVA defrag move with a packed copy m= apping. > + * > + * Only the changed (non-borrowed) pages of @new_tt are DMA mapped, pack= ed > + * contiguously into the front of its reservation, the GPU copy blits th= em from > + * the old tt at natural offsets, and a post-copy finalize job adopts th= e old > + * tt's full reservation and relinks the changed runs. Returns the final= ize > + * job's finished fence (the fence the move waits on), or an ERR_PTR on = failure > + * with all partial state unwound. > + */ > +static struct dma_fence * > +xe_bo_defrag_iova_copy(struct xe_device *xe, struct xe_migrate *migrate, > + struct xe_bo *bo, struct ttm_resource *old_mem, > + struct ttm_resource *new_mem, struct ttm_tt *old_tt, > + bool handle_system_ccs) > +{ > + struct ttm_tt *new_tt =3D bo->ttm.ttm; > + struct xe_ttm_tt *new_xe_tt =3D container_of(new_tt, struct xe_ttm_tt, = ttm); > + struct xe_ttm_tt *old_xe_tt =3D container_of(old_tt, struct xe_ttm_tt, = ttm); > + struct drm_sched_entity *entity =3D > + xe_dep_scheduler_entity(xe->mem.defrag.iova_sched); > + struct xe_iova_defrag_job *job; > + struct dma_fence *copy_fence; > + struct dma_fence *fence; > + struct xe_tt_iova_copy copy; > + int err; > + > + xe_assert(xe, new_xe_tt->iova_eligible && !new_xe_tt->use_iova); > + xe_assert(xe, old_xe_tt->use_iova && old_xe_tt->iova_linked); > + > + err =3D xe_tt_iova_copy_init(new_tt, old_tt, ©); > + if (err) > + return ERR_PTR(err); > + > + /* > + * TTM fails a defrag move that (re)allocates no chunk, so at least one > + * page always differs from the old tt. > + */ > + if (XE_WARN_ON(!copy.nr_changed)) { > + err =3D -EINVAL; > + goto err_copy; > + } > + > + err =3D xe_tt_map_iova_copy(xe, new_tt, ©); > + if (err) > + goto err_copy; > + > + copy_fence =3D xe_migrate_copy_defrag_iova(migrate, bo, old_mem, new_me= m, > + old_tt, copy.nr_changed, > + handle_system_ccs); [Severity: Medium] Can xe_bo_defrag_iova_copy() hit XE_WARN_ON(!fence) in __xe_migrate_copy() when a defrag slice only upgrades Flat-CCS extra_pages? On integrated platforms with Flat-CCS, xe_ttm_tt_create() appends CCS extra_pages to tt->num_pages, and ttm_pool_alloc() upgrades and tracks TTM_TT_FLAG_BENEFICIAL_ORDER_FAILED across the full tt->num_pages array. When a defrag pass borrows all data pages in [0, xe_bo_size(bo)) from old_tt and only reallocates a chunk in those trailing extra_pages (for example, on the final defrag slice of a >=3D 1 GB compressible BO where extra_pages >=3D 512), xe_tt_iova_copy_init() walks new_tt->num_pages and sets copy.nr_changed > 0. However, xe_migrate_copy_defrag_iova() -> __xe_migrate_copy() only iterates over size =3D xe_bo_size(src_bo). Because all pages in that range were borrowed, xe_migrate_leading_borrowed_pages() skips the entire buffer without emitting a job, hitting XE_WARN_ON(!fence) and returning -EINVAL. TTM then restores old_tt with TTM_TT_FLAG_BENEFICIAL_ORDER_FAILED still set, leaving the BO at the head of xe->mem.defrag.list to warn and abort the defrag worker on every retry. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202233323.3743= 190-1-matthew.brost@intel.com?part=3D33