From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.180 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796503134; b=14QFvMK+FUEa8nILqGWWg24xt3kejBfrLKGm8lIjUYz0Npozrcy7AnShrKWVmESCUtIT bIwGvGRGz4ODbNsHbt+7C2KOZ7l37pcVrEzSvaRzrYlFhtk9CLFKVrZscwqMj4sG+mBLk ZB3exkTgHyNAWQWp4fOdbMMyjacyOuXmia2csIh47benHktswXsTKAu/9T/uIXPljpU2o nXGpBs6F2NYKw8AsOQ3hyAYZA8jTKupuQfZsSLeXYBJSkXJs3ac6LSLx6/nZ3u/oC6AL5 0+hNdSJZpRVTHsJOeC4u4iRklvIivzV684sFaRgTca9uF0dQ2mN0aHhdVVvRHpuQ3YA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796503134; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Type:X-Mailer:X-Developer-Signature: X-Developer-Key:Content-Transfer-Encoding; bh=rkcpNlDBaa59+EtFoRMDSeGVHyoIo/e4fsBCWTBMcpY=; b=vZ0tP3PkFj7fU/VMXyU2Ddu0OKmGNY14+eQTuTHjjjmUNDN6lbNE8LUvqHF+TXNj+7+Q trf5Z6PKGqKpdc5QNEgY8+wh4T2cBz1W0e08/8U/R+A+vaXsV3E0xcnghMujRbp3gV550 9qz/ejM+lENQpsxENzMivV1LXoK5v8YuKBf5f/RgI0EwtqFJeBXk1uxeAM/D9rKk9ril3 L8SmVzFE+k16dxPkNIhUo5lfA7/hefErV3aiaKdq5bDTf2kpo7Z97+kIgDmfHbclaNKTH +xoVzxkLk8haJSxFt6q6xFwT9U5gX7KQYvfnwSj3E44jfeQRiJRi3m9auh9v7SnK2zA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=mfZVdeEE; arc=none smtp.remote-ip=209.85.128.180 Received: from mail-yw1-f180.google.com (mail-yw1-f180.google.com [209.85.128.180]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F2E8606A31F for ; Sat, 5 Dec 2026 20:38:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3F2E8606A31F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=mfZVdeEE Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-8b51389f58cso20655517b3.3 for ; Sat, 05 Dec 2026 12:38:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796503132; x=1797107932; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=rkcpNlDBaa59+EtFoRMDSeGVHyoIo/e4fsBCWTBMcpY=; b=mfZVdeEEYfuxi7vz9BqooBA0g+E4rTTjVoL7ePvT2MYVLFBfgjwCrYcE9qck7a+PpM NoP6BB7kVC6h0LyfoOyZvgMIPzRNfMpcYaNfVKaX5eBjAUMYxQMtVKRqS8Xt8FBNOcuv ZtPwdQ07ZiEUouhWzvFBu6ww1Mz5lzikYdnFLYOy6jYg5PLDxJp07ftDJ93k+m8QexPw zGkn5BYMMy5XeveqMoXncq1Bq9ZXf3zb8jMYffJka5ANwc9+EzIWbJsLYXA9bRMjlNaa +po3J1lC2aaNXxnKxhhqh2tqOBXAO2znPJtjr9MQ3HYsH/DAe69968XRoFCTjL7zQYYF 5yGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796503132; x=1797107932; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=rkcpNlDBaa59+EtFoRMDSeGVHyoIo/e4fsBCWTBMcpY=; b=i2bhmvm4DsxOA6oBcWXYU++vnx7ePV5ZJHXLVTlPviXmMBinVeDn14jRsPK6TP77YD x6F6Hgou31wom7bgEAzJVf+sVthbMh7PhsyO+S34782FPu+O0L00VJYN0fLvCd5RHETj 8VrUP0yGfMaeN2J+0jxrZ7WrhAcZulOCpgQ2EkQ9aXjBsL1ax6nB8wTikh00gYhSeYaU HOiquKZYFlB7eBi06EsEDEc4Z4ynyONevSJ0VjCdxAqvB2a/pqIovmYfm2dgk6jzYfRI EY4zFU+hVhCEY4ox2rPx7op34Wi3R0dNHD+g/Rt+pdYTwWy9Pdn5DKsombZsM6b5UfaN F9ng== X-Forwarded-Encrypted: i=1; AL+hErHjnTCYsADhmdyYkG4Cro/zJRXxnzVqyTfBIk7IvVIehzqhV2iMKPUnjNlmrDOFcQ6aqaSvN9qgAlyQVr8=@vger.kernel.org X-Gm-Message-State: AB4q+uEJ3qqUIw+AObFHEwJfPEORB6u5EgQ1KNGDiqpX7NvMEDRgAsiR 0x9kgc5T1lwWjnxUgdgulNr43eJcvUSgbymJ/hFbXv0P4qGDEcm70Jys X-Gm-Gg: AZFdTZdMoOuIGEPhNltelcxq2/F0PIJjVWpUxK9BFbJu9OyFyLpYSRELHx12BuoAgHl bxD10vqrU+q6T+VhAiAtlmpGrVdjSMg0dfbeuLv+5J+3T/8U/u11SahUzeLvePO4KspwXwDv1Tm 5H5NVljgCJsSGtbr1VkZjzou35+ieX1IXNXTjJZ/UL5PlqBWrT66lqkiA2b46AiD81nTuhz/fFe IWAFVRywmBXhzJtPHLdtoluhgcsq0JTKiIwfrUy+xHbeEFhQn65132+46k66H4549khjzSLBV7N iHLYWhbTe8vmpfAq4sb8GLsA8Od2UoTzonLKIJOYKIpMJPNFAs5Z/uwFf2/yypSq9tquwc/bITC Atxz/S4LYTP+Sd8f23HDGDIA8jGqMgLP7OA0Uhny4LaQ3+7hjaV2OpPqVdauIKZRnpbYP4BnszV m8pLFft5Gy9F4D8yQBoTrIFwyGBeW8i9GRoeTx6XQPOm0SF+bryj5bVFkc3FJET4HJt19isy9Vv vMM6TXiq9GOXVzl+PsASMOzAACGOaSqJ9r9husZb6jMx1UFgAZC/dNatSSLuqYZagHiMrh3FeEt bi7Zi/UOCMwdIzBN8StFuCqcOe5G1wJupPVppxD4T3FPKPgh9llrCCFHC8JOVbfqb1bdQswpBaa 88PGA3X5riqZar28zkkivCk0UGw6lPYv8fLcDZcSyfWpNMY3CNoKWh7HLrQ3KWsZ/X87E//sDI6 FUv60W2hb31FxSGroDfQ== X-Received: by 2002:a05:690c:d20:b0:8b4:d2c9:6e31 with SMTP id 00721157ae682-8b660e1214amr20494497b3.109.1796503132148; Sat, 05 Dec 2026 12:38:52 -0800 (PST) Received: from localhost (107-220-129-194.lightspeed.chrlnc.sbcglobal.net. [107.220.129.194]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-67f0cd06396sm2706721d50.11.2026.12.05.12.38.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2026 12:38:51 -0800 (PST) From: Matt Turner To: Richard Henderson , Magnus Lindholm Cc: linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] alpha: Use rpcc when WTINT is configured but not implemented Date: Sat, 5 Dec 2026 15:38:48 -0500 Message-ID: <20261205-alpha-rpcc-smp-v1-1-aae5b79e7bac@gmail.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261205-alpha-rpcc-smp-v1-0-084c39baee43@gmail.com> References: <20261205-alpha-rpcc-smp-v1-0-084c39baee43@gmail.com> X-Mailing-List: linux-kernel@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" X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4808; i=mattst88@gmail.com; h=from:subject:message-id; bh=q0Jb8P1J/eEhCIrjakxsf2ouNeIN30Zy56ij6LJB6/0=; b=owGbwMvMwCW25rVmCc8sv+mMp9WSGLJFyhyKF7xxLeJo4DtdeXRKyc2KVQvvhxuaLJ8uqCyx8 MTeXjWXjo8sDGJcDDPFFFni1iuyzGrbsdTntPQvmDmsTCBDpEUaGICAhYEvNzGv1EjHSM9U21DP EMjQMYqHyOkxaGQWF5emFummFRQ55OWXJJZk5ucV6+UXpOYVpBfopWWmlWRk5BcVpwKN0MtLLTF 1dXQzMjQwsXS0MHOycDQ1cXZ2MnRyc3R0dnUysjQ3MXC2dDRxtTRn4OIUgLlmrT7Df+9Kloe/58 38tfhv8Ydmp1UKE7fOOMaxTUhbQJv910ePcAmGP7y5EtylB0x/vtjYovu8MC0lo+mM/YyZ2oYJJ w/ItiwKZQcA X-Developer-Key: i=mattst88@gmail.com; a=openpgp; fpr=3BB639E56F861FA2E86505690FDD682D974CA72A Content-Transfer-Encoding: 8bit With CONFIG_ALPHA_WTINT, which most SMP configurations enable, the rpcc clocksource is compiled out: CALL_PAL WTINT may slow or stop the cycle counter while the CPU waits for an interrupt. But not every PALcode implements WTINT. Where it does not, the call raises an OPCDEC fault and do_entIF() patches it into a no-op, so the counter keeps running and the kernel is left on the jiffies clocksource for no reason. The Tru64 PALcode in the Marvel (ES47, GS1280) firmware is one of these: its WTINT entry is the same stub as its unassigned CALL_PAL functions, and on an ES47 the call traps. Always build the rpcc clocksource and record in do_entIF() that WTINT had to be emulated. Register the clocksource from a device_initcall() instead of time_init(), which runs with interrupts disabled, and before that call WTINT once with interrupts enabled: where it is implemented it returns at the next interrupt, and where it is not, the emulation says so. Signed-off-by: Matt Turner --- arch/alpha/kernel/proto.h | 1 + arch/alpha/kernel/time.c | 40 ++++++++++++++++++++++++++++++++-------- arch/alpha/kernel/traps.c | 4 ++++ 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/arch/alpha/kernel/proto.h b/arch/alpha/kernel/proto.h index 7ece3b635e27..0226aa8281f0 100644 --- a/arch/alpha/kernel/proto.h +++ b/arch/alpha/kernel/proto.h @@ -190,6 +190,7 @@ extern void do_entDbg(struct pt_regs *); struct allregs; extern void do_entUna(void *, unsigned long, unsigned long, struct allregs *); extern void do_entUnaUser(void __user *, unsigned long, unsigned long, struct pt_regs *); +extern bool alpha_wtint_missing; /* irq_alpha.c */ extern void notrace lockdep_on_restore(unsigned long ps, unsigned long ip); diff --git a/arch/alpha/kernel/time.c b/arch/alpha/kernel/time.c index 4d01c392ab14..7a5aa0ce5ac5 100644 --- a/arch/alpha/kernel/time.c +++ b/arch/alpha/kernel/time.c @@ -246,7 +246,6 @@ common_init_rtc(void) } -#ifndef CONFIG_ALPHA_WTINT /* * The RPCC as a clocksource primitive. * @@ -258,7 +257,7 @@ common_init_rtc(void) * * When using the WTINT PALcall, the RPCC may shift to a lower frequency, * or stop altogether, while waiting for the interrupt. Therefore we cannot - * use this method when WTINT is in use. + * use this method when the PALcode implements WTINT. */ static u64 read_rpcc(struct clocksource *cs) @@ -273,7 +272,8 @@ static struct clocksource clocksource_rpcc = { .mask = CLOCKSOURCE_MASK(32), .flags = CLOCK_SOURCE_IS_CONTINUOUS }; -#endif /* ALPHA_WTINT */ + +static unsigned long rpcc_freq __initdata; /* Validate a computed cycle counter result against the known bounds for @@ -434,17 +434,41 @@ time_init(void) "and unable to estimate a proper value!\n"); } - /* See above for restrictions on using clocksource_rpcc. */ -#ifndef CONFIG_ALPHA_WTINT - if (hwrpb->nr_processors == 1) - clocksource_register_hz(&clocksource_rpcc, cycle_freq); -#endif + /* Registered by init_rpcc_clocksource(). */ + rpcc_freq = cycle_freq; /* Startup the timer source. */ alpha_mv.init_rtc(); init_rtc_clockevent(); } +/* + * Registered from an initcall rather than time_init(), which runs with + * interrupts disabled, too early to probe for WTINT. + */ +static int __init init_rpcc_clocksource(void) +{ + /* QEMU uses qemu_cs; time_init() leaves rpcc_freq unset. */ + if (alpha_using_qemu) + return 0; + + /* See above for restrictions on using clocksource_rpcc. */ + if (hwrpb->nr_processors != 1) + return 0; + + if (IS_ENABLED(CONFIG_ALPHA_WTINT)) { + /* Returns at the next interrupt, or traps if unimplemented. */ + wtint(0); + if (!alpha_wtint_missing) + return 0; + } + + clocksource_register_hz(&clocksource_rpcc, rpcc_freq); + + return 0; +} +device_initcall(init_rpcc_clocksource); + /* Initialize the clock_event_device for secondary cpus. */ #ifdef CONFIG_SMP void __init diff --git a/arch/alpha/kernel/traps.c b/arch/alpha/kernel/traps.c index db6277b3bed0..b335928c8314 100644 --- a/arch/alpha/kernel/traps.c +++ b/arch/alpha/kernel/traps.c @@ -196,6 +196,9 @@ do_entArith(unsigned long summary, unsigned long write_mask, send_sig_fault_trapno(SIGFPE, si_code, (void __user *) regs->pc, 0, current); } +/* Set once do_entIF() has had to emulate CALL_PAL WTINT. */ +bool alpha_wtint_missing; + asmlinkage void do_entIF(unsigned long type, struct pt_regs *regs) { @@ -234,6 +237,7 @@ do_entIF(unsigned long type, struct pt_regs *regs) *pinsn = 0x47e01400; /* mov 0,$0 */ imb(); regs->r0 = 0; + alpha_wtint_missing = true; return; } } -- 2.56.1