Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5121189rwb; Mon, 21 Nov 2022 17:10:24 -0800 (PST) X-Google-Smtp-Source: AA0mqf43KYewqN9/ppHKVQC+ID+guUT7pfBJU70Dw2Ca6XATSxJEPFuKUGNVdtUmK/LVKRbOZ3L/ X-Received: by 2002:a17:906:1695:b0:7aa:493b:679 with SMTP id s21-20020a170906169500b007aa493b0679mr1548900ejd.320.1669079423950; Mon, 21 Nov 2022 17:10:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669079423; cv=none; d=google.com; s=arc-20160816; b=HHxVno5J82/ao3ytuRq9gc5Ycc7zKf6FhxkYk3xSw3sWczIJMWhf/QmDIbps29kyht nc/whSkJDRP1RcnTRpw8zc0qlGjbBiGFPvOe1bLmJcztOKcsbHKaSfU+TtdJexfJ4Kue BjKH12gC/EqEqTVZAaxLO2Js5Nqzl867ku1WgFmmnYe6URZliMJPeuX1453D3YNUNlv5 PHCIQ5eMRcw7q77VgByt3Bev7p3cS9JKg2zK3UNTixOrtAhg7ziaJ5Z+hls06LGmdwGg SeeTXCq58hsGTiT5KMaQOsmmLe3omIXZqnI0XB+jIqTQvxJ9A0xiAFHxGd+J9lUur/hK YfHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :from:references:cc:to:content-language:user-agent:mime-version:date :message-id:feedback-id:dkim-signature:dkim-signature; bh=fDo4wIRpT/cr00JSFZyRJXJl6OzORncK/vIgc7ZRQkk=; b=lpfm1MW0dKBq0KRwdLIIOrkaX4Q+j9nSKBJt2Ve6YF1T7p2hYJDpQHnmcKFIjVdoCT n2xvqOr0C/gfR74nTjBT/vNMjWUkBKFlPXIJQBRGX2SGeObr8ANld71OdFR8djgyvHLI lUG7xrRsNxFrISQoECID9HiJEZKR2SqRwjBq8aE2UtNQgSzKcyzsQB96f5CJt4kLkjeb dkhmTo+tNxT//BZo7/bffpVwAOKaGWaVINTWxLS6zBV9KFUftlvuzq+ANO3H3BR8qy20 C8dBK8OgdjuB8riA11Gg2OKQa6pQZ+uXQEfO7fp25GpK3RBXhBnX0fsyFj+5YhxGh10R 3msw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sholland.org header.s=fm2 header.b=J6CnMjqO; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=VnJZxtfG; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sholland.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hs31-20020a1709073e9f00b0078e27ef9501si10103605ejc.750.2022.11.21.17.09.59; Mon, 21 Nov 2022 17:10:23 -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=@sholland.org header.s=fm2 header.b=J6CnMjqO; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=VnJZxtfG; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sholland.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229873AbiKVArF (ORCPT + 92 others); Mon, 21 Nov 2022 19:47:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231899AbiKVApa (ORCPT ); Mon, 21 Nov 2022 19:45:30 -0500 Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1766A13F2F; Mon, 21 Nov 2022 16:45:29 -0800 (PST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id C2AE032009D7; Mon, 21 Nov 2022 19:45:27 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Mon, 21 Nov 2022 19:45:28 -0500 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=fm2; t=1669077927; x= 1669164327; bh=fDo4wIRpT/cr00JSFZyRJXJl6OzORncK/vIgc7ZRQkk=; b=J 6CnMjqONXI2E8ioFDyVdFNnyvY9ueuRBNt/1e26aLfKYAlgFhVS2hel8L1xo8We4 NTYSTpdzySKpFbIhsX4pkj8++3yIFa1rLeE5J3mz0FM4zKmk7yQNSbGolsbMFq5r M8mXmPB9g4HGNKO1FdbHFuHpvPJbEkd++eT++A2EQxdsIR/uc+7Qzvd20inmEnJs 2mPE3SKyf4UX8km4FaZG+ZcQZtF2Tlfc3/EK721qDYW+mIgWsTnoe9sJQrrEjLm4 af7LtAi+BSe9MStIZi77K8M41RGKWjO8FKWj4AR0jhOm0n55EwepzYPq1lHHEDrE 8hShbPP0pCwmsedUWfJvw== 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=fm1; t=1669077927; x= 1669164327; bh=fDo4wIRpT/cr00JSFZyRJXJl6OzORncK/vIgc7ZRQkk=; b=V nJZxtfGEVMrF6eg8Ky2o+OwLEwr0qWH4WDtXfKZW4ubG0wPZhoUTcUtV/aF7stxL 5R531aiFniq99980T+GAVs9G7ZaEHCJYi6IGjvjG0sMDCvJJu52oDmirdPXZNTss 2yxe0hUdqK1pvbH78w/FwN3N8gB7ev+5uZGXQo0QNAcFZWeZC8bvcUCsfIzZIdOY f7TERsbeOhzNMG+BysOGxzQ029YLfXWGWf5TP2DvwPsHIw4BuWdlzHT2q0FAW4Gj gJhOmIBCd+zQHH/GVUhCF369+g60Ohdd9AC7TzYquTDwaXfmPDKLnkGcwugLlc7Q k3z8lJ7qxKAh6LoCc3aOA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrheejgddviecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkffggfgfvvehfhffujggtgfesthejredttdefjeenucfhrhhomhepufgrmhhu vghlucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecugg ftrfgrthhtvghrnhepudeuuefgleeludegueegvdeggffhveejgfeileejveegiefhffev ieffiedvkeehnecuffhomhgrihhnpehgihhthhhusgdrtghomhenucevlhhushhtvghruf hiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehsrghmuhgvlhesshhhohhllhgr nhgurdhorhhg X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 21 Nov 2022 19:45:26 -0500 (EST) Message-ID: Date: Mon, 21 Nov 2022 18:45:25 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux ppc64le; rv:102.0) Gecko/20100101 Thunderbird/102.3.3 Content-Language: en-US To: Palmer Dabbelt , Conor Dooley Cc: anup@brainfault.org, rafael@kernel.org, daniel.lezcano@linaro.org, Paul Walmsley , Palmer Dabbelt , aou@eecs.berkeley.edu, linux-pm@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux@rivosinc.com References: <20221121205647.23343-1-palmer@rivosinc.com> From: Samuel Holland Subject: Re: [PATCH] cpuidle: riscv-sbi: Stop using non-retentive suspend In-Reply-To: <20221121205647.23343-1-palmer@rivosinc.com> Content-Type: text/plain; charset=UTF-8 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 Palmer, On 11/21/22 14:56, Palmer Dabbelt wrote: > From: Palmer Dabbelt > > As per [1], whether or not the core can wake up from non-retentive > suspend is a platform-specific detail. We don't have any way to encode > that, so just stop using them until we've sorted that out. We do have *exactly* a way to encode that. Specifically, the existence or non-existence of a non-retentive CPU suspend state in the DT. If a hart has no way of resuming from non-retentive suspend (i.e. a complete lack of interrupt delivery in non-retentive suspend), then it makes zero sense to advertise such a suspend state in the DT. Therefore, if the state exists in the DT, you can assume there is *some* interrupt that can wake up the hart. And I would extend that to assume at least one of those wakeup-capable interrupts is a timer interrupt, although not necessarily the architectural timer interrupt. > Link: https://github.com/riscv-non-isa/riscv-sbi-doc/issues/98#issuecomment-1288564687 This comment refers specifically to the architectural timer interrupt, not interrupts more generally. > Fixes: 6abf32f1d9c5 ("cpuidle: Add RISC-V SBI CPU idle driver") > Signed-off-by: Palmer Dabbelt > > --- > > This should allow us to revert 232ccac1bd9b ("clocksource/drivers/riscv: > Events are stopped during CPU suspend"), which fixes suspend on the D1 > but breaks timers everywhere. I understand that reverting 232ccac1bd9b is the easiest way to fix the issues you and others are seeing. I do not have any functioning RISC-V hardware with SMP, so it is hard for me to help debug the root issue in the Linux timer code. I do not know why turning on the C3STOP flag breaks RCU stall detection or clock_nanosleep(), but I agree that breakage should not happen. So while I still think 232ccac1bd9b is the right change to make from a "following the spec" standpoint, I am okay with reverting it for pragmatic reasons. Since the D1 has another timer driver that is currently used in preference to the RISC-V/SBI timer triver, reverting 232ccac1bd9b does not break non-retentive suspend for the D1. But please do not make the change below. It is unnecessarily broad, and will break something that works fine right now. If the DT advertises a CPU suspend state that cannot be woken up from at all, then that is a bug in the DT. Linux should not try to work around that. So revert 232ccac1bd9b for now, and we can figure out what to do about the DT property, but please do not merge this. Regards, Samuel > --- > drivers/cpuidle/cpuidle-riscv-sbi.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/drivers/cpuidle/cpuidle-riscv-sbi.c b/drivers/cpuidle/cpuidle-riscv-sbi.c > index 05fe2902df9a..9d1063a54495 100644 > --- a/drivers/cpuidle/cpuidle-riscv-sbi.c > +++ b/drivers/cpuidle/cpuidle-riscv-sbi.c > @@ -214,6 +214,17 @@ static bool sbi_suspend_state_is_valid(u32 state) > if (state > SBI_HSM_SUSPEND_NON_RET_DEFAULT && > state < SBI_HSM_SUSPEND_NON_RET_PLATFORM) > return false; > + > + /* > + * Whether or not RISC-V systems deliver interrupts to harts in a > + * non-retentive suspend state is a platform-specific detail. This can > + * leave the hart unable to wake up, so just mark these states as > + * unsupported until we have a mechanism to expose these > + * platform-specific details to Linux. > + */ > + if (state & SBI_HSM_SUSP_NON_RET_BIT) > + return false; > + > return true; > } >