Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4326165pxb; Tue, 2 Mar 2021 12:08:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJwZkmCaWfD3VjJBPVOMXPxsvnwfgZDocNNESyIdfyv5g2qM59Mv6NrouS0ijc4pnfkBBa7E X-Received: by 2002:a05:6402:40b:: with SMTP id q11mr22125070edv.36.1614715594405; Tue, 02 Mar 2021 12:06:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614715594; cv=none; d=google.com; s=arc-20160816; b=OWP45Z1PC8cfEk4nyhtmguFBWZjzX3Xb9IWbVqfPU5ZkT+hECO2kxFDWp8+kD8O2xf mu48d1N+vTs4OMJdMI/mc2YRHqqmA3N/Ap5epn6mIJmdEv56gJGPGQRlb1zPPLKv7OVH hCtaAlMR8jPlN4aZYG9S1A5gacPZE0UhUSB6drpSW0NWiM6GteG1RMz5MBUouxeX9+Cw z0pn6FVXxNcMy3cDNQcyM91ZoejoBqKk/tZBtIcqVQkZFMnZ/Ks8O+6psAgmp4Nt+Y6w VOicVkG+s3NiCaoftoAFi6upSpqC9lxGG2Bsgy0sQ7oMn/XTNa2osX3K/8EVfq256lqn xU+g== 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=tfd97WX1co/bA1GShyJOLBPAN41kKS3JMrc0KxlzgGU=; b=0HfVyaISEZ/aO9nHOCrA4j8Gmw3v23jOqXND3al/ykP1FKCPprki069iuJS4IVskrH GvVxhazELv9XR7HnLlW2s8Xd2J/HElMloFOkSyVS3zd5cUciKLJBirmX6Fd7ok1a9wW8 gYOvH94C+3ahaSGirvraUhFiWEXcXmbMuoTv2XlSRrYR5OzvD+KrPEKx3VVXkyXFcmRk +5w3zDP6NXBjnWqFOjyKKiBO2eTVlp7xPFrgcOC6PzFgFJUHXD8DD4XCgUvzey+cD8xH /0s/CdvEu3uneUPUc7L9rl6v46LzGe0wQoG5KkC+8g4jC6A+SYkE+WI/gVj6k686pAVh zx/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=X3HySQSo; 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 p88si14272646edp.145.2021.03.02.12.06.02; Tue, 02 Mar 2021 12:06:34 -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=X3HySQSo; 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 S1836765AbhCBHUp (ORCPT + 99 others); Tue, 2 Mar 2021 02:20:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344753AbhCBGnZ (ORCPT ); Tue, 2 Mar 2021 01:43:25 -0500 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6D0DC06178C for ; Mon, 1 Mar 2021 22:42:38 -0800 (PST) Received: by mail-wr1-x429.google.com with SMTP id a18so10423750wrc.13 for ; Mon, 01 Mar 2021 22:42: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=tfd97WX1co/bA1GShyJOLBPAN41kKS3JMrc0KxlzgGU=; b=X3HySQSox1FrvVZIqGKp3GG6HIrkQQVlWJxpD5Cco4Ge2nF0iwz+VlZzafhh+7M7kK Ec3QuQX8AccyoXeXbACGA6WDmbvBYjKDKKH+UpLB01eR6ha3wPafBmLjBhmpY6qJiOqw bK2kyAE5fEuIRwu+B6ITr7rrY30tatyMOpGz+8exxEsQP2enrIsMEIN27dRfsMvLplZx nlH+uXvkTP0FbPoFiBFwLFeJVzY0lU+WxTi+Y3lnpg+eG+caUSBga2HP1cv0ixswGjec VRhGC6ZRxaBRCEeJrksMHekp+Xah/I+GfxaeShSi7hK5InuZn7lg7zDRWsnbVXyGYh6R IsFg== 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=tfd97WX1co/bA1GShyJOLBPAN41kKS3JMrc0KxlzgGU=; b=DjZeLxLc8wOSspIFNn/L94Nz3dacQhMyBS60h06tdXsLFJSGTz1ACJBEgUOF1xMAdQ GyV1jAl0v/H5I4WeAOiVvDC8Sgx9Dcrzn7Nq211BRMb+khJ+/fEAI4t25J5xohrjlRqu V9tee4hhkQ9h3VcE+r2K+TRnb3s2fHSzLXSikYHn2BPEqsOmt3H+dUBQXdI4j5RnQiEM VCGCgL9oQ9CLxBtbrF263MaduH47RIlZ14/CZxzQArqeZ5RvK3305ejGDQ2G6PVRvXnw TPHJNq7lzj5SsiVW6XU3D9AFqHWQDlvURGprW+aTz1cZgisivlXc98ZEdth7RUhj3OJc ZPQA== X-Gm-Message-State: AOAM532ORxzgP9IZboexapOUSCf+of4lwLwc2i4VayBMNBwJ4l5cUn0s 09GSQYiavZwiCzyBVmPnmD5UQnCX1bYDtgGo4gq/jA== X-Received: by 2002:a5d:464f:: with SMTP id j15mr21059836wrs.390.1614667357370; Mon, 01 Mar 2021 22:42:37 -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: Tue, 2 Mar 2021 12:12:26 +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 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 ? This option is selected by CONFIG_SOC_VIRT so it is being removed from defconfig by savedefconfig. > > > 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 ? This is enabled by default so savedefconfig removes it. > > > 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 ? > > > + * 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