Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1203027pxb; Fri, 26 Feb 2021 05:19:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJxQDpB8p+w97luC07JtfzSL8i333SAwpn1ib2vsUTGp7sSA/r7wWuY/U6xYOL65XL5qCpsw X-Received: by 2002:a17:906:4f02:: with SMTP id t2mr3324379eju.121.1614345588902; Fri, 26 Feb 2021 05:19:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614345588; cv=none; d=google.com; s=arc-20160816; b=PdCBrNsCa0zmInJqdS4G7TdPu7nq58czZQvEnSAyhTYqe0SI0wwFU6rSqOhbdETIl+ fRg9snbce7+5lu+EG3WXX2o7cMU27BnNmHlqXfC/cO8UBqqRkxyEtfqUBSfRGU2brNVM y6rWWEvrs33fSZu9ww0jsdhL6z/08MUMJbYWMROrFp1ouqfrjTIYuqkDuSwq5ghLXlb9 aKUDDmDZlWMgSLoWvwF8y42OkPz7Ezi0UoBppSE7g/l4QAt9cAyX/kBaWJvaHBQWhHpp /akzvjsEsbd0WwFiqtXYrcegCLTKtVwIK3QDyAzqm8dAp2ngey79oxmVuYbUhdhHTejl 1SVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=MlUY8iOf1IjeOXZTfdwMBRPnYA2pq/e0yfEcpv0zq5A=; b=F72hl+gSlQZlxZUKJiPdGmrYpT07IE8A2Qo5joQ0gHZVBq4+41d7jF52iKhXvXLUsx PNbt30alR9Lhu1s6XSuaEo97kKbVtsVhegcjlwMAkS8nPo6zCul36S7VyRPZdn2rZq9P JwuwvRnwnJc/3ZgUbpY4y0rhQFdZwLC6c3DuwuX0XVnFThXlde9YAa1cwsvrpISFV7q4 x7sQNfYoapKY0smsszhJ7r9VWRsoophtmqk6UKA3qFAUmIcaK/aCyg6G0x6g/db0i7cS 7oaxx3sRjLL279fuaTJEhw9g0lo8STA8DrUp7YedSaTrj+FtYivFhvXeRMifBmzLrDlG meKg== ARC-Authentication-Results: i=1; mx.google.com; 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 p12si5819699ejm.633.2021.02.26.05.19.25; Fri, 26 Feb 2021 05:19:48 -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; 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 S229849AbhBZNRV (ORCPT + 99 others); Fri, 26 Feb 2021 08:17:21 -0500 Received: from relay8-d.mail.gandi.net ([217.70.183.201]:34883 "EHLO relay8-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229545AbhBZNRU (ORCPT ); Fri, 26 Feb 2021 08:17:20 -0500 X-Originating-IP: 81.185.174.212 Received: from [192.168.43.237] (212.174.185.81.rev.sfr.net [81.185.174.212]) (Authenticated sender: alex@ghiti.fr) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id DA1281BF203; Fri, 26 Feb 2021 13:16:15 +0000 (UTC) Subject: Re: [RFC PATCH 1/8] RISC-V: Enable CPU_IDLE drivers To: Anup Patel , Palmer Dabbelt , Palmer Dabbelt , Paul Walmsley , Albert Ou , Daniel Lezcano , Ulf Hansson , "Rafael J . Wysocki" , Pavel Machek , Rob Herring Cc: devicetree@vger.kernel.org, linux-pm@vger.kernel.org, Anup Patel , linux-kernel@vger.kernel.org, Atish Patra , Alistair Francis , Liush , linux-riscv@lists.infradead.org, Sandeep Tripathy , linux-arm-kernel@lists.infradead.org References: <20210221093758.210981-1-anup.patel@wdc.com> <20210221093758.210981-2-anup.patel@wdc.com> From: Alex Ghiti Message-ID: <3a6e2af7-934d-078f-4e19-d4241809e7fb@ghiti.fr> Date: Fri, 26 Feb 2021 08:16:15 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210221093758.210981-2-anup.patel@wdc.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Anup, Le 2/21/21 ? 4:37 AM, Anup Patel a ?crit?: > 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/defconfig > index 6c0625aa96c7..dc4927c0e44b 100644 > --- a/arch/riscv/configs/defconfig > +++ b/arch/riscv/configs/defconfig > @@ -13,11 +13,13 @@ CONFIG_USER_NS=y > CONFIG_CHECKPOINT_RESTORE=y > CONFIG_BLK_DEV_INITRD=y > CONFIG_EXPERT=y > +# CONFIG_SYSFS_SYSCALL is not set > CONFIG_BPF_SYSCALL=y > CONFIG_SOC_SIFIVE=y > CONFIG_SOC_VIRT=y > CONFIG_SMP=y > CONFIG_HOTPLUG_CPU=y > +CONFIG_CPU_IDLE=y > CONFIG_JUMP_LABEL=y > CONFIG_MODULES=y > CONFIG_MODULE_UNLOAD=y > @@ -65,10 +67,9 @@ CONFIG_HW_RANDOM=y > CONFIG_HW_RANDOM_VIRTIO=y > CONFIG_SPI=y > CONFIG_SPI_SIFIVE=y > +# CONFIG_PTP_1588_CLOCK is not set > CONFIG_GPIOLIB=y > CONFIG_GPIO_SIFIVE=y > -# CONFIG_PTP_1588_CLOCK is not set > -CONFIG_POWER_RESET=y Why do you remove this config ? > CONFIG_DRM=y > CONFIG_DRM_RADEON=y > CONFIG_DRM_VIRTIO_GPU=y > @@ -132,5 +133,3 @@ CONFIG_DEBUG_BLOCK_EXT_DEVT=y > # CONFIG_FTRACE is not set > # CONFIG_RUNTIME_TESTING_MENU is not set > CONFIG_MEMTEST=y > -# CONFIG_SYSFS_SYSCALL is not set > -CONFIG_EFI=y And this is one too ? If those removals are intentional, maybe you can add something about that in the commit description ? > diff --git a/arch/riscv/configs/rv32_defconfig b/arch/riscv/configs/rv32_defconfig > index 8dd02b842fef..332e43a4a2c3 100644 > --- a/arch/riscv/configs/rv32_defconfig > +++ b/arch/riscv/configs/rv32_defconfig > @@ -13,12 +13,14 @@ CONFIG_USER_NS=y > CONFIG_CHECKPOINT_RESTORE=y > CONFIG_BLK_DEV_INITRD=y > CONFIG_EXPERT=y > +# CONFIG_SYSFS_SYSCALL is not set > CONFIG_BPF_SYSCALL=y > CONFIG_SOC_SIFIVE=y > CONFIG_SOC_VIRT=y > CONFIG_ARCH_RV32I=y > CONFIG_SMP=y > CONFIG_HOTPLUG_CPU=y > +CONFIG_CPU_IDLE=y > CONFIG_JUMP_LABEL=y > CONFIG_MODULES=y > CONFIG_MODULE_UNLOAD=y > @@ -67,7 +69,6 @@ CONFIG_HW_RANDOM_VIRTIO=y > CONFIG_SPI=y > CONFIG_SPI_SIFIVE=y > # CONFIG_PTP_1588_CLOCK is not set > -CONFIG_POWER_RESET=y > CONFIG_DRM=y > CONFIG_DRM_RADEON=y > CONFIG_DRM_VIRTIO_GPU=y > @@ -131,4 +132,3 @@ CONFIG_DEBUG_BLOCK_EXT_DEVT=y > # CONFIG_FTRACE is not set > # CONFIG_RUNTIME_TESTING_MENU is not set > CONFIG_MEMTEST=y > -# 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(); > } > >