From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B74A4C433DB for ; Tue, 2 Mar 2021 08:27:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 738D964D9C for ; Tue, 2 Mar 2021 08:27:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1836770AbhCBHUq (ORCPT ); Tue, 2 Mar 2021 02:20:46 -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-Google-Smtp-Source: ABdhPJz1mZd5y4d1mGFzB+y5OipFPnyMJbdA+7nb01Qbnev+st2N3Fi1s+PseO+OVJpZp0oP8W2X+LgHDA+7KkohnTo= 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