From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 A6AE539B97D for ; Mon, 2 Mar 2026 10:29:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772447382; cv=none; b=XKgYqXNYw28GAtNzBrhJlG7S/jTczzINuPG3GjCa2kQkNaHg0gq5Kdar+Mto2guAaGEfhxnQZqLj3MpHB+LClE9kRNMD8Z74l0/M8X1HWudH8c20Dc8QfGuaWSVzLwoodRr+0mu+8v1w8QPZaziKu0dmncVNImiX/x4VZ5ezauc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772447382; c=relaxed/simple; bh=PlhXgFp9jn4wn5ui/B/bv4QBDAuir3YiMvnBhoH2GEI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Bk12WAccAyWKlEx0GNQm4J0PM3ykhJ7dK5K78q80yLnO1fajtmQC01XT+NNLDmmC42xDSZLeumKJW+j4TtAf5XY2RzHOf+8v+ksWJmCIg9XCl1NbG7jcxgxZ9vID8BW1n4yPwlygmbuIEDaBm4f7EhnaB2K6RqShmrxQqDqdPHQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tRSoUG62; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tRSoUG62" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82EF9C2BCB0; Mon, 2 Mar 2026 10:29:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772447382; bh=PlhXgFp9jn4wn5ui/B/bv4QBDAuir3YiMvnBhoH2GEI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tRSoUG62ioBFBeu7ATvGvmF+Cdu1gkDxyoo6VhjeackIcMX4q97YqQjy7MnSiJB+h q84xkQM3/4xyhGH1fHAglPqmoU+0TXUt8LXzCSZQ2M8Qt69XMoxwf7XBLQTN3JBN+4 BRdBpAplrQ/+XEqkEtBZ22Oiivh9xl0+ZMW/HdW1glBWCtWQcoPItFLcysNYdo+OFF nqH3Uk2sblMa0Y0hiGEd5Q8XvIvyndB0xEHq01POIyCDW+joPzqFKas+chJw7ERsZ5 iOU/PnrqjObytd1BeZfupXJ+aUeNTKqTJYMPK+w0yNW7CZg7A+fbIe0oG3SOdY2kwR L0msueHO0HMPQ== 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 1vx0Wy-0000000FBCc-1Ywd; Mon, 02 Mar 2026 10:29: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 2/5] clocksource/drivers/arm_arch_timer: Convert counter accessors to a static key alternative Date: Mon, 2 Mar 2026 10:29:34 +0000 Message-ID: <20260302102937.1516059-3-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260302102937.1516059-1-maz@kernel.org> References: <20260302102937.1516059-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 | 38 +++++++++++++++------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c index c5b42001c9282..723ba698b8c46 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(); } @@ -946,21 +958,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) { - 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; -- 2.47.3