From patchwork Tue Mar 16 10:41:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 401885 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=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable 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 7D188C4332B for ; Tue, 16 Mar 2021 10:43:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3BEEF6500C for ; Tue, 16 Mar 2021 10:43:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236766AbhCPKmp (ORCPT ); Tue, 16 Mar 2021 06:42:45 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:13445 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236769AbhCPKmV (ORCPT ); Tue, 16 Mar 2021 06:42:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1615891340; x=1647427340; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=yTb4qoGUflJi8m7HSJa5+nLEjyRfrdKGIcYDXHbPmSw=; b=fm994LnllHYvuYiK40/RPo6bgB8heBAwQ0qmkJR5m81i3NihrUeAVSZX +eYuw2kqwbtnvJoQxG4x8QoBBVvLbQLJlRZ5LX7YXnD9f4it8QBFczNzk zHOguK68NIvbuw9Keb3QQLRmzp0zO9gNo+PkjrcgXufy4Vm4Q3X/6YxO3 yNSCIMdbZHEWBHFrP1K9yMWRYKS3oh2535bMorTMB5+2ZHYzPDTCEenIq 7tFt/4JJkLWqRakeGIx/QUyCuIJ6wu4JRQgBmndha+9jjZIeB7MCltiF5 QOdA4Rar8kIT2TPWXHfpGIcuqV1XpCCuNezLbAUm6WnbLxxqFoA+YbdwS g==; IronPort-SDR: /NFbKST4N0gn6c2KYbF/N2d0nQsN1yGU0tAt9YQ4a188C784xULLgbcTVvoSHSf1jqx0Dx/M9h DLwSiCMX/Z5JjVr0WcHYFlE8z/S57wopxJy2ic3XL6GRrLj47v5Ggz9VDCWF4MXqL/XAf5+DJ+ ZOVgE4pgiNc76ehY8Are06rpwUKf7FfhbdG4iadJX0O6Lw/QwNuqPreYWMRAzL8EjJOzNHQe2c MmZGXrKYKZopI1Gi1o4dOU4WuzqDCjYimexl0MaxkZORSV09dwyIILQy6e6j34w8tC4ST2Suv8 wEA= X-IronPort-AV: E=Sophos;i="5.81,251,1610380800"; d="scan'208";a="272971730" Received: from mail-dm6nam12lp2177.outbound.protection.outlook.com (HELO NAM12-DM6-obe.outbound.protection.outlook.com) ([104.47.59.177]) by ob1.hgst.iphmx.com with ESMTP; 16 Mar 2021 18:42:17 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D9Oqf/y82PyQ70ZTxAbkVOmHGGtzzuUxMKwO8RIt0t8wfF3neiwUUCLFzFBh8q0M0nd6DH0gKsapLEdoxKpdVK81nOiWH0ZVxK488E3/X2vmrlxl19jIKJ3pvEp3WyLkZLj3gNFZbCYHhZDDVSGXdBHUtw2bmWgSDvuoLdK+TS+VOlL2fyHZroi0Jw+fdGYl3iYqLVjdKwna1XLH5DlbxI1ByEqgshm4yPZN3GtN+WEx+FXbETjm0i/69d+3U7Mnif/lZ2Ux3gZsjlWprdJtf7poY3ehORAK7V0eoXyNJlGsVt9xAO0X4tQh5RounN6WctpwuiwxcESgOoLSO9qPkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KvODrHxjR9O17ndKUIDhzXHw4AWnkKpIZcsCTapVmys=; b=OAlNNpAW4+L7SMJxqZS1mhlmjMXY4lNhUzyTs5EpnUCVUUcv3q+8AqfBCl+BW7XjtVHdBsIBF+tqGl4muvQx/4xe33HqtF8gMi3f9udNbegpcsJnxTvdIYUc/9hg17ZVuMqOu56RyDAW8LfowYeIDu7eZiCJ/Vz9StK1b/CqMzUCLpAucWhynbJcBgoEb3ChYILLSJ/rkA3uiDRRq13uFPk+BEoBpx3Lymef0vOURjj3Fs0pS5WBMyYbwQBxgLlXNjO7yWBp7w0IuaAEcwTyWqnquzJHj0oJscflLQPFnIxpKspr4nA2/UaTN/XB813wC4h1SbOVxCaNnmemBJiV+w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wdc.com; dmarc=pass action=none header.from=wdc.com; dkim=pass header.d=wdc.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector2-sharedspace-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KvODrHxjR9O17ndKUIDhzXHw4AWnkKpIZcsCTapVmys=; b=nxLHwjiNq4q95N67Gh4t4aGkebfZuV8KDsn0kRjT870EbnNpaNiwXi8jvRAOqpj1jXSogCKqMFbvD/RZzDwHTAiX/C72wvgHIs0F49SiMRVpUvoLa0FujEkGY+CTmJyb0lzFm0w4MlvwZUQRbqRIw+NmSqsJ096SaaWd/521/kk= Authentication-Results: dabbelt.com; dkim=none (message not signed) header.d=none; dabbelt.com; dmarc=none action=none header.from=wdc.com; Received: from DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) by DM6PR04MB6377.namprd04.prod.outlook.com (2603:10b6:5:1e6::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.31; Tue, 16 Mar 2021 10:42:16 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::38c0:cc46:192b:1868]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::38c0:cc46:192b:1868%7]) with mapi id 15.20.3933.032; Tue, 16 Mar 2021 10:42:16 +0000 From: Anup Patel To: Palmer Dabbelt , Palmer Dabbelt , Paul Walmsley , Albert Ou , Daniel Lezcano , Ulf Hansson , "Rafael J . Wysocki" , Pavel Machek , Rob Herring Cc: Sandeep Tripathy , Atish Patra , Alistair Francis , Liush , Anup Patel , devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Anup Patel Subject: [RFC PATCH v2 1/8] RISC-V: Enable CPU_IDLE drivers Date: Tue, 16 Mar 2021 16:11:33 +0530 Message-Id: <20210316104140.878019-2-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210316104140.878019-1-anup.patel@wdc.com> References: <20210316104140.878019-1-anup.patel@wdc.com> X-Originating-IP: [122.167.218.45] X-ClientProxiedBy: MA1PR01CA0136.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:35::30) To DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.167.218.45) by MA1PR01CA0136.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:35::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.31 via Frontend Transport; Tue, 16 Mar 2021 10:42:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: ce5575a4-7d08-4453-26ee-08d8e8682a4d X-MS-TrafficTypeDiagnostic: DM6PR04MB6377: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4f6HilFrua3AV9312PesQbsIM2jCsSejZRpy95fc/w75/9ix5yEuolLMXK950FsfgFVmiFW6rYKvx3C1u+XVI+L5gmH/56/ygnr2iW6aOkWT1eEyXmXptLHxfzUaPeQLy6r9h0O9l/KWT50ndh9o3FiW+VonKlcOXxqW7w5cXbn5HFph0y8y434LelV1h/eqR9YCtbA53CpfBIiEE1sFHdObgBSmmukcl/bUi5p0jCAwIscPV6C8lKpjYQa7qUnT5OU8so6ICYbUqkvTLOKdKctp89JtqbRWnqvMLq+jUO35s2qSxqNmIorbjFLpj6iklssdRk/a3k6Q2Rt1AN66YXqCrgGxpFQ1LtVjFA2NsQvzWA2sc3ZSBQNF09toJi1H0y7UkC0nVXC4HV8aG3hw3eIMtKmSnLH4u2TXoW1NkJeZ8aFMbGjkozt4Oo+/5HWux/tg3sLstG/pUOEAUSNh8ha5nvpCgEoW3fZuWqEPN24fzSAFOuqi2RpgqzXxKwbe5bof4dk7Y2500a64oI2G9sSGxRjWnEZNigEnIB9gDttCt/qGZ8tm+QgKavtv6YYS X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR04MB6201.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(8676002)(36756003)(44832011)(52116002)(86362001)(83380400001)(110136005)(7696005)(8936002)(66946007)(8886007)(55016002)(7416002)(186003)(66556008)(16526019)(66476007)(26005)(956004)(2906002)(2616005)(4326008)(6666004)(5660300002)(498600001)(1076003)(54906003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: QrFnsxUkAcHaoBCR/hoZdDQX+1NmaBcRvHqc0RY9d0A/qMQyiCe/9FUOVc3GoLsRZ8eEQolJBlqZt5UPmaIXd2K+0JSRY03BpXx4ofonCsu1nVBfxF8S6rYbKCvxuPDCJ06XP0tIZyfRafRz1p6pSmzN6zUMWr21rO5DKiQgwzS659knbIzFSJev3k8NsopUA81O1x2DR0Ix91sj0TldojuHt/3okFJjiZntMyMUF2q7wKaih7gGVzosIXXBo9YNMygTbj0kVY7DF13JSxM3u8fsEqTYgpUiOmF5cG27tRvWrzjKMVKqZE94AOqVtTPcPF+6PIfrVgVDj4aPZbNU++Mn1aexJiAiHsXhP8XhXFJvXpRPR2jBAW3KjiP/3oiqKGpKI8u6fItfX4LJ9WUMtRd1aXtf+9DceSMWSIZC5+ttjSarb6vT3vc9bckvN4QTq1mgti3Qd5p5y1MYLvo8zcayg6aR0HeZbHd5AB+4VTHS4QNCgmHabOdBS6u+jwxsaKh44hVmCLxFSFgglwKMPT95H4F2lVDXhqLcAyaOm4voDxch0RgeKyWGNQQHUvGaBQSsHQqZbhmQxItO10JOxJiFXEmyNZ/UkrkVg+I8IhWRyxViP5r9u1O1OxkJKKUfTd6fTQJ04M/eTDyZlQlYmi0uFngPfzjsgtAbAIOWTl13mu43WQBM3Jrqd4kwx12lf/XGMdflgxpl24GdJkM/gnLLWIjV3gy4oFc+Xjc+nO/d0Zn5QAK9THT8NmDeClCwQj4l1+gJcnSTDdfIbpr5yVukH+FiA8mSIe14K3uO49W5TQd3UDi3bK05rc2nq9Mdqm13szL77jhU9B1+IF2gCv9S4CbSmg0sctWKJ3f3dH+iieTkhbBukuBrHhoa7stpmFLxx5ew5alGpSJnHSaotLEV8jn4s4mzTPzcSyy5I2EH96cu+mZd8bHUBTJIaI66cVQeqxw/NNmqNYxOyg4ct7Ecb+En2LUu6ek2EeBYZQP4u/tBbfJV3KTqaMC5C0hf2OL2+95JN5OpAfuLjXKqhU+Ay6/I9BNqJjzLXcMFUusCjvuz6kc4odpAFwYuEHiIS16dtS57JR4iFsXYGZRdHlKxO7kbCt1sRFTsWsg0OqvIdf/1u4kMxaGJwKd4mWzjNRCHzCRs1aw7im4y4zYMWQ5m5cDeFOgDd7xtgTz5b8Eeil0uiWXf0II4KaqE5l0KoaGmSqqaKtLbAjTWTQ+JnwIgkP6p+rNzcfrrJFFl1AN4zKSsoJx8DT7reNlIUhpO2m3sUTvjdyFoKAkQ9x3PuzgU8XybVfESn+cTgPJY+ywzqW4Rc2iGazR5OpvjAif0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: ce5575a4-7d08-4453-26ee-08d8e8682a4d X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Mar 2021 10:42:15.9215 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +gWcb3aQEFt3EIhbIfGfWuoo2Uw5UI+4SzYGoLtsFNatJ83gMu+c55TUIykL4SGGH5YmKTuho0OiC9nOj6TzCw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6377 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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 468642c4e92f..19c9ae909001 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 @@ -475,4 +476,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 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 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..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(); + wait_for_interrupt(); +} + +#endif diff --git a/arch/riscv/kernel/process.c b/arch/riscv/kernel/process.c index 6f728e731bed..dd2ef18517f4 100644 --- a/arch/riscv/kernel/process.c +++ b/arch/riscv/kernel/process.c @@ -22,6 +22,7 @@ #include #include #include +#include register unsigned long gp_in_global __asm__("gp"); @@ -36,7 +37,7 @@ extern asmlinkage void ret_from_kernel_thread(void); void arch_cpu_idle(void) { - wait_for_interrupt(); + cpu_do_idle(); raw_local_irq_enable(); }