Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp11921044rwl; Tue, 3 Jan 2023 06:41:15 -0800 (PST) X-Google-Smtp-Source: AMrXdXuj5PxEkk7ht8JhctvHLAADsJklhGSxj6RJoSIEMDeI1eErPTy3qrlzR+lqGFkcwBh+95V7 X-Received: by 2002:a05:6a21:998b:b0:a6:713d:4343 with SMTP id ve11-20020a056a21998b00b000a6713d4343mr73514684pzb.5.1672756875411; Tue, 03 Jan 2023 06:41:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672756875; cv=none; d=google.com; s=arc-20160816; b=qrHSCLujf1Pu3mu8lXgj79JRb7T8F8nydk52NVkcg3/5y/oEn/wHp5y3pqPcgq+tp1 txxYJppLtfF0yx56MMYwHBTuazEECZt8AvYbOgGFWsSfM22g/DYXKkOcnTy0fs/kMCLk NEa4mMU2hf92eyEQ5lovNG66bgHoah1b/wlL0LOJZGBOuuGXv9EVFNbvfgJ5CVTPTEx1 MCNsc0VIQGVH0lvs9ZEAjSXO1GioQOsOZSCQxuti6cZkjOfR6yJ+0vgo1Qr3E88NohyU gjLsy9YfBrVttTEqfi9cs3kRUgp/vpEc+10oS+Ve2b97rZQsxz/Mmu7qKMjdWCXxQeZp iupA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Dlh2CMNdSoUIQxTaEwlbl5D9rexWqbuQ4H+cWHRWlxo=; b=01RnX4lDurBiuDtuyVs/BlTI5Z0I5pVnT4xTf4BNCHm+8SCktu9FpyVFazBlN433yG JgfuvniJS8EIyZYwZMccjvgJa/b6+LALApCAMa9py08iH7gCOfX40BwIByCzNmFpJAv4 Ik97FzC8pyriyGL2zxV8fBVsEQe+lG9SlWTeJp3TwnQAZdOdOSpuJGTqnS/FaJmGt0aE PpVc/8uiiBGnzmoLmfX4On68zpRNSSGbutv1WQJfiLOO5rrerWwsrtQx+8DMe/kfG4Oh dx53+BquHnbr1ZHVKHb2JHg9J65ZSDNplM4R5/Am8ztSIyJ6mXugK3d/Dw1EoOPV5hPv Utqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=gzxbqIdl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p33-20020a635b21000000b004921cae2a13si31786768pgb.151.2023.01.03.06.41.07; Tue, 03 Jan 2023 06:41:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=gzxbqIdl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237758AbjACOL0 (ORCPT + 60 others); Tue, 3 Jan 2023 09:11:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237589AbjACOLX (ORCPT ); Tue, 3 Jan 2023 09:11:23 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED2846365 for ; Tue, 3 Jan 2023 06:11:18 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id o21so2858277pjw.0 for ; Tue, 03 Jan 2023 06:11:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Dlh2CMNdSoUIQxTaEwlbl5D9rexWqbuQ4H+cWHRWlxo=; b=gzxbqIdlnLfc3CYwtD5PIBA+jLZSmjFqO8TrRQZJuC42pQak+JX3HPhYh9kRLnYkaQ IaNUcVXwgUgpIb7WxUwbVgIZTjHbJrnm6mkhnhjO3DW6Zg/KlWGnVI4/aNBMGdR2Lusq JBoCwrorLqqrMfcK9UZRKP8m6KfWIgDYLVLMIutcA9c7n3zw1DeAgC+FR88evKH7XaiP J5OC6TsRJ13W6bv21/QL4g+jkB3ZNW1N5XNfxobqRPNJgkHoS+m/sLHIWLbijyCJtlxB kNl7QDifcdudr9IwAvQj38CfDJ6gjsGhJKHdo6UfuELXzch5CTYyyl97H1pfxicIvnSV WBLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Dlh2CMNdSoUIQxTaEwlbl5D9rexWqbuQ4H+cWHRWlxo=; b=K+A7jjTI7opX9gN2fHqkDv4SQzfum9eCRVqQbDDwlxPuf6+1bS1L77gkwQHFfjP8YA HLahMIruRAP2K5PedfcYXMfDwKSkeLuZfsCc8YBtjna2qFLmRr3IddiKKK/yDer0KQds Nup2lK5FhBUIuPHVBsZxRyhhP+X2AYC9rj8THz8GfMoy+QOWPZSTvuA40GM+Qc1kbyBm CRUR6pIuLBYo53uIYdrxmAbv/JR8kCfUZRPvVpZdBnxkPmLUUbomD7XAoLJMu+B6Vqqo uoph01wdlBSPP1aeRN8cKTSxoWyFQ/d6M7xMbPGnwU9kB8mk4mno0BQHIgwzGeNmjHL/ jJ/w== X-Gm-Message-State: AFqh2kpVCzVx9kXJcMcqCugRfrEhytX8nwDNMSymIe/j91F2cjOXRC8L iAekLct1FcV8EUoZqHelEYXWcw== X-Received: by 2002:a17:902:d3cc:b0:192:9141:ace5 with SMTP id w12-20020a170902d3cc00b001929141ace5mr25598340plb.13.1672755078370; Tue, 03 Jan 2023 06:11:18 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([171.76.85.241]) by smtp.gmail.com with ESMTPSA id l3-20020a170902e2c300b00192bf7eaf28sm6146117plc.286.2023.01.03.06.11.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 06:11:17 -0800 (PST) From: Anup Patel To: Rob Herring , Krzysztof Kozlowski , Palmer Dabbelt , Paul Walmsley , Daniel Lezcano , Thomas Gleixner Cc: Andrew Jones , Atish Patra , Samuel Holland , Conor Dooley , Anup Patel , devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel , Palmer Dabbelt Subject: [PATCH v6 1/3] RISC-V: time: initialize hrtimer based broadcast clock event device Date: Tue, 3 Jan 2023 19:41:00 +0530 Message-Id: <20230103141102.772228-2-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230103141102.772228-1-apatel@ventanamicro.com> References: <20230103141102.772228-1-apatel@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Conor Dooley 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 --- 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 8217b0f67c6c..1cf21db4fcc7 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) -- 2.34.1