From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32EE4C4743D for ; Sun, 6 Jun 2021 18:39:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1729C613AD for ; Sun, 6 Jun 2021 18:39:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230196AbhFFSlh (ORCPT ); Sun, 6 Jun 2021 14:41:37 -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; > ... From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6D29C4743E for ; Sun, 6 Jun 2021 18:40:22 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6A57E613C7 for ; Sun, 6 Jun 2021 18:40:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6A57E613C7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:Cc:To:Subject:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=G38FShIXTdTipGKUtYmuVC6uJfUIBVG9dqN2e9urncM=; b=MtT+f7/NSOI6KBOOZUILLYxxGI YJwyhy2OE5NJcmf1RYPKJLNAkwbsr7tUy24RvQZEZYmtI3oj9xCqtb81xoQJf0flBvWiPjZSzbaJA 9UdZkwOwxRONBpkr0ZfSEkwZDb4YWavUimXEP642P/QEhpTh1d6mL89ICNWQ7pI0TRgr1JGJUZOJF lRgYnkzyc7PUKdZCJqL7+kSEFrAoZ0BLPfTlYXjyY93RrWmBxeeup2odLVoEyD+YR8MjGncWlgrqi ZtkWGQiNmLzQY2P0tXMKKvrFp5oLoz7k5GDdg2wY80VmnL5mHtnyKvt2XR/aGRhl9wm3vMjA8qMJB KDMKJxiA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lpxgn-000fU4-8S; Sun, 06 Jun 2021 18:40:01 +0000 Received: from new3-smtp.messagingengine.com ([66.111.4.229]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lpxgY-000fSp-Sq; Sun, 06 Jun 2021 18:39:48 +0000 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-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210606_113947_041527_6881B7A8 X-CRM114-Status: GOOD ( 24.79 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.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; > ... _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5DC05C4743D for ; Sun, 6 Jun 2021 18:41:17 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 25B17613C7 for ; Sun, 6 Jun 2021 18:41:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 25B17613C7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:Cc:To:Subject:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=pUSycPlRcxZB4PKinMxEQU6epo4psYVchBCovl2KxFc=; b=GYXBURgyBEbAVad8qkYJC3qWH0 9OxW1mhKjt/xe/lhGsQfwQQVvQ3Uou0xTKPR3Wc4yG/rJh73boZSVSpkVXMh8xtPpEjzv2J2vHlnM IbmDOuHhk8jLNh5M1p55Lng2FhP9zRC74mEBUVQa5YBFJDuddKmQJGtG100wNOM/cRHJ/c7GwY/4K YXuTzGNWrKF15EmLkQ/KkNtbH7dP9fFIis/2OtFMPcY5uT+aOPX46MqQ7wvFp40i2tiqyUByjju5W ZxaT0Cx+JciD1fMmM9kJM5pFPI0VpbdQY4D5d7+TtdnubSv6PEKdycPsmb68+kT4u/4aQ8Y72CUEW a+oYK+0w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lpxgd-000fTS-8E; Sun, 06 Jun 2021 18:39:51 +0000 Received: from new3-smtp.messagingengine.com ([66.111.4.229]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lpxgY-000fSp-Sq; Sun, 06 Jun 2021 18:39:48 +0000 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-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210606_113947_041527_6881B7A8 X-CRM114-Status: GOOD ( 24.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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; > ... _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel