Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 22EB026980F for ; Sat, 1 Aug 2026 14:04:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785593048; cv=none; b=mKHeOceGJ9XdtZNb3R7EYRTdDAMTaMmhLfCMVFi6NzPJW7XETpceit+J4WGZwQ7n8H1p77+dyGZVbGRzuvo5rWVGDiX/lw1Abaqfluz/OsHQKAnedWi9SGh7xDEG+efMqu7CXUcXC2+NVRAzqvuoZTndk/X/r+mF9IE69qErQQY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785593048; c=relaxed/simple; bh=BMZ+Vt30lvAvBWo0ZCJQoy772+4AKkIVEqlgSdDaDLE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HqlLBHULozbReVrnFfuC+o7hnBKPrsJ5ii5LJqZLJC3301yqoK6SqEsIHCr+ZIk116xL1z50FVV5t9Lx52Dl8cdA1W/jqG6RxSUMZUI7jboxQnHRkiIRn9um2Lv5YBsH7tno3OEGH/6foMXj1HnXxeH3Iz61WBgfds52tWBYKFU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NX0UdVgw; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NX0UdVgw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BE06E1F00ACF; Sat, 1 Aug 2026 14:04:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785593046; bh=GK8laBCLa/ecNlrOrmZFSMqNVGa0V20+mWsO/2hsWMQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NX0UdVgwIM5z4QQxpWZNEYMvXaTXQmR/nkTIwDSnpsSACIVPG3G01viy+PnGq5SfP ylOhqzFwjLbckk1dlgBsCB1pAGqLZ0Or8IXALJHaF1SCMVM5jLQixULP+qK2vejISt EL6GpgTv6ETF0Rn4+ammR1Vl46XWfaU5/ZEhwdj2x4d7jAbXCCOvLeFtERtMySK8Ba hAfSZQWGnAbreOY1bc8Sy7E7h/5PbStYKpwR3I78YxEmNmByEiYYr7HxEPsDrPIDXJ ztb+HMTyRrggb8x/kNKw4QZ1pw4ItgofFkIHqxjkjohIw+ZUtmGRinOdHjnKs2LCUZ v4tN7WzP4+ayw== From: Sasha Levin To: stable@vger.kernel.org Cc: Nitin Gote , Matthew Brost , Matthew Auld , Sasha Levin Subject: [PATCH 6.18.y 2/5] drm/xe: add xe_migrate_resolve wrapper and is_vram_resolve support Date: Sat, 1 Aug 2026 10:03:56 -0400 Message-ID: <20260801140402.3645391-2-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260801140402.3645391-1-sashal@kernel.org> References: <2026072936-hummus-emblem-55be@gregkh> <20260801140402.3645391-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Nitin Gote [ Upstream commit be97fd06458d66a53aefb6d9429db0df734c81c0 ] Introduce an internal __xe_migrate_copy(..., is_vram_resolve) path and expose a small wrapper xe_migrate_resolve() that calls it with is_vram_resolve=true. For resolve/decompression operations we must ensure the copy code uses the compression PAT index when appropriate; this change centralizes that behavior and allows callers to schedule a resolve (decompress) operation via the migrate API. v3: Fix kernel-doc warnings v2: (Matt) - Simplify xe_migrate_resolve(), use single BO/resource; remove copy_only_ccs argument as it's always false. Cc: Matthew Brost Cc: Matthew Auld Reviewed-by: Matthew Brost Signed-off-by: Nitin Gote Signed-off-by: Matthew Auld Link: https://patch.msgid.link/20260304123758.3050386-7-nitin.r.gote@intel.com Stable-dep-of: 7bc597ce74ba ("drm/xe/vm: Fix BO prefetch with CONSULT_MEM_ADVISE_PREF_LOC") Signed-off-by: Sasha Levin --- drivers/gpu/drm/xe/xe_migrate.c | 90 +++++++++++++++++++++++---------- drivers/gpu/drm/xe/xe_migrate.h | 4 ++ 2 files changed, 67 insertions(+), 27 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_migrate.c b/drivers/gpu/drm/xe/xe_migrate.c index b6905f35d6c8..86a0e38f5a99 100644 --- a/drivers/gpu/drm/xe/xe_migrate.c +++ b/drivers/gpu/drm/xe/xe_migrate.c @@ -764,31 +764,13 @@ static u32 xe_migrate_ccs_copy(struct xe_migrate *m, return flush_flags; } -/** - * xe_migrate_copy() - Copy content of TTM resources. - * @m: The migration context. - * @src_bo: The buffer object @src is currently bound to. - * @dst_bo: If copying between resources created for the same bo, set this to - * the same value as @src_bo. If copying between buffer objects, set it to - * the buffer object @dst is currently bound to. - * @src: The source TTM resource. - * @dst: The dst TTM resource. - * @copy_only_ccs: If true copy only CCS metadata - * - * Copies the contents of @src to @dst: On flat CCS devices, - * the CCS metadata is copied as well if needed, or if not present, - * the CCS metadata of @dst is cleared for security reasons. - * - * Return: Pointer to a dma_fence representing the last copy batch, or - * an error pointer on failure. If there is a failure, any copy operation - * started by the function call has been synced. - */ -struct dma_fence *xe_migrate_copy(struct xe_migrate *m, - struct xe_bo *src_bo, - struct xe_bo *dst_bo, - struct ttm_resource *src, - struct ttm_resource *dst, - bool copy_only_ccs) +static struct dma_fence *__xe_migrate_copy(struct xe_migrate *m, + struct xe_bo *src_bo, + struct xe_bo *dst_bo, + struct ttm_resource *src, + struct ttm_resource *dst, + bool copy_only_ccs, + bool is_vram_resolve) { struct xe_gt *gt = m->tile->primary_gt; struct xe_device *xe = gt_to_xe(gt); @@ -809,8 +791,15 @@ struct dma_fence *xe_migrate_copy(struct xe_migrate *m, bool copy_ccs = xe_device_has_flat_ccs(xe) && xe_bo_needs_ccs_pages(src_bo) && xe_bo_needs_ccs_pages(dst_bo); bool copy_system_ccs = copy_ccs && (!src_is_vram || !dst_is_vram); - bool use_comp_pat = type_device && xe_device_has_flat_ccs(xe) && - GRAPHICS_VER(xe) >= 20 && src_is_vram && !dst_is_vram; + + /* + * For decompression operation, always use the compression PAT index. + * Otherwise, only use the compression PAT index for device memory + * when copying from VRAM to system memory. + */ + bool use_comp_pat = is_vram_resolve || (type_device && + xe_device_has_flat_ccs(xe) && + GRAPHICS_VER(xe) >= 20 && src_is_vram && !dst_is_vram); /* Copying CCS between two different BOs is not supported yet. */ if (XE_WARN_ON(copy_ccs && src_bo != dst_bo)) @@ -969,6 +958,53 @@ struct dma_fence *xe_migrate_copy(struct xe_migrate *m, return fence; } +/** + * xe_migrate_copy() - Copy content of TTM resources. + * @m: The migration context. + * @src_bo: The buffer object @src is currently bound to. + * @dst_bo: If copying between resources created for the same bo, set this to + * the same value as @src_bo. If copying between buffer objects, set it to + * the buffer object @dst is currently bound to. + * @src: The source TTM resource. + * @dst: The dst TTM resource. + * @copy_only_ccs: If true copy only CCS metadata + * + * Copies the contents of @src to @dst: On flat CCS devices, + * the CCS metadata is copied as well if needed, or if not present, + * the CCS metadata of @dst is cleared for security reasons. + * + * Return: Pointer to a dma_fence representing the last copy batch, or + * an error pointer on failure. If there is a failure, any copy operation + * started by the function call has been synced. + */ +struct dma_fence *xe_migrate_copy(struct xe_migrate *m, + struct xe_bo *src_bo, + struct xe_bo *dst_bo, + struct ttm_resource *src, + struct ttm_resource *dst, + bool copy_only_ccs) +{ + return __xe_migrate_copy(m, src_bo, dst_bo, src, dst, copy_only_ccs, false); +} + +/** + * xe_migrate_resolve() - Resolve and decompress a buffer object if required. + * @m: The migrate context + * @bo: The buffer object to resolve + * @res: The reservation object + * + * Wrapper around __xe_migrate_copy() with is_vram_resolve set to true + * to trigger decompression if needed. + * + * Return: A dma_fence that signals on completion, or an ERR_PTR on failure. + */ +struct dma_fence *xe_migrate_resolve(struct xe_migrate *m, + struct xe_bo *bo, + struct ttm_resource *res) +{ + return __xe_migrate_copy(m, bo, bo, res, res, false, true); +} + /** * xe_migrate_lrc() - Get the LRC from migrate context. * @migrate: Migrate context. diff --git a/drivers/gpu/drm/xe/xe_migrate.h b/drivers/gpu/drm/xe/xe_migrate.h index bc55f650204b..1a986609d870 100644 --- a/drivers/gpu/drm/xe/xe_migrate.h +++ b/drivers/gpu/drm/xe/xe_migrate.h @@ -127,6 +127,10 @@ struct dma_fence *xe_migrate_copy(struct xe_migrate *m, struct ttm_resource *dst, bool copy_only_ccs); +struct dma_fence *xe_migrate_resolve(struct xe_migrate *m, + struct xe_bo *bo, + struct ttm_resource *res); + int xe_migrate_ccs_rw_copy(struct xe_tile *tile, struct xe_exec_queue *q, struct xe_bo *src_bo, enum xe_sriov_vf_ccs_rw_ctxs read_write); -- 2.53.0