Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2725323pxj; Sun, 6 Jun 2021 11:42:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJzZ+BgQr7xq/XB+QgMrT+PxTmrj4ttSwtyCnzIR/39GQWngT/HlSypueSAX726N6FdgBc X-Received: by 2002:a17:906:919:: with SMTP id i25mr14062312ejd.171.1623004969795; Sun, 06 Jun 2021 11:42:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623004969; cv=none; d=google.com; s=arc-20160816; b=chidKgJde3t++c/7je89eIzQ48CgkFnwlUtbSQt43OVcwjyImnr1HlNG/TfUuYCIq/ ieK9mUC8P9wlvJPEdomAS8+Ar8g9ygqzX33zaB4v/5O0WT03YSfQ+wTNwFnYxY3s8aND rty1pmKL0sTOyjiOqv7+mJtA1z0001vuoHxrZeNEt5zPHD594tbVrSPWQjwG8zoblLjw LO1U0SOOMth9VLvutv0NxixC/zyzSk8HL+oQtc/R96IA7aKHxVUVuRHIXkd3UdYGxwxO bhQD7INSoIrPayRFzZfdNa9b17z9i1RJDaLTt/OMxv8er1EXR9CVlmY5uAP+odc9uNfR kctw== 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:dkim-signature:dkim-signature; bh=/jdo7cePtO24oEruM82Zm8LlZTN5Vu0LoLWniZZ9ji8=; b=tgZT0073nMfSxnBq9xxIFOVeKiO6DlVID3PX/SQgCWJfaZ0d3hm2Wc5RRaSK8y6lL1 3JaFEIaMiCIlrOTRujKTK+NQZBLkHbSqi3zaEgIYxMUJyyReIxeLYN8qcrSIc5LIR78j Q0XZgM2ACwJKame449GLLZ610nb9eqBmv862hx4O+mcbG8lSWEJl1vT/0NjsG5Ub4KDs roR92ywWou87UKdeT0Agl4CzSbdqJuo/FJFmU5YX6+cn0t7YJJIvcD1qGW7/6hgvPDxz tCqQGbHH+mxBlCG6XZHT8uQrmM/dErs/dcuLqsxKyBXL8xsvzdohI/bfBUSDG7HmfcNv AimA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sholland.org header.s=fm2 header.b=OhvTP95h; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=T4WtxARG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s2si10064981edt.551.2021.06.06.11.42.26; Sun, 06 Jun 2021 11:42:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@sholland.org header.s=fm2 header.b=OhvTP95h; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=T4WtxARG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230173AbhFFSlg (ORCPT + 99 others); Sun, 6 Jun 2021 14:41:36 -0400 Received: from new3-smtp.messagingengine.com ([66.111.4.229]:43873 "EHLO new3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229697AbhFFSlg (ORCPT ); Sun, 6 Jun 2021 14:41:36 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id E2A3758094C; Sun, 6 Jun 2021 14:39:45 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 06 Jun 2021 14:39:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm2; bh=/ jdo7cePtO24oEruM82Zm8LlZTN5Vu0LoLWniZZ9ji8=; b=OhvTP95hppIbju+O/ OH7w5xIuU3nVosv6KggLjXzehodZLMWfCh3S4Zb8B5Wcxp55Vbg5sK2JFFp5sPp5 e1HaEwfcjZVH8/UydNusK+GnXT2O0pG2dOtmcPGfOdFOsDNWLMIWdB6WsaxT19g3 uD2N8M8FJ4yPWvb9w46CfBxrnX5h/CF2+Hs+br3RlpIIuY0hNn+fSgDcvIuGdi2l jNQihj706UnbV0FVVACRxIbqpcb7xJX71v7p/dG2Y0KHRhxj2Q1IaQukTKNRmhe+ GDT7daGhU9oFPqR7ADJ4s8x0HWDtgoC+5lqiQmgu6z2XkS3XVHZgmRMfbrASqEPA ImWKQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=/jdo7cePtO24oEruM82Zm8LlZTN5Vu0LoLWniZZ9j i8=; b=T4WtxARGFX9OVC4HmhDCc3JnbLM35Wx39jiPIx53ynKyjhS6kaPX4oyCg KqiK9MgKHLaF/0yirHteTrEVY8PfgcoPGaErj4sp58qdrJFuFVxiqDgHX5cRe3u5 tlnJUaiejdXzNHriD6+lB98rF60TUdoaKA3RmatIrz3FmqT2VUpApTXvNEbGB0ji KSr4GoxuN3mNYCHkmHDfPc8+pLjcWdKFy1D2Pf4C8yDJ/heawtmlPMP13poWYdRb TeDDNZnqb1e6jYEErTMoFn8D1doX+tJTKRWX4vDJ3es+ueVTk9E9PBZu9YV9uyRM si5EuoAS3kk8p1U3FMSxacoM+NdbQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfedthedgudeftdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefuvfhfhffkffgfgggjtgfgsehtjeertddtfeejnecuhfhrohhmpefurghm uhgvlhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenuc ggtffrrghtthgvrhhnpefgveffteelheffjeeukedvkedviedtheevgeefkeehueeiieeu teeugfettdeggeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 6 Jun 2021 14:39:43 -0400 (EDT) Subject: Re: [PATCH v5 6/8] cpuidle: Add RISC-V SBI CPU idle driver To: Anup Patel Cc: Sandeep Tripathy , Atish Patra , Alistair Francis , Liush , Anup Patel , devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Palmer Dabbelt , Palmer Dabbelt , Ulf Hansson , Rob Herring , Albert Ou , "Rafael J . Wysocki" , Daniel Lezcano , Paul Walmsley , Pavel Machek References: <20210602112321.2241566-1-anup.patel@wdc.com> <20210602112321.2241566-7-anup.patel@wdc.com> From: Samuel Holland Message-ID: <26cddfa8-75e2-7b5b-1a47-e01cc1c7821e@sholland.org> Date: Sun, 6 Jun 2021 13:39:43 -0500 User-Agent: Mozilla/5.0 (X11; Linux ppc64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <20210602112321.2241566-7-anup.patel@wdc.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/2/21 6:23 AM, Anup Patel wrote: > The RISC-V SBI HSM extension provides HSM suspend call which can > be used by Linux RISC-V to enter platform specific low-power state. > > This patch adds a CPU idle driver based on RISC-V SBI calls which > will populate idle states from device tree and use SBI calls to > entry these idle states. > > Signed-off-by: Anup Patel > --- > MAINTAINERS | 7 + > drivers/cpuidle/Kconfig | 5 + > drivers/cpuidle/Kconfig.riscv | 15 + > drivers/cpuidle/Makefile | 4 + > drivers/cpuidle/cpuidle-sbi.c | 626 ++++++++++++++++++++++++++++++++++ > 5 files changed, 657 insertions(+) > create mode 100644 drivers/cpuidle/Kconfig.riscv > create mode 100644 drivers/cpuidle/cpuidle-sbi.c > > ... > diff --git a/drivers/cpuidle/cpuidle-sbi.c b/drivers/cpuidle/cpuidle-sbi.c > new file mode 100644 > index 000000000000..f743684d07de > --- /dev/null > +++ b/drivers/cpuidle/cpuidle-sbi.c > @@ -0,0 +1,626 @@ > ... > + /* Initialize idle states from DT. */ > + ret = sbi_cpuidle_dt_init_states(dev, drv, cpu, state_count); > + if (ret) { > + pr_err("HART%ld: failed to init idle states\n", > + cpuid_to_hartid_map(cpu)); > + return ret; > + } > + > + ret = cpuidle_register(drv, NULL); > + if (ret) > + goto deinit; > + > + cpuidle_cooling_register(drv); > + > + return 0; > +deinit: > + sbi_cpuidle_deinit_cpu(cpu); > + return ret; > +} > + > +static int sbi_cpuidle_pd_power_off(struct generic_pm_domain *pd) This function should be moved inside the CONFIG_DT_IDLE_GENPD block below. Otherwise it is defined but unused. > +{ > + struct genpd_power_state *state = &pd->states[pd->state_idx]; > + u32 *pd_state; > + > + if (!state->data) > + return 0; > + > + if (!sbi_cpuidle_pd_allow_domain_state) > + return -EBUSY; > + > + /* OSI mode is enabled, set the corresponding domain state. */ > + pd_state = state->data; > + sbi_set_domain_state(*pd_state); > + > + return 0; > +} > + > +static void sbi_cpuidle_domain_sync_state(struct device *dev) > +{ > + /* > + * All devices have now been attached/probed to the PM domain > + * topology, hence it's fine to allow domain states to be picked. > + */ > + sbi_cpuidle_pd_allow_domain_state = true; > +} > + > +#ifdef CONFIG_DT_IDLE_GENPD > + > +struct sbi_pd_provider { > + struct list_head link; > + struct device_node *node; > +}; > + > +static LIST_HEAD(sbi_pd_providers); > + > +static int sbi_pd_init(struct device_node *np) > +{ > + struct generic_pm_domain *pd; > + struct sbi_pd_provider *pd_provider; > + struct dev_power_governor *pd_gov; > + int ret = -ENOMEM, state_count = 0; > + > + pd = dt_idle_pd_alloc(np, sbi_dt_parse_state_node); > + if (!pd) > + goto out; > ...