Message ID | 20221201123954.1111603-4-apatel@ventanamicro.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp240412wrr; Thu, 1 Dec 2022 04:48:24 -0800 (PST) X-Google-Smtp-Source: AA0mqf45FTYx1AwsT7NMb9ix3oySQc41TvachzybzALemi9/MM7nqZaThOLyEmMqAFjtuAo7Izqm X-Received: by 2002:a63:1e49:0:b0:46b:1590:2625 with SMTP id p9-20020a631e49000000b0046b15902625mr39700134pgm.569.1669898904462; Thu, 01 Dec 2022 04:48:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669898904; cv=none; d=google.com; s=arc-20160816; b=Z+fMe4MQeDWiGnAGHdxBHByDXd/a/m0C63eODs3R6YR9Vg3SYiNsd8iLvUrys5nYam wXQ4WyWmXQ3G6fRxjW0ipGaYcALuVFK9CezwUvq5G9ouYTWLgv4NUmA2pJEvFMW5Hn3R DM8H3ibiR7k2vtQkNYGwe56EjYyR1Dyi8StaOGb4jpXCb/i6kQwpqQAGwUsBmTE9eB83 oNxlZRlNvdaCpp1S2gj3B9V7WF1vnylbjCu6fvZgdp+asocKyUSjouvNWiLb+p4qBYD2 rmkuj2POgOtmSzMOHbU+HzT/2tgmuAw7g7/BIjK04xX+5RxqiAyzgKcrbz3othfT7CkT XLHw== 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=6S7naxVeL+Tq1XdOeQt8X5QpTYGWrVZhiHOlENIaVW4=; b=RYK9JkhQEGs2SrGvkEnFCvWpFH8EY73E/ehrbjucy0x/ShPBJzT1G0m4rnHvySnDKD B9o9+IpvtBHSh3K5Qs7G0puAme2xmnA4FPWW4q1Hm0WVTrvIf2h8y+oxZ3OtHiShv2CF p7CH8dLa2MZNx+eq27hJj4+42I5XF0c8Kjgd18zwFWuGfK5CsHrRxHJ+Co2Hhroz1KCE vHq6lcaLQu1xRWxI8PsFBeOLMlgmBN/kNETN0JXa25G2B/gFSrtySXRxZMVzUjSbWZs8 7XKvlrGdbNXc8Tq0MeWUmihY/5xGalEEMeLKpNyqm8PZSa7LUCMKM+RUZawHGIfJQLXK WfQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=ODFqGsjS; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n27-20020aa7985b000000b0056dc342ea54si4280968pfq.206.2022.12.01.04.48.11; Thu, 01 Dec 2022 04:48:24 -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=ODFqGsjS; 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 S230266AbiLAMke (ORCPT <rfc822;heyuhang3455@gmail.com> + 99 others); Thu, 1 Dec 2022 07:40:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231477AbiLAMk3 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 1 Dec 2022 07:40:29 -0500 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B37EBA0A6 for <linux-kernel@vger.kernel.org>; Thu, 1 Dec 2022 04:40:21 -0800 (PST) Received: by mail-pj1-x102c.google.com with SMTP id u15-20020a17090a3fcf00b002191825cf02so1916548pjm.2 for <linux-kernel@vger.kernel.org>; Thu, 01 Dec 2022 04:40:21 -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=6S7naxVeL+Tq1XdOeQt8X5QpTYGWrVZhiHOlENIaVW4=; b=ODFqGsjSBR77IhnwGSMqT5Cedqv+o+83HTdoL9r+54VqgGotTXmXpohITgE49F7wSd Tkur0/NYoqgk92i4gk54CRC/pqYBBmM2Zbo6r10FLJYhD2qqf8jup2GHELUwP4gwflmR zHYM7ShhCJW76jq1Qu2vQBginDdz04Pbwt71TzSOIEVOWuPV44OgVizwpklWWnB7e+Y5 D4+z2VkQ+x3EEWAciK1knsKdG5FhwxYEmrPWeSjvn7rHX4xtesNCG3kcL9kYwyxbC5ya FHhXlzp0mt54IMjKmv9qfrLyPhAifG9KdRWdez3fjVDG0RQP0zP5aj9Gdf9VUb814ry7 1cfA== 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=6S7naxVeL+Tq1XdOeQt8X5QpTYGWrVZhiHOlENIaVW4=; b=tOyoPHnHd2giSZmDqP4RsQMJ5TdEzaR9ko6b/BBHu/2hQvCX70k+842xmLNldYX9TC GHRAo/ICBrx9izoCtbN+2rj5nO5kZujf8CrnAy19EfonXtP9oQx7lvUdKWn3QPScUiUf h29QDF4S8WrdWWp6idu9toirRGhfckfZyXKgZQEfI3tnmQM2B2LUtqUSflFi5rL2E+HE MW1iz1vxwI/XxA3TqlUGys32pUeDLXqjqJ4JfUu1LY+3sESdO5bWYWfRONXElanmYDej ePtHd2r8BG24QJ5M235yb35BdGcTY+tfQosoxp+K+1o2HPEjOUCPotZ2IiWi/1TZJLPt oSVw== X-Gm-Message-State: ANoB5pnxE58TclhTrtc1QSlx55HiRjFre1HO1HHYdkplZrod3ygrM4VU Jq1Y9JKA4K4Bl3XG70/pjVyPnA== X-Received: by 2002:a17:902:ec01:b0:186:878e:3b0d with SMTP id l1-20020a170902ec0100b00186878e3b0dmr47042474pld.149.1669898420501; Thu, 01 Dec 2022 04:40:20 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([171.76.81.69]) by smtp.gmail.com with ESMTPSA id b65-20020a62cf44000000b0056f0753390csm3246981pfg.96.2022.12.01.04.40.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 04:40:20 -0800 (PST) From: Anup Patel <apatel@ventanamicro.com> To: Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Palmer Dabbelt <palmer@dabbelt.com>, Paul Walmsley <paul.walmsley@sifive.com>, Daniel Lezcano <daniel.lezcano@linaro.org>, Thomas Gleixner <tglx@linutronix.de> Cc: Andrew Jones <ajones@ventanamicro.com>, Atish Patra <atishp@atishpatra.org>, Samuel Holland <samuel@sholland.org>, Conor Dooley <conor.dooley@microchip.com>, Anup Patel <anup@brainfault.org>, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel <apatel@ventanamicro.com>, Palmer Dabbelt <palmer@rivosinc.com> Subject: [PATCH v5 3/3] clocksource: timer-riscv: Set CLOCK_EVT_FEAT_C3STOP based on DT Date: Thu, 1 Dec 2022 18:09:54 +0530 Message-Id: <20221201123954.1111603-4-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221201123954.1111603-1-apatel@ventanamicro.com> References: <20221201123954.1111603-1-apatel@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751015913426014617?= X-GMAIL-MSGID: =?utf-8?q?1751015913426014617?= |
Series |
Improve CLOCK_EVT_FEAT_C3STOP feature setting
|
|
Commit Message
Anup Patel
Dec. 1, 2022, 12:39 p.m. UTC
We should set CLOCK_EVT_FEAT_C3STOP for a clock_event_device only when riscv,timer-cannot-wake-cpu DT property is present in the RISC-V timer DT node. This way CLOCK_EVT_FEAT_C3STOP feature is set for clock_event_device based on RISC-V platform capabilities rather than having it set for all RISC-V platforms. Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-by: Conor Dooley <conor.dooley@microchip.com> Acked-by: Palmer Dabbelt <palmer@rivosinc.com> --- drivers/clocksource/timer-riscv.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
Comments
On Thu, Dec 01, 2022 at 06:09:54PM +0530, Anup Patel wrote: > We should set CLOCK_EVT_FEAT_C3STOP for a clock_event_device only > when riscv,timer-cannot-wake-cpu DT property is present in the RISC-V > timer DT node. > > This way CLOCK_EVT_FEAT_C3STOP feature is set for clock_event_device > based on RISC-V platform capabilities rather than having it set for > all RISC-V platforms. > > Signed-off-by: Anup Patel <apatel@ventanamicro.com> > Reviewed-by: Conor Dooley <conor.dooley@microchip.com> > Acked-by: Palmer Dabbelt <palmer@rivosinc.com> > --- > drivers/clocksource/timer-riscv.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c > index 969a552da8d2..1b4b36df5484 100644 > --- a/drivers/clocksource/timer-riscv.c > +++ b/drivers/clocksource/timer-riscv.c > @@ -28,6 +28,7 @@ > #include <asm/timex.h> > > static DEFINE_STATIC_KEY_FALSE(riscv_sstc_available); > +static bool riscv_timer_cannot_wake_cpu; > > static int riscv_clock_next_event(unsigned long delta, > struct clock_event_device *ce) > @@ -51,7 +52,7 @@ static int riscv_clock_next_event(unsigned long delta, > static unsigned int riscv_clock_event_irq; > static DEFINE_PER_CPU(struct clock_event_device, riscv_clock_event) = { > .name = "riscv_timer_clockevent", > - .features = CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_C3STOP, > + .features = CLOCK_EVT_FEAT_ONESHOT, A platform that depended on CLOCK_EVT_FEAT_C3STOP being set will break with this change because its existing DT will not have the new property. It needs to be the other way around which would effectively be the existing 'always-on' property. > .rating = 100, > .set_next_event = riscv_clock_next_event, > }; > @@ -85,6 +86,8 @@ static int riscv_timer_starting_cpu(unsigned int cpu) > > ce->cpumask = cpumask_of(cpu); > ce->irq = riscv_clock_event_irq; > + if (riscv_timer_cannot_wake_cpu) > + ce->features |= CLOCK_EVT_FEAT_C3STOP; > clockevents_config_and_register(ce, riscv_timebase, 100, 0x7fffffff); > > enable_percpu_irq(riscv_clock_event_irq, > @@ -139,6 +142,13 @@ static int __init riscv_timer_init_dt(struct device_node *n) > if (cpuid != smp_processor_id()) > return 0; > > + child = of_find_compatible_node(NULL, NULL, "riscv,timer"); > + if (child) { > + riscv_timer_cannot_wake_cpu = of_property_read_bool(child, > + "riscv,timer-cannot-wake-cpu"); > + of_node_put(child); > + } > + > domain = NULL; > child = of_get_compatible_child(n, "riscv,cpu-intc"); > if (!child) { > -- > 2.34.1 > >
On Fri, Dec 2, 2022 at 5:36 AM Rob Herring <robh@kernel.org> wrote: > > On Thu, Dec 01, 2022 at 06:09:54PM +0530, Anup Patel wrote: > > We should set CLOCK_EVT_FEAT_C3STOP for a clock_event_device only > > when riscv,timer-cannot-wake-cpu DT property is present in the RISC-V > > timer DT node. > > > > This way CLOCK_EVT_FEAT_C3STOP feature is set for clock_event_device > > based on RISC-V platform capabilities rather than having it set for > > all RISC-V platforms. > > > > Signed-off-by: Anup Patel <apatel@ventanamicro.com> > > Reviewed-by: Conor Dooley <conor.dooley@microchip.com> > > Acked-by: Palmer Dabbelt <palmer@rivosinc.com> > > --- > > drivers/clocksource/timer-riscv.c | 12 +++++++++++- > > 1 file changed, 11 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c > > index 969a552da8d2..1b4b36df5484 100644 > > --- a/drivers/clocksource/timer-riscv.c > > +++ b/drivers/clocksource/timer-riscv.c > > @@ -28,6 +28,7 @@ > > #include <asm/timex.h> > > > > static DEFINE_STATIC_KEY_FALSE(riscv_sstc_available); > > +static bool riscv_timer_cannot_wake_cpu; > > > > static int riscv_clock_next_event(unsigned long delta, > > struct clock_event_device *ce) > > @@ -51,7 +52,7 @@ static int riscv_clock_next_event(unsigned long delta, > > static unsigned int riscv_clock_event_irq; > > static DEFINE_PER_CPU(struct clock_event_device, riscv_clock_event) = { > > .name = "riscv_timer_clockevent", > > - .features = CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_C3STOP, > > + .features = CLOCK_EVT_FEAT_ONESHOT, > > A platform that depended on CLOCK_EVT_FEAT_C3STOP being set will break > with this change because its existing DT will not have the new property. > > It needs to be the other way around which would effectively be the > existing 'always-on' property. There are no RISC-V platforms using C3STOP. The patch which added C3STOP has been reverted. (Refer, https://lore.kernel.org/lkml/a218ebf8-0fba-168d-6598-c970bbff5faf@sholland.org/T/) I just need to rebase this patch upon the C3STOP revert patch. > > > .rating = 100, > > .set_next_event = riscv_clock_next_event, > > }; > > @@ -85,6 +86,8 @@ static int riscv_timer_starting_cpu(unsigned int cpu) > > > > ce->cpumask = cpumask_of(cpu); > > ce->irq = riscv_clock_event_irq; > > + if (riscv_timer_cannot_wake_cpu) > > + ce->features |= CLOCK_EVT_FEAT_C3STOP; > > clockevents_config_and_register(ce, riscv_timebase, 100, 0x7fffffff); > > > > enable_percpu_irq(riscv_clock_event_irq, > > @@ -139,6 +142,13 @@ static int __init riscv_timer_init_dt(struct device_node *n) > > if (cpuid != smp_processor_id()) > > return 0; > > > > + child = of_find_compatible_node(NULL, NULL, "riscv,timer"); > > + if (child) { > > + riscv_timer_cannot_wake_cpu = of_property_read_bool(child, > > + "riscv,timer-cannot-wake-cpu"); > > + of_node_put(child); > > + } > > + > > domain = NULL; > > child = of_get_compatible_child(n, "riscv,cpu-intc"); > > if (!child) { > > -- > > 2.34.1 > > > > Regards, Anup
Hey Rob, Anup, Prabhakar, On Fri, Dec 02, 2022 at 12:03:05PM +0530, Anup Patel wrote: > On Fri, Dec 2, 2022 at 5:36 AM Rob Herring <robh@kernel.org> wrote: > > > > On Thu, Dec 01, 2022 at 06:09:54PM +0530, Anup Patel wrote: > > > We should set CLOCK_EVT_FEAT_C3STOP for a clock_event_device only > > > when riscv,timer-cannot-wake-cpu DT property is present in the RISC-V > > > timer DT node. > > > > > > This way CLOCK_EVT_FEAT_C3STOP feature is set for clock_event_device > > > based on RISC-V platform capabilities rather than having it set for > > > all RISC-V platforms. > > > > > > Signed-off-by: Anup Patel <apatel@ventanamicro.com> > > > Reviewed-by: Conor Dooley <conor.dooley@microchip.com> > > > Acked-by: Palmer Dabbelt <palmer@rivosinc.com> > > > --- > > > drivers/clocksource/timer-riscv.c | 12 +++++++++++- > > > 1 file changed, 11 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c > > > index 969a552da8d2..1b4b36df5484 100644 > > > --- a/drivers/clocksource/timer-riscv.c > > > +++ b/drivers/clocksource/timer-riscv.c > > > @@ -28,6 +28,7 @@ > > > #include <asm/timex.h> > > > > > > static DEFINE_STATIC_KEY_FALSE(riscv_sstc_available); > > > +static bool riscv_timer_cannot_wake_cpu; > > > > > > static int riscv_clock_next_event(unsigned long delta, > > > struct clock_event_device *ce) > > > @@ -51,7 +52,7 @@ static int riscv_clock_next_event(unsigned long delta, > > > static unsigned int riscv_clock_event_irq; > > > static DEFINE_PER_CPU(struct clock_event_device, riscv_clock_event) = { > > > .name = "riscv_timer_clockevent", > > > - .features = CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_C3STOP, > > > + .features = CLOCK_EVT_FEAT_ONESHOT, > > > > A platform that depended on CLOCK_EVT_FEAT_C3STOP being set will break > > with this change because its existing DT will not have the new property. > > > > It needs to be the other way around which would effectively be the > > existing 'always-on' property. > > There are no RISC-V platforms using C3STOP. The patch which > added C3STOP has been reverted. > (Refer, https://lore.kernel.org/lkml/a218ebf8-0fba-168d-6598-c970bbff5faf@sholland.org/T/) > > I just need to rebase this patch upon the C3STOP revert patch. I guess you could say that the C3STOP addition was done spec-ulatively*, as the platform that actually exhibits that behaviour does not use the riscv-timer & its maintainer acked the revert (allwinner d1 family). *The spec does not make any guarantees about whether events arrive during suspend, only the behaviour *if* they arrive. Switching the property to "always-on" would require retrofitting that property to every other existing platform (and therefore regressing some behaviour there, no?). Most of the existing platforms are "toys" or demo platforms though, so it would not, I guess, be the end of the world to do so. Doubly so since none of them actually implement any sleep states that making it an "always-on" property. I've said since the start that defaulting to C3STOP is the "safer" thing to do, and although we disagreed on this last time Anup, I think the better outcome of someone missing a DT property is inaccessible sleep states rather than going into sleep states they cannot get out of. For PolarFire SoC, which I guess is one of the few "commerical" platforms, I'd be willing to accept retrofitting, since we have not yet implemented such sleep states yet. Maybe Prabhakar knows whether the RZ/Five has either a) implemented sleep states and b) which side of the "timer events arrive in suspend" divide their platform lies on. I'm particular interested here since that is not a SiFive core complex. I would like to get DT maintainer approval of an approach here soon-ish so that we can something sorted for the jh7110 stuff and for the bouffalolabs SoC - the latter of which may very well be in the "no events in suspend" camp as it also uses thead stuff. Sorry for kinda rowing back on my previous acceptance of the approach, but I am really between two minds on this. Thanks, Conor.
On 12/4/22 17:34, Conor Dooley wrote: > Hey Rob, Anup, Prabhakar, > > On Fri, Dec 02, 2022 at 12:03:05PM +0530, Anup Patel wrote: >> On Fri, Dec 2, 2022 at 5:36 AM Rob Herring <robh@kernel.org> wrote: >>> >>> On Thu, Dec 01, 2022 at 06:09:54PM +0530, Anup Patel wrote: >>>> We should set CLOCK_EVT_FEAT_C3STOP for a clock_event_device only >>>> when riscv,timer-cannot-wake-cpu DT property is present in the RISC-V >>>> timer DT node. >>>> >>>> This way CLOCK_EVT_FEAT_C3STOP feature is set for clock_event_device >>>> based on RISC-V platform capabilities rather than having it set for >>>> all RISC-V platforms. >>>> >>>> Signed-off-by: Anup Patel <apatel@ventanamicro.com> >>>> Reviewed-by: Conor Dooley <conor.dooley@microchip.com> >>>> Acked-by: Palmer Dabbelt <palmer@rivosinc.com> >>>> --- >>>> drivers/clocksource/timer-riscv.c | 12 +++++++++++- >>>> 1 file changed, 11 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c >>>> index 969a552da8d2..1b4b36df5484 100644 >>>> --- a/drivers/clocksource/timer-riscv.c >>>> +++ b/drivers/clocksource/timer-riscv.c >>>> @@ -28,6 +28,7 @@ >>>> #include <asm/timex.h> >>>> >>>> static DEFINE_STATIC_KEY_FALSE(riscv_sstc_available); >>>> +static bool riscv_timer_cannot_wake_cpu; >>>> >>>> static int riscv_clock_next_event(unsigned long delta, >>>> struct clock_event_device *ce) >>>> @@ -51,7 +52,7 @@ static int riscv_clock_next_event(unsigned long delta, >>>> static unsigned int riscv_clock_event_irq; >>>> static DEFINE_PER_CPU(struct clock_event_device, riscv_clock_event) = { >>>> .name = "riscv_timer_clockevent", >>>> - .features = CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_C3STOP, >>>> + .features = CLOCK_EVT_FEAT_ONESHOT, >>> >>> A platform that depended on CLOCK_EVT_FEAT_C3STOP being set will break >>> with this change because its existing DT will not have the new property. >>> >>> It needs to be the other way around which would effectively be the >>> existing 'always-on' property. >> >> There are no RISC-V platforms using C3STOP. The patch which >> added C3STOP has been reverted. >> (Refer, https://lore.kernel.org/lkml/a218ebf8-0fba-168d-6598-c970bbff5faf@sholland.org/T/) >> >> I just need to rebase this patch upon the C3STOP revert patch. > > I guess you could say that the C3STOP addition was done spec-ulatively*, > as the platform that actually exhibits that behaviour does not use the > riscv-timer & its maintainer acked the revert (allwinner d1 family). For clarity: that doesn't mean the platform will _never_ use the SBI timer facility, just that Linux happens to not use it right now. > *The spec does not make any guarantees about whether events arrive > during suspend, only the behaviour *if* they arrive. > > Switching the property to "always-on" would require retrofitting that > property to every other existing platform (and therefore regressing some > behaviour there, no?). > > Most of the existing platforms are "toys" or demo platforms though, so > it would not, I guess, be the end of the world to do so. Doubly so since > none of them actually implement any sleep states that making it an > "always-on" property. Specifically, only sleep states with a "local-timer-stop" property would be inhibited by the C3STOP flag, so there is only possibility of a regression if some DT declaring such a sleep state exists anywhere. Regards, Samuel > I've said since the start that defaulting to C3STOP is the "safer" thing > to do, and although we disagreed on this last time Anup, I think the > better outcome of someone missing a DT property is inaccessible sleep > states rather than going into sleep states they cannot get out of. > > For PolarFire SoC, which I guess is one of the few "commerical" > platforms, I'd be willing to accept retrofitting, since we have not yet > implemented such sleep states yet. > > Maybe Prabhakar knows whether the RZ/Five has either a) implemented > sleep states and b) which side of the "timer events arrive in suspend" > divide their platform lies on. > I'm particular interested here since that is not a SiFive core complex. > > I would like to get DT maintainer approval of an approach here soon-ish > so that we can something sorted for the jh7110 stuff and for the > bouffalolabs SoC - the latter of which may very well be in the "no > events in suspend" camp as it also uses thead stuff. > > Sorry for kinda rowing back on my previous acceptance of the approach, > but I am really between two minds on this. > > Thanks, > Conor. >
On Mon, Dec 05, 2022 at 02:17:40AM -0600, Samuel Holland wrote: > On 12/4/22 17:34, Conor Dooley wrote: > > Hey Rob, Anup, Prabhakar, > > > > On Fri, Dec 02, 2022 at 12:03:05PM +0530, Anup Patel wrote: > >> On Fri, Dec 2, 2022 at 5:36 AM Rob Herring <robh@kernel.org> wrote: > >>> > >>> On Thu, Dec 01, 2022 at 06:09:54PM +0530, Anup Patel wrote: > >>>> We should set CLOCK_EVT_FEAT_C3STOP for a clock_event_device only > >>>> when riscv,timer-cannot-wake-cpu DT property is present in the RISC-V > >>>> timer DT node. > >>>> > >>>> This way CLOCK_EVT_FEAT_C3STOP feature is set for clock_event_device > >>>> based on RISC-V platform capabilities rather than having it set for > >>>> all RISC-V platforms. > >>>> > >>>> Signed-off-by: Anup Patel <apatel@ventanamicro.com> > >>>> Reviewed-by: Conor Dooley <conor.dooley@microchip.com> > >>>> Acked-by: Palmer Dabbelt <palmer@rivosinc.com> > >>>> --- > >>>> drivers/clocksource/timer-riscv.c | 12 +++++++++++- > >>>> 1 file changed, 11 insertions(+), 1 deletion(-) > >>>> > >>>> diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c > >>>> index 969a552da8d2..1b4b36df5484 100644 > >>>> --- a/drivers/clocksource/timer-riscv.c > >>>> +++ b/drivers/clocksource/timer-riscv.c > >>>> @@ -28,6 +28,7 @@ > >>>> #include <asm/timex.h> > >>>> > >>>> static DEFINE_STATIC_KEY_FALSE(riscv_sstc_available); > >>>> +static bool riscv_timer_cannot_wake_cpu; > >>>> > >>>> static int riscv_clock_next_event(unsigned long delta, > >>>> struct clock_event_device *ce) > >>>> @@ -51,7 +52,7 @@ static int riscv_clock_next_event(unsigned long delta, > >>>> static unsigned int riscv_clock_event_irq; > >>>> static DEFINE_PER_CPU(struct clock_event_device, riscv_clock_event) = { > >>>> .name = "riscv_timer_clockevent", > >>>> - .features = CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_C3STOP, > >>>> + .features = CLOCK_EVT_FEAT_ONESHOT, > >>> > >>> A platform that depended on CLOCK_EVT_FEAT_C3STOP being set will break > >>> with this change because its existing DT will not have the new property. > >>> > >>> It needs to be the other way around which would effectively be the > >>> existing 'always-on' property. > >> > >> There are no RISC-V platforms using C3STOP. The patch which > >> added C3STOP has been reverted. > >> (Refer, https://lore.kernel.org/lkml/a218ebf8-0fba-168d-6598-c970bbff5faf@sholland.org/T/) > >> > >> I just need to rebase this patch upon the C3STOP revert patch. > > > > I guess you could say that the C3STOP addition was done spec-ulatively*, > > as the platform that actually exhibits that behaviour does not use the > > riscv-timer & its maintainer acked the revert (allwinner d1 family). > > For clarity: that doesn't mean the platform will _never_ use the SBI > timer facility, just that Linux happens to not use it right now. Yeah sorry - should have been a bit clearer there. There's a few other SoCs about that are using the thead cores, so I'd be "worried" that they share the timer behaviour but do not have an alternative like you do on the D1. That's part of what's kinda given me cold feet on the current approach. > > *The spec does not make any guarantees about whether events arrive > > during suspend, only the behaviour *if* they arrive. > > > > Switching the property to "always-on" would require retrofitting that > > property to every other existing platform (and therefore regressing some > > behaviour there, no?). > > > > Most of the existing platforms are "toys" or demo platforms though, so > > it would not, I guess, be the end of the world to do so. Doubly so since > > none of them actually implement any sleep states that making it an > > "always-on" property. > > Specifically, only sleep states with a "local-timer-stop" property would > be inhibited by the C3STOP flag, so there is only possibility of a > regression if some DT declaring such a sleep state exists anywhere. > > Regards, > Samuel > > > I've said since the start that defaulting to C3STOP is the "safer" thing > > to do, and although we disagreed on this last time Anup, I think the > > better outcome of someone missing a DT property is inaccessible sleep > > states rather than going into sleep states they cannot get out of. > > > > For PolarFire SoC, which I guess is one of the few "commerical" > > platforms, I'd be willing to accept retrofitting, since we have not yet > > implemented such sleep states yet. > > > > Maybe Prabhakar knows whether the RZ/Five has either a) implemented > > sleep states and b) which side of the "timer events arrive in suspend" > > divide their platform lies on. > > I'm particular interested here since that is not a SiFive core complex. > > > > I would like to get DT maintainer approval of an approach here soon-ish > > so that we can something sorted for the jh7110 stuff and for the > > bouffalolabs SoC - the latter of which may very well be in the "no > > events in suspend" camp as it also uses thead stuff. > > > > Sorry for kinda rowing back on my previous acceptance of the approach, > > but I am really between two minds on this. > > > > Thanks, > > Conor. > > > > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv
Hi Conor, On Sun, Dec 4, 2022 at 11:34 PM Conor Dooley <conor@kernel.org> wrote: > > Hey Rob, Anup, Prabhakar, > > On Fri, Dec 02, 2022 at 12:03:05PM +0530, Anup Patel wrote: > > On Fri, Dec 2, 2022 at 5:36 AM Rob Herring <robh@kernel.org> wrote: > > > > > > On Thu, Dec 01, 2022 at 06:09:54PM +0530, Anup Patel wrote: > > > > We should set CLOCK_EVT_FEAT_C3STOP for a clock_event_device only > > > > when riscv,timer-cannot-wake-cpu DT property is present in the RISC-V > > > > timer DT node. > > > > > > > > This way CLOCK_EVT_FEAT_C3STOP feature is set for clock_event_device > > > > based on RISC-V platform capabilities rather than having it set for > > > > all RISC-V platforms. > > > > > > > > Signed-off-by: Anup Patel <apatel@ventanamicro.com> > > > > Reviewed-by: Conor Dooley <conor.dooley@microchip.com> > > > > Acked-by: Palmer Dabbelt <palmer@rivosinc.com> > > > > --- > > > > drivers/clocksource/timer-riscv.c | 12 +++++++++++- > > > > 1 file changed, 11 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c > > > > index 969a552da8d2..1b4b36df5484 100644 > > > > --- a/drivers/clocksource/timer-riscv.c > > > > +++ b/drivers/clocksource/timer-riscv.c > > > > @@ -28,6 +28,7 @@ > > > > #include <asm/timex.h> > > > > > > > > static DEFINE_STATIC_KEY_FALSE(riscv_sstc_available); > > > > +static bool riscv_timer_cannot_wake_cpu; > > > > > > > > static int riscv_clock_next_event(unsigned long delta, > > > > struct clock_event_device *ce) > > > > @@ -51,7 +52,7 @@ static int riscv_clock_next_event(unsigned long delta, > > > > static unsigned int riscv_clock_event_irq; > > > > static DEFINE_PER_CPU(struct clock_event_device, riscv_clock_event) = { > > > > .name = "riscv_timer_clockevent", > > > > - .features = CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_C3STOP, > > > > + .features = CLOCK_EVT_FEAT_ONESHOT, > > > > > > A platform that depended on CLOCK_EVT_FEAT_C3STOP being set will break > > > with this change because its existing DT will not have the new property. > > > > > > It needs to be the other way around which would effectively be the > > > existing 'always-on' property. > > > > There are no RISC-V platforms using C3STOP. The patch which > > added C3STOP has been reverted. > > (Refer, https://lore.kernel.org/lkml/a218ebf8-0fba-168d-6598-c970bbff5faf@sholland.org/T/) > > > > I just need to rebase this patch upon the C3STOP revert patch. > > I guess you could say that the C3STOP addition was done spec-ulatively*, > as the platform that actually exhibits that behaviour does not use the > riscv-timer & its maintainer acked the revert (allwinner d1 family). > > *The spec does not make any guarantees about whether events arrive > during suspend, only the behaviour *if* they arrive. > > Switching the property to "always-on" would require retrofitting that > property to every other existing platform (and therefore regressing some > behaviour there, no?). > > Most of the existing platforms are "toys" or demo platforms though, so > it would not, I guess, be the end of the world to do so. Doubly so since > none of them actually implement any sleep states that making it an > "always-on" property. > > I've said since the start that defaulting to C3STOP is the "safer" thing > to do, and although we disagreed on this last time Anup, I think the > better outcome of someone missing a DT property is inaccessible sleep > states rather than going into sleep states they cannot get out of. > > For PolarFire SoC, which I guess is one of the few "commerical" > platforms, I'd be willing to accept retrofitting, since we have not yet > implemented such sleep states yet. > > Maybe Prabhakar knows whether the RZ/Five has either a) implemented > sleep states and b) which side of the "timer events arrive in suspend" > divide their platform lies on. > I'm particular interested here since that is not a SiFive core complex. > On RZ/Five we haven't implemented the sleep states yet. Cheers, Prabhakar
Hey Anup (& Daniel++), On Mon, Dec 05, 2022 at 08:33:53AM +0000, Conor Dooley wrote: > On Mon, Dec 05, 2022 at 02:17:40AM -0600, Samuel Holland wrote: > > On 12/4/22 17:34, Conor Dooley wrote: > > > Hey Rob, Anup, Prabhakar, > > > > > > On Fri, Dec 02, 2022 at 12:03:05PM +0530, Anup Patel wrote: > > >> On Fri, Dec 2, 2022 at 5:36 AM Rob Herring <robh@kernel.org> wrote: > > >>> > > >>> On Thu, Dec 01, 2022 at 06:09:54PM +0530, Anup Patel wrote: > > >>>> We should set CLOCK_EVT_FEAT_C3STOP for a clock_event_device only > > >>>> when riscv,timer-cannot-wake-cpu DT property is present in the RISC-V > > >>>> timer DT node. > > >>>> > > >>>> This way CLOCK_EVT_FEAT_C3STOP feature is set for clock_event_device > > >>>> based on RISC-V platform capabilities rather than having it set for > > >>>> all RISC-V platforms. > > >>>> > > >>>> Signed-off-by: Anup Patel <apatel@ventanamicro.com> > > >>>> Reviewed-by: Conor Dooley <conor.dooley@microchip.com> > > >>>> Acked-by: Palmer Dabbelt <palmer@rivosinc.com> > > >>>> --- > > >>>> drivers/clocksource/timer-riscv.c | 12 +++++++++++- > > >>>> 1 file changed, 11 insertions(+), 1 deletion(-) > > >>>> > > >>>> diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c > > >>>> index 969a552da8d2..1b4b36df5484 100644 > > >>>> --- a/drivers/clocksource/timer-riscv.c > > >>>> +++ b/drivers/clocksource/timer-riscv.c > > >>>> @@ -28,6 +28,7 @@ > > >>>> #include <asm/timex.h> > > >>>> > > >>>> static DEFINE_STATIC_KEY_FALSE(riscv_sstc_available); > > >>>> +static bool riscv_timer_cannot_wake_cpu; > > >>>> > > >>>> static int riscv_clock_next_event(unsigned long delta, > > >>>> struct clock_event_device *ce) > > >>>> @@ -51,7 +52,7 @@ static int riscv_clock_next_event(unsigned long delta, > > >>>> static unsigned int riscv_clock_event_irq; > > >>>> static DEFINE_PER_CPU(struct clock_event_device, riscv_clock_event) = { > > >>>> .name = "riscv_timer_clockevent", > > >>>> - .features = CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_C3STOP, > > >>>> + .features = CLOCK_EVT_FEAT_ONESHOT, > > >>> > > >>> A platform that depended on CLOCK_EVT_FEAT_C3STOP being set will break > > >>> with this change because its existing DT will not have the new property. > > >>> > > >>> It needs to be the other way around which would effectively be the > > >>> existing 'always-on' property. > > >> > > >> There are no RISC-V platforms using C3STOP. The patch which > > >> added C3STOP has been reverted. > > >> (Refer, https://lore.kernel.org/lkml/a218ebf8-0fba-168d-6598-c970bbff5faf@sholland.org/T/) > > >> > > >> I just need to rebase this patch upon the C3STOP revert patch. > > > > > > I guess you could say that the C3STOP addition was done spec-ulatively*, > > > as the platform that actually exhibits that behaviour does not use the > > > riscv-timer & its maintainer acked the revert (allwinner d1 family). > > > > For clarity: that doesn't mean the platform will _never_ use the SBI > > timer facility, just that Linux happens to not use it right now. > > Yeah sorry - should have been a bit clearer there. There's a few other > SoCs about that are using the thead cores, so I'd be "worried" that they > share the timer behaviour but do not have an alternative like you do on > the D1. That's part of what's kinda given me cold feet on the current > approach. > > > > *The spec does not make any guarantees about whether events arrive > > > during suspend, only the behaviour *if* they arrive. > > > > > > Switching the property to "always-on" would require retrofitting that > > > property to every other existing platform (and therefore regressing some > > > behaviour there, no?). > > > > > > Most of the existing platforms are "toys" or demo platforms though, so > > > it would not, I guess, be the end of the world to do so. Doubly so since > > > none of them actually implement any sleep states that making it an > > > "always-on" property. > > > > Specifically, only sleep states with a "local-timer-stop" property would > > be inhibited by the C3STOP flag, so there is only possibility of a > > regression if some DT declaring such a sleep state exists anywhere. What is the plan for this series? IIRC, a rebase was required on top of the revert? I'm not overly pushed either way at this point, I'd like to get this C3STOP issue sorted out before more thead powered SoCs start showing up with the same implementation issues. I know it is the Christmas period so not expecting anything to actually happen right away. Thanks, Conor. > > > I've said since the start that defaulting to C3STOP is the "safer" thing > > > to do, and although we disagreed on this last time Anup, I think the > > > better outcome of someone missing a DT property is inaccessible sleep > > > states rather than going into sleep states they cannot get out of. > > > > > > For PolarFire SoC, which I guess is one of the few "commerical" > > > platforms, I'd be willing to accept retrofitting, since we have not yet > > > implemented such sleep states yet. > > > > > > Maybe Prabhakar knows whether the RZ/Five has either a) implemented > > > sleep states and b) which side of the "timer events arrive in suspend" > > > divide their platform lies on. > > > I'm particular interested here since that is not a SiFive core complex. > > > > > > I would like to get DT maintainer approval of an approach here soon-ish > > > so that we can something sorted for the jh7110 stuff and for the > > > bouffalolabs SoC - the latter of which may very well be in the "no > > > events in suspend" camp as it also uses thead stuff. > > > > > > Sorry for kinda rowing back on my previous acceptance of the approach, > > > but I am really between two minds on this.
diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c index 969a552da8d2..1b4b36df5484 100644 --- a/drivers/clocksource/timer-riscv.c +++ b/drivers/clocksource/timer-riscv.c @@ -28,6 +28,7 @@ #include <asm/timex.h> static DEFINE_STATIC_KEY_FALSE(riscv_sstc_available); +static bool riscv_timer_cannot_wake_cpu; static int riscv_clock_next_event(unsigned long delta, struct clock_event_device *ce) @@ -51,7 +52,7 @@ static int riscv_clock_next_event(unsigned long delta, static unsigned int riscv_clock_event_irq; static DEFINE_PER_CPU(struct clock_event_device, riscv_clock_event) = { .name = "riscv_timer_clockevent", - .features = CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_C3STOP, + .features = CLOCK_EVT_FEAT_ONESHOT, .rating = 100, .set_next_event = riscv_clock_next_event, }; @@ -85,6 +86,8 @@ static int riscv_timer_starting_cpu(unsigned int cpu) ce->cpumask = cpumask_of(cpu); ce->irq = riscv_clock_event_irq; + if (riscv_timer_cannot_wake_cpu) + ce->features |= CLOCK_EVT_FEAT_C3STOP; clockevents_config_and_register(ce, riscv_timebase, 100, 0x7fffffff); enable_percpu_irq(riscv_clock_event_irq, @@ -139,6 +142,13 @@ static int __init riscv_timer_init_dt(struct device_node *n) if (cpuid != smp_processor_id()) return 0; + child = of_find_compatible_node(NULL, NULL, "riscv,timer"); + if (child) { + riscv_timer_cannot_wake_cpu = of_property_read_bool(child, + "riscv,timer-cannot-wake-cpu"); + of_node_put(child); + } + domain = NULL; child = of_get_compatible_child(n, "riscv,cpu-intc"); if (!child) {