From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796345651; b=MNWU7+/yuBvaVITg9pGOeSYbe+veyG1VaPr+Sbby8vOuVHyhTrr4LghwjLveiw6rmRO6 8uMC3TFl0kM+gyw8vzZrZHBZc/AD04yaXSqvZ17O2UT29CWmjm3MurwiBp9RWeXq/oJZh gDhN3dIbK96yAqTYlDvmNSL8DZ9lj2RTh03EYk8A2TtK8IVSLRNtG0TYFh9IApUCO2lk6 W2FDWITTEsaNeFunPDF8d51tAAvixF4mi2zllONIAKkbW+QgZ7MvU3as1mwVrkns6Lw37 KKIlbNWALvtp+TAKPQafQpg/h6nBTvLeS9HdmwX1PjrOr0iui6o7ecqqMXRBpOAuOhw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796345651; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=i2td1hn1tojGVskrna3/kRn7fmVol6tzUtLpc7Ldqgo=; b=SUEpzMrfyjzST1aA1+w5h4KOMTGLxCqoExe4XPFvzfDamnC5nK+Hpmqgsgw6fLsAj7y2 eb5w2XN+crC8r9CpnfdBIXBc7tt4JOixuHkWdOzoEHvdo9wZRVBrAE1kDhHSrknpOcWvi ZP/XiG3MDUdMhQ7TgS8aC/T5WU8RBDf5Vf/NKrr+2FV16OtP92/nENYGyFHy6k8K03tto DpSuj7FDr3aGb40cLTc7U9QlJgr2nlOGuGVCMfi0gOOxjeGho6sJIGj1gIVR0l13Bwf1f u1xHEg8dhJ3d3g+jcji0LUDseDSX+UR1oto8SIoRwIT1wEzmCY2XHL6HD0FofQYrTAw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=BAiZPRaK; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BEA62606A32C for ; Fri, 4 Dec 2026 00:54:11 +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=BAiZPRaK Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC4C31F000C2; Fri, 4 Dec 2026 00:54:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796345651; bh=i2td1hn1tojGVskrna3/kRn7fmVol6tzUtLpc7Ldqgo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=BAiZPRaKSlIC58OKj7ychGryX2XKeEcUvkqn52lEGA64m/bjPEJfsHHEiOOdBjjsq QMb3b+T8CFDS5qEI9s23YVUApfNp/8/XDsO5J0mdFON5Zw/K/BlFOKQrPv0GAqEpaX nVrxWparGsmeQ1kEWnlGBdwSm4iGoMzDhu8eRud5OmwvL86b6VV7qhxOVAQ/zkAiri ZxOMcyQg/09cUjoLi/LyA0KyIF4vRgRAOLdIc+sNngXwoNgQVtbGTxnRrf0lDKPLoL tMtBxz68MXPk7c6Vr8BkxaSFubAK95JyHG55/WEtLEJsYGeQHVRoIliaH7pPOBN1R0 QyJWbaMwIxW0w== From: Sasha Levin To: stable@vger.kernel.org Cc: Tejas Upadhyay , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , Sasha Levin Subject: [PATCH 6.18.y 1/3] drm/xe/xe3p_lpg: flush shrinker bo cachelines manually Date: Thu, 3 Dec 2026 19:54:07 -0500 Message-ID: <20261204005309.1533197-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026120224-clinking-mayday-f935@gregkh> References: <2026120224-clinking-mayday-f935@gregkh> 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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Tejas Upadhyay [ Upstream commit 4e7ebff69aed345f65f590a17b3119c0cb5eadde ] XA, new pat_index introduced post xe3p_lpg, is memory shared between the CPU and GPU is treated differently from other GPU memory when the Media engine is power-gated. XA is *always* flushed, like at the end-of-submssion (and maybe other places), just that internally as an optimisation hw doesn't need to make that a full flush (which will also include XA) when Media is off/powergated, since it doesn't need to worry about GT caches vs Media coherency, and only CPU vs GPU coherency, so can make that flush a targeted XA flush, since stuff tagged with XA now means it's shared with the CPU. The main implication is that we now need to somehow flush non-XA before freeing system memory pages, otherwise dirty cachelines could be flushed after the free (like if Media suddenly turns on and does a full flush) V4: Add comments for L2 flush path V3(Thomas/MattA/MattR): Restrict userptr with non-xa, then no need to flush manually V2(MattA): Expand commit description Reviewed-by: Thomas Hellström Link: https://patch.msgid.link/20260305121902.1892593-7-tejas.upadhyay@intel.com Signed-off-by: Tejas Upadhyay Stable-dep-of: 9de430b6fbbd ("drm/xe: Don't abort the shrinker walk on -EBUSY") Signed-off-by: Sasha Levin --- drivers/gpu/drm/xe/xe_bo.c | 7 ++++++- drivers/gpu/drm/xe/xe_device.c | 23 +++++++++++++++++++++++ drivers/gpu/drm/xe/xe_device.h | 1 + 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c index 2496b24840be8..91aa4add821de 100644 --- a/drivers/gpu/drm/xe/xe_bo.c +++ b/drivers/gpu/drm/xe/xe_bo.c @@ -743,7 +743,12 @@ static int xe_bo_trigger_rebind(struct xe_device *xe, struct xe_bo *bo, if (!xe_vm_in_fault_mode(vm)) { drm_gpuvm_bo_evict(vm_bo, true); - continue; + /* + * L2 cache may not be flushed, so ensure that is done in + * xe_vm_invalidate_vma() below + */ + if (!xe_device_is_l2_flush_optimized(xe)) + continue; } if (!idle) { diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c index 4c5a87c682a0c..dab849639e61c 100644 --- a/drivers/gpu/drm/xe/xe_device.c +++ b/drivers/gpu/drm/xe/xe_device.c @@ -1059,6 +1059,29 @@ static void tdf_request_sync(struct xe_device *xe) } } +/** + * xe_device_is_l2_flush_optimized - if L2 flush is optimized by HW + * @xe: The device to check. + * + * Return: true if the HW device optimizing L2 flush, false otherwise. + */ +bool xe_device_is_l2_flush_optimized(struct xe_device *xe) +{ + /* XA is *always* flushed, like at the end-of-submssion (and maybe other + * places), just that internally as an optimisation hw doesn't need to make + * that a full flush (which will also include XA) when Media is + * off/powergated, since it doesn't need to worry about GT caches vs Media + * coherency, and only CPU vs GPU coherency, so can make that flush a + * targeted XA flush, since stuff tagged with XA now means it's shared with + * the CPU. The main implication is that we now need to somehow flush non-XA before + * freeing system memory pages, otherwise dirty cachelines could be flushed after the free + * (like if Media suddenly turns on and does a full flush) + */ + if (GRAPHICS_VER(xe) >= 35 && !IS_DGFX(xe)) + return true; + return false; +} + void xe_device_l2_flush(struct xe_device *xe) { struct xe_gt *gt; diff --git a/drivers/gpu/drm/xe/xe_device.h b/drivers/gpu/drm/xe/xe_device.h index 32cc6323b7f64..0cdab55a1890a 100644 --- a/drivers/gpu/drm/xe/xe_device.h +++ b/drivers/gpu/drm/xe/xe_device.h @@ -179,6 +179,7 @@ void xe_device_snapshot_print(struct xe_device *xe, struct drm_printer *p); u64 xe_device_canonicalize_addr(struct xe_device *xe, u64 address); u64 xe_device_uncanonicalize_addr(struct xe_device *xe, u64 address); +bool xe_device_is_l2_flush_optimized(struct xe_device *xe); void xe_device_td_flush(struct xe_device *xe); void xe_device_l2_flush(struct xe_device *xe); -- 2.53.0