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 58CC8606A320 for ; Wed, 2 Dec 2026 00:18: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=JbVTtR94 Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B336310E47E; Wed, 2 Dec 2026 00:17:57 +0000 (UTC) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by gabe.freedesktop.org (Postfix) with ESMTPS id EBFB210EA7D; Wed, 2 Dec 2026 00:17:50 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 715A861F15; Wed, 2 Dec 2026 00:17:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 801821F00897; Wed, 2 Dec 2026 00:17:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796170669; bh=Ejw+2MTf0BwiwDPFRYUVxyFtZFMjolwX7IogIvmGpSg=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=JbVTtR94X3lUL7sOBE+a0q5TKn32FypwJzds5BMqOiWJPaofuZC5Nmwgx6lYKupvO 8EJqpCsRFtHd5zxlOiuFQ5DOKnPvrdbdZcuCmgYhOn/pLertAA6jaaHsHXE81R76gY Iu88QYjV7b+Xr7FcWlZIGqbY0/ZQMTQsirR/ntdROMMK+1lBmnbcjunIidHBfnyx4n x4eKqVTdJ4J0V6yqBamtOPxBx5QyO3GLOshz32Vgq4qJqucGcsoxWsfzUQ5vPjU02k zIx3xnN/PItNs6O0plgc1tiDiKoJRaanvXtwc+pcKmBD20glz8/HN/YhHzauoVTT83 W77hxpoSgyW9g== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v4 29/33] drm/xe: Blit src-natural to dst-packed for defrag-IOVA copies To: "Matthew Brost" , intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org In-Reply-To: <20261201234915.3305331-30-matthew.brost@intel.com> References: <20261201234915.3305331-1-matthew.brost@intel.com> <20261201234915.3305331-30-matthew.brost@intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 00:17:49 +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 2 potential issues to consider: - [Medium] drm/xe: commit message contradicts CCS and skip logic in __xe_migrate_copy() - [Low] drm/xe: duplicated logic in emit_ccs_copy_chunks() and defrag copy wrappers -- commit 681da51913c9f8bb7ed8b338e9df09061c4b206e Author: Matthew Brost drm/xe: Blit src-natural to dst-packed for defrag-IOVA copies This commit teaches __xe_migrate_copy() to copy changed pages from their natural source offsets into a packed destination IOVA prefix, and exposes this mode via xe_migrate_copy_defrag_iova(). > - Size the destination PTE update for each chunk from the changed-page > count (xe_migrate_count_changed_pages()) rather than the full chunk, > and skip the destination PTEs entirely for an all-borrowed chunk. > > - Extend emit_copy_chunks() with a @pack_dst flag so each emitted run is > blitted from its natural source offset into a running packed > destination offset that only advances for changed runs. The > all-borrowed skip leaves the packed destination cursor untouched. > > Expose this via xe_migrate_copy_defrag_iova(). It is only valid when the > BO needs no CCS pass, since the separate CCS pass migrates aux state for > all pages and would require the full destination mapping. The existing > xe_migrate_copy_defrag() (full destination mapping) remains the path for > CCS BOs and the non-IOVA fallback. [Severity: Medium] Does the commit message match the implementation on CCS support and all-borrowed chunks? xe_migrate_copy_defrag_iova() takes a need_ccs parameter and runs a second XE_MIGRATE_COPY_DEFRAG_CCS pass with dst_packed_pages using the new emit_ccs_copy_chunks() helper and ccs_pack path in __xe_migrate_copy(). Also, the post-pte_update_size() all-borrowed chunk skip (if (skip_borrowed && !ndata_blits)) is removed in favor of fast-forwarding leading borrowed pages up front via xe_migrate_leading_borrowed_pages(), after which __xe_migrate_copy() asserts that nchg and ndata_blits are non-zero. > diff --git a/drivers/gpu/drm/xe/xe_migrate.c b/drivers/gpu/drm/xe/xe_migr= ate.c > index 43267bc0f5e08..8cb4a8c182ec0 100644 > --- a/drivers/gpu/drm/xe/xe_migrate.c > +++ b/drivers/gpu/drm/xe/xe_migrate.c [ ... ] > @@ -1276,9 +1342,71 @@ static u32 emit_copy_chunks(struct xe_gt *gt, stru= ct xe_bb *bb, > =20 > if (bb) > emit_copy(gt, bb, src_ofs + (u64)i * PAGE_SIZE, > - dst_ofs + (u64)i * PAGE_SIZE, > + dst_ofs + > + (u64)(pack_dst ? pack : i) * PAGE_SIZE, > run * PAGE_SIZE, XE_PAGE_SIZE); > nblits++; > + pack +=3D run; > + i +=3D run; > + } > + > + return nblits; > +} > + > +/* > + * emit_ccs_copy_chunks() - Emit the indirect CCS aux copies for one pac= ked > + * defrag L0 chunk, skipping borrowed pages. > + * @gt: The GT. > + * @bb: The batch buffer to emit into, or NULL to only count the copies = needed. > + * @src_L0_ofs: GPU offset of the source pages mapped (comp PAT) for thi= s chunk. > + * @dst_L0_ofs: GPU offset of the destination pages mapped (comp PAT) fo= r this > + * chunk (the packed changed-page prefix). > + * @src_L0: Byte size of the L0 chunk (page aligned). > + * @src_tt: Source (old) tt providing the page pointers. > + * @dst_tt: Destination (new) tt providing the page pointers. > + * @start_page: Page offset of this L0 chunk within the tt page arrays. > + * > + * Companion to emit_copy_chunks() for the packed defrag CCS pass. The f= lat-CCS > + * aux state is migrated indirectly through the data-page mappings, so it > + * follows the physical page regardless of the (packed) GPU VA layout. B= orrowed > + * pages alias the same physical page on both sides, so their aux is alr= eady > + * identical and is skipped; only the changed runs are copied, from the = source > + * at its natural offset to the destination at its packed offset. > + * > + * Return: The number of CCS copies emitted (or that would be emitted wh= en @bb > + * is NULL). > + */ > +static u32 emit_ccs_copy_chunks(struct xe_gt *gt, struct xe_bb *bb, > + u64 src_L0_ofs, u64 dst_L0_ofs, u32 src_L0, > + struct ttm_tt *src_tt, struct ttm_tt *dst_tt, > + pgoff_t start_page) > +{ > + u32 npages =3D src_L0 >> PAGE_SHIFT; > + u32 i =3D 0, pack =3D 0, nblits =3D 0; > + > + while (i < npages) { > + u32 run =3D 0; > + > + /* Skip a run of borrowed pages (src and dst alias). */ > + if (src_tt->pages[start_page + i] =3D=3D > + dst_tt->pages[start_page + i]) { > + i++; > + continue; > + } > + > + /* Coalesce a run of pages whose aux must be migrated. */ > + while (i + run < npages && > + src_tt->pages[start_page + i + run] !=3D > + dst_tt->pages[start_page + i + run]) > + run++; > + > + if (bb) > + emit_copy_ccs(gt, bb, > + dst_L0_ofs + (u64)pack * PAGE_SIZE, true, > + src_L0_ofs + (u64)i * PAGE_SIZE, true, > + run * PAGE_SIZE); > + nblits++; > + pack +=3D run; > i +=3D run; > } > =20 > return nblits; > } [ ... ] > @@ -1711,13 +1912,62 @@ struct dma_fence *xe_migrate_copy_defrag(struct x= e_migrate *m, > bool need_ccs) > { > struct dma_fence *fence2, *fence =3D > - __xe_migrate_copy(m, bo, bo, src, dst, src_tt, > + __xe_migrate_copy(m, bo, bo, src, dst, src_tt, 0, > + XE_MIGRATE_COPY_DEFRAG_DATA, false); > + > + if (IS_ERR(fence) || !need_ccs) > + return fence; > + > + fence2 =3D __xe_migrate_copy(m, bo, bo, src, dst, src_tt, 0, > + XE_MIGRATE_COPY_DEFRAG_CCS, false); > + if (IS_ERR(fence2)) > + dma_fence_wait(fence, false); > + dma_fence_put(fence); > + > + return fence2; > +} > + > +/** > + * xe_migrate_copy_defrag_iova() - Copy a defrag move into a packed IOVA= dst. > + * @m: The migration context. > + * @bo: The buffer object being defragmented. > + * @src: The source (old) TTM resource. > + * @dst: The destination (new) TTM resource. > + * @src_tt: The stashed source (old) tt providing the page pointers, ful= ly > + * IOVA-mapped at natural offsets. > + * @dst_packed_pages: Number of changed pages packed into the destinatio= n tt's > + * IOVA prefix by xe_tt_map_iova_copy(). > + * @need_ccs: Whether the BO has flat-CCS aux state that must be migrate= d too. > + * > + * Defrag copy variant for IOVA-mapped BOs where the destination only ma= ps the > + * changed (non-borrowed) pages, packed contiguously into the first > + * @dst_packed_pages of its IOVA. The source is read from the old tt at = its > + * natural offsets and each changed run is blitted into the packed desti= nation > + * prefix. When @need_ccs is set a second pass migrates the flat-CCS aux= state > + * of the same changed pages indirectly through their (packed) data mapp= ings; > + * borrowed pages share the physical page and its aux, so only the chang= ed runs > + * are touched. > + * > + * Return: Pointer to a dma_fence representing the last copy batch, or a= n error > + * pointer on failure. > + */ > +struct dma_fence *xe_migrate_copy_defrag_iova(struct xe_migrate *m, > + struct xe_bo *bo, > + struct ttm_resource *src, > + struct ttm_resource *dst, > + struct ttm_tt *src_tt, > + pgoff_t dst_packed_pages, > + bool need_ccs) > +{ > + struct dma_fence *fence2, *fence =3D > + __xe_migrate_copy(m, bo, bo, src, dst, src_tt, dst_packed_pages, > XE_MIGRATE_COPY_DEFRAG_DATA, false); > =20 > if (IS_ERR(fence) || !need_ccs) > return fence; > =20 > fence2 =3D __xe_migrate_copy(m, bo, bo, src, dst, src_tt, > + dst_packed_pages, > XE_MIGRATE_COPY_DEFRAG_CCS, false); > if (IS_ERR(fence2)) > dma_fence_wait(fence, false); > dma_fence_put(fence); > =20 > return fence2; > } [Severity: Low] This isn't a bug, but emit_ccs_copy_chunks() and xe_migrate_copy_defrag_iova() duplicate existing helpers. emit_ccs_copy_chunks() repeats the run-coalescing loop of emit_copy_chunks(), differing only in calling emit_copy_ccs() instead of emit_copy() when bb is non-NULL (__xe_migrate_copy() already calls emit_copy_chunks() with bb =3D=3D NULL to count the runs for ccs_pack). Likewise, xe_migrate_copy_defrag() can just call xe_migrate_copy_defrag_iova(m, bo, src, dst, src_tt, 0, need_ccs). --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201234915.3305= 331-1-matthew.brost@intel.com?part=3D29