Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1709456pxb; Fri, 26 Feb 2021 20:03:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJy2ApedyuKDfCd4y/dUH4cyYnGVw4RAQ9us2UzAgVux/eLueSNT7L1KZ13J4Yk6djLuyKyK X-Received: by 2002:a17:906:3801:: with SMTP id v1mr6568249ejc.353.1614398633155; Fri, 26 Feb 2021 20:03:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614398633; cv=none; d=google.com; s=arc-20160816; b=OR+PFOtowM2EYeR6cBU6zwsKZq+zXJ5v7yTfQBe0wMinBb1rxoqKpB78HI969YNSD0 vywNvTezFv0O8AjTr9AJ4dcILetGWfGLYmQWGm5dNIL9xcJwftl2qpahpWFT5w1nYXNc niUoUh3uf3Y0FRgFmq9avhhFua393uRQcIRn4M1j+Jx0R8Q8MuHCxB8PJunYp4k7n7by NyBLJc+JWHQmyQTHews6AZInfBCkpiQLiM7DX7NcQuempjuY3TJzpL7CgN1zHRBDDWJs HpFP39011/+j41Q9TOGsIQZwyGrcpxZygxWdk2eyqLGJbETzhxoNvu3jfqPEKyHEA/KD D//Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=IozGx7C0T19f0wHA2sRVJGAa+F8rFFKpX1D9A8YR8PU=; b=qiiTO+TFj66n985klKBmaOsTPIjzXEPUaL2rOKowlrOUWd+hoRKnTSt1ADHlgsK/4f p33PgeQzLc93lko1TItBtMceHmKtVbtwy9X9JMlTucqJxYL5pYiws370UlEU6bnZVR+P YF/TBZDoyCr1xynR4UlpxBoPEfgRH1u34eUKgbFasChnviX6pbrjNkEgL8Oeop8LUvQ4 KrPO30ydwsByWPMgFIYfbNz0hUllxGevrSeq9Hd2oG453WP01dHxWmyIwcEIt2OTNlO9 WapF50fx/PdKL25IzctWph/4MW97Y5XLfaJPTNEpnNrIjXoOORDfETgx34vOVVrpxqYM EqKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=HCQVZ5Ej; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d19si6597329edt.189.2021.02.26.20.03.30; Fri, 26 Feb 2021 20:03:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=HCQVZ5Ej; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230010AbhB0EAW (ORCPT + 99 others); Fri, 26 Feb 2021 23:00:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229864AbhB0EAS (ORCPT ); Fri, 26 Feb 2021 23:00:18 -0500 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70CC8C061756 for ; Fri, 26 Feb 2021 19:59:38 -0800 (PST) Received: by mail-lj1-x22b.google.com with SMTP id 2so8405475ljr.5 for ; Fri, 26 Feb 2021 19:59:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=IozGx7C0T19f0wHA2sRVJGAa+F8rFFKpX1D9A8YR8PU=; b=HCQVZ5EjAhlPbe6PMaX7ZUJILWMltz2qOzxlQTW/cLhl4wTjGnAAFQ9DhlsKHlbPoh uhreFWU/8syefOSG9GjCSk0NkbeHR5owmvGV6uHWbk4ij2eRQnsGu0Gp0OzBTtGBkRyN 22tqA9FjtcndeULj4onrEi3jcyHapzSrHghIwcup5y45alrBxDPasblkR4ddZytTmJzf P9W2H1RygxjlfJ4KLdg+914UOoZnQeeeSEUbcd2ddMXmOZCXXhAUB/1R4TzwOta3TjRr T/+00ElxyBnmBLV6Cx1a23XWFILvofLUstmlM/qyR0YPBisY03vE2xjKFIH8sq5Xb8z+ F3ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=IozGx7C0T19f0wHA2sRVJGAa+F8rFFKpX1D9A8YR8PU=; b=kN96glW+v3IYRpn1cnwo42i4RYxeKHE6oi+AbKYRj3bzaFb30dlxGoSIBcOlGrY3Lw vZLf2p8MDt48utCVeIrLY/+CbRllSaHl6pYatX/FC/OZvDLRDZV07ID36VyKlS9pdYyS COnMr1M+J4WLIkZBpjQO7A3krxbuFXTB8+IVS5ir2rd+8DpNXDlILNPEqGJcMv4FgnhG WW5alZPsBbYkY0sLEv8IXBMbcowAv5tbjquIlwfhi8lNOWpyC1yzu1CPJ5aCWN74jlSk jfgoWAnuhYAtC/CXAUGRcXkXzASZkBHBRPvpbrIPepc29nsUR1IR+h3Wkro10qBsSYjh z9GQ== X-Gm-Message-State: AOAM531StGMRf5U1V3mc13TSxCzzIb7iA0NSg4WJ212ClZhY6eFw28eM ca8sFXCKBaWXoKmHkpQsVri0qGCVBnQ+Ft1JoOWAFw== X-Received: by 2002:a05:651c:15:: with SMTP id n21mr3539853lja.284.1614398376751; Fri, 26 Feb 2021 19:59:36 -0800 (PST) MIME-Version: 1.0 References: <20210221093758.210981-1-anup.patel@wdc.com> <20210221093758.210981-2-anup.patel@wdc.com> <3a6e2af7-934d-078f-4e19-d4241809e7fb@ghiti.fr> In-Reply-To: <3a6e2af7-934d-078f-4e19-d4241809e7fb@ghiti.fr> From: Anup Patel Date: Sat, 27 Feb 2021 09:29:24 +0530 Message-ID: Subject: Re: [RFC PATCH 1/8] RISC-V: Enable CPU_IDLE drivers To: Alexandre Ghiti Cc: Anup Patel , Palmer Dabbelt , Palmer Dabbelt , Paul Walmsley , Albert Ou , Daniel Lezcano , Ulf Hansson , "Rafael J . Wysocki" , Pavel Machek , Rob Herring , devicetree@vger.kernel.org, linux-pm@vger.kernel.org, "linux-kernel@vger.kernel.org List" , Atish Patra , Alistair Francis , Liush , linux-riscv , Sandeep Tripathy , linux-arm-kernel Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Alex, On Fri, Feb 26, 2021 at 6:46 PM Alex Ghiti wrote: > > Hi Anup, > > Le 2/21/21 =C3=A0 4:37 AM, Anup Patel a =C3=A9crit : > > 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 > > --- > > arch/riscv/Kconfig | 7 +++++++ > > arch/riscv/configs/defconfig | 7 +++---- > > arch/riscv/configs/rv32_defconfig | 4 ++-- > > arch/riscv/include/asm/cpuidle.h | 24 ++++++++++++++++++++++++ > > arch/riscv/kernel/process.c | 3 ++- > > 5 files changed, 38 insertions(+), 7 deletions(-) > > create mode 100644 arch/riscv/include/asm/cpuidle.h > > > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig > > index fe6862b06ead..4901200b6b6c 100644 > > --- a/arch/riscv/Kconfig > > +++ b/arch/riscv/Kconfig > > @@ -37,6 +37,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 > > @@ -430,4 +431,10 @@ source "kernel/power/Kconfig" > > > > endmenu > > > > +menu "CPU Power Management" > > + > > +source "drivers/cpuidle/Kconfig" > > + > > +endmenu > > + > > source "drivers/firmware/Kconfig" > > diff --git a/arch/riscv/configs/defconfig b/arch/riscv/configs/defconfi= g > > index 6c0625aa96c7..dc4927c0e44b 100644 > > --- a/arch/riscv/configs/defconfig > > +++ b/arch/riscv/configs/defconfig > > @@ -13,11 +13,13 @@ CONFIG_USER_NS=3Dy > > CONFIG_CHECKPOINT_RESTORE=3Dy > > CONFIG_BLK_DEV_INITRD=3Dy > > CONFIG_EXPERT=3Dy > > +# CONFIG_SYSFS_SYSCALL is not set > > CONFIG_BPF_SYSCALL=3Dy > > CONFIG_SOC_SIFIVE=3Dy > > CONFIG_SOC_VIRT=3Dy > > CONFIG_SMP=3Dy > > CONFIG_HOTPLUG_CPU=3Dy > > +CONFIG_CPU_IDLE=3Dy > > CONFIG_JUMP_LABEL=3Dy > > CONFIG_MODULES=3Dy > > CONFIG_MODULE_UNLOAD=3Dy > > @@ -65,10 +67,9 @@ CONFIG_HW_RANDOM=3Dy > > CONFIG_HW_RANDOM_VIRTIO=3Dy > > CONFIG_SPI=3Dy > > CONFIG_SPI_SIFIVE=3Dy > > +# CONFIG_PTP_1588_CLOCK is not set > > CONFIG_GPIOLIB=3Dy > > CONFIG_GPIO_SIFIVE=3Dy > > -# CONFIG_PTP_1588_CLOCK is not set > > -CONFIG_POWER_RESET=3Dy > > Why do you remove this config ? Argh, I don't know how this got here. I will remove this change in the next revision. Thanks for catching. > > > CONFIG_DRM=3Dy > > CONFIG_DRM_RADEON=3Dy > > CONFIG_DRM_VIRTIO_GPU=3Dy > > @@ -132,5 +133,3 @@ CONFIG_DEBUG_BLOCK_EXT_DEVT=3Dy > > # CONFIG_FTRACE is not set > > # CONFIG_RUNTIME_TESTING_MENU is not set > > CONFIG_MEMTEST=3Dy > > -# CONFIG_SYSFS_SYSCALL is not set > > -CONFIG_EFI=3Dy > > And this is one too ? If those removals are intentional, maybe you can > add something about that in the commit description ? I will remove this change as well. > > > diff --git a/arch/riscv/configs/rv32_defconfig b/arch/riscv/configs/rv3= 2_defconfig > > index 8dd02b842fef..332e43a4a2c3 100644 > > --- a/arch/riscv/configs/rv32_defconfig > > +++ b/arch/riscv/configs/rv32_defconfig > > @@ -13,12 +13,14 @@ CONFIG_USER_NS=3Dy > > CONFIG_CHECKPOINT_RESTORE=3Dy > > CONFIG_BLK_DEV_INITRD=3Dy > > CONFIG_EXPERT=3Dy > > +# CONFIG_SYSFS_SYSCALL is not set > > CONFIG_BPF_SYSCALL=3Dy > > CONFIG_SOC_SIFIVE=3Dy > > CONFIG_SOC_VIRT=3Dy > > CONFIG_ARCH_RV32I=3Dy > > CONFIG_SMP=3Dy > > CONFIG_HOTPLUG_CPU=3Dy > > +CONFIG_CPU_IDLE=3Dy > > CONFIG_JUMP_LABEL=3Dy > > CONFIG_MODULES=3Dy > > CONFIG_MODULE_UNLOAD=3Dy > > @@ -67,7 +69,6 @@ CONFIG_HW_RANDOM_VIRTIO=3Dy > > CONFIG_SPI=3Dy > > CONFIG_SPI_SIFIVE=3Dy > > # CONFIG_PTP_1588_CLOCK is not set > > -CONFIG_POWER_RESET=3Dy > > CONFIG_DRM=3Dy > > CONFIG_DRM_RADEON=3Dy > > CONFIG_DRM_VIRTIO_GPU=3Dy > > @@ -131,4 +132,3 @@ CONFIG_DEBUG_BLOCK_EXT_DEVT=3Dy > > # CONFIG_FTRACE is not set > > # CONFIG_RUNTIME_TESTING_MENU is not set > > CONFIG_MEMTEST=3Dy > > -# CONFIG_SYSFS_SYSCALL is not set > > diff --git a/arch/riscv/include/asm/cpuidle.h b/arch/riscv/include/asm/= cpuidle.h > > new file mode 100644 > > index 000000000000..1042d790e446 > > --- /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 access are completed prior > > accessES ? Okay will update. > > > + * to enter WFI. > > + */ > > + mb(); > > + wait_for_interrupt(); > > +} > > + > > +#endif > > diff --git a/arch/riscv/kernel/process.c b/arch/riscv/kernel/process.c > > index dd5f985b1f40..b5b51fd26624 100644 > > --- a/arch/riscv/kernel/process.c > > +++ b/arch/riscv/kernel/process.c > > @@ -21,6 +21,7 @@ > > #include > > #include > > #include > > +#include > > > > register unsigned long gp_in_global __asm__("gp"); > > > > @@ -35,7 +36,7 @@ extern asmlinkage void ret_from_kernel_thread(void); > > > > void arch_cpu_idle(void) > > { > > - wait_for_interrupt(); > > + cpu_do_idle(); > > raw_local_irq_enable(); > > } > > > > Regards, Anup