Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1838200pxb; Wed, 9 Feb 2022 05:40:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJwXb6tFDCY33kmZewFJf77U1xf+XcZrtCCbxxeXJKR1yT91nDCeXvqIfLUXUbfcXg9aI4+v X-Received: by 2002:a05:6a00:1a53:: with SMTP id h19mr2365276pfv.65.1644414047261; Wed, 09 Feb 2022 05:40:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644414047; cv=none; d=google.com; s=arc-20160816; b=Hw2aNglyKApbKD+JTohnrvqXPJzhwGnCTn8b2EAkHcc7XtzjcgwEQim41Ryh7OzMBZ QyuM5jh4JpxsjkiDdKN4pXG+Q2iaJil2FOonzq6y4DqCMgzJKQOBC+2H4+CxWsMfm957 u/UgVFjwdt87QV3G2RuVJTbrFdbJO/cgwXZg2M6kWcy3yLWY17FYKyZh8ZmGEo4aPpLB OZK4aif5W/0D2Fe4WHPxUNhPY+iv/B0B/GtxhVNrqdMb8WzUornVgMA1GWkBK6lUXRA3 LYxtLBaZqIdPrH9ZKFdb/8hd8z2IPPM4eqH8Z46jNCTQJN5kPavzqdpCe41m90y1M7rq WXKQ== 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=R83kg3J8lh5wnpwznu/c6c1j21tsi5+UW4ZNVbTpfkQ=; b=CAwHUeBH/IP3+OTCiJSo0ZN1YJxLL84ibNzU/GYkCFTSfHPYy0kKkkDTxk5djGFTU0 rdbCEfKFYczTFWNkcH14a4bh1KJX0NvVvPX4jzlkaR8knysWd079Qycv/9RSvyrzsF/8 YG1kJDYUNI/U7hZLYDIBFbQrXy6bgD/N5RL/sVyMSghuFLNdUjYKKNdXYtoLymbwqvip s9Q6N7iyAAPvtKtc/eI0lm97iCXvuj2JHMZfYAO2J8w8OJTYYr87+XU+PHnwKXW5XJ8g XqD8pu84SSHEmA2VRrYejq01Xu2C9VdARZ1qV5e7O4UGz3qMZl4u6+xLPcSli9z533eO u0FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=cQLt8iTa; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id a15si14889363pls.569.2022.02.09.05.40.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 05:40:47 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=cQLt8iTa; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 89013E13DC73; Wed, 9 Feb 2022 02:23:16 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230288AbiBIFYI (ORCPT + 99 others); Wed, 9 Feb 2022 00:24:08 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:40408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240304AbiBIFPW (ORCPT ); Wed, 9 Feb 2022 00:15:22 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B247C03BFD8 for ; Tue, 8 Feb 2022 21:15:18 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id r131so700150wma.1 for ; Tue, 08 Feb 2022 21:15:18 -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=R83kg3J8lh5wnpwznu/c6c1j21tsi5+UW4ZNVbTpfkQ=; b=cQLt8iTabwlg2Ev6+vNAfrfaVsetuJTsCIXfsbWxN2KJQ58d0KT0yZirQMTcbt0NXE LOfXB+yowzcYh6fsRbs+oRvGDrIyudB2kSF8OJDHN3A6K3ERrtV52t9beearu5kOexbl R/AilxUl1TEcYp7coPdkyR+2dFjXdBhU/4jKHmOAsBkBREdBpjS7BJ5H1/TM7y8VY1k+ geFLbW0Sot0MDg/GGIDq4Uc5Phh2KwSsIUry0D33+azOc/I+Dh+yY82X10zhxY91RO0J QSagJNSO2WAfgnvRxfYUQ3nOofM6gq8dOXjEYfRV99IN5qHnqkdG+8+9UZC7Qp+gs90d G67g== 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=R83kg3J8lh5wnpwznu/c6c1j21tsi5+UW4ZNVbTpfkQ=; b=JZ5R/tVQ4aBqqxJT143XdZsbpx97fkGP+fYCnyAlAtOI1s8AmzdVpuKqWw+x3uutyA Hj/c+0BIZtirbXFg0fjS63fTwPysPTM30+13akfc1HzvPXjWexkU91/2tvYhmR0trEFs I/X4ob9JGuOqWQ1aVsNEMRkrc8DiiuSfgR2Es0pB9EqbV7gKIbNE+/4L9IHfZ9TN9q2t hLzR6eW8gbr5PnpxCGpL/kPa3gKTv6u8/978Zv7FaboPCdE5iYTdBJog9NOM+xaVo61y CUTxXrc2BzhLkPdHeRDbxb29rb1552uP5r1uYe+FdDGKuLEgxzh/Xpus73Y6W3WPfhmw /tgg== X-Gm-Message-State: AOAM531sTAGqEtW1XFE7r9JXXG01mZkJB8vityzDsEK+lSh4Aa4yygce D5E+hxUZdr9oSknSbpNv4BgC8KO8pnwETVDjc1UOWQ== X-Received: by 2002:a05:600c:4185:: with SMTP id p5mr467679wmh.61.1644383716505; Tue, 08 Feb 2022 21:15:16 -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:45:05 +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. 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. 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/