Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp904386pxb; Tue, 8 Feb 2022 05:15:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJyPtwjbo9rsCwTilqnpbrD+zfozGM1tnoDaQa2hndKLC7J8Ffb3NPtcoq/yi3HoPPpTQAHi X-Received: by 2002:a17:902:b286:: with SMTP id u6mr4198963plr.155.1644326153642; Tue, 08 Feb 2022 05:15:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644326153; cv=none; d=google.com; s=arc-20160816; b=Eo2zXLunGXDsoiJ0w5OSn4Y0d2f6XltEiXFecKnO8pE4jmD0NjYDY0ULSyHdzcb4jM kCN+ciiGnmSRKU5wL59ZCEJ7/7CUvQmTs/BV48eiJZ/R8aQwKh26oWrvXmvz/9QPWXkQ 2VfAcoBrKhCZ9eL9KDJG97hlwBkT/7eyzTXVdD75ZYhxmYyEpgbP0Zw4nuMuvYcwjzYM pkH2lfFT/ha80ZsMRQnqvBwnSap+9CxQlFQ2FQno2tPhEjqNXt6INbQYziHuCkPzeziZ cq6BYNXAfiowsedz5dgO2j2aLntOo5/oUFqzLujremlyD1ozrQQ83ZoAYsDJErPgJqSj qa8g== 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=yb2Bdismc/diVmNaDGErykE/4f+EkP+RACrq46HHqa0=; b=SWFlNdeFdFtfemFvameJNUCx5eFmyxpkPm4+aiiHqBANgNjU/PVmVpZeqdEPHvaoeK f3XQGsPxNCHCDrWOe0m30EEgNJxY8y0nxGQktA2546B6skZOOY+EHgJB2j/2R9ptvqdo WeswL2LVA+dypsnUn1PaTWInQJngSbiB55jhl9OR8PZycDxunWs03EUiXmBB++1epTxO 0FPwwvbSSXpwl0ZqgChpQvD7Oo+HnWVVwUt3DPG41Gy8pB6m1lFDSm40Y7hiUiPd31jb LfUMoqCRDqE4GcVyRwIQqOd+xVSt3IsWQokiIXUVplZ+0IUPXI7xcv/30aJFpU0GxnES ImOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=r9tSS+hZ; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y62si13141806pgd.801.2022.02.08.05.15.40; Tue, 08 Feb 2022 05:15:53 -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=@kernel.org header.s=k20201202 header.b=r9tSS+hZ; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347009AbiBHGQa (ORCPT + 99 others); Tue, 8 Feb 2022 01:16:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230433AbiBHGQ2 (ORCPT ); Tue, 8 Feb 2022 01:16:28 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C1B8C0401DC; Mon, 7 Feb 2022 22:16:27 -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 017A0615D8; Tue, 8 Feb 2022 06:16:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E4E4C340F4; Tue, 8 Feb 2022 06:16:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644300986; bh=dHQMD6sRezY/QyXmR0/JUOowSsiJgm5wiz6FK1pVu7E=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=r9tSS+hZgfGVOukzJ8sI6tp690L4pbCRLjrVJ4ErzzX/0dK3ujjVrcSIHIldY77hU O/erpSFAaaHV4StoWQsW+r8UYstmYbtnhCkjFm2t3As0+YO1w7HwOFb4xad139Y6p8 /+MIR4RUnpKEbelOr9h8EF/6QS9lCB8NI2ATE/AHqviT8MURbREe3Th0cdLDmOVhE2 OLhaEWCfhQ3Wz8MQLHKpm9ntd1YC19+nmRKNlNqLHe4ycM7tKHHNB+zlNYTzBlufQz no7y3XendmsNBTEkInTA5xGoaog7i7WKNunl2BaKQbCcmUR0HqnQtI9rh6podUiT1Y krg5A2Mo2L48A== Received: by mail-vs1-f44.google.com with SMTP id g10so2266933vss.1; Mon, 07 Feb 2022 22:16:26 -0800 (PST) X-Gm-Message-State: AOAM531X3Vrz+mblVzf2u7TluAZs9XvQeR8QYIILaflVe5ruQFqQjkbc 0N+1eR52AFhweznUDlLQZTCHpKEfSljF/Ls04L0= X-Received: by 2002:a67:ec4e:: with SMTP id z14mr1021025vso.8.1644300985309; Mon, 07 Feb 2022 22:16:25 -0800 (PST) MIME-Version: 1.0 References: <20220126114452.692512-1-apatel@ventanamicro.com> <20220126114452.692512-2-apatel@ventanamicro.com> In-Reply-To: <20220126114452.692512-2-apatel@ventanamicro.com> From: Guo Ren Date: Tue, 8 Feb 2022 14:16:14 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v10 1/8] RISC-V: Enable CPU_IDLE drivers To: Anup Patel Cc: Palmer Dabbelt , Paul Walmsley , Albert Ou , Daniel Lezcano , Ulf Hansson , "Rafael J . Wysocki" , Pavel Machek , Rob Herring , Sandeep Tripathy , Atish Patra , Alistair Francis , Liush , Anup Patel , devicetree , linux-riscv , Linux Kernel Mailing List , linux-pm@vger.kernel.org, Linux ARM , kvm-riscv@lists.infradead.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 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. > + 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/