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=1796208861; b=xn2yqJMYKfqNidjO36dtxEIOCfCz7sqfFkUgQX7OsWwgMxHROGwHaVsb5RA3PTamiRq4 uQkLkrhHWkkk+PjCxSLKG64+5SZBG0cW39eWRtt42l4OBkBIm+XUrR3nLGO/ACCUfLM/t np9otYOG+o6/mmuXeRuHuqk+dTw4KcePK3bKN9U04KjTV0L75vNJyLEhxEq7fpLzSqT/n ppUFIz63EKzJdvW101VY08Cc5xo/6CJSWZpoVCBx02zSqxitpqMvfXNCtWBOIPMYylkjl 0XsbozFb6glTaPGrnSZmudoRpljrHwoZoeuZaS+09RxAZwDj4MPmL47zmR0tU5q41VA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796208861; h=Received:DKIM-Signature:Subject:To:Cc:From:Date:Message-ID: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=XbzG4/YYhuGXahdOfgyrmuvTuhWRHesD2NnvrCFFOjQ=; b=C0mK75jiUgaGFjWy+TNftE6jtuqnDgtvWQVi5tDJsKiRCwvEIQSFESbtPc9XeFVr24on nIqZN7NGeG8Xu7Sfu164qzyDspmO+/WwsyXb/vUQxzpF/LVqirlAgYDdJZZqRDBb5B+z2 psizqqfZ3DiunGOlt3Iq0xuZefzvrUCD/pdIkdZ3oqSvzQOalB4jObnkIFFL345GAAwor 36MfrHTKSQ+rdbtro9Gr3XrNUquQ6tjH/HPXStAqQjN9HQvN0i2yt5qzFUUSM/dkxiTNf SywnQC5hpovmc7hcpIUNXNUQyV2ze/Dz4HDdVocVdnG7xeWiDED5Do/7AxIPq7hJogA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=WVEYk7tg; 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 4A229606A322 for ; Wed, 2 Dec 2026 10:54:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=WVEYk7tg Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F3251F00897; Wed, 2 Dec 2026 10:54:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796208860; bh=XbzG4/YYhuGXahdOfgyrmuvTuhWRHesD2NnvrCFFOjQ=; h=Subject:To:Cc:From:Date; b=WVEYk7tgGnqcXgzK1dod3rDka4DkV5Oj57GJYLBH203RqInY/MpOEc6LQIPutYMgX KuO5h5ZjoOL07HnkCFyq9onTA2K700OT+5vdGNG+AfNLojLu/hVWTPx7jUiocJ3M1E 5kfOiJs4sspp/jIFAPhsiaIsHf0oOpsiv1uQYUUc= Subject: FAILED: patch "[PATCH] drm/xe/query: Use ordered clock reads for engine cycles" failed to apply to 6.12-stable tree To: sanjay.kumar.yadav@intel.com,aleksander.czerwionka@intel.com,matthew.brost@intel.com,rodrigo.vivi@intel.com,stable@vger.kernel.org,umesh.nerlige.ramappa@intel.com Cc: From: Date: Wed, 02 Dec 2026 11:54:18 +0100 Message-ID: <2026120218-riverside-pedigree-b26f@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=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.12-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y git checkout FETCH_HEAD git cherry-pick -x 65ef9dec511c018bcbe5993e9749c52c26e573e2 # git commit -s git send-email --to '' --in-reply-to '2026120218-riverside-pedigree-b26f@gregkh' --subject-prefix 'PATCH 6.12.y' 'HEAD^..' Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 65ef9dec511c018bcbe5993e9749c52c26e573e2 Mon Sep 17 00:00:00 2001 From: Sanjay Yadav Date: Wed, 11 Nov 2026 14:34:02 +0530 Subject: [PATCH] drm/xe/query: Use ordered clock reads for engine cycles cpu_delta cpu_delta is meant to bound the time taken to read the engine timestamp register, but it is measured with local_clock(), which on x86 is a plain RDTSC that is not ordered against loads. Either end of the window can thus be sampled while an earlier MMIO read is still in flight. A reproducer looping on DRM_XE_DEVICE_QUERY_ENGINE_CYCLES on BMG reports cpu_delta as low as 18 ns, while the MMIO read alone takes > 1.5 us. Use ktime_get_raw_ns() at both ends instead. Its clocksource read is ordered (rdtsc_ordered() on x86). With this, the reproducer reports min/median cpu_delta of 1567/1745 ns and no short values. Fixes: 7793d00d1bf5 ("drm/xe: Correlate engine and cpu timestamps with better accuracy") Cc: # v6.8+ Cc: Umesh Nerlige Ramappa Cc: Matthew Brost Cc: Rodrigo Vivi Suggested-by: Aleksander Czerwionka Signed-off-by: Sanjay Yadav Reviewed-by: Umesh Nerlige Ramappa Signed-off-by: Umesh Nerlige Ramappa Link: https://patch.msgid.link/20261111090401.975803-2-sanjay.kumar.yadav@intel.com (cherry picked from commit 146dec4ce1f0794fefe5ad1d549655745358b515) Signed-off-by: Matthew Brost diff --git a/drivers/gpu/drm/xe/xe_query.c b/drivers/gpu/drm/xe/xe_query.c index dc975f595368..9cc35fc83954 100644 --- a/drivers/gpu/drm/xe/xe_query.c +++ b/drivers/gpu/drm/xe/xe_query.c @@ -6,7 +6,6 @@ #include "xe_query.h" #include -#include #include #include @@ -97,13 +96,14 @@ hwe_read_timestamp(struct xe_hw_engine *hwe, u64 *engine_ts, u64 *cpu_ts, u32 upper, lower, old_upper, loop = 0; struct xe_reg upper_reg = RING_TIMESTAMP_UDW(hwe->mmio_base), lower_reg = RING_TIMESTAMP(hwe->mmio_base); + u64 delta_start; upper = xe_mmio_read32(mmio, upper_reg); do { - *cpu_delta = local_clock(); + delta_start = ktime_get_raw_ns(); *cpu_ts = cpu_clock(); lower = xe_mmio_read32(mmio, lower_reg); - *cpu_delta = local_clock() - *cpu_delta; + *cpu_delta = ktime_get_raw_ns() - delta_start; old_upper = upper; upper = xe_mmio_read32(mmio, upper_reg); } while (upper != old_upper && loop++ < 2);