Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD08FC636CC for ; Mon, 13 Feb 2023 18:27:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230402AbjBMS1M (ORCPT ); Mon, 13 Feb 2023 13:27:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230293AbjBMS03 (ORCPT ); Mon, 13 Feb 2023 13:26:29 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38586F1; Mon, 13 Feb 2023 10:26:28 -0800 (PST) Date: Mon, 13 Feb 2023 18:26:25 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1676312785; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zBhCRTh8osu7xSxgDbCZKBz8vh3/bGHBs81Gav2hZ2w=; b=f9C7H+9uFWfaEFbMdrA64RhrmSH9ZRv3dckMTM263JBuSLTwtCFikmaQuRFUF5QxbZwFRu GtxnEPDWKCu6QOUgwgMyqtHmJTbhJB0Z63EmmUGTr4pj05C032Z90MXzXQ9eO4qOzC5nE1 cA75Z4+JEPfqpJGL3C750xObESa3eOmw95Q1BhvPKex6xiOuC+DFTU1dKdZei5thxfv6hY WFfN3O3l9Yl+FjNil/ww8On9Wn8y6ZQ6SBhvo9I+MN3IVLY1y/QIlRUjbTJcDwRIASRB+x 4cI1Tzk8bsDN9iNHw+Am4MmJsSxIYZgZg2Zoyurd+Ujj/b8ryzbvUU4BDOa+ZQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1676312785; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zBhCRTh8osu7xSxgDbCZKBz8vh3/bGHBs81Gav2hZ2w=; b=KrO/9O3uNW1aYZ63NPoJ26Ha4f2f6UpHYm/sigW2yMyeJ/7AWpnKXtp/EgBC+VfrzywTFh KLyifKKLtpfkivDA== From: "tip-bot2 for Conor Dooley" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/core] RISC-V: time: initialize hrtimer based broadcast clock event device Cc: Samuel Holland , Conor Dooley , Anup Patel , Palmer Dabbelt , Daniel Lezcano , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230103141102.772228-2-apatel@ventanamicro.com> References: <20230103141102.772228-2-apatel@ventanamicro.com> MIME-Version: 1.0 Message-ID: <167631278533.4906.4080664832019272480.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the timers/core branch of tip: Commit-ID: 8b3b8fbb4896984b5564789a42240e4b3caddb61 Gitweb: https://git.kernel.org/tip/8b3b8fbb4896984b5564789a42240e4b3caddb61 Author: Conor Dooley AuthorDate: Tue, 03 Jan 2023 19:41:00 +05:30 Committer: Daniel Lezcano CommitterDate: Mon, 13 Feb 2023 13:10:16 +01:00 RISC-V: time: initialize hrtimer based broadcast clock event device Similarly to commit 022eb8ae8b5e ("ARM: 8938/1: kernel: initialize broadcast hrtimer based clock event device"), RISC-V needs to initiate hrtimer based broadcast clock event device before C3STOP can be used. Otherwise, the introduction of C3STOP for the RISC-V arch timer in commit 232ccac1bd9b ("clocksource/drivers/riscv: Events are stopped during CPU suspend") leaves us without any broadcast timer registered. This prevents the kernel from entering oneshot mode, which breaks timer behaviour, for example clock_nanosleep(). A test app that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & C3STOP enabled, the sleep times are rounded up to the next jiffy: == CPU: 1 == == CPU: 2 == == CPU: 3 == == CPU: 4 == Mean: 7.974992 Mean: 7.976534 Mean: 7.962591 Mean: 3.952179 Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193 Hi: 9.472000 Hi: 10.495000 Hi: 8.864000 Hi: 4.736000 Lo: 6.087000 Lo: 6.380000 Lo: 4.872000 Lo: 3.403000 Samples: 521 Samples: 521 Samples: 521 Samples: 521 Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/ Fixes: 232ccac1bd9b ("clocksource/drivers/riscv: Events are stopped during CPU suspend") Suggested-by: Samuel Holland Signed-off-by: Conor Dooley Signed-off-by: Anup Patel Reviewed-by: Samuel Holland Acked-by: Palmer Dabbelt Link: https://lore.kernel.org/r/20230103141102.772228-2-apatel@ventanamicro.com Signed-off-by: Daniel Lezcano --- arch/riscv/kernel/time.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/riscv/kernel/time.c b/arch/riscv/kernel/time.c index 8217b0f..1cf21db 100644 --- a/arch/riscv/kernel/time.c +++ b/arch/riscv/kernel/time.c @@ -5,6 +5,7 @@ */ #include +#include #include #include #include @@ -29,6 +30,8 @@ void __init time_init(void) of_clk_init(NULL); timer_probe(); + + tick_setup_hrtimer_broadcast(); } void clocksource_arch_init(struct clocksource *cs)