From mboxrd@z Thu Jan 1 00:00:00 1970 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 37FE83CAA49 for ; Sun, 2 Aug 2026 16:53:42 +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=1785689624; cv=none; b=dW1GuAu7p/n+pa7lBWuogxXKClMwh+GM2BEzZGKnpWp2sljQ5nGGl5x05ZosUnj3S4i3GK1yXjuZLQqJqxsNHSqAtLf08U94HyRhLKINF/7JZnn2I0Jg8QFOKLytXxSAgm9OEwQdGqjtrITYGRQkmDbFpId1imJEfNKIf9Fp7uk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785689624; c=relaxed/simple; bh=82dVbqROx6vZYLs8uhqb6IT0srAPqmKyngtBeXm4hE0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oniC74KUXy8p0JkdzaaboB4yKEKjse/lGkKGzCoNKj391cEiRd5/Tk3u9U6nZlSpV3qlL9asH4rvRZD4kamYBQcIAaYX7Fd60Ii0cTLoGSJKhekPIkWIwPUsBooRrfQ7kKzAnLfBMOTpZOVxqMJQDhNm9tNA8P2bxf3ElPIvoE8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=P/s9zczN; 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="P/s9zczN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2FF41F00A3E; Sun, 2 Aug 2026 16:53:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785689622; bh=l1E7eRaD45mE8Ul8FpAjG4IxkSoELLrr3ZiMXm4Q0lg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=P/s9zczNz132ZOtuHL3raiD+3ZJ7B879S6nJaCwPAU7opM9PJcnHK4if8lD5WO74d XWEsGOQm/OH3c8Bj61MrvEpm2zvyTw5+Qu0nvy1p+s0wOx1PH/QIb9AJasm1v6E3AW mgFAJJRot2my7SuocvMiy/GEg3E1CztBUKpcyMgmMwxJ+ePhDU9vJpY7u3k9sT4sxZ Plzna+uSCiac3RGHx09ItFAxMIb/enwWuBIr2C9nlKHotGyFj0otOthpMUw2ndJsy4 UqB803E91mupNooSXFNs7sxixHRU1fbb1EdsMYe2GP2ZYTQmDKkR9CXjlpm7m6EeHe n8KI1w4i88Udw== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wqZRU-0000000BVIZ-0F1R; Sun, 02 Aug 2026 16:53:40 +0000 From: Marc Zyngier To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Catalin Marinas , Will Deacon , Mark Rutland , Thomas Gleixner , Ben Horgan , Daniel Lezcano Subject: [PATCH v3 3/8] clocksource/drivers/arm_arch_timer: Convert counter accessors to a static key alternative Date: Sun, 2 Aug 2026 17:53:22 +0100 Message-ID: <20260802165327.385217-4-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260802165327.385217-1-maz@kernel.org> References: <20260802165327.385217-1-maz@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, tglx@kernel.org, ben.horgan@arm.com, daniel.lezcano@linaro.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Now that we have a reliable static key to control whether our counter accessors need to be worked around, use it in these accessors and simplify the logic that picks which accessor to use. Signed-off-by: Marc Zyngier --- drivers/clocksource/arm_arch_timer.c | 44 ++++++++++++++-------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c index 8ee317e33c864..f645aa562895b 100644 --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c @@ -92,9 +92,12 @@ static int arch_counter_get_width(void) */ static inline bool arch_counter_broken_accessors(void); -static noinstr u64 raw_counter_get_cntpct_stable(void) +static noinstr u64 raw_counter_get_cntpct(void) { - return __arch_counter_get_cntpct_stable(); + if (arch_counter_broken_accessors()) + return __arch_counter_get_cntpct_stable(); + + return __arch_counter_get_cntpct(); } static notrace u64 arch_counter_get_cntpct_stable(void) @@ -108,12 +111,18 @@ static notrace u64 arch_counter_get_cntpct_stable(void) static noinstr u64 arch_counter_get_cntpct(void) { + if (arch_counter_broken_accessors()) + return arch_counter_get_cntpct_stable(); + return __arch_counter_get_cntpct(); } -static noinstr u64 raw_counter_get_cntvct_stable(void) +static noinstr u64 raw_counter_get_cntvct(void) { - return __arch_counter_get_cntvct_stable(); + if (arch_counter_broken_accessors()) + return __arch_counter_get_cntvct_stable(); + + return __arch_counter_get_cntvct(); } static notrace u64 arch_counter_get_cntvct_stable(void) @@ -127,6 +136,9 @@ static notrace u64 arch_counter_get_cntvct_stable(void) static noinstr u64 arch_counter_get_cntvct(void) { + if (arch_counter_broken_accessors()) + return arch_counter_get_cntvct_stable(); + return __arch_counter_get_cntvct(); } @@ -950,21 +962,11 @@ static void __init arch_counter_register(void) if ((IS_ENABLED(CONFIG_ARM64) && !is_hyp_mode_available()) || arch_timer_uses_ppi == ARCH_TIMER_VIRT_PPI || arch_timer_uses_ppi == ARCH_TIMER_HYP_VIRT_PPI) { - if (arch_timer_counter_has_wa()) { - rd = arch_counter_get_cntvct_stable; - scr = raw_counter_get_cntvct_stable; - } else { - rd = arch_counter_get_cntvct; - scr = arch_counter_get_cntvct; - } + rd = arch_counter_get_cntvct; + scr = raw_counter_get_cntvct; } else { - if (arch_timer_counter_has_wa()) { - rd = arch_counter_get_cntpct_stable; - scr = raw_counter_get_cntpct_stable; - } else { - rd = arch_counter_get_cntpct; - scr = arch_counter_get_cntpct; - } + rd = arch_counter_get_cntpct; + scr = raw_counter_get_cntpct; } arch_timer_read_counter = rd; @@ -990,10 +992,8 @@ bool read_sched_clock_is_arch_counter(const struct clock_read_data *crd) { u64 (*rd)(void) = crd->read_sched_clock; - return (rd == raw_counter_get_cntvct_stable || - rd == raw_counter_get_cntpct_stable || - rd == arch_counter_get_cntvct || - rd == arch_counter_get_cntpct); + return (rd == raw_counter_get_cntvct || + rd == raw_counter_get_cntpct); } static void arch_timer_stop(struct clock_event_device *clk) -- 2.47.3