Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1787540pxb; Wed, 9 Feb 2022 04:37:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJyPJ29DSvWmyreFJZHz9g0PLTQ70nPjGiIUnGSrX7QAS27HM5mXrJMoKTvnNjq7XE2jB0Tm X-Received: by 2002:a63:5226:: with SMTP id g38mr1735873pgb.620.1644410248030; Wed, 09 Feb 2022 04:37:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644410248; cv=none; d=google.com; s=arc-20160816; b=A4QBdMueVdFcWuGb8f6eTQu30II5ABYKkh1jMUV4gIDw1Lzx9nOTtB5DGl4SPJ/LDt NbGmvQG+xDlG5nvQgyWD75nPBrOvKhRJm9O5JkXx1Wewq1GGcX3kDkMdeqp1up1JFmZV n19g44s/rv3J+x8Lao57vAYoYiY25O4le7Jda6Z+X4787ly+gOaB/JgMYK2+8J76ltCn 9NyoOHEqceZr/UqEyLrXcHFn5XfSo4Ng3D+WbbZs7datSWyW7VFNS7ugxGeJhfYtwmSr 3YL7O2Q7Lu2VDi4zwf2ul+vhyyhAuNaLysN/aquuW0nHFZW06+baTW4402mC5ZWb7EsD dIIw== 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=wAsSnnD9JIeAeZJ9p3BQTgq96g2Q9LHlXoe8+WeEVfI=; b=nIpw44Eh98I3+qCIUA4AVoaM2QE1kdPXMWM0baJVC1tPQSZUWUyC5nq0TnDbb6k97p zIAj+odOi58e3stCIaa1NWW9RraEdAiKgqN5MFm3/1Y94LfQDV9VyfT3aLLTJ24WzHZ/ zjoHGHkqg2NtDGuPCKnTWeqbqp1hs7LXSMnzw/6s8RdQr7BLHd6g6K182MEEjvY3wS+D xodejYeAbGYQOXqTajavnOCl6aL1aMM0DGRMBmXUAfNP/N0hJrO2BLcb9yx6ZwS2vRIF EItQ9H9qygEMfoQxpfhW/SW3Pma4/037UdA3vzrOGBteZ8qxd/2E/Dv+nrubvTWTdu4V Hb5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=1tKXU6TX; 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 Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q7si16509187pfs.96.2022.02.09.04.37.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 04:37:28 -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=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=1tKXU6TX; 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 57E95E090D4B; Wed, 9 Feb 2022 02:23:48 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232740AbiBIFY0 (ORCPT + 99 others); Wed, 9 Feb 2022 00:24:26 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:48880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234963AbiBIFUh (ORCPT ); Wed, 9 Feb 2022 00:20:37 -0500 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20676C043180 for ; Tue, 8 Feb 2022 21:20:41 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id k3-20020a1ca103000000b0037bdea84f9cso751103wme.1 for ; Tue, 08 Feb 2022 21:20:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=wAsSnnD9JIeAeZJ9p3BQTgq96g2Q9LHlXoe8+WeEVfI=; b=1tKXU6TXAd28+p0tvCpH0D5QBomKCxkddDWl5LVsYFX8hIdbe6CzV6wuulBu+sQEps AeaTcuXTxF9e8cIPmKTyUX9QS/MLzuiJ3poPshrD3N/JwthsFwtR7IqmJ/qp78VdQzKC EXqidiNi/RX6zBYFOA0F0nOb+555/L5wYmFW+TC4IxgMpILOkbFejGn9NmToUD47VYv6 VODXl9hVeDhlGEWLaNdgOkZgRtBATLz3GRtmkcoO1HawYxr03sK0DnYLDDdfYEJ4uErA Jtbl/MdVrVMc95sx7r0egcRaQ5U2Mm2BKbFsBg2cO/Jq5juetaFMNFhUAyh1A0Te5JOo C15w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wAsSnnD9JIeAeZJ9p3BQTgq96g2Q9LHlXoe8+WeEVfI=; b=0jY1KL2c/09jaSG4BhZmuQKibEDP6nLBNXfaAt+G00hZYpTfSyxLehv5dw0sbtFoJ1 YuxyPH4uXh+gTtiJjGp1cBzjiqr6XSgBJYs5TVR/KDFpfaPMa3VhvcT5+17sPDIgQlkJ Mn7iaRAmoCuJvjw1kYOGqPCDxSnsHQ0p5hBB2uh02B1E2xLt2xZ+ptsmASjjvsx8/QCG U+7wKN5ahzsiSRbBmFMbSGbJPNdJTECJcQo6iu99b4ICWsFWt+aXXyGbM03Lm3vAsjxM zmSj0weZxbDghJ/Z7uIc1YxdEovG+6yyiOCyWm4hDNcmTR7HWBtu0jkQnMaeLpmnuY8y MRkQ== X-Gm-Message-State: AOAM532cxScuvs1dOz6b0uWcfqA6tiTSCGYywSCL4G4tjajnCnoX7CKr AtiFa37wHkdwbC3IE+BG7HNVWHyhQy9AeYjEKv/LrQ== X-Received: by 2002:a7b:c7d5:: with SMTP id z21mr496193wmk.59.1644384039591; Tue, 08 Feb 2022 21:20:39 -0800 (PST) MIME-Version: 1.0 References: <20220126114452.692512-1-apatel@ventanamicro.com> <20220126114452.692512-2-apatel@ventanamicro.com> In-Reply-To: From: Anup Patel Date: Wed, 9 Feb 2022 10:50:28 +0530 Message-ID: Subject: Re: [PATCH v10 1/8] RISC-V: Enable CPU_IDLE drivers To: Guo Ren 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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 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. > > > + 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(); We can't add "mb()" here because cpu_do_idle() is called directly from linux/cpuidle.h and arch_cpu_idle() is only called when CPU idle is disabled. Regards, Anup > 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/