Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1839507pxb; Wed, 9 Feb 2022 05:42:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJwsWzNo7p5iVrmXtduXg+uREbsNSplxlReiJUBG7XtaX8735k1iw905rMbfaRVDLHVCH9rM X-Received: by 2002:a17:902:e885:: with SMTP id w5mr2137917plg.147.1644414141340; Wed, 09 Feb 2022 05:42:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644414141; cv=none; d=google.com; s=arc-20160816; b=HJg9z1g5j6/bA59bt0lnsZ0sbrCyjgj5Um3nQo7zjyXiRW1R6nr4gDTqpW7+CH56ee PelzkQk1rfnsducZIBaRCbtKtOFyPfRHbL6ZDNaDnae16t7xFm7rd2Xf69yJUfIoINvt 2cAlvf62e92BBPgGr6GpPuSvVPpBgDqxsruA2TIkubLhIXL74DUZAyiYkY1bXFKyRCdU QSnVKudMsfFdTn0dVbSOLLcV6B+a2YbV9MIszIrkgIDioCQFWICQSlLDsbzJ2hL9dGD2 h5q3N5JZqVANYa5hr7d7aXfgSAjCiDM2vHl9tXb1ktKxcTb3Fqqi2zYzzFSy/5EC2I9v n47Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=fAvXH6tVNrqK0V/EFbv56SQ++vMzyDgW6+wYBow1F4M=; b=OXld3M3pvHnpV9HxO5LInzJ1nkZ5kXAMyFodplYz4Qjt8MLJ2gdOCP9kFe/+L47ydk 6u3EFz2wZxDXydTgq9GHnpVzYzSphUMdc6Hvd93vAF6zPAVYeViGHX/cswyNkY2Gqlgw fOM85tqffbeuEGfkIYBczY49BP+Gi1NJVpxMXsj3TVSjAqie2On21PhdT9tmV5l0mphf 6haIy1D936GJxxFM812WYHO5+1pPsfu2gGpylrQsGlW0GhS/NuGdPllaWvdS8iI3JEpm wmdlV0UMTxpZSnZoGPnGRbzJbN/ahikJw0APydQ7vw+mmGdcPvZbO+kpAc2d4HjDYKnb U53w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Qtkir0uj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id e19si19563760pgl.870.2022.02.09.05.42.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 05:42:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Qtkir0uj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 01743E04FF1A; Wed, 9 Feb 2022 02:24:33 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234381AbiBIGCs (ORCPT + 99 others); Wed, 9 Feb 2022 01:02:48 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:51130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233185AbiBIGAn (ORCPT ); Wed, 9 Feb 2022 01:00:43 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0779BC0302E1; Tue, 8 Feb 2022 22:00:47 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1F26F61672; Wed, 9 Feb 2022 06:00:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C951C340F6; Wed, 9 Feb 2022 06:00:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644386414; bh=H1Il4OnrZcVzTgnRCSfIq6w+2cA8lG5GY5uvlt5naWQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Qtkir0ujjb3mIuWq7ct9FTz1yRDsLAWnTNN3gaiC/I8cPPPCuezabteArA7REpv7F KycdMcfVAsPHB25wa3B8wIzZmErdwXbJWeojnfz2e/FN3kRCgPoWhpzuR53iXc1Zdl 4LaiXrFP9RKO+1pHDtfwPVyR5EgwswdNl263d3zGaRsiRQQYm3uTpx8AWvJMgVYfWD jLdD6o94RMOEVu1kS8GE+FY8/7qmB8Xs6JTNx+i2x+XKN4rg4rsorPNtam+Jm4KAIN W9D1+yLFUCVwBkY4hbGXlTxiLS+NObLhQ6VbjFG4BBY5WhzpR6DPgcgztPfBK76Qvg /WWmFgfjXLRLA== Received: by mail-vs1-f42.google.com with SMTP id g10so1471601vss.1; Tue, 08 Feb 2022 22:00:14 -0800 (PST) X-Gm-Message-State: AOAM5306oBm91eBTViow08Erazb3V4WBpIY1UW8mRgtI0KRhnFdCdkNf hXE4M/myHq+QgSzPcuBhKc7WiQisHhB3XsYhsTU= X-Received: by 2002:a67:e0d9:: with SMTP id m25mr200489vsl.51.1644386413208; Tue, 08 Feb 2022 22:00:13 -0800 (PST) MIME-Version: 1.0 References: <20220126114452.692512-1-apatel@ventanamicro.com> <20220126114452.692512-2-apatel@ventanamicro.com> In-Reply-To: From: Guo Ren Date: Wed, 9 Feb 2022 14:00:02 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v10 1/8] RISC-V: Enable CPU_IDLE drivers To: Anup Patel Cc: Anup Patel , Palmer Dabbelt , Paul Walmsley , Albert Ou , Daniel Lezcano , Ulf Hansson , "Rafael J . Wysocki" , Pavel Machek , Rob Herring , Sandeep Tripathy , Atish Patra , Alistair Francis , Liush , devicetree , linux-riscv , Linux Kernel Mailing List , "open list:THERMAL" , Linux ARM , kvm-riscv@lists.infradead.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On Wed, Feb 9, 2022 at 1:15 PM Anup Patel wrote: > > On Tue, Feb 8, 2022 at 11:46 AM Guo Ren wrote: > > > > Reviewed-by: Guo Ren > > > > small questions: > > > > On Wed, Jan 26, 2022 at 7:46 PM Anup Patel wrote: > > > > > > From: Anup Patel > > > > > > We force select CPU_PM and provide asm/cpuidle.h so that we can > > > use CPU IDLE drivers for Linux RISC-V kernel. > > > > > > Signed-off-by: Anup Patel > > > Signed-off-by: Anup Patel > > > --- > > > arch/riscv/Kconfig | 7 +++++++ > > > arch/riscv/configs/defconfig | 1 + > > > arch/riscv/configs/rv32_defconfig | 1 + > > > arch/riscv/include/asm/cpuidle.h | 24 ++++++++++++++++++++++++ > > > arch/riscv/kernel/process.c | 3 ++- > > > 5 files changed, 35 insertions(+), 1 deletion(-) > > > create mode 100644 arch/riscv/include/asm/cpuidle.h > > > > > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig > > > index 5adcbd9b5e88..76976d12b463 100644 > > > --- a/arch/riscv/Kconfig > > > +++ b/arch/riscv/Kconfig > > > @@ -46,6 +46,7 @@ config RISCV > > > select CLONE_BACKWARDS > > > select CLINT_TIMER if !MMU > > > select COMMON_CLK > > > + select CPU_PM if CPU_IDLE > > > select EDAC_SUPPORT > > > select GENERIC_ARCH_TOPOLOGY if SMP > > > select GENERIC_ATOMIC64 if !64BIT > > > @@ -547,4 +548,10 @@ source "kernel/power/Kconfig" > > > > > > endmenu > > > > > > +menu "CPU Power Management" > > > + > > > +source "drivers/cpuidle/Kconfig" > > > + > > > +endmenu > > > + > > > source "arch/riscv/kvm/Kconfig" > > > diff --git a/arch/riscv/configs/defconfig b/arch/riscv/configs/defconfig > > > index f120fcc43d0a..a5e0482a4969 100644 > > > --- a/arch/riscv/configs/defconfig > > > +++ b/arch/riscv/configs/defconfig > > > @@ -20,6 +20,7 @@ CONFIG_SOC_SIFIVE=y > > > CONFIG_SOC_VIRT=y > > > CONFIG_SMP=y > > > CONFIG_HOTPLUG_CPU=y > > > +CONFIG_CPU_IDLE=y > > > CONFIG_VIRTUALIZATION=y > > > CONFIG_KVM=m > > > CONFIG_JUMP_LABEL=y > > > diff --git a/arch/riscv/configs/rv32_defconfig b/arch/riscv/configs/rv32_defconfig > > > index 8b56a7f1eb06..d1b87db54d68 100644 > > > --- a/arch/riscv/configs/rv32_defconfig > > > +++ b/arch/riscv/configs/rv32_defconfig > > > @@ -20,6 +20,7 @@ CONFIG_SOC_VIRT=y > > > CONFIG_ARCH_RV32I=y > > > CONFIG_SMP=y > > > CONFIG_HOTPLUG_CPU=y > > > +CONFIG_CPU_IDLE=y > > > CONFIG_VIRTUALIZATION=y > > > CONFIG_KVM=m > > > CONFIG_JUMP_LABEL=y > > > diff --git a/arch/riscv/include/asm/cpuidle.h b/arch/riscv/include/asm/cpuidle.h > > > new file mode 100644 > > > index 000000000000..71fdc607d4bc > > > --- /dev/null > > > +++ b/arch/riscv/include/asm/cpuidle.h > > > @@ -0,0 +1,24 @@ > > > +/* SPDX-License-Identifier: GPL-2.0 */ > > > +/* > > > + * Copyright (C) 2021 Allwinner Ltd > > > + * Copyright (C) 2021 Western Digital Corporation or its affiliates. > > > + */ > > > + > > > +#ifndef _ASM_RISCV_CPUIDLE_H > > > +#define _ASM_RISCV_CPUIDLE_H > > > + > > > +#include > > > +#include > > > + > > > +static inline void cpu_do_idle(void) > > > +{ > > > + /* > > > + * Add mb() here to ensure that all > > > + * IO/MEM accesses are completed prior > > > + * to entering WFI. > > > + */ > > > + mb(); > > I think it's a separate fixup. > > This one is tricky to move as separate fixup because there > is no cpu_do_idle() until this patch adds it. > > If we deliberately have a separate patch for "mb()" then it > will be only fixing cpu_do_idle() function added by previous > patch in the same series. You are right, I misunderstood the usage of asm/cpuidle.h. > > Regards, > Anup > > > > > > + wait_for_interrupt(); > > > +} > > > + > > > +#endif > > > diff --git a/arch/riscv/kernel/process.c b/arch/riscv/kernel/process.c > > > index 03ac3aa611f5..504b496787aa 100644 > > > --- a/arch/riscv/kernel/process.c > > > +++ b/arch/riscv/kernel/process.c > > > @@ -23,6 +23,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > > > > register unsigned long gp_in_global __asm__("gp"); > > > > > > @@ -37,7 +38,7 @@ extern asmlinkage void ret_from_kernel_thread(void); > > > > > > void arch_cpu_idle(void) > > > { > > maybe below is enough. > > + mb(); > > wait_for_interrupt(); > > > > > - wait_for_interrupt(); > > > + cpu_do_idle(); > > > > > > > raw_local_irq_enable(); > > > } > > > > > > -- > > > 2.25.1 > > > > > > > > > -- > > > kvm-riscv mailing list > > > kvm-riscv@lists.infradead.org > > > http://lists.infradead.org/mailman/listinfo/kvm-riscv > > > > > > > > -- > > Best Regards > > Guo Ren > > > > ML: https://lore.kernel.org/linux-csky/ -- Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/