Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4138294imw; Mon, 18 Jul 2022 23:51:44 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uLSiWtyFaoobyyWGBudfbefLaFoyNYqzjz5CMpwjba9HEps3bRtPiFQ35vZEGCaB4ixfvn X-Received: by 2002:a05:6402:110b:b0:43a:e0b7:1788 with SMTP id u11-20020a056402110b00b0043ae0b71788mr42474169edv.109.1658213504444; Mon, 18 Jul 2022 23:51:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658213504; cv=none; d=google.com; s=arc-20160816; b=b9v6P9MwazUe/wYx8b7YuNQr6gqlGnYf1B9NiWQpZk3xpiuisj0As0D/1AJGPt0nr5 Bfkk/hokEK28TUvdIajOK4OISJTNQDc0FRohXZlqzwxnMAtxtQkH/NCdyIAyiJwYzBGj uUkfIF1lrZPVIdR3ZjbyHOWRLQHZwOGDLIup+MibBhEzpfjmZU9MBgHkWdIm54Q3e8Bw ezYEudtTGIoHrzAAYl5/YgiUiwGPVlJl4KZn0Baifv7d//Jzvv9DKtZi77vrfA3bqCp9 Ty6SsbedGI7xG3HTLrQvtVhA80mjC0umoulcXiDMxArTvXGKkw1/1gzY36dR+ahPRcCi kPaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:feedback-id:dkim-signature:dkim-signature; bh=/GcQTqnB2ExgalRjmVV8XkUuxgcyJVL6766PkWjqgyc=; b=XbwdZXIFBm1eCRkOcwsZ4zd4k1X3P1JdPm4uy9H+bPzTu9S2RmBC24QFReFbXdtRzh FPDuAs97+LVcl1yAQV1RruN80GpXQ1r6mC/k2MwIWyy44rWKPOkKY7naNHq5deWuVQQO x96frMvvRyzp3YgMzVuSP/h0/46E1S/39fZk4IiJDAEW5yvac881WMPMLB2sKlel0egP v+FhcdK++s0l4+cABrYF3qk4Fag/AqODEgWRwtFB+pC/K6ly+ilcWilK5A5FrRkT7Etg 8UALZrau5QqblkVQATvURtTLutCu1CHvZqBPCgO1IRt5mWZ4VhOZC1iQmPrrS+VMoDLA p5dQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sholland.org header.s=fm1 header.b=I4nLQvXl; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=rTkQEOJ6; 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 s23-20020a056402037700b0043ba0c9c0b7si367625edw.207.2022.07.18.23.51.20; Mon, 18 Jul 2022 23:51:44 -0700 (PDT) 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=@sholland.org header.s=fm1 header.b=I4nLQvXl; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=rTkQEOJ6; 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 S237059AbiGSGm5 (ORCPT + 99 others); Tue, 19 Jul 2022 02:42:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233168AbiGSGm4 (ORCPT ); Tue, 19 Jul 2022 02:42:56 -0400 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CA821D0E8; Mon, 18 Jul 2022 23:42:53 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id DC5EF32004E7; Tue, 19 Jul 2022 02:42:49 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Tue, 19 Jul 2022 02:42:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1658212969; x= 1658299369; bh=/GcQTqnB2ExgalRjmVV8XkUuxgcyJVL6766PkWjqgyc=; b=I 4nLQvXlSPceoku3CMa/zXjocV9d7ngPSRWkIYe7C+/aJpMuwwV+4FyL3A/tekWZ2 8NqCCamttp3wfvFJ6j1LEA1JPesQal797n3Gs96aQvBBANcveWvdFb7Zj5UsF2rR NZuqs4nt3v1Ar7vcPKvSZg12ynTOjyeu7+wEDcVCggT4izQRKl7BRGvePND5nEdi 2HWefHhE15tVQ801T8wilA8h5Ndt8RqoK7rOAL6UhX3M/BV3CF1iaZRuGjQ7zdjd C5IL8kwJq/Xng9UJNK1QqgRD5MHMbxG4Mk1PbrWumxQjRy9rFVFSSMz4E+ZY2c2X p2sFcmTVEa/oT2YsaN7tg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1658212969; x= 1658299369; bh=/GcQTqnB2ExgalRjmVV8XkUuxgcyJVL6766PkWjqgyc=; b=r TkQEOJ6NJxkfyptcCjFZiG3Mw2Uj77BopsXua/wPn6z9wvN1Cvn9HDk7dxmHDIhM pHQHoRB6OJQAMRlN1Yf6iAPjK8yO2fD7X7t0ZsTvUUaGkTEeNtmIBVhfco0Gckf/ frtVOzw4DYYHDn6Xkr9LKjNov04enG22YUrh+JDqnOwMCUlDaWc6TbHG51F8TyG8 P5JZq8APxceziPXvOlLvvW0VVoLkLbUzFlqgjzpHQ+SNKPX6EbIkkQFTk4mGTk4/ 1QLqbCZjl+uj1gmE9C15UMpXPtiEKLWaJeBkRSA+jJrjdQb9Yuaf049jX9iXOFP2 n3EK5q6l6PsLaAq9E8Qiw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudekledgudduvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefuvfevfhfhkffffgggjggtgfesthejredttdefjeenucfhrhhomhepufgr mhhuvghlucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqne cuggftrfgrthhtvghrnhepffdtveekvdegkeeuueetgfetffeileevudekuefhheelvdfh iedtheduhfduhefhnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepshgrmhhuvghlsehshhholhhlrghnugdrohhrgh X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 19 Jul 2022 02:42:47 -0400 (EDT) Subject: Re: [PATCH 2/2] clocksource: timer-riscv: Set CLOCK_EVT_FEAT_C3STOP based on DT property To: Anup Patel , Palmer Dabbelt , Paul Walmsley , Daniel Lezcano , Thomas Gleixner Cc: Rob Herring , Krzysztof Kozlowski , Atish Patra , Anup Patel , devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org References: <20220719054729.2224766-1-apatel@ventanamicro.com> <20220719054729.2224766-3-apatel@ventanamicro.com> From: Samuel Holland Message-ID: <315d9850-e660-f71e-2321-b0684f7df950@sholland.org> Date: Tue, 19 Jul 2022 01:42:47 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20220719054729.2224766-3-apatel@ventanamicro.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,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 Hi Anup, On 7/19/22 12:47 AM, Anup Patel wrote: > We should set CLOCK_EVT_FEAT_C3STOP for a clock_event_device only when > riscv,timer-always-on DT property is not present for the corresponding > CPU. The timer maintaining its context (and continuing to count) during non-retentive CPU suspend is not sufficient to drop CLOCK_EVT_FEAT_C3STOP. Another requirement is that the timer interrupt is generated and routed outside the CPU's power/reset domain, to whatever hardware is responsible for turning the CPU back on. It does not matter if the timer interrupt fires, if that interrupt cannot wake up the CPU. So something closer to "riscv,timer-can-wake-cpu" would be a more accurate property name for how you are using it. And even then, that ability is a property of the SBI implementation, not just the hardware. In the motivating example for the flag (Allwinner D1), the CLINT cannot wake the CPU from reset, but the SoC contains other MMIO timers that can. So the capability of the SBI timer extension depends on which timer hardware the SBI implementation chooses to use. So I am not sure that the property belongs in the CPU node. Maybe it makes sense to report this capability via a function in the SBI timer extension? Regards, Samuel > 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 > --- > drivers/clocksource/timer-riscv.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c > index 593d5a957b69..3015324f2b59 100644 > --- a/drivers/clocksource/timer-riscv.c > +++ b/drivers/clocksource/timer-riscv.c > @@ -34,7 +34,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, > }; > @@ -65,9 +65,13 @@ static struct clocksource riscv_clocksource = { > static int riscv_timer_starting_cpu(unsigned int cpu) > { > struct clock_event_device *ce = per_cpu_ptr(&riscv_clock_event, cpu); > + struct device_node *np = of_get_cpu_node(cpu, NULL); > > ce->cpumask = cpumask_of(cpu); > ce->irq = riscv_clock_event_irq; > + if (!of_property_read_bool(np, "riscv,timer-always-on")) > + ce->features |= CLOCK_EVT_FEAT_C3STOP; > + of_node_put(np); > clockevents_config_and_register(ce, riscv_timebase, 100, 0x7fffffff); > > enable_percpu_irq(riscv_clock_event_irq, >