From patchwork Thu Jun 10 05:22:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 458847 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.8 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=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 C5272C47094 for ; Thu, 10 Jun 2021 05:22:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B16F1613E4 for ; Thu, 10 Jun 2021 05:22:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230113AbhFJFYv (ORCPT ); Thu, 10 Jun 2021 01:24:51 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:11455 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230084AbhFJFYs (ORCPT ); Thu, 10 Jun 2021 01:24:48 -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=1623302576; x=1654838576; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=Pu9Io5ABNyIwu1+haflsV13kIurdSAe5IlMVtkIEsvw=; b=p3KmEycGstiufHSU4JwcVV4mgCyQLl8Ez2jaAP+bXnpDgYUTfKoqBuRC b74xlk7msc8FqXOnDVjl3+gHP9zDPkJWKm4dnx1biZY2JDqRE2yg0TTq4 uyyyTN1SDwWafnWpGUKJCxGzn4LPKTlAlWeXRtaYIxdVmR1Eea6ZFCTpd OL4Di2rl4W22XAn6wgaAzK+PG7/ei/0MR04BPm7z9Dbw5gcQ9KyJMp3NQ r2ybgqnFXWBswk7+FJ7+BLtmHyxlw6alotXovDNfvss0wom1b4AFEyUqe x8G6xVtyRLK5NaroRGTzWYCoCUCyUibMVDyOAR85bR2oNvTKRrfftC98T w==; IronPort-SDR: QvfQ5vvVFcvHHOHEXKeO3HyVvOUch7Ft2CPFYGOBnAkfxTjb97+bal5Ol6zv1LWggqrT6Uo2KY X16LTR2QAWMbbEGe+6S+vXyUA0BS5W2lCHAsZuLBC9Cry6j1WIvFQyewLRk6hUV9kCYXYHLVHz wV3MNHqJ+fFgQIpZtGEm34C6cW74vLIWCmDLbpn+qZquEjQfvyGYp55KFoL4V7hAy5n2WWDf1a uW+NJs3BkxgfhMn/E2ZbvNeiwlwiPshittMXGeE6jx8OvzL+VHuMOWdQhiWnQlHME8JAmjvYiB 0Vc= X-IronPort-AV: E=Sophos;i="5.83,262,1616428800"; d="scan'208";a="275211776" Received: from mail-dm6nam11lp2169.outbound.protection.outlook.com (HELO NAM11-DM6-obe.outbound.protection.outlook.com) ([104.47.57.169]) by ob1.hgst.iphmx.com with ESMTP; 10 Jun 2021 13:22:53 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QJCqwcCNvph4lgBOTUHrVpFJoRNKLGWwr2jyydgYlezmkMIkioV96O/csDpXQFx7+lA39hBPgfLaM5J7Pxp5U9jOyE+14L8SqZzN2bsIrPb4JpM/cfQDxHedIdrVH/edsRDxljOcUbsj8SEshlnNMSAob/S0ZkJl8mnCeRHlLi4++DRnwJQchas4sFjSlrk2ehk+VocZHdJsvh2ORodprgvq5v4xa1mgnGr+Ok/vv0Bv8IMIH38vs9STN7EdRa/98SDWbAO525w4QU1LUGEW6p1i5xI0w1aE6rJ9cpyj0zCzyv92fKdYI+/q5I/7KONfWSAB8fbcCZ81qT/S6uj6Qw== 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=8J3Z51tt91nROm/qGQh6Y5Ld7cjzveYM0Ru5f9vIizU=; b=e96DWae29dV8oRBzRJmkLo1vMA3WAbC6XeAoZIbJq0Jl9V4VBu5DELMi1VxaeVhj4hbvR/gstCbjbP5sLKqyFUiXCQ2mGEfWj9Qq70HTkIFCQ1Z3xolxPVR9vso5NHzDzfV255pqgLDFAdrL88j4z0cyvchE16fG1bwmtYGAqtCs0Pg4OtW1TnEk2eUufb0XtKaJXUGi5KZk3Y6JcIvjnCm9D0jTDNZ8MKhKrBGs421jc8P1oXb1/1f+6MX/RiMqU4itL0B2nJ9srEZjAAuvVfj4NKjkF4ZuCKt6zTSy9ScdTbF22MD2Ggd/9rL3JmZVXgLpA7AotMFwbIipoEcKFw== 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=8J3Z51tt91nROm/qGQh6Y5Ld7cjzveYM0Ru5f9vIizU=; b=PA9A90cG8ZW8UIBe6liNaqReKLvKvx80q1i3WZpWCY8vsyaBY6hWw3Pbvebf07byVMD4ARFOihWWl2VEm6T3ZzYR8QRfggDS2TyxOPPZZyKjiue7yeH3DUVj32YbnEJzf4tj+x3aLjHQt2OLmruug7YUY/Ye9ThtTbqy7nfk8Ng= Authentication-Results: dabbelt.com; dkim=none (message not signed) header.d=none; dabbelt.com; dmarc=none action=none header.from=wdc.com; Received: from CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) by CO6PR04MB7778.namprd04.prod.outlook.com (2603:10b6:303:13e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21; Thu, 10 Jun 2021 05:22:50 +0000 Received: from CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8]) by CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8%9]) with mapi id 15.20.4219.021; Thu, 10 Jun 2021 05:22:50 +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: [PATCH v7 1/8] RISC-V: Enable CPU_IDLE drivers Date: Thu, 10 Jun 2021 10:52:14 +0530 Message-Id: <20210610052221.39958-2-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210610052221.39958-1-anup.patel@wdc.com> References: <20210610052221.39958-1-anup.patel@wdc.com> X-Originating-IP: [122.171.172.180] X-ClientProxiedBy: MA1PR01CA0182.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:d::8) To CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.171.172.180) by MA1PR01CA0182.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:d::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21 via Frontend Transport; Thu, 10 Jun 2021 05:22:45 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 80f77d6e-27d8-4157-f8ca-08d92bcfca29 X-MS-TrafficTypeDiagnostic: CO6PR04MB7778: 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: gHcSjn6xEMBT+WGvqcw8zfMsjAz1DDD35yh/c+9QgT5opDrIfIleb8fn8qEZrXKtCWmUHcaHyYO3b7XZjRwLVgByzurMZHfLd3ebj7BDvlYAIQEvRc5a06WqT6AR9Zte5cfPUvH8VE0b1uqhgF7mERz2hO+uTXtzugBtYIXuhAy7dghZthFh7IUOCUyOR0b2KWTfcUbH10LbouY5rrPKdxeNKgi3I4+J0e6N2YKaLjwqK3jjJBkso7uxuBoV2tnAvfice6GYaoc1qGFNrdu8x7m0+8WpsEAmSQmPT146PBIPlbieqcsxK8V5HJfDEoOHxGLGgAARNjQsKov6Ka5zJNMygo2aPg5AsmMM5Nbso1G97duhOFc6RrF8JxQNh7XyIOk0b4XS/5A5aNb7JFZvBLKhr+z6TPck7BRFEak1D2yz+3Vmh3IXz891sZXCJ8x4BNZ6tJRWA9wf6YAKLVakIKKG3sMAnpjRbD+nth3pwgGV/zAL+EqVeyGhQb4ks2lAngpQxNpDGgBNnz6EAWdnB1aOyD/J7xN+LlR/pxtxrBEOQhJJJuIGFSccmZZYUkz1/FRsz+LCCJbyivSIi/EI04yXGN4thfYNS2r/HiGEuvrCxVUJlgNrZimrB6zSMbjmZ1UfjALRvTPzDWuXpz0XF6AElDmSngKavCj5JwudHvQ= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO6PR04MB7812.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(396003)(346002)(39860400002)(136003)(376002)(8936002)(110136005)(54906003)(44832011)(55016002)(5660300002)(7696005)(8676002)(316002)(83380400001)(8886007)(956004)(66946007)(66476007)(4326008)(1076003)(478600001)(38350700002)(2616005)(36756003)(66556008)(26005)(16526019)(2906002)(7416002)(6666004)(38100700002)(186003)(86362001)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3ZUgAb2UWUuZ8hNXnw3FS1E6+DRCL94F0z7C2qLm4q1rsJGw1Q28VsvCosP9zQbBXKvIOTRQse9SbGCcTxkFcAIgCVKF9qTtFIsQdiDJVlR8vnF2y3ArhcCsdTncQgHrbR8PqsDcF0eg9/U2l5AYg4l1quhgYWjesDBQDXTpEeXnsRYQByvhFiL0p8jLO/xMGtsSnOCPbl1v9BDSfAxgccTAt9AZz0ErMFBd2EEFbqqP2LzdQ20FvaUNQctNPkdDWq9THKpue9N9E6n7Sa16xZJ89aY/kX6OFsJPnHpACmSjwL9Y5tg/6AvNbrMPwU6jDhqm8eYr71cdeGn3H7qssBImvbIjCldw1RUb7uDTdqW/Ma9t90hjSCdeQ36F69BE3Te0vhOt5uO2NTM+27ncNdOoggLMVKJS4oV65sBlmtI5RuujJ+NaJJ1bOArhipDRctvcSJ8RGi9mvmO/PuRWC9fw0jLvnAT9lnKsGX/J80JOpXyzgMFCI9DGB76ZnbEEv23bRnYGB67ruGNt8cZCf5xmcRxUv97FYcuKoFQdvj3DUjww8pn6JmHZ1xjDPNFhRM4dwzuZXQs0DveR65lwRfHZyDbYzw3vM9q9JfIZ38+QwUi0xDNzM+EjgM1XS9moHNOWPGOQJTFp8cAoGKQvTNvpdEMoJtPXzXDkO4yEcW6UN6NET84H/hEcT7YcZAZzZ2w+SgXoo9xJdBPQ7qTV5wDsNjEondCjmFbGDdgQZ//tJ7ovmzHU1lSuX1Q+i7n/+U/r7i/i2tYUlhRHLXmUHdQ8uBiHKyJlaR3G9/xk7SqZ6dbLgGAY7KwwtqZt7ZJM1UxOyyA3/846jtKDtmoXQYjmIcSmyPaY7p+W1djYmjDOUEFjAjyLb3m6NEPqxUzPYoxz/YDvQP0XPazp4VILDtb40vCxwepHtu+1FCa7A0sXfVpnjWg5cQfXB+X8TniIA2+d6AguljIVNx4q/WPlyjjDppHRSNLHCLKEGLIrHr0WfkRhOfSK7uqmRs5f1QAnN7TaHcv866CRupLw6P5+xm12ZFNClKFtoPhd7Js8idxtDdcdP88aaelwIMsal7SBDOpJbH+BBt+ELxHnb1PiYrDEI/XIyC7ijWb5USts6eLausx5XeCxnqQzdNa2x/wszDq6FXGTnDyp7icJh6gV+DySnjqRIqEcbx4k0/055+5DNYZ0Lc3ecu0uaDDtP9tKqvhpTYlNMl5essLHRg9N+9Arzcnyb+0DnlWiLK8MVsNvcR6SLLQzydT6r8hG0m0tOD7NYomIM15Uyq4bi3cxBry2pj8KsW2mdmYEHKhfTx4tjc/GQ5d4xCY8Y2Av7Kij X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 80f77d6e-27d8-4157-f8ca-08d92bcfca29 X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jun 2021 05:22:50.3481 (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: vSfnpjbVE10tIydU+KFQninB3ScYQ4NH4br6nJuj+eFjMaiYReNvTSE8vQD6kNmWjbX2vCf9OmBPA6FV36X1WA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7778 Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 | 12 +++++------- arch/riscv/configs/rv32_defconfig | 5 ++--- arch/riscv/include/asm/cpuidle.h | 24 ++++++++++++++++++++++++ arch/riscv/kernel/process.c | 3 ++- 5 files changed, 40 insertions(+), 11 deletions(-) create mode 100644 arch/riscv/include/asm/cpuidle.h diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 31750d3d415a..e3646db8fd5e 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -43,6 +43,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 @@ -556,4 +557,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 1f2be234b11c..57a24d40d43f 100644 --- a/arch/riscv/configs/defconfig +++ b/arch/riscv/configs/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_MICROCHIP_POLARFIRE=y CONFIG_SOC_SIFIVE=y CONFIG_SOC_VIRT=y -CONFIG_SOC_MICROCHIP_POLARFIRE=y CONFIG_SMP=y CONFIG_HOTPLUG_CPU=y +CONFIG_CPU_IDLE=y CONFIG_JUMP_LABEL=y CONFIG_MODULES=y CONFIG_MODULE_UNLOAD=y @@ -66,10 +68,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 @@ -83,10 +84,10 @@ CONFIG_USB_OHCI_HCD=y CONFIG_USB_OHCI_HCD_PLATFORM=y CONFIG_USB_STORAGE=y CONFIG_USB_UAS=y +CONFIG_MMC=y CONFIG_MMC_SDHCI=y CONFIG_MMC_SDHCI_PLTFM=y CONFIG_MMC_SDHCI_CADENCE=y -CONFIG_MMC=y CONFIG_MMC_SPI=y CONFIG_RTC_CLASS=y CONFIG_VIRTIO_PCI=y @@ -135,6 +136,3 @@ CONFIG_RCU_EQS_DEBUG=y 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..97d899df2445 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 @@ -130,5 +131,3 @@ CONFIG_RCU_EQS_DEBUG=y 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 f9cd57c9c67d..461520222589 100644 --- a/arch/riscv/kernel/process.c +++ b/arch/riscv/kernel/process.c @@ -23,6 +23,7 @@ #include #include #include +#include register unsigned long gp_in_global __asm__("gp"); @@ -37,7 +38,7 @@ extern asmlinkage void ret_from_kernel_thread(void); void arch_cpu_idle(void) { - wait_for_interrupt(); + cpu_do_idle(); raw_local_irq_enable(); } From patchwork Thu Jun 10 05:22:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 458171 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.8 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 7F50DC48BCD for ; Thu, 10 Jun 2021 05:23:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 68FC3613E1 for ; Thu, 10 Jun 2021 05:23:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230155AbhFJFY5 (ORCPT ); Thu, 10 Jun 2021 01:24:57 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:11467 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230134AbhFJFYy (ORCPT ); Thu, 10 Jun 2021 01:24:54 -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=1623302580; x=1654838580; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=qMoC26aE1t/imsmMoQjUxEhGnzi1b1hiqgTM5NyeOBU=; b=SZkuER4ge+Op7uKqUUwqoMptymwwvQVJTbbqx99kA0/sVyuK5bjC1MWb /VLThB5fxmqTrXxHhaDxej75N9FFmjGfieB6A9d+TBuZ3ma1UvU05b+tM 7ikLPHAmcyF8hA4xZzuBQNNxYXSGTkMPMzKSfimyNhg58kYkEq4fXXIlk qE3XmJFjdY4j829qfK+n/ylP83CIw+xj56aXZJkndMsY7yhYri1FKcksH uU9BAc92DCwASOUPoWTsk91pzGckjgfAcdwF/Ian3JPeh4xANBpqIkFiA G4T1KTiK8EfD7bAw6u9ia+AHGzCkqULby1FUtvXcSlQtZuaDxoiAN7jEk w==; IronPort-SDR: bmnYwauylbrZ3D4f8cu+z4W97mZF2ZHzqYtZOTFThh7V3YM1Ri6xRzeB2AwMcPSADmYIv4I0jS VzzlpqBifvO0V5g8/Fw85FBIfR4l0RVQHOSX3jeYNuq/cYjs/5IvHBCPlj1qjIrEQVcmRLXZPO z5R5RENilmc+GMXPaaJa8g2YD+iTJu5PbKjpeo/VIZ/To1nGAdu4bDwdiiQFVgDgIGFygRj3RQ 9xp0hMpG6AMZQewFxq+gpeeF82+RsvOTvh33xH1oYcX3ck9D3gYyl4MGDtLmUZuK6pzyMPhfKA 4/s= X-IronPort-AV: E=Sophos;i="5.83,262,1616428800"; d="scan'208";a="275211785" Received: from mail-dm6nam11lp2170.outbound.protection.outlook.com (HELO NAM11-DM6-obe.outbound.protection.outlook.com) ([104.47.57.170]) by ob1.hgst.iphmx.com with ESMTP; 10 Jun 2021 13:22:57 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WhJzuCH2OGNqMNl7Sy9MuZV6GvT4Plq0D2zH81x9lpg0hjENWF0HDQ4j4IENXZVUHOwomkEN21RYtJ6xtuNXCuKGoaHKlQk6YnH3J8g0yngFse91z1SdXEJEhAn/7ZXKlpXyRVy+2n13s8GGSJn2tWdTAlTnsW0CmotL3w3k52GROMK1zWJWJdx3ZSJObpDbkxjjJQ/FX0s69TRt9uxshEb1IuEHad9l0FF9iILXsSN2aUPcs6ZTuelBYwG0h++ATELmKdtzvQBxb+vwha/BSzyL/Nax93Ya6dnxtRPaLE9P4S0qHX0fScFg6nK6+bxoN5Nmxv2QcpJZVJUvpOoCEA== 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=GdFS0rAEtKE6yd9Zx3nNwSnuIUcrKnIom98JvQmaI1w=; b=mnAeKrlow5uLDQOlGYSbrfjfj0/oNGaBPJ9gPku2CoFu42p4AaLkM7p1GuUXKspuLKQxNRY+yl0TXH2Ucy91se2qLxyMARZfehueRLiqyI/1L8sf74iGD29oG2JV9rOEixdflohhgm4Ue079bURoPYYopKHHyySRKECDiiIhCY/9IznYswUFxelxjUOv4grQZBkcDFxAtCcuZ5ObW4vIFvHyDnVxGAz3iY++v9QcV7U28DGYHlhuVIEny2nfSKpJpeJ5DJSKOORxD1eRta4fm7GuQPQBnyGBcy4YRm8ScXK3trOH7Vt6bPCmqbm3bTWcU75S1nh3LGeUl+7gMlZiSA== 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=GdFS0rAEtKE6yd9Zx3nNwSnuIUcrKnIom98JvQmaI1w=; b=OWB5hOZ26ELm5Gb6wreQe9AS7GH44pOcHk5Xa7uteWu7FaMxkZypbwxoluR32T7Q7DijbrkN5CbNAt4XEH8DwAAgyxROtF8JJ08CxXPVmov+y6f9ckKduLWOklhUsxZCYO3m4neAaLuRGXUuQ/Pabvd25Ie3mmT4OQxgv0GmD7o= Authentication-Results: dabbelt.com; dkim=none (message not signed) header.d=none; dabbelt.com; dmarc=none action=none header.from=wdc.com; Received: from CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) by CO6PR04MB7778.namprd04.prod.outlook.com (2603:10b6:303:13e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21; Thu, 10 Jun 2021 05:22:55 +0000 Received: from CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8]) by CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8%9]) with mapi id 15.20.4219.021; Thu, 10 Jun 2021 05:22:55 +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: [PATCH v7 2/8] RISC-V: Rename relocate() and make it global Date: Thu, 10 Jun 2021 10:52:15 +0530 Message-Id: <20210610052221.39958-3-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210610052221.39958-1-anup.patel@wdc.com> References: <20210610052221.39958-1-anup.patel@wdc.com> X-Originating-IP: [122.171.172.180] X-ClientProxiedBy: MA1PR01CA0182.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:d::8) To CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.171.172.180) by MA1PR01CA0182.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:d::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21 via Frontend Transport; Thu, 10 Jun 2021 05:22:50 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 58128431-17d7-42f2-2e4a-08d92bcfcd62 X-MS-TrafficTypeDiagnostic: CO6PR04MB7778: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:3276; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iUnrDM3bRn56qKzFfEpcWy82D8iGW93h1KcLs25blpqOVLkIIDtfmWO+QOwLeOsR0I5YQRaScARyLsixT7M8LMnwIfzqxHkTGh+dCeINv1wJJumEfDk0u+3ewaso6Wjl+oPvOfO5Yryw5kl0h+Hnc3Wh5vQK/tCWal5VM5rympEpMQuou1RNIbtiHaIc9inafS9pxT1r53Qg/4UuYApBc9e9BJmG4TCabCIGciuzXTsVUz51WmUnSe1RhkIY0OqMEDb/AS+Xw4y5/x8QDA5DPNWTjqGZRFpG6DGv7zD+iw0ohDY38ULqTDJhI3CL6O8Nff4kkb+Q9SOaHySReW0auwlUy87rVZH1lVxXlK5l+R4M2jH7D+249jw+8HZQncb2JsIbvRdWnmhpRNB9etwjUpOXr7AWO5K+4vWRy0s9nuXETEQ5oE7BRPOgWLTXJRtdD1zf+w70QiN0dJ1OjN10aeXfpTOUaEMi6FV+0LqDnrZ39zN5SwgE5J+AMiWMYjJOrfgcIMxV1Wz+y2cI9aOp6YbD7BQlb7qGyMEpX8swdtlh3A69d3UfkGvvNOQEpdurIUBNmNW7bWRsW7kHk5MvBIyS8jehX72uvI51fes0JkpKP7lPHhpG2gCYVXbQ/ZYkuJhsovtvxy+rrZPUEp/aeA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO6PR04MB7812.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(396003)(346002)(39860400002)(136003)(376002)(8936002)(110136005)(54906003)(44832011)(55016002)(5660300002)(7696005)(8676002)(316002)(83380400001)(8886007)(956004)(66946007)(66476007)(4326008)(1076003)(478600001)(38350700002)(2616005)(36756003)(66556008)(26005)(16526019)(2906002)(7416002)(6666004)(38100700002)(186003)(86362001)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Eh1XiF3wVl3LTYs7IQbhZBcPtYNu8sYTm+p6B3LBxwOXEiLrrY+4krbcHAixVYGHuM0DcI0cRQvgwocQDV05oLetavleDIlJmocsyd5iZJrFMRMUPJltUyJmmCRenFuZouf8GxkSybiFVZtj9hwHwV7hMtclOutWNA8t64XGIZ/NykcgFWEHDBj6w3BjB2EEBWK1k7SraHK9j9t3/ZSLiFS/JUlSJsHESGRA8yLPrGUNkRfVnkUebzangEW66Eh5lrdx5pvA5TrItN7n91sSXppV1zPKEPMkjbvRd3uCZxBPaTwgae918FVfzALSpCp17ms8kgwwR3+7bwt8oFq92pEqRyvtvtwq02xj0xC8haYtlhID45J+1G2V1p7g96YX8by7OLYUVHrVsxPJ35DkuVwWsOrqwz4Iuy2UFXwtmIEq0qcHVxmpl/XymBfOGGACaV4bz3RwaN6MSDm/R8qXB/8mX0J5u94mTNXC3tuQejSWsgZAvP6tWAThjJB5x1ls1VsiWhf9C2GMMSdZifChLzG27yveGC9ECohyE3hVIR8zj7Ez990W6fMrwHkXyRJKLxYZ66WJ68SrSUQDjG4quVv/e+MjIZVuF93YQ0lG7RemoKY5Pfxf+APGntq8pUeuqS2kybDq68mHavhtdT62F8EVOA/d9/NjHweZEZNt3JFZ6az46UaSYQQS8rghaG2Je0gqlYWRty6yjuibAHj6/FdKnWzaGzngq4kvkuq55QWfgkyw4XsKJ3INqm/CB5Ftkfl89nne14FxzImEBRBArgU2//9tNvkT2lnlvacIfkb9xMKI+5QiJ+OasptiEBExoJRqvEllT3DgD44IBcfHPC8/OzTSVrKq+59WzDXhVr1t89v7JULP8gKfl9BGEbw9IN7cHMp5iKqNU1wh5ltbxiJcm4+Z2xDHyTSr7+q8DR96GBtFA9l8xZstaVrfzZlJmH1rkQh/pbDgog/nNhRTz0QwcMKS2/5E4XfZZGM8gHNht+f8Pes3Vbf+ydqy48fLqNE3USemgeINAWdKQ4j+peU9eagKRO+rLtyxAGfbn9ImPt+79kMP1BbdXiwGmBN08ncvQS8dnkvRY4oium4fPBX8DRVSjpbDR7OohjtBQ2RioPMtDgNnBmt8i2FA/h4fjTEstnML8Pr5S/RQWslHXfFJN1aLRZBpvN9IB8RdWIT/Q4kiRJxR2Eg8OC1V8V+XRpI8WPGRxyQKAZVyo4DZ71X7Fh9cycYwIrWwYraC00V7n90wJhe9GDIJcY3NlPBAuh6FHPUH44nuDr3UUpbs1IG0fa8uXAwiHVNDPLQUKvSNg2/Tvobc53gIFcfdObST X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 58128431-17d7-42f2-2e4a-08d92bcfcd62 X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jun 2021 05:22:55.7586 (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: 3mjEBt1mQbQIz+k1lXLdFGntSmqCt8Fz0y1ihB+bSjQqkRpdyRIHX0YfumBUvbDPIWjyKxZUo2f8MyAuxon0rw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7778 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The low-level relocate() function enables mmu and relocates execution to link-time addresses. We rename relocate() function to relocate_enable_mmu() function which is more informative. Also, the relocate_enable_mmu() function will be used in the resume path when a CPU wakes-up from a non-retentive suspend so we make it global symbol. Signed-off-by: Anup Patel --- arch/riscv/kernel/head.S | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S index 89cc58ab52b4..a44c0bc9c2f3 100644 --- a/arch/riscv/kernel/head.S +++ b/arch/riscv/kernel/head.S @@ -79,7 +79,8 @@ pe_head_start: .align 2 #ifdef CONFIG_MMU -relocate: + .global relocate_enable_mmu +relocate_enable_mmu: /* Relocate return address */ la a1, kernel_virt_addr XIP_FIXUP_OFFSET a1 @@ -174,7 +175,7 @@ secondary_start_common: /* Enable virtual memory and relocate to virtual address */ la a0, swapper_pg_dir XIP_FIXUP_OFFSET a0 - call relocate + call relocate_enable_mmu #endif call setup_trap_vector tail smp_callin @@ -311,7 +312,7 @@ clear_bss_done: #ifdef CONFIG_MMU la a0, early_pg_dir XIP_FIXUP_OFFSET a0 - call relocate + call relocate_enable_mmu #endif /* CONFIG_MMU */ call setup_trap_vector From patchwork Thu Jun 10 05:22:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 458846 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.8 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 A420FC48BE6 for ; Thu, 10 Jun 2021 05:23:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 880C9613E1 for ; Thu, 10 Jun 2021 05:23:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230164AbhFJFZB (ORCPT ); Thu, 10 Jun 2021 01:25:01 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:11467 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230169AbhFJFY7 (ORCPT ); Thu, 10 Jun 2021 01:24:59 -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=1623302586; x=1654838586; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=WRiii23Z6QzfuX16+FZ4tI7GR0aXkmDaWpjIGuDJwLM=; b=LPDLTgEXAOtjz5CO3xoD3Y4cc1TIQ++Us+zHxtNDQt2z7fBl/B/0HO0C am1IMeBsSjaC8ml+0XaKayZe3+opIz/Edxpv5XT6sjqiyDfwryHNNpRgz my0+0FGad1g+UBTL2OU4z2CzTpkj2L0F2gTgXBnEzKXL2z64qyO8AbDvL DEJC0d3Eft4pboOpy+rDutSiB9tRfavQTp4Htolk6Yd6UuBMHrIebDRQE jPa8IU4h/ha0MOUxWMPBATjx3L4Sq15x40P0x01nsEwJgj3OcQ5GW9LCR mKDcprYKJxVi6k40Mdn14MUBtc1jlso1DQERsTksv/8UogfskCpqIpP3T Q==; IronPort-SDR: 6TR9A/Nx2IOP9vg2dU3Z+Q7o3mCbqv/CCziQJ1qLOW6GdpRqxdEFvx3/wCQV4fg97/+u+Kx89G yRD/EeiquQ4oFwJV0eFkkGwctSkFuhyMiP3HshShcSczStLQ/Z9wrYYZekvniQyyEmm4bE6aGa hdpCt6NIY73RizHOOGvLPXlSGPu2lWGGvJn79G31aLx0IRsnNRwvz6+qFp+xJLBl0S3JyQPufY BFLcdoSkd1giYjZv2ugXzaUglR2HZ9hqlwe0yPoNR9U+ms5NxOtUCxRMGwYGClsXu3dC9VdmsD oV4= X-IronPort-AV: E=Sophos;i="5.83,262,1616428800"; d="scan'208";a="275211794" Received: from mail-dm6nam11lp2172.outbound.protection.outlook.com (HELO NAM11-DM6-obe.outbound.protection.outlook.com) ([104.47.57.172]) by ob1.hgst.iphmx.com with ESMTP; 10 Jun 2021 13:23:03 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RQImWRfLWX/aV4TxhfwUb2O5NJU9fLGE6c+YqtGLpndGVWeOV4Tj2kAOcieQzqiDhODpEAuf0fv82/xvU3uYHJEfgb+gKlNinW+jIRlQze5nhneUW9Fk51OeAsZoDMIlbG9vdFajsOiQZSd8BTKRKI/7eK/RZUE8bahUqwUKZgcsPasQ4phpSTWJZ1eykFashxj5tVRAtFQaTTz48NwAPwqZZD5fxwAQkCzFsS1LM+6aZcNE3+w5NRWvgVFqVtCXoFyvatZyQhiWKAgJjdhBbYRxg/PbmoIIkrjCUaRpCtBMmw0bHPK3dKJ8Jwl8XWXvYyXBURz///Fp0f1Bm4/JkA== 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=lUYD4VxNiVhQdYFN5kCIwzDGeWn5RGAjIKEex8OoBz4=; b=U0Kk8ezfqW6GCsHnNFUm5fGiroprZx+RdG05A6wLRajsc5p1fmb/lx2yCEn1kMVCSQsqfqnBUOCjkf5ueE/Ohnu495wexysmjREWNSgabQyxt2Qb4+VR6fPd6Tq0acqirT1ZDshLfK5sh3esPtmOOuBvlQGPf5rVvUq9zRGghDLdE5APumyM6GE0ToztL0gbc9Y3C2CvlgPz99+Fj7j83A9773wvad29BcPrdafXjLnWbnHMzOUfLR+VsL3xLS2cINhBpgDiohqmNirDiwji/w6CcLggBTxO0KF0dzvb15xUB2cXx965Ji1b7eorY3Cvn8IG9OsCONo08onc2BEZiw== 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=lUYD4VxNiVhQdYFN5kCIwzDGeWn5RGAjIKEex8OoBz4=; b=bd6Zo6SIbrO93zD8CIUT8LzGg70R0v3J60JSFXxAbcMy6tN/h1FXIC8tq5g7QkOdNoA/gHYr8HU2Dc7YJN/XuY9CBAwaHdXJUcf8yCVPtvuc18ZfBTQWr4j5XLyxz5n0sY6F28TeQlxThPEUJmgunivFZ+CJs6fZh7MmCCmkee4= Authentication-Results: dabbelt.com; dkim=none (message not signed) header.d=none; dabbelt.com; dmarc=none action=none header.from=wdc.com; Received: from CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) by CO6PR04MB7778.namprd04.prod.outlook.com (2603:10b6:303:13e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21; Thu, 10 Jun 2021 05:23:01 +0000 Received: from CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8]) by CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8%9]) with mapi id 15.20.4219.021; Thu, 10 Jun 2021 05:23:01 +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: [PATCH v7 3/8] RISC-V: Add arch functions for non-retentive suspend entry/exit Date: Thu, 10 Jun 2021 10:52:16 +0530 Message-Id: <20210610052221.39958-4-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210610052221.39958-1-anup.patel@wdc.com> References: <20210610052221.39958-1-anup.patel@wdc.com> X-Originating-IP: [122.171.172.180] X-ClientProxiedBy: MA1PR01CA0182.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:d::8) To CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.171.172.180) by MA1PR01CA0182.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:d::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21 via Frontend Transport; Thu, 10 Jun 2021 05:22:56 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e4112b13-39f3-4da1-86f9-08d92bcfd095 X-MS-TrafficTypeDiagnostic: CO6PR04MB7778: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BJzHhTGn4wzDo8u9zk9OrMZn0uINmvjv5ZSse+S+qnmVMeXpX7IHtEOZzc4Dg6kW3W7w+v9dsnPW0SS/EY+yrK0jXNCyRMNzh6UZd24G4hLQg3C48AW3GSLyTKKqTbtPLUdzpdaE1GhoLA+9g2DMD3d/bWgfKPPNPSG+Zx2aYmFhN4Awz6CMo15a3sp/pk2kTeAp1PNxrwyQXPDakgffzxUBdNQi6/Fim7AEvow+tkF7zy8GPLrWyPZFEy6G5Vj8T0L/6L+cbWusrZJkUNww10MOpk8z/QFdz4vRAVQHMe7UzxrQwZiLJ9tqiqF1HEGUogG5Ze+B5Gd3JOBQf/+dzM4Riswmj0zfPkez+uDe/E1Vr9kt3DsjJ6C03ZJXNZMFOU8Hmq2f64VtGK8LlxB4IGB6YgnYMDgg/1yT88XEvRNFso04x3TFmYLBekPRrXAFVVEyaZmK47cjx8moCcZ5eSkBoxSsym9tO3LROBDeDgxrKugwm+t7dfcEoAh8w8s44bTBTfmhQP0buS30yuYZALUnf4LAqJsS6EJeLVlXeZZK9Z1av/zCKtGADLFnfzDYbjxmrI/zMkeL87pC4Y9z14dCWHHmuwvAu5YKNeXJXP83wBmvQPl2Ks1+EIFg9R8nSrJd9t3K8TYp4UDB96H4rg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO6PR04MB7812.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(396003)(346002)(39860400002)(136003)(376002)(8936002)(110136005)(54906003)(44832011)(55016002)(5660300002)(7696005)(8676002)(316002)(83380400001)(8886007)(956004)(66946007)(66476007)(30864003)(4326008)(1076003)(478600001)(38350700002)(2616005)(15650500001)(36756003)(66556008)(26005)(16526019)(2906002)(7416002)(6666004)(38100700002)(186003)(86362001)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DWfyOGrQl2nrdt+d5WaFtKXoZYRlhVli/OonWnEUOeYESpHPbLdvoRV/kZ293yVz/qV5PXPcv1uexQEU8jIbg5kqZc6nlPVgs6qaA6rVyGA73iJ0SA4zv9c4ouF0SZBCBFmZ27HsyeSKUsjSCQszcDx+YGqr4p7ALvA8U0TPgYGzkkRfspMCZ1lBm+pjcZwCSpqe/D/SWDFeixHbgYNcUAvVfB4ByBWUMKGZxZeRf9nku+AIsJ3u4JRk0yFUrpog0ich6X6TugPgCT8SkT+HAs/CZPgqOBjBEEHxv5MfphOn7JXNiZWc20bEzrAbqJbwdsN30CPinvJXEXlU5zNp9i7ZASGuHROrnYoDid/4uF31uEiUBGioOis7am6FSLcJOiguUOxs7oyVb6kwG0/10bJFnXwNQ6G3gwnmN2+kSc0h6vmHCb+W/76koDzpvW40y4W/Fjj0n0NRpZNdd44rlObRl/GWuCwCnFg40BdqFQm5buKRetn4El5RQNUfh1P98zdeRYdrFZNtSUQU+mJUKVArEzjXtD5XX0cVwUJpDyL0cCqgJLaDDR2OhWEQgmgvBm3BS0VAIu6hdRDWuvX1suIu5RNTJulhUkfMYOQ0Ucm149Jw1aMp2VLsJMEViTC/2jmcyFGpdX2fKxIBOeMwYL8LxQzxypA2YZ0VwKkWusdK8SXz5wWCHgFi61DogTaFFhce4l+SHrHzDfFUc2DECcdJI14NSdru4pajuxuiExwU53JWD1wao4RRY/sWUweBksiU2KnIo9SRFeDMkEVuLpbDnkTntPCAiiaYGmTm4c6Ms6Phu8JCm5Wnd6Tee1Rmtc3WZBMEHdLqYzp1bi3RoKqBqeW69i8few7BpRc2y2srWASm51B0uzd7dOBjqVbh8ilGjAKX3iOxiafUlRaj9Q4XXmqtHCtXuDjMe0WatWLG8sLIo3zak9CVkLFKvgQsFI90eO361XJdeDmEJGwYaAXPj90/H79/5VEMMw6F/af/ejMpX/42tusz+ohZjytwhKxwrR09Ok+v8ldXsicyJFAQey2sfVnjkWeQVlJOtVKrK8r1yMc8uVMBHgCNHk7JO35ipN/yqgEzXvZ+dT7FG8u1ddzShfiw9tPmWo270QdZn6VIIal9Svt1KgZB8TeN64ABLNOvwuN13Kbgqbv0RBobaOPr2VIyAHNOotd6MkssrLTGpw82Qx5Y4+vE1ch4Nd9+tDPBk8NaXtOto5y6FoRjHKRVFXA143nVJ7qhH2ylQlKCi+YPgT0TiWSU7hfz4OfJkKYWaq7VkLhxk3peh/a03mEuj60gcZ/tKsicJYjgy6IfnBfwFWPQzoYVKbQ2 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: e4112b13-39f3-4da1-86f9-08d92bcfd095 X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jun 2021 05:23:01.0745 (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: RQbq3qn+YXZ/7QbXYwBmMSUlNCJW4Hag7KG4NVtayNP3tVRlqqUxnC0/SKMaDXWoKIbfKnN7jBjvW+HoEHfqfg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7778 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The hart registers and CSRs are not preserved in non-retentative suspend state so we provide arch specific helper functions which will save/restore hart context upon entry/exit to non-retentive suspend state. These helper functions can be used by cpuidle drivers for non-retentive suspend entry/exit. Signed-off-by: Anup Patel --- arch/riscv/include/asm/asm.h | 17 +++++ arch/riscv/include/asm/suspend.h | 35 +++++++++ arch/riscv/kernel/Makefile | 2 + arch/riscv/kernel/asm-offsets.c | 3 + arch/riscv/kernel/head.S | 11 --- arch/riscv/kernel/suspend.c | 86 +++++++++++++++++++++ arch/riscv/kernel/suspend_entry.S | 123 ++++++++++++++++++++++++++++++ 7 files changed, 266 insertions(+), 11 deletions(-) create mode 100644 arch/riscv/include/asm/suspend.h create mode 100644 arch/riscv/kernel/suspend.c create mode 100644 arch/riscv/kernel/suspend_entry.S diff --git a/arch/riscv/include/asm/asm.h b/arch/riscv/include/asm/asm.h index 618d7c5af1a2..6c93f2806eb7 100644 --- a/arch/riscv/include/asm/asm.h +++ b/arch/riscv/include/asm/asm.h @@ -67,4 +67,21 @@ #error "Unexpected __SIZEOF_SHORT__" #endif +#ifdef __ASSEMBLY__ + +/* Common assembly source macros */ + +#ifdef CONFIG_XIP_KERNEL +.macro XIP_FIXUP_OFFSET reg + REG_L t0, _xip_fixup + add \reg, \reg, t0 +.endm +_xip_fixup: .dword CONFIG_PHYS_RAM_BASE - CONFIG_XIP_PHYS_ADDR - XIP_OFFSET +#else +.macro XIP_FIXUP_OFFSET reg +.endm +#endif /* CONFIG_XIP_KERNEL */ + +#endif + #endif /* _ASM_RISCV_ASM_H */ diff --git a/arch/riscv/include/asm/suspend.h b/arch/riscv/include/asm/suspend.h new file mode 100644 index 000000000000..63e9f434fb89 --- /dev/null +++ b/arch/riscv/include/asm/suspend.h @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2021 Western Digital Corporation or its affiliates. + */ + +#ifndef _ASM_RISCV_SUSPEND_H +#define _ASM_RISCV_SUSPEND_H + +#include + +struct suspend_context { + /* Saved and restored by low-level functions */ + struct pt_regs regs; + /* Saved and restored by high-level functions */ + unsigned long scratch; + unsigned long tvec; + unsigned long ie; +#ifdef CONFIG_MMU + unsigned long satp; +#endif +}; + +/* Low-level CPU suspend entry function */ +int __cpu_suspend_enter(struct suspend_context *context); + +/* High-level CPU suspend which will save context and call finish() */ +int cpu_suspend(unsigned long arg, + int (*finish)(unsigned long arg, + unsigned long entry, + unsigned long context)); + +/* Low-level CPU resume entry function */ +int __cpu_resume_enter(unsigned long hartid, unsigned long context); + +#endif diff --git a/arch/riscv/kernel/Makefile b/arch/riscv/kernel/Makefile index d3081e4d9600..5a2fc649ad11 100644 --- a/arch/riscv/kernel/Makefile +++ b/arch/riscv/kernel/Makefile @@ -47,6 +47,8 @@ obj-$(CONFIG_SMP) += cpu_ops_spinwait.o obj-$(CONFIG_MODULES) += module.o obj-$(CONFIG_MODULE_SECTIONS) += module-sections.o +obj-$(CONFIG_CPU_PM) += suspend_entry.o suspend.o + obj-$(CONFIG_FUNCTION_TRACER) += mcount.o ftrace.o obj-$(CONFIG_DYNAMIC_FTRACE) += mcount-dyn.o diff --git a/arch/riscv/kernel/asm-offsets.c b/arch/riscv/kernel/asm-offsets.c index 9ef33346853c..2628dfd0f77d 100644 --- a/arch/riscv/kernel/asm-offsets.c +++ b/arch/riscv/kernel/asm-offsets.c @@ -10,6 +10,7 @@ #include #include #include +#include void asm_offsets(void); @@ -111,6 +112,8 @@ void asm_offsets(void) OFFSET(PT_BADADDR, pt_regs, badaddr); OFFSET(PT_CAUSE, pt_regs, cause); + OFFSET(SUSPEND_CONTEXT_REGS, suspend_context, regs); + /* * THREAD_{F,X}* might be larger than a S-type offset can handle, but * these are used in performance-sensitive assembly so we can't resort diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S index a44c0bc9c2f3..03bf2edfe9b2 100644 --- a/arch/riscv/kernel/head.S +++ b/arch/riscv/kernel/head.S @@ -15,17 +15,6 @@ #include #include "efi-header.S" -#ifdef CONFIG_XIP_KERNEL -.macro XIP_FIXUP_OFFSET reg - REG_L t0, _xip_fixup - add \reg, \reg, t0 -.endm -_xip_fixup: .dword CONFIG_PHYS_RAM_BASE - CONFIG_XIP_PHYS_ADDR - XIP_OFFSET -#else -.macro XIP_FIXUP_OFFSET reg -.endm -#endif /* CONFIG_XIP_KERNEL */ - __HEAD ENTRY(_start) /* diff --git a/arch/riscv/kernel/suspend.c b/arch/riscv/kernel/suspend.c new file mode 100644 index 000000000000..49dddec30e99 --- /dev/null +++ b/arch/riscv/kernel/suspend.c @@ -0,0 +1,86 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2021 Western Digital Corporation or its affiliates. + */ + +#include +#include +#include + +static void suspend_save_csrs(struct suspend_context *context) +{ + context->scratch = csr_read(CSR_SCRATCH); + context->tvec = csr_read(CSR_TVEC); + context->ie = csr_read(CSR_IE); + + /* + * No need to save/restore IP CSR (i.e. MIP or SIP) because: + * + * 1. For no-MMU (M-mode) kernel, the bits in MIP are set by + * external devices (such as interrupt controller, timer, etc). + * 2. For MMU (S-mode) kernel, the bits in SIP are set by + * M-mode firmware and external devices (such as interrupt + * controller, etc). + */ + +#ifdef CONFIG_MMU + context->satp = csr_read(CSR_SATP); +#endif +} + +static void suspend_restore_csrs(struct suspend_context *context) +{ + csr_write(CSR_SCRATCH, context->scratch); + csr_write(CSR_TVEC, context->tvec); + csr_write(CSR_IE, context->ie); + +#ifdef CONFIG_MMU + csr_write(CSR_SATP, context->satp); +#endif +} + +int cpu_suspend(unsigned long arg, + int (*finish)(unsigned long arg, + unsigned long entry, + unsigned long context)) +{ + int rc = 0; + struct suspend_context context = { 0 }; + + /* Finisher should be non-NULL */ + if (!finish) + return -EINVAL; + + /* Save additional CSRs*/ + suspend_save_csrs(&context); + + /* + * Function graph tracer state gets incosistent when the kernel + * calls functions that never return (aka finishers) hence disable + * graph tracing during their execution. + */ + pause_graph_tracing(); + + /* Save context on stack */ + if (__cpu_suspend_enter(&context)) { + /* Call the finisher */ + rc = finish(arg, __pa_symbol(__cpu_resume_enter), + (ulong)&context); + + /* + * Should never reach here, unless the suspend finisher + * fails. Successful cpu_suspend() should return from + * __cpu_resume_entry() + */ + if (!rc) + rc = -EOPNOTSUPP; + } + + /* Enable function graph tracer */ + unpause_graph_tracing(); + + /* Restore additional CSRs */ + suspend_restore_csrs(&context); + + return rc; +} diff --git a/arch/riscv/kernel/suspend_entry.S b/arch/riscv/kernel/suspend_entry.S new file mode 100644 index 000000000000..b8d20decfc28 --- /dev/null +++ b/arch/riscv/kernel/suspend_entry.S @@ -0,0 +1,123 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2021 Western Digital Corporation or its affiliates. + */ + +#include +#include +#include +#include + + .text + .altmacro + .option norelax + +ENTRY(__cpu_suspend_enter) + /* Save registers (except A0 and T0-T6) */ + REG_S ra, (SUSPEND_CONTEXT_REGS + PT_RA)(a0) + REG_S sp, (SUSPEND_CONTEXT_REGS + PT_SP)(a0) + REG_S gp, (SUSPEND_CONTEXT_REGS + PT_GP)(a0) + REG_S tp, (SUSPEND_CONTEXT_REGS + PT_TP)(a0) + REG_S s0, (SUSPEND_CONTEXT_REGS + PT_S0)(a0) + REG_S s1, (SUSPEND_CONTEXT_REGS + PT_S1)(a0) + REG_S a1, (SUSPEND_CONTEXT_REGS + PT_A1)(a0) + REG_S a2, (SUSPEND_CONTEXT_REGS + PT_A2)(a0) + REG_S a3, (SUSPEND_CONTEXT_REGS + PT_A3)(a0) + REG_S a4, (SUSPEND_CONTEXT_REGS + PT_A4)(a0) + REG_S a5, (SUSPEND_CONTEXT_REGS + PT_A5)(a0) + REG_S a6, (SUSPEND_CONTEXT_REGS + PT_A6)(a0) + REG_S a7, (SUSPEND_CONTEXT_REGS + PT_A7)(a0) + REG_S s2, (SUSPEND_CONTEXT_REGS + PT_S2)(a0) + REG_S s3, (SUSPEND_CONTEXT_REGS + PT_S3)(a0) + REG_S s4, (SUSPEND_CONTEXT_REGS + PT_S4)(a0) + REG_S s5, (SUSPEND_CONTEXT_REGS + PT_S5)(a0) + REG_S s6, (SUSPEND_CONTEXT_REGS + PT_S6)(a0) + REG_S s7, (SUSPEND_CONTEXT_REGS + PT_S7)(a0) + REG_S s8, (SUSPEND_CONTEXT_REGS + PT_S8)(a0) + REG_S s9, (SUSPEND_CONTEXT_REGS + PT_S9)(a0) + REG_S s10, (SUSPEND_CONTEXT_REGS + PT_S10)(a0) + REG_S s11, (SUSPEND_CONTEXT_REGS + PT_S11)(a0) + + /* Save CSRs */ + csrr t0, CSR_EPC + REG_S t0, (SUSPEND_CONTEXT_REGS + PT_EPC)(a0) + csrr t0, CSR_STATUS + REG_S t0, (SUSPEND_CONTEXT_REGS + PT_STATUS)(a0) + csrr t0, CSR_TVAL + REG_S t0, (SUSPEND_CONTEXT_REGS + PT_BADADDR)(a0) + csrr t0, CSR_CAUSE + REG_S t0, (SUSPEND_CONTEXT_REGS + PT_CAUSE)(a0) + + /* Return non-zero value */ + li a0, 1 + + /* Return to C code */ + ret +END(__cpu_suspend_enter) + +ENTRY(__cpu_resume_enter) + /* Load the global pointer */ + .option push + .option norelax + la gp, __global_pointer$ + .option pop + +#ifdef CONFIG_MMU + /* Save A0 and A1 */ + add t0, a0, zero + add t1, a1, zero + + /* Enable MMU */ + la a0, swapper_pg_dir + XIP_FIXUP_OFFSET a0 + call relocate_enable_mmu + + /* Restore A0 and A1 */ + add a0, t0, zero + add a1, t1, zero +#endif + + /* Make A0 point to suspend context */ + add a0, a1, zero + + /* Restore CSRs */ + REG_L t0, (SUSPEND_CONTEXT_REGS + PT_EPC)(a0) + csrw CSR_EPC, t0 + REG_L t0, (SUSPEND_CONTEXT_REGS + PT_STATUS)(a0) + csrw CSR_STATUS, t0 + REG_L t0, (SUSPEND_CONTEXT_REGS + PT_BADADDR)(a0) + csrw CSR_TVAL, t0 + REG_L t0, (SUSPEND_CONTEXT_REGS + PT_CAUSE)(a0) + csrw CSR_CAUSE, t0 + + /* Restore registers (except A0 and T0-T6) */ + REG_L ra, (SUSPEND_CONTEXT_REGS + PT_RA)(a0) + REG_L sp, (SUSPEND_CONTEXT_REGS + PT_SP)(a0) + REG_L gp, (SUSPEND_CONTEXT_REGS + PT_GP)(a0) + REG_L tp, (SUSPEND_CONTEXT_REGS + PT_TP)(a0) + REG_L s0, (SUSPEND_CONTEXT_REGS + PT_S0)(a0) + REG_L s1, (SUSPEND_CONTEXT_REGS + PT_S1)(a0) + REG_L a1, (SUSPEND_CONTEXT_REGS + PT_A1)(a0) + REG_L a2, (SUSPEND_CONTEXT_REGS + PT_A2)(a0) + REG_L a3, (SUSPEND_CONTEXT_REGS + PT_A3)(a0) + REG_L a4, (SUSPEND_CONTEXT_REGS + PT_A4)(a0) + REG_L a5, (SUSPEND_CONTEXT_REGS + PT_A5)(a0) + REG_L a6, (SUSPEND_CONTEXT_REGS + PT_A6)(a0) + REG_L a7, (SUSPEND_CONTEXT_REGS + PT_A7)(a0) + REG_L s2, (SUSPEND_CONTEXT_REGS + PT_S2)(a0) + REG_L s3, (SUSPEND_CONTEXT_REGS + PT_S3)(a0) + REG_L s4, (SUSPEND_CONTEXT_REGS + PT_S4)(a0) + REG_L s5, (SUSPEND_CONTEXT_REGS + PT_S5)(a0) + REG_L s6, (SUSPEND_CONTEXT_REGS + PT_S6)(a0) + REG_L s7, (SUSPEND_CONTEXT_REGS + PT_S7)(a0) + REG_L s8, (SUSPEND_CONTEXT_REGS + PT_S8)(a0) + REG_L s9, (SUSPEND_CONTEXT_REGS + PT_S9)(a0) + REG_L s10, (SUSPEND_CONTEXT_REGS + PT_S10)(a0) + REG_L s11, (SUSPEND_CONTEXT_REGS + PT_S11)(a0) + + /* Return zero value */ + add a0, zero, zero + + /* Return to C code */ + ret +END(__cpu_resume_enter) From patchwork Thu Jun 10 05:22:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 458170 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.8 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 E65E2C48BD1 for ; Thu, 10 Jun 2021 05:23:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CCBD4613E1 for ; Thu, 10 Jun 2021 05:23:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230236AbhFJFZG (ORCPT ); Thu, 10 Jun 2021 01:25:06 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:11490 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230215AbhFJFZE (ORCPT ); Thu, 10 Jun 2021 01:25:04 -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=1623302590; x=1654838590; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=UeD+FgLO9aIjFzdKrHDcrkqDgbjr4ljOtP7t6+n6Irg=; b=OZYj5Uf2tsum9BlzZipE12WgIeWF4HF2q7xph2Z7f444Zt4ObGCb0auP HpGbDRd0F65BZcr5/QHZCu3iHmM6rzxaqVQ7d7uMFmbTNR/ojeQZi5Rei AjCI5rWBDpFuTRHVKnC+lsKe2RfGYwHaaFkZXvT+0m4yH5NBiWQatBH/I K5iDkzoGtnJM3q2PVOnbFj0ZXp+I2g8QAWyBWO7lKU3gMLH+qFWgnxt9t cGAD3kVQOW1oypvsGvvO6QuZnnbGeQUoptwsCXJDjRjzpZey/JNnHLooy nPYbAi1AK2SYr+pqjwuNY9kZyU45b8RFCyS2cCMdHuErjUTmdMVraMSqb A==; IronPort-SDR: X2efCUNs9rpXmv4F5h3aBnhkuqxkpzHKSCn3H8RnSWzYl2yXYWN1/KiISZmQ+e4gcb8AytCKo2 JCCuo/RvPGmSRcoKQrGWiRIzxPVCw+ogHbbkQe+khPa3QLziUxnN4nUIFR2DIOu+q578wuhB/g 7E6XOmgFxEauRH8kKX2TYefxnERwzHYbKh3yv9mgISGylv4l/tlUNfajYfDvN++a4eQ1bNmgJH XsbrlmZD0JMGYz6yfHbQaWnE2mNL0JNgBwSBQGXNwLZnPSAE6ULS8qBbDQBrcs9eQAZPy89JnH 8N0= X-IronPort-AV: E=Sophos;i="5.83,262,1616428800"; d="scan'208";a="275211803" Received: from mail-dm6nam11lp2176.outbound.protection.outlook.com (HELO NAM11-DM6-obe.outbound.protection.outlook.com) ([104.47.57.176]) by ob1.hgst.iphmx.com with ESMTP; 10 Jun 2021 13:23:07 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QmVE5xFC4cttD2mGJMEf+ptv5ju+xGvrK+UZ4CmtakFYG84zKYvaLwCyxdWpLBsGnNyGPZ8nFyMxUagIL6B6nfcULjLISLlJG8npe2g9NIISgWjUTy7awbigKe3ecjcQjPhDqpmEpLBvlV/0lXms4TERsaw8hUdGVXSqko/3/wx77q2+GSfXq0mWgQVZG8s6joo0+pH+7RtyLBbcVZa6fMiV4YZ6yy93rXC1KNuX+xOogl9LQ3mhzy7T8cmZyZg9WgqDsX2FNNihI+xSPK8u1BLLgN2pJK+tANe63Eoi2PACyNioqqF/PG7ec+P/AepUzwEilzAWsH8ADMQDfCRhxA== 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=4QXaNsRGTyDgz2Sn7I2zPdXMtXIGlsEhVecpbL/TqiQ=; b=mP59kk1sJNmZbrUusFFDoCZGNBkTWkXTbXELL/Np3acMzeDrnM9chxNijrnTaIfwbq6t1xd1rf01cf5nxPc49c0DzyYhpgZziJlqWgPqIZmIEDgwXqPH3IarhmEeDpR1a6SqfuTp0OZ+sxwVs5ELSzLtm2jgi9Y+vc8ZXZj0ubNx9rgQrvWx/kE01Dj7sZTJ4q/Bc35DXoZHe1PTOgqbHmMo7wPrcpwRvcOuMwPiLcUjrmCLQiIh1GwbayC2SNvtgx6yDmgsY45HGa0RY4kpT74lBdxefrE6Tn5RyKYjQ1O6tw2UlViq1kApl7KIUjJtkn52+SqRQBBUnhuTauznLg== 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=4QXaNsRGTyDgz2Sn7I2zPdXMtXIGlsEhVecpbL/TqiQ=; b=ScbhqNSZRfICQFC5bza20Z0rVZPy+82xLCgEDjL9b6rHO83Tjd3FsxFkuTw5PsyvzESeA+Ls+RAAt0B06yvIyz/zRG+jwUKnaRnt4KIGnQmT0kL8Yv/LYFxlHBJ8uGH7R1gxiS+yBSbR+1VGbtMEdpQrrlipLOhT0xAGSsCprMY= Authentication-Results: dabbelt.com; dkim=none (message not signed) header.d=none; dabbelt.com; dmarc=none action=none header.from=wdc.com; Received: from CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) by CO6PR04MB7778.namprd04.prod.outlook.com (2603:10b6:303:13e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21; Thu, 10 Jun 2021 05:23:06 +0000 Received: from CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8]) by CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8%9]) with mapi id 15.20.4219.021; Thu, 10 Jun 2021 05:23:06 +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: [PATCH v7 4/8] RISC-V: Add SBI HSM suspend related defines Date: Thu, 10 Jun 2021 10:52:17 +0530 Message-Id: <20210610052221.39958-5-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210610052221.39958-1-anup.patel@wdc.com> References: <20210610052221.39958-1-anup.patel@wdc.com> X-Originating-IP: [122.171.172.180] X-ClientProxiedBy: MA1PR01CA0182.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:d::8) To CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.171.172.180) by MA1PR01CA0182.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:d::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21 via Frontend Transport; Thu, 10 Jun 2021 05:23:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1d3ca70b-97e1-4624-ab28-08d92bcfd3c0 X-MS-TrafficTypeDiagnostic: CO6PR04MB7778: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:220; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZCVkzW+WFIB+YOp8jLCBJTooMcceB1PPAQpcgX1MI11EgU3t/WrpBOI11aMuSQCvublrzdqhIyg+lk+oNrUoj0Bwj3/8A1K3NW7bGwUQ33aNd+6Q7HkHWdpzvpb7R4N2F5hfib6sJnzHTnu3nPiVh1wo6wgUfcm/fBfm9LHVG26SBv5RLftVAwnuTRR4MzPwW2pxzT3LX9XYx4E3C6PNaNl4t7LwGEuXLLnPZ+OroHR+MtxHUXJz5PPiLbZsnEfE1ZieV8QtGXLxBrf5GZsI6NFaVkHFG5paQCNV23ZVrqt3zX8xl0l4EVLyTg7mK4OA3WXNkOdKSmEiWSqLye+e3fwH2CAu4K01HZ4ziFVP7dK0Mm7BYblG3zAYBSKCDHxqGTMlReMfc+d493VnwukZXWAP2jdxzl/jzUNEGq8yXxGOP7UPQXcynA4vReXCgOGJDwwruDE7InOR1sV2yb1pPgOylTYNwa4nuDv7OeKz55BA31iMUjMfRmgANb7EbDfv0YOXn7hGxVy6YZInqujt3mDheND+gzjqYTKxJ9bycJosF03XN4g7sisjmQf+T2KO0UnlWPGENqprGWkMPp80R2setcdtA3CVselrOFhH8L7vZ5ponkjwLw30QId6U4Ovu2Egz1VBL9MdxEm0jw1dgw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO6PR04MB7812.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(396003)(346002)(39860400002)(136003)(376002)(8936002)(110136005)(54906003)(44832011)(55016002)(5660300002)(7696005)(8676002)(316002)(83380400001)(8886007)(956004)(66946007)(66476007)(4326008)(1076003)(478600001)(38350700002)(2616005)(15650500001)(36756003)(66556008)(26005)(16526019)(2906002)(7416002)(6666004)(38100700002)(186003)(86362001)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: h7HN5H+N8GowDvNktpUSXf0An/9BC9Xs3AMtQ93AYeLH03UYvOiCMbSFk7RmZhqzn7xjen1+on5WRYt/kh9m6B5MxU5K5pIG3LA2QFdFuaDqvVsgXW3fYlTD0oL9twbQ373n5go5zHlN+eWiYk4XUP8B8KesE9ow5oDv9mfH+ad4qGo4fHjTPZJLehI/ZmDIiLij3BaxsG3o/oCyC3+ev+Ca7g1kNHE1GvU5rbRP8HhPw8LZyz2Kd7JSsYlY1OU/VC1ezJ+wzU06AaKjZspOtWTwiYPrFyG2XeDtqo0ZJvT9LIdcc9hw09GKJGZPL1g8cRBX1yxvdVEouPhbMW6yrOSjEEitGgAB6+gDRZOtUB/xfEiyeWTpRXFnSvEhI27AoAJUT2FHjPmmHLxKZl5wKx6urp2PmmgbI3lxVlZ/oRRWA8DscC92DYjWtjM3ylfubYsu5mCqU3tTYgJ6YMuPgBsxHziq6qhCp+isQX//Br5k6SGp7zupi5mvJHku2ZHpBbXRjXPPcM2GSqN5afxCvbs/ZNf3h4A+5Ck65hOuNdlwDJbRoJ6N7jFWe9vlbp3OBetqfExKWxm7h8f8MSghJNoOxaE4ezx253c5v2+DBNSuJbwzezk48W2kOvls/35TB/opYcQb+FDYktRhtU7JcCLy3I+qZpD6NO69R5H6eGAqUbJlgvsgqtuiwkKBLOypBbWMby+ffyTfMXLSVWOj0UXrHAQjDFdiYKWrTCVmywz5ADojGAv5lgC2q/n17hgCCXBRW/eCTNyqMYqCJVZdtEcxmCBP1zcz2SPzKHAYdv6dv1yvnia1kXa3rbiMt53vwreoQddfbG5QDv1yzCV1Yx0L4dw9lFdu/2fATNR7h4P86WvMFmX/3fYHFNuPc1NxwNe7W1jZIf5Zv2T+YEbZ9d05zSvDLU+yB9p95CsqeSEka5UIelU/Y7F9ExcRBoSXMSvvKsuYeuDVMl0ZMb7rSJBpNbHj5O0UgxMkmldXL4XUd0qvC3B6JKX0Y2acTEYxSK4ScJw9smpjDmvBnqrHi1iIBI5IKbvM7LM8WtrwHb7iA/0HsNOVFuqKjHL/ZhWP2Hdkv+AEne5lSFh2tKorOTAIabqTb/tbkT8Y7vZmv1t271KHiKJRYaGq9RT2uvVafqFDknKTqXN+Y97jWErFJqVHvApcJGWswFoiNj8fa8G6EKpyGdirHTI/F9Nq4Fp4Hyc+qpOb6ZrLqepAMCWnN9VzLHAKj2srhOnimGvlB4OZxPPGZlcQQIskoqjCnuDdZrkIGy9FxwU5sxLzsLxTCfv+0PIG54QyspXTmYw/HziB7pKPrrY25LEBXqWS+MAm X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1d3ca70b-97e1-4624-ab28-08d92bcfd3c0 X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jun 2021 05:23:06.2192 (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: chqJOEhVI9fjCOBDPDbQ0k26vg6eQTvXZTc8RoqR7r9UopvNorUH3LO/nPYFFVrJiRx+eW/Xf7hf4lJOqsDT+g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7778 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org We add defines related to SBI HSM suspend call and also update HSM states naming as-per latest SBI specification. Signed-off-by: Anup Patel --- arch/riscv/include/asm/sbi.h | 27 ++++++++++++++++++++++----- arch/riscv/kernel/cpu_ops_sbi.c | 2 +- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h index 289621da4a2a..ab9782f8da52 100644 --- a/arch/riscv/include/asm/sbi.h +++ b/arch/riscv/include/asm/sbi.h @@ -62,15 +62,32 @@ enum sbi_ext_hsm_fid { SBI_EXT_HSM_HART_START = 0, SBI_EXT_HSM_HART_STOP, SBI_EXT_HSM_HART_STATUS, + SBI_EXT_HSM_HART_SUSPEND, }; -enum sbi_hsm_hart_status { - SBI_HSM_HART_STATUS_STARTED = 0, - SBI_HSM_HART_STATUS_STOPPED, - SBI_HSM_HART_STATUS_START_PENDING, - SBI_HSM_HART_STATUS_STOP_PENDING, +enum sbi_hsm_hart_state { + SBI_HSM_STATE_STARTED = 0, + SBI_HSM_STATE_STOPPED, + SBI_HSM_STATE_START_PENDING, + SBI_HSM_STATE_STOP_PENDING, + SBI_HSM_STATE_SUSPENDED, + SBI_HSM_STATE_SUSPEND_PENDING, + SBI_HSM_STATE_RESUME_PENDING, }; +#define SBI_HSM_SUSP_BASE_MASK 0x7fffffff +#define SBI_HSM_SUSP_NON_RET_BIT 0x80000000 +#define SBI_HSM_SUSP_PLAT_BASE 0x10000000 + +#define SBI_HSM_SUSPEND_RET_DEFAULT 0x00000000 +#define SBI_HSM_SUSPEND_RET_PLATFORM SBI_HSM_SUSP_PLAT_BASE +#define SBI_HSM_SUSPEND_RET_LAST SBI_HSM_SUSP_BASE_MASK +#define SBI_HSM_SUSPEND_NON_RET_DEFAULT SBI_HSM_SUSP_NON_RET_BIT +#define SBI_HSM_SUSPEND_NON_RET_PLATFORM (SBI_HSM_SUSP_NON_RET_BIT | \ + SBI_HSM_SUSP_PLAT_BASE) +#define SBI_HSM_SUSPEND_NON_RET_LAST (SBI_HSM_SUSP_NON_RET_BIT | \ + SBI_HSM_SUSP_BASE_MASK) + enum sbi_ext_srst_fid { SBI_EXT_SRST_RESET = 0, }; diff --git a/arch/riscv/kernel/cpu_ops_sbi.c b/arch/riscv/kernel/cpu_ops_sbi.c index 685fae72b7f5..5fd90f03a3e9 100644 --- a/arch/riscv/kernel/cpu_ops_sbi.c +++ b/arch/riscv/kernel/cpu_ops_sbi.c @@ -97,7 +97,7 @@ static int sbi_cpu_is_stopped(unsigned int cpuid) rc = sbi_hsm_hart_get_status(hartid); - if (rc == SBI_HSM_HART_STATUS_STOPPED) + if (rc == SBI_HSM_STATE_STOPPED) return 0; return rc; } From patchwork Thu Jun 10 05:22:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 458845 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.8 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=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 69768C47094 for ; Thu, 10 Jun 2021 05:23:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4F884613E1 for ; Thu, 10 Jun 2021 05:23:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230250AbhFJFZK (ORCPT ); Thu, 10 Jun 2021 01:25:10 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:11511 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230215AbhFJFZK (ORCPT ); Thu, 10 Jun 2021 01:25:10 -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=1623302598; x=1654838598; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=nzy9pCl8zwYLJGc+tqg047HMq9wQYVcYuA1f89D7X7Y=; b=CwSRhD/FvEiDaQwGXtjmTlakxYtW3zwzt1Wonop7uHNRBrVQTQ50Ey8/ Bu+Z7WulT/WfHd8vm22VfOYW0zhjditzePnaJGAGwPMAQPKMvrLXqgYHV kDPi67fDJk1/41huGITBlUcVDQ8ONaUnYMXOG8kFXKkxG2c5W30IzyZx8 X8jA3IBRPnYDhDoo6u+7F1AT7MbOKRZRp7ef3962TFe4XdOAkiJZho3YK tPlAXLPrBAoft/9XKZdzta+deyKS6CMP3Pq0oTBlTwtNdCO8JBbyjdU6h MOrI3cC5K65QXR+ooz/33CW2+qptboaimr3qOLe8CWt82z5ZuL/As49mg w==; IronPort-SDR: Etm4rhUoG4y/SoyUmBgezK5YD8LXFa1Z8F6tkVts3nom0bdHHhLPSPp72mAHeKG7REz7aUcQHx yVCwS7uOMpMBYDzKhjTnmxmgBZ6BHon80X1cCBXNOZ3LQp5iYymz7SzcBEbwARUaOBB+eEfVWp sjj+QBgSmpJxZ+snWjnJSLV1oK3urWdfshU6QXanlefFbQo09illjE8/Jxhyqb1oruoon6e4lK FzT65/8Y1Z06BeZ6C1zbpC4737JX//wIhZLj8502CZTEk3AYmNOE+LBgTuacnmGwlfsiTrvtAW qEE= X-IronPort-AV: E=Sophos;i="5.83,262,1616428800"; d="scan'208";a="275211808" Received: from mail-dm6nam11lp2169.outbound.protection.outlook.com (HELO NAM11-DM6-obe.outbound.protection.outlook.com) ([104.47.57.169]) by ob1.hgst.iphmx.com with ESMTP; 10 Jun 2021 13:23:15 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hB1kQNFBoCJg68JSPoRAhQG7ZOqYDVlIQy8qYn/zLPYNbmJaY2r233RYPQnQZONFqcW6Fx63Xg2r4mVZ45l1ZhRLcqBe09l1Cmrx+2BJF/I3bD7pMZyuBxO15KJ8OiV6CEJ48j/iEY7nPptsFVs4ZbIx3Y7b8l1uYgO1scAFiBHP5DDV0qiG5aBxnmrjO/bqg23g4waM6d8Ddng+h4udmn7KkGY97oonf9Nb4ou1MGITxy75EmT8zou2KeHnsa31ANiAp0MCTZ+r2UUWkMq55AJ2PZIHqurK/EVvXzp09/fRp3u5mHexvJeoaLNOhCCOtCwPglj7bKZvKXdmgzonxg== 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=Y/jB78KPasPpB+gWqSbtnjXrkCttN6l+ligdt5QCVT0=; b=FOTHk1GAJe/Hjb6QCEUmMNxJccRfsi08Au8bEznpYeFsLIbu1CmyN1Red/YZiZjVfphU3x+GGxYHv13SpsjzvuWjmwu9xjOUM1rexyPGUfo4bTkxJxM8fkdPRVUSORHuecNTFpd6SXDACz0m6kmNCCDtQaY0hqcBlBKz+09BvLIneqACbyiqAtr4Uc8fCXn3W/hJ53SIVoy/OfxLVU7F8JNkffxq0rGvcsUaudvllQJCx474DORH/L98V9LyL3+oq7DL/al9YubyIqQ7pD+c6J4yrrp6J+7kuee/G5IJrCRH4ftjyXXYQIHrxDW8+4MSYUhKQDnZM31g787bLcQPfA== 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=Y/jB78KPasPpB+gWqSbtnjXrkCttN6l+ligdt5QCVT0=; b=O81nb+Pr7HPmNH1VqNCX+Ly6GVCEjcVnx/WbNIuJ7hESKBklmNuTfLbO2TajGWujJ/MXot1BcvUu6jLY96ZOlT+/GUJhDD9sMMlp38w0dr68I9ezyg/DVWWLuMwoBb46SeFfT5v326GVCYO34nmuYXRViBIOQItV5GCg28EjT3s= Authentication-Results: dabbelt.com; dkim=none (message not signed) header.d=none; dabbelt.com; dmarc=none action=none header.from=wdc.com; Received: from CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) by CO6PR04MB7778.namprd04.prod.outlook.com (2603:10b6:303:13e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21; Thu, 10 Jun 2021 05:23:11 +0000 Received: from CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8]) by CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8%9]) with mapi id 15.20.4219.021; Thu, 10 Jun 2021 05:23:11 +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: [PATCH v7 5/8] cpuidle: Factor-out power domain related code from PSCI domain driver Date: Thu, 10 Jun 2021 10:52:18 +0530 Message-Id: <20210610052221.39958-6-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210610052221.39958-1-anup.patel@wdc.com> References: <20210610052221.39958-1-anup.patel@wdc.com> X-Originating-IP: [122.171.172.180] X-ClientProxiedBy: MA1PR01CA0182.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:d::8) To CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.171.172.180) by MA1PR01CA0182.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:d::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21 via Frontend Transport; Thu, 10 Jun 2021 05:23:06 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9cb738dc-de20-47e9-bad7-08d92bcfd6d9 X-MS-TrafficTypeDiagnostic: CO6PR04MB7778: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OhTg8DLvomm4tWdtrQ173uzFGHFn8bSYqCWThWm3M0qJA4l3KbSOJ5uGxJPrD4Xo3zLL7c0SHuvEbyQbEAF83Xih1lO4AA2jhqP9o4+3JRBE0emUbhm3putUy7+Xf95LOf00Hg4sg73DB7TnWhMl8RLjetTVtlwU/vNLOZdAAX9ZZgGUfp3NJ598T2toYLfaZKpdFBxe+Xcit/PD41AhOCQXASg299SR3HwPAKE72+Y+uz1craIPyb/dP9J2i7yKG2OQtug9UR+L7HsUzCtBZgFUOGy42mbTABTmAtHAizLbaoMAR7In689RrKYeiSPCWEAdcVucryGkVx9Uam8wX/8GDf9c086yHuZp1+IvOaA/krspXcIc5VTkLh/pwBOJya9hI52YKpKf6YawUiDhvfWrJZfrmFbDqlYpx3WqFbkBuqb49Gl2hi+4p7MZs2eSObX6dl0nErGfjHLz5Reb7rJxBaW8VbDux/75MxLu9Qs8IMDWRV02GbpT5HWQeSlyDkVkIGqIRg5dFGFc220FoxuIJ+u1HzmCwDug5E4IvFCOBRigHZVZy6nmpuhpJSdTb9d5XIbUgwTfwJ2glYU/vJLWHuYluqysjlBwuqEHD76f2ltuN9i7nfezv87wxEy9k5txf9vaoeJ6jmdgdW39XA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO6PR04MB7812.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(396003)(346002)(39860400002)(136003)(376002)(8936002)(110136005)(54906003)(44832011)(55016002)(5660300002)(7696005)(8676002)(316002)(83380400001)(8886007)(956004)(66946007)(66476007)(30864003)(4326008)(1076003)(478600001)(38350700002)(2616005)(36756003)(66556008)(26005)(16526019)(2906002)(7416002)(6666004)(38100700002)(186003)(86362001)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: htucyUT7Ksu2avULFP/n/TV7opC5+l1ewFOcu+JJj6uAuBjQajyOzr1mACZ2MbgFGRXU4rDIbsKJU8W4n8C3svAojUf0MFps4s1tI0FLUGazkbl+GRKrEUnHNer2TKO++2BO3iZbTTgJ9+OMkqKweAly7XboUtw5r+fzInhTNH2koZM/lbo412rDjpU6UoDBzth+9GZXFBTArTI3UB6dFiXWekej5SXgOe5jory5uqf0yJYzh0Ih7lRBl5T2vv9YWI0NyNsdcEYe/cm800Kck1qdHbEydir1uypux1xP15ptzG+rWCr1xZIygkvrOtlkVEae3OVPqWPtA/lFKSlAjy5WfPdVIYWPTc6j0xUIHFfY0oc2lgUkDLhy/lxFr5UPdUappAqeiBMbshJilf7EcG7Cg0JY2lARAEawHV5rjUkbat2cS8/Onx3Ud/hpkNmp6lGevEvVDUL5aVeDKAZr+YUwGrPTRMbwoM8UzZ7xBBSaZDu5at7iHprETFp0xBpugf65vfv1Gdi7BjLkDonBBYpjMuZr1i3rAIWkiT7g6jA3u+Ff2+90444H9raGVAZs3srogt8rus8L4ooDLF2/gwR3tqaZK8YI8PDITKd8uAzk3Uqque4YdaznAsFTpw16lmBZ2iT9fXGyBV+OxxJxw/7pDdNA2NlcFOjFhXIQPK09F1O7ooEqvx8myu+SorAAwFcVbo9ztHuLpejhX1GFlHuNSNx/9e4KwIAhOuMoEGFlR4JcOxu+AF7vKtQKY3hg080Zl+n75QEJ0UclZF3gXXmFsemQs+wtPSqNTsZ60NkIWz4IrgXWLeb7G1r9iM2EJgA2KPoYSJU+/vgShRMiS54vJII3px098jebhqdNdfZsD2VfSwqPoDIjYHLjmp+NdhIPIDuDoMjUBTlCirT8zxmmrN1kM55BRf6UlAWxq/FKe7K0jKgAbQaUaLajVJyqu2NUCbS0II7O3awbqbNgAf1m5FRwovbMLndXRP788LfJM7BdPPcOWViI4XLCalMxfCU7QJtwtp58kQ8+Ni0iAimfVYowDHHwECX6ZAYdCcLirGoUs2vYT/TKDMG00gtElLdOBX7uFWO2ASdRqkq+6v/i8VAG2+xyXImI7y3Gr9X7eeyCjok1psRgmcRFe7ZyaJovJOnM7HpeX1ty5o+SVMEOQY6NrgnYHRDsKBlrlD3zfaK0LRoA3p4LOZl1hj5KQX3tiEIlV++s/Z1eblTRjqZ2+MUGMo9QpCAtdfWRApDoLwmmhUg/Mjzfe90IqcQA0klHEMsZAUjJmcpdseCtQIeXEWuTRTw1TOeqS7XoMhIHrJryB57vWQpGA3icK3Ep X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9cb738dc-de20-47e9-bad7-08d92bcfd6d9 X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jun 2021 05:23:11.4156 (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: ZTtb+5sFWIlxIwf+xp4UFdmHXZjaXCuvsix76QeXnfVoOU/ffyGdQbyAVyyZnO3yJHpwkqNW7m1qTFDfHhK5Qw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7778 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The generic power domain related code in PSCI domain driver is largely independent of PSCI and can be shared with RISC-V SBI domain driver hence we factor-out this code into dt_idle_genpd.c and dt_idle_genpd.h. Signed-off-by: Anup Patel Reviewed-by: Ulf Hansson --- MAINTAINERS | 7 + drivers/cpuidle/Kconfig | 4 + drivers/cpuidle/Kconfig.arm | 1 + drivers/cpuidle/Makefile | 1 + drivers/cpuidle/cpuidle-psci-domain.c | 138 +------------------- drivers/cpuidle/cpuidle-psci.h | 15 ++- drivers/cpuidle/dt_idle_genpd.c | 177 ++++++++++++++++++++++++++ drivers/cpuidle/dt_idle_genpd.h | 50 ++++++++ 8 files changed, 258 insertions(+), 135 deletions(-) create mode 100644 drivers/cpuidle/dt_idle_genpd.c create mode 100644 drivers/cpuidle/dt_idle_genpd.h diff --git a/MAINTAINERS b/MAINTAINERS index b706dd20ff2b..5108b5058502 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4789,6 +4789,13 @@ S: Supported F: drivers/cpuidle/cpuidle-psci.h F: drivers/cpuidle/cpuidle-psci-domain.c +CPUIDLE DRIVER - DT IDLE PM DOMAIN +M: Ulf Hansson +L: linux-pm@vger.kernel.org +S: Supported +F: drivers/cpuidle/dt_idle_genpd.c +F: drivers/cpuidle/dt_idle_genpd.h + CRAMFS FILESYSTEM M: Nicolas Pitre S: Maintained diff --git a/drivers/cpuidle/Kconfig b/drivers/cpuidle/Kconfig index c0aeedd66f02..f1afe7ab6b54 100644 --- a/drivers/cpuidle/Kconfig +++ b/drivers/cpuidle/Kconfig @@ -47,6 +47,10 @@ config CPU_IDLE_GOV_HALTPOLL config DT_IDLE_STATES bool +config DT_IDLE_GENPD + depends on PM_GENERIC_DOMAINS_OF + bool + menu "ARM CPU Idle Drivers" depends on ARM || ARM64 source "drivers/cpuidle/Kconfig.arm" diff --git a/drivers/cpuidle/Kconfig.arm b/drivers/cpuidle/Kconfig.arm index 334f83e56120..be12a9ca78f0 100644 --- a/drivers/cpuidle/Kconfig.arm +++ b/drivers/cpuidle/Kconfig.arm @@ -27,6 +27,7 @@ config ARM_PSCI_CPUIDLE_DOMAIN bool "PSCI CPU idle Domain" depends on ARM_PSCI_CPUIDLE depends on PM_GENERIC_DOMAINS_OF + select DT_IDLE_GENPD default y help Select this to enable the PSCI based CPUidle driver to use PM domains, diff --git a/drivers/cpuidle/Makefile b/drivers/cpuidle/Makefile index 26bbc5e74123..11a26cef279f 100644 --- a/drivers/cpuidle/Makefile +++ b/drivers/cpuidle/Makefile @@ -6,6 +6,7 @@ obj-y += cpuidle.o driver.o governor.o sysfs.o governors/ obj-$(CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED) += coupled.o obj-$(CONFIG_DT_IDLE_STATES) += dt_idle_states.o +obj-$(CONFIG_DT_IDLE_GENPD) += dt_idle_genpd.o obj-$(CONFIG_ARCH_HAS_CPU_RELAX) += poll_state.o obj-$(CONFIG_HALTPOLL_CPUIDLE) += cpuidle-haltpoll.o diff --git a/drivers/cpuidle/cpuidle-psci-domain.c b/drivers/cpuidle/cpuidle-psci-domain.c index ff2c3f8e4668..755bbdfc5b82 100644 --- a/drivers/cpuidle/cpuidle-psci-domain.c +++ b/drivers/cpuidle/cpuidle-psci-domain.c @@ -47,73 +47,14 @@ static int psci_pd_power_off(struct generic_pm_domain *pd) return 0; } -static int psci_pd_parse_state_nodes(struct genpd_power_state *states, - int state_count) -{ - int i, ret; - u32 psci_state, *psci_state_buf; - - for (i = 0; i < state_count; i++) { - ret = psci_dt_parse_state_node(to_of_node(states[i].fwnode), - &psci_state); - if (ret) - goto free_state; - - psci_state_buf = kmalloc(sizeof(u32), GFP_KERNEL); - if (!psci_state_buf) { - ret = -ENOMEM; - goto free_state; - } - *psci_state_buf = psci_state; - states[i].data = psci_state_buf; - } - - return 0; - -free_state: - i--; - for (; i >= 0; i--) - kfree(states[i].data); - return ret; -} - -static int psci_pd_parse_states(struct device_node *np, - struct genpd_power_state **states, int *state_count) -{ - int ret; - - /* Parse the domain idle states. */ - ret = of_genpd_parse_idle_states(np, states, state_count); - if (ret) - return ret; - - /* Fill out the PSCI specifics for each found state. */ - ret = psci_pd_parse_state_nodes(*states, *state_count); - if (ret) - kfree(*states); - - return ret; -} - -static void psci_pd_free_states(struct genpd_power_state *states, - unsigned int state_count) -{ - int i; - - for (i = 0; i < state_count; i++) - kfree(states[i].data); - kfree(states); -} - static int psci_pd_init(struct device_node *np, bool use_osi) { struct generic_pm_domain *pd; struct psci_pd_provider *pd_provider; struct dev_power_governor *pd_gov; - struct genpd_power_state *states = NULL; int ret = -ENOMEM, state_count = 0; - pd = kzalloc(sizeof(*pd), GFP_KERNEL); + pd = dt_idle_pd_alloc(np, psci_dt_parse_state_node); if (!pd) goto out; @@ -121,22 +62,6 @@ static int psci_pd_init(struct device_node *np, bool use_osi) if (!pd_provider) goto free_pd; - pd->name = kasprintf(GFP_KERNEL, "%pOF", np); - if (!pd->name) - goto free_pd_prov; - - /* - * Parse the domain idle states and let genpd manage the state selection - * for those being compatible with "domain-idle-state". - */ - ret = psci_pd_parse_states(np, &states, &state_count); - if (ret) - goto free_name; - - pd->free_states = psci_pd_free_states; - pd->name = kbasename(pd->name); - pd->states = states; - pd->state_count = state_count; pd->flags |= GENPD_FLAG_IRQ_SAFE | GENPD_FLAG_CPU_DOMAIN; /* Allow power off when OSI has been successfully enabled. */ @@ -149,10 +74,8 @@ static int psci_pd_init(struct device_node *np, bool use_osi) pd_gov = state_count > 0 ? &pm_domain_cpu_gov : NULL; ret = pm_genpd_init(pd, pd_gov, false); - if (ret) { - psci_pd_free_states(states, state_count); - goto free_name; - } + if (ret) + goto free_pd_prov; ret = of_genpd_add_provider_simple(np, pd); if (ret) @@ -166,12 +89,10 @@ static int psci_pd_init(struct device_node *np, bool use_osi) remove_pd: pm_genpd_remove(pd); -free_name: - kfree(pd->name); free_pd_prov: kfree(pd_provider); free_pd: - kfree(pd); + dt_idle_pd_free(pd); out: pr_err("failed to init PM domain ret=%d %pOF\n", ret, np); return ret; @@ -195,30 +116,6 @@ static void psci_pd_remove(void) } } -static int psci_pd_init_topology(struct device_node *np) -{ - struct device_node *node; - struct of_phandle_args child, parent; - int ret; - - for_each_child_of_node(np, node) { - if (of_parse_phandle_with_args(node, "power-domains", - "#power-domain-cells", 0, &parent)) - continue; - - child.np = node; - child.args_count = 0; - ret = of_genpd_add_subdomain(&parent, &child); - of_node_put(parent.np); - if (ret) { - of_node_put(node); - return ret; - } - } - - return 0; -} - static bool psci_pd_try_set_osi_mode(void) { int ret; @@ -282,7 +179,7 @@ static int psci_cpuidle_domain_probe(struct platform_device *pdev) goto no_pd; /* Link genpd masters/subdomains to model the CPU topology. */ - ret = psci_pd_init_topology(np); + ret = dt_idle_pd_init_topology(np); if (ret) goto remove_pd; @@ -314,28 +211,3 @@ static int __init psci_idle_init_domains(void) return platform_driver_register(&psci_cpuidle_domain_driver); } subsys_initcall(psci_idle_init_domains); - -struct device *psci_dt_attach_cpu(int cpu) -{ - struct device *dev; - - dev = dev_pm_domain_attach_by_name(get_cpu_device(cpu), "psci"); - if (IS_ERR_OR_NULL(dev)) - return dev; - - pm_runtime_irq_safe(dev); - if (cpu_online(cpu)) - pm_runtime_get_sync(dev); - - dev_pm_syscore_device(dev, true); - - return dev; -} - -void psci_dt_detach_cpu(struct device *dev) -{ - if (IS_ERR_OR_NULL(dev)) - return; - - dev_pm_domain_detach(dev, false); -} diff --git a/drivers/cpuidle/cpuidle-psci.h b/drivers/cpuidle/cpuidle-psci.h index d8e925e84c27..4e132640ed64 100644 --- a/drivers/cpuidle/cpuidle-psci.h +++ b/drivers/cpuidle/cpuidle-psci.h @@ -10,8 +10,19 @@ void psci_set_domain_state(u32 state); int psci_dt_parse_state_node(struct device_node *np, u32 *state); #ifdef CONFIG_ARM_PSCI_CPUIDLE_DOMAIN -struct device *psci_dt_attach_cpu(int cpu); -void psci_dt_detach_cpu(struct device *dev); + +#include "dt_idle_genpd.h" + +static inline struct device *psci_dt_attach_cpu(int cpu) +{ + return dt_idle_attach_cpu(cpu, "psci"); +} + +static inline void psci_dt_detach_cpu(struct device *dev) +{ + dt_idle_detach_cpu(dev); +} + #else static inline struct device *psci_dt_attach_cpu(int cpu) { return NULL; } static inline void psci_dt_detach_cpu(struct device *dev) { } diff --git a/drivers/cpuidle/dt_idle_genpd.c b/drivers/cpuidle/dt_idle_genpd.c new file mode 100644 index 000000000000..db385fd2507e --- /dev/null +++ b/drivers/cpuidle/dt_idle_genpd.c @@ -0,0 +1,177 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * PM domains for CPUs via genpd. + * + * Copyright (C) 2019 Linaro Ltd. + * Author: Ulf Hansson + * + * Copyright (c) 2021 Western Digital Corporation or its affiliates. + */ + +#define pr_fmt(fmt) "dt-idle-genpd: " fmt + +#include +#include +#include +#include +#include +#include +#include + +#include "dt_idle_genpd.h" + +static int pd_parse_state_nodes( + int (*parse_state)(struct device_node *, u32 *), + struct genpd_power_state *states, int state_count) +{ + int i, ret; + u32 state, *state_buf; + + for (i = 0; i < state_count; i++) { + ret = parse_state(to_of_node(states[i].fwnode), &state); + if (ret) + goto free_state; + + state_buf = kmalloc(sizeof(u32), GFP_KERNEL); + if (!state_buf) { + ret = -ENOMEM; + goto free_state; + } + *state_buf = state; + states[i].data = state_buf; + } + + return 0; + +free_state: + i--; + for (; i >= 0; i--) + kfree(states[i].data); + return ret; +} + +static int pd_parse_states(struct device_node *np, + int (*parse_state)(struct device_node *, u32 *), + struct genpd_power_state **states, + int *state_count) +{ + int ret; + + /* Parse the domain idle states. */ + ret = of_genpd_parse_idle_states(np, states, state_count); + if (ret) + return ret; + + /* Fill out the dt specifics for each found state. */ + ret = pd_parse_state_nodes(parse_state, *states, *state_count); + if (ret) + kfree(*states); + + return ret; +} + +static void pd_free_states(struct genpd_power_state *states, + unsigned int state_count) +{ + int i; + + for (i = 0; i < state_count; i++) + kfree(states[i].data); + kfree(states); +} + +void dt_idle_pd_free(struct generic_pm_domain *pd) +{ + pd_free_states(pd->states, pd->state_count); + kfree(pd->name); + kfree(pd); +} + +struct generic_pm_domain *dt_idle_pd_alloc(struct device_node *np, + int (*parse_state)(struct device_node *, u32 *)) +{ + struct generic_pm_domain *pd; + struct genpd_power_state *states = NULL; + int ret, state_count = 0; + + pd = kzalloc(sizeof(*pd), GFP_KERNEL); + if (!pd) + goto out; + + pd->name = kasprintf(GFP_KERNEL, "%pOF", np); + if (!pd->name) + goto free_pd; + + /* + * Parse the domain idle states and let genpd manage the state selection + * for those being compatible with "domain-idle-state". + */ + ret = pd_parse_states(np, parse_state, &states, &state_count); + if (ret) + goto free_name; + + pd->free_states = pd_free_states; + pd->name = kbasename(pd->name); + pd->states = states; + pd->state_count = state_count; + + pr_debug("alloc PM domain %s\n", pd->name); + return pd; + +free_name: + kfree(pd->name); +free_pd: + kfree(pd); +out: + pr_err("failed to alloc PM domain %pOF\n", np); + return NULL; +} + +int dt_idle_pd_init_topology(struct device_node *np) +{ + struct device_node *node; + struct of_phandle_args child, parent; + int ret; + + for_each_child_of_node(np, node) { + if (of_parse_phandle_with_args(node, "power-domains", + "#power-domain-cells", 0, &parent)) + continue; + + child.np = node; + child.args_count = 0; + ret = of_genpd_add_subdomain(&parent, &child); + of_node_put(parent.np); + if (ret) { + of_node_put(node); + return ret; + } + } + + return 0; +} + +struct device *dt_idle_attach_cpu(int cpu, const char *name) +{ + struct device *dev; + + dev = dev_pm_domain_attach_by_name(get_cpu_device(cpu), name); + if (IS_ERR_OR_NULL(dev)) + return dev; + + pm_runtime_irq_safe(dev); + if (cpu_online(cpu)) + pm_runtime_get_sync(dev); + + dev_pm_syscore_device(dev, true); + + return dev; +} + +void dt_idle_detach_cpu(struct device *dev) +{ + if (IS_ERR_OR_NULL(dev)) + return; + + dev_pm_domain_detach(dev, false); +} diff --git a/drivers/cpuidle/dt_idle_genpd.h b/drivers/cpuidle/dt_idle_genpd.h new file mode 100644 index 000000000000..a95483d08a02 --- /dev/null +++ b/drivers/cpuidle/dt_idle_genpd.h @@ -0,0 +1,50 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __DT_IDLE_GENPD +#define __DT_IDLE_GENPD + +struct device_node; +struct generic_pm_domain; + +#ifdef CONFIG_DT_IDLE_GENPD + +void dt_idle_pd_free(struct generic_pm_domain *pd); + +struct generic_pm_domain *dt_idle_pd_alloc(struct device_node *np, + int (*parse_state)(struct device_node *, u32 *)); + +int dt_idle_pd_init_topology(struct device_node *np); + +struct device *dt_idle_attach_cpu(int cpu, const char *name); + +void dt_idle_detach_cpu(struct device *dev); + +#else + +static inline void dt_idle_pd_free(struct generic_pm_domain *pd) +{ +} + +static inline struct generic_pm_domain *dt_idle_pd_alloc( + struct device_node *np, + int (*parse_state)(struct device_node *, u32 *)) +{ + return NULL; +} + +static inline int dt_idle_pd_init_topology(struct device_node *np) +{ + return 0; +} + +static inline struct device *dt_idle_attach_cpu(int cpu, const char *name) +{ + return NULL; +} + +static inline void dt_idle_detach_cpu(struct device *dev) +{ +} + +#endif + +#endif From patchwork Thu Jun 10 05:22:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 458169 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.9 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, UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT 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 CF2CDC48BCD for ; Thu, 10 Jun 2021 05:23:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BA384613E7 for ; Thu, 10 Jun 2021 05:23:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230215AbhFJFZR (ORCPT ); Thu, 10 Jun 2021 01:25:17 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:11527 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230255AbhFJFZP (ORCPT ); Thu, 10 Jun 2021 01:25:15 -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=1623302607; x=1654838607; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=jxNSrEryjuEr8sDJcBYsY9HCSgDST5gnNG8YkzNiWj8=; b=iiI0rMGSpX6DgVfYMEBHBySJAPkELyFifDXHvLM1Q4h+4KTdvp5ZZ3pC hEKr60KUuG6CEjQFs0Mp4SuEjVSTFw8eguuGNhC+3Zy6aWfskbd8FZTfX 8Kx4nty4wf4FlQkKf0GwNXSICAOsjDAtHrwmhy+A5Kt2TfK14E4VznSGE umnksH6VCeOdcYgQOZuGJhucOGV5lGSRenqgbd76FPHR3YaYxdtL68WZj 1IQxu+k7vPPYQkz01Zq6Nx0uVPI1cYWcK7i01DmGSgWjhHNDwPdx4B+yZ K0Td890WMmlzh1NgpLQ/sH1oz/SkhecT4T5WrKRvGWw0fJ/DkvUWIPIPE Q==; IronPort-SDR: oLqxTIGW28bg7g1TE6ODq+Y3+Kstjn8VVfWdeXBLe9XlWU7l8/6r7i839dXvYbtGGSwl0b7cLo N7l0ksfBGJpGUW4nDtauOqcP77Y3oTcrUFFbJx1VcoPoWeyrNW3Thxnh7kzaVc/VGro/GP24pD BHO7Inh/F/Nx10tL+jzCkqK5R0ZFSW+uUMwQZF+ToXSgTAn3wPhqQoz8N4LGkXkDzUGgNd6TwY 18Qg19JS4BbwdvAj9NNXG8nURWGdHYAV7HSaC82SGLdwEkYIWOgk/wY+uOImJX37Cj4A2VffrX Dsg= X-IronPort-AV: E=Sophos;i="5.83,262,1616428800"; d="scan'208";a="275211815" Received: from mail-dm6nam11lp2177.outbound.protection.outlook.com (HELO NAM11-DM6-obe.outbound.protection.outlook.com) ([104.47.57.177]) by ob1.hgst.iphmx.com with ESMTP; 10 Jun 2021 13:23:24 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WxViFRZF8j1BL+dJVxuXxvVWfMfcBgEcAwsTFmxI+rim4GGbv2daEPf4xypb6Fp2cz/vSiuptQ3xIo6BuRd9olvcmC4nHL7PuHVHQmL722dSBu8AE9bnVOd0cxDoOXFLIz7LeGUpUSmPDWsXFCq27wIOYJCg5tRpigEMGTL5xjkm6vH4qWGcqHUhs8JqgP+wWBVfKUbbcfVXMCpUN8OitSVtQ8wxJBZgQF7cQEcFuZVrMJIi/BFYUaSPdTcamZKaEdiDlJSH+RvGxjvI0w1UndgaxCfLwj4RAu/oaiZRHCzd3cwRsoiqIQeSEjgOB7zmuVGBc/0qS2RoZaacushBUQ== 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=R/ECZRh6NH9dNqWNXq4Q0uKl27Vnn8yb/s2D0AI9gGA=; b=V+osIgcJS7q5Xf0WYUZ2UAtD/mRX7fhkYpA74YZvkuylcdfDSiB8HPWG4PSYd8qiZhOT/JVvcdZ4chD7NuuGAEOmgKnNhJ8daanN9b3JPXANgZim41bQl2jSesY4xIZCdsFeodP++D1M2pGtFV70c4hH91d7xAqtvzKRkHHCo9ra62A8Q8ccWqQBudctJWQ1dhGPN0rdVeeKIujMNL+DA9u7cQNETki7a+zBoYaOo92A5x+aiCe09R9e1n5mLvWvVTWOQGpjsjiya0J7qkAx/c0vHG8OhGEMY9HByFSGwDF58HTLaoQ9AqXA7BVGjdGnvXK/ngIc7cuFIEarh253ag== 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=R/ECZRh6NH9dNqWNXq4Q0uKl27Vnn8yb/s2D0AI9gGA=; b=pNjheiobVTbnrlLO/3ij015NJOqQGfGhOdaoML7PgYoF7gh4c0ZVAfI5NXCbLdxMb9ukYHlsI97tlbBM4KgGShoUbC52hL6IEx3K9Gvee1XFrrW6YtjPDrFMkcsLJ21Vrp5s4JB1lbN8i6xEJE4cF5srCoUJsBU0lPuMfoVqL7s= Authentication-Results: dabbelt.com; dkim=none (message not signed) header.d=none; dabbelt.com; dmarc=none action=none header.from=wdc.com; Received: from CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) by CO6PR04MB7778.namprd04.prod.outlook.com (2603:10b6:303:13e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21; Thu, 10 Jun 2021 05:23:17 +0000 Received: from CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8]) by CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8%9]) with mapi id 15.20.4219.021; Thu, 10 Jun 2021 05:23: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: [PATCH v7 6/8] cpuidle: Add RISC-V SBI CPU idle driver Date: Thu, 10 Jun 2021 10:52:19 +0530 Message-Id: <20210610052221.39958-7-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210610052221.39958-1-anup.patel@wdc.com> References: <20210610052221.39958-1-anup.patel@wdc.com> X-Originating-IP: [122.171.172.180] X-ClientProxiedBy: MA1PR01CA0182.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:d::8) To CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.171.172.180) by MA1PR01CA0182.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:d::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21 via Frontend Transport; Thu, 10 Jun 2021 05:23:11 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7f34f3e8-05dc-4ab6-4bc0-08d92bcfd9ef X-MS-TrafficTypeDiagnostic: CO6PR04MB7778: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 78ZgtwC3NjCUAwhlnfpUi9tquXMQQ2/B8eymXT3Ms5S46tlYqi3nNsXVDxis6orNdkO+8S982p18yVkcRbfuvKLgpRqrTPpVpuJfokkbAHYUN8oGvbNxtTSZxWf/sDmuiWYsfJSZeiRXGeu25tYqFQW6vBiXDya7IsP5FoNNv+a5BZczDkYEXKRxo1pg3E2by2Wfuf+0zh1Dzu5AEfgqSjBeQS1li8UFTKG61gX7o2wUIZmvW71gol2FYxkohksh1aaysfHnER52L0VcevKN4Yx2r17Yyl74boM1pMMgV18HhCY1VUaZ2aUbPO9BX+JnCcRm/GcdHBklGvXhvEzm5BXoAsrZU1o8/UmowVV34QcqihLPNI9Xc0yKTHIz+PSOkFXtJxPeAH7v20c7eCzb1OEUk9Egerb3+ehtA9Eq8VjyqDYVtwXVm/F8rrFrGpUaCQKAk/vZNTmCUTnlzlJMZFnvGVUADt34DCacUUQb1tUU8PqsWbIgdN2pyIpT6BKPoY3hxl04Bs8E2YimTYhbbUYi1VXacPAG9jnqOWSGq4W9XHC1NeYRYFrd+LF6wBfgZuk/PBROGZHBBpeatCxEE83cA5xTyV2FTVr5Fhs//jo1bE905d+4cHDdluMRMQrSbhSHGemhtqTic/LmasZdvg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO6PR04MB7812.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(396003)(346002)(39860400002)(136003)(376002)(8936002)(110136005)(54906003)(44832011)(55016002)(5660300002)(7696005)(8676002)(316002)(83380400001)(8886007)(956004)(66946007)(66476007)(30864003)(4326008)(1076003)(478600001)(38350700002)(2616005)(36756003)(66556008)(26005)(16526019)(2906002)(7416002)(38100700002)(186003)(86362001)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: aEKm4td7h35dcJkXP0B4vVYCR8CYK3mR3DdNEC7Js+gJOsXkQnK74nd3F+wdT/Nu4HVnFlXpcbUqIIkoi/KSh/rzHUW8Mn/T1k32T3q12dDDGnugaplyF9qdFi7lScq9qOOyuRVkepIGfxLOkMYZ22owO6J4pcTOMaY7dZpfwAtPD2BLXYfriexO9saz2gOrmDIAKR5II7g0aK+KZzncIVwBGubE9li/++uMHRPNk56UgqDyBDgVh8WRY54ScgtHRAadyT5kGKRCUkNjFTD7cxF1SM63lUPUnacpzGbZ7U7MtORO1UZ3Qar8A8W09OFqwRuZXotCp13XAxeYLUDqmIp5JZkPrV6gt/H+vQMZVI/XJV3s5Jtey56QOMIYrQUnJwLOEzR3t7K0Me1DlqkdOGdgQIgZXjSbOaBXViPs9dYiOdfHj/fzmsbTIgMTrdLYrvP0CmNXxsjOKlWGIFzaKhE9jCxzNFfDylymt5a9qe3SJQ8fbsIkWmXPFQJuUFK5U+MJEQOQg40TF+/58n6PaDI0mF/vOUKUiU0P1DyF+ofeTvsAD2Iw4wcGRdSwjAoD1aUDV8BOU3he5aaUxnFIBPcNBPc3TSjVITV4LA2EAB9EQbzvVoZo6N+ok87L4dOywabKj+RIpJ5KZ+IFFIJmss6I56Ap7hf5a97eKKGrAZcp1UcUTKRIyTQICc3LAaDRxUdas+8Kr4qbW4YPau+nMdjJcssZwJR7sWiOU0WpsAKRnAPjO1+WjsP+vU8r16JEwi/aMZ2UgAy1eWtnGnljNrdp+5yKef6Q3aHaMqj1hpc9/G2WS/RFVUTBb0tquXkCVDek6FhpbRQ+wI3L1pBHeiiVcQNiT5neGFeojkyPGwySUUUgAx324UeeR+JD18Wg+2F2BCTxpRl+1V4OPgv6DQ2nbbSzdr7gh+dV3t9ETNMdNPbllQxgbCDe9xuIJV3FSSdgbZIzeJKd4nee5vs8uVIfKfrfsL0/kTIFhF5ToO1nDnyPalEu+7+4yLrMCLZO7Mbv1iSl1G2FaM3leWFrxIX8xGdmfO9RAw6NBEvy9UfCvZj6lRl4CAYxmpFsyzLzD0SMaJgB3eV/5j8sGjKG5ZhXf+uWCGiZyoBwJPZ63L/YHCzFdQ3REwvF2+mFgzKM64Img3vL5dotb4LFjTAz1DhRHy/Eaq6HrU6YARnREd3Qk9vz7yBnF7EwfIfBZhq+QcYzZHwWrF0ajzdtF8PkcyQCMlZull6HzjYNIux+r3c7J7b0E9HDhupLlPQYIK3Ftx49tb9i0EiSAVGlUvt7JiAt71ob8I2u/WRfeEZ9f/3u+4w77LHEIBzhXBCox7ii X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7f34f3e8-05dc-4ab6-4bc0-08d92bcfd9ef X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jun 2021 05:23:16.7793 (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: hdyWQe99nHDOizlQbfO9mzHsYdcCOc31cTlSGtnXISAZHfvBaEL8tBh5FO5fERQ6cdd+ljl+uc9U20Gj/njVNQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7778 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The RISC-V SBI HSM extension provides HSM suspend call which can be used by Linux RISC-V to enter platform specific low-power state. This patch adds a CPU idle driver based on RISC-V SBI calls which will populate idle states from device tree and use SBI calls to entry these idle states. Signed-off-by: Anup Patel --- MAINTAINERS | 7 + drivers/cpuidle/Kconfig | 5 + drivers/cpuidle/Kconfig.riscv | 15 + drivers/cpuidle/Makefile | 4 + drivers/cpuidle/cpuidle-sbi.c | 626 ++++++++++++++++++++++++++++++++++ 5 files changed, 657 insertions(+) create mode 100644 drivers/cpuidle/Kconfig.riscv create mode 100644 drivers/cpuidle/cpuidle-sbi.c diff --git a/MAINTAINERS b/MAINTAINERS index 5108b5058502..a16b14c687b5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4796,6 +4796,13 @@ S: Supported F: drivers/cpuidle/dt_idle_genpd.c F: drivers/cpuidle/dt_idle_genpd.h +CPUIDLE DRIVER - RISC-V SBI +M: Anup Patel +L: linux-pm@vger.kernel.org +L: linux-riscv@lists.infradead.org +S: Supported +F: drivers/cpuidle/cpuidle-sbi.c + CRAMFS FILESYSTEM M: Nicolas Pitre S: Maintained diff --git a/drivers/cpuidle/Kconfig b/drivers/cpuidle/Kconfig index f1afe7ab6b54..ff71dd662880 100644 --- a/drivers/cpuidle/Kconfig +++ b/drivers/cpuidle/Kconfig @@ -66,6 +66,11 @@ depends on PPC source "drivers/cpuidle/Kconfig.powerpc" endmenu +menu "RISC-V CPU Idle Drivers" +depends on RISCV +source "drivers/cpuidle/Kconfig.riscv" +endmenu + config HALTPOLL_CPUIDLE tristate "Halt poll cpuidle driver" depends on X86 && KVM_GUEST diff --git a/drivers/cpuidle/Kconfig.riscv b/drivers/cpuidle/Kconfig.riscv new file mode 100644 index 000000000000..78518c26af74 --- /dev/null +++ b/drivers/cpuidle/Kconfig.riscv @@ -0,0 +1,15 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# RISC-V CPU Idle drivers +# + +config RISCV_SBI_CPUIDLE + bool "RISC-V SBI CPU idle Driver" + depends on RISCV_SBI + select DT_IDLE_STATES + select CPU_IDLE_MULTIPLE_DRIVERS + select DT_IDLE_GENPD if PM_GENERIC_DOMAINS_OF + help + Select this option to enable RISC-V SBI firmware based CPU idle + driver for RISC-V systems. This drivers also supports hierarchical + DT based layout of the idle state. diff --git a/drivers/cpuidle/Makefile b/drivers/cpuidle/Makefile index 11a26cef279f..a36922c18510 100644 --- a/drivers/cpuidle/Makefile +++ b/drivers/cpuidle/Makefile @@ -35,3 +35,7 @@ obj-$(CONFIG_MIPS_CPS_CPUIDLE) += cpuidle-cps.o # POWERPC drivers obj-$(CONFIG_PSERIES_CPUIDLE) += cpuidle-pseries.o obj-$(CONFIG_POWERNV_CPUIDLE) += cpuidle-powernv.o + +############################################################################### +# RISC-V drivers +obj-$(CONFIG_RISCV_SBI_CPUIDLE) += cpuidle-sbi.o diff --git a/drivers/cpuidle/cpuidle-sbi.c b/drivers/cpuidle/cpuidle-sbi.c new file mode 100644 index 000000000000..286172b0368d --- /dev/null +++ b/drivers/cpuidle/cpuidle-sbi.c @@ -0,0 +1,626 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * RISC-V SBI CPU idle driver. + * + * Copyright (c) 2021 Western Digital Corporation or its affiliates. + */ + +#define pr_fmt(fmt) "cpuidle-sbi: " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "dt_idle_states.h" +#include "dt_idle_genpd.h" + +struct sbi_cpuidle_data { + u32 *states; + struct device *dev; +}; + +struct sbi_domain_state { + bool available; + u32 state; +}; + +static DEFINE_PER_CPU_READ_MOSTLY(struct sbi_cpuidle_data, sbi_cpuidle_data); +static DEFINE_PER_CPU(struct sbi_domain_state, domain_state); +static bool sbi_cpuidle_use_osi; +static bool sbi_cpuidle_use_cpuhp; +static bool sbi_cpuidle_pd_allow_domain_state; + +static inline void sbi_set_domain_state(u32 state) +{ + struct sbi_domain_state *data = this_cpu_ptr(&domain_state); + + data->available = true; + data->state = state; +} + +static inline u32 sbi_get_domain_state(void) +{ + struct sbi_domain_state *data = this_cpu_ptr(&domain_state); + + return data->state; +} + +static inline void sbi_clear_domain_state(void) +{ + struct sbi_domain_state *data = this_cpu_ptr(&domain_state); + + data->available = false; +} + +static inline bool sbi_is_domain_state_available(void) +{ + struct sbi_domain_state *data = this_cpu_ptr(&domain_state); + + return data->available; +} + +static int sbi_suspend_finisher(unsigned long suspend_type, + unsigned long resume_addr, + unsigned long opaque) +{ + struct sbiret ret; + + ret = sbi_ecall(SBI_EXT_HSM, SBI_EXT_HSM_HART_SUSPEND, + suspend_type, resume_addr, opaque, 0, 0, 0); + + return (ret.error) ? sbi_err_map_linux_errno(ret.error) : 0; +} + +static int sbi_suspend(u32 state) +{ + if (state & SBI_HSM_SUSP_NON_RET_BIT) + return cpu_suspend(state, sbi_suspend_finisher); + else + return sbi_suspend_finisher(state, 0, 0); +} + +static int sbi_cpuidle_enter_state(struct cpuidle_device *dev, + struct cpuidle_driver *drv, int idx) +{ + u32 *states = __this_cpu_read(sbi_cpuidle_data.states); + + return CPU_PM_CPU_IDLE_ENTER_PARAM(sbi_suspend, idx, states[idx]); +} + +static int __sbi_enter_domain_idle_state(struct cpuidle_device *dev, + struct cpuidle_driver *drv, int idx, + bool s2idle) +{ + struct sbi_cpuidle_data *data = this_cpu_ptr(&sbi_cpuidle_data); + u32 *states = data->states; + struct device *pd_dev = data->dev; + u32 state; + int ret; + + ret = cpu_pm_enter(); + if (ret) + return -1; + + /* Do runtime PM to manage a hierarchical CPU toplogy. */ + rcu_irq_enter_irqson(); + if (s2idle) + dev_pm_genpd_suspend(pd_dev); + else + pm_runtime_put_sync_suspend(pd_dev); + rcu_irq_exit_irqson(); + + if (sbi_is_domain_state_available()) + state = sbi_get_domain_state(); + else + state = states[idx]; + + ret = sbi_suspend(state) ? -1 : idx; + + rcu_irq_enter_irqson(); + if (s2idle) + dev_pm_genpd_resume(pd_dev); + else + pm_runtime_get_sync(pd_dev); + rcu_irq_exit_irqson(); + + cpu_pm_exit(); + + /* Clear the domain state to start fresh when back from idle. */ + sbi_clear_domain_state(); + return ret; +} + +static int sbi_enter_domain_idle_state(struct cpuidle_device *dev, + struct cpuidle_driver *drv, int idx) +{ + return __sbi_enter_domain_idle_state(dev, drv, idx, false); +} + +static int sbi_enter_s2idle_domain_idle_state(struct cpuidle_device *dev, + struct cpuidle_driver *drv, + int idx) +{ + return __sbi_enter_domain_idle_state(dev, drv, idx, true); +} + +static int sbi_cpuidle_cpuhp_up(unsigned int cpu) +{ + struct device *pd_dev = __this_cpu_read(sbi_cpuidle_data.dev); + + if (pd_dev) + pm_runtime_get_sync(pd_dev); + + return 0; +} + +static int sbi_cpuidle_cpuhp_down(unsigned int cpu) +{ + struct device *pd_dev = __this_cpu_read(sbi_cpuidle_data.dev); + + if (pd_dev) { + pm_runtime_put_sync(pd_dev); + /* Clear domain state to start fresh at next online. */ + sbi_clear_domain_state(); + } + + return 0; +} + +static void sbi_idle_init_cpuhp(void) +{ + int err; + + if (!sbi_cpuidle_use_cpuhp) + return; + + err = cpuhp_setup_state_nocalls(CPUHP_AP_CPU_PM_STARTING, + "cpuidle/sbi:online", + sbi_cpuidle_cpuhp_up, + sbi_cpuidle_cpuhp_down); + if (err) + pr_warn("Failed %d while setup cpuhp state\n", err); +} + +static const struct of_device_id sbi_cpuidle_state_match[] = { + { .compatible = "riscv,idle-state", + .data = sbi_cpuidle_enter_state }, + { }, +}; + +static bool sbi_suspend_state_is_valid(u32 state) +{ + if (state > SBI_HSM_SUSPEND_RET_DEFAULT && + state < SBI_HSM_SUSPEND_RET_PLATFORM) + return false; + if (state > SBI_HSM_SUSPEND_NON_RET_DEFAULT && + state < SBI_HSM_SUSPEND_NON_RET_PLATFORM) + return false; + return true; +} + +static int sbi_dt_parse_state_node(struct device_node *np, u32 *state) +{ + int err = of_property_read_u32(np, "riscv,sbi-suspend-param", state); + + if (err) { + pr_warn("%pOF missing riscv,sbi-suspend-param property\n", np); + return err; + } + + if (!sbi_suspend_state_is_valid(*state)) { + pr_warn("Invalid SBI suspend state %#x\n", *state); + return -EINVAL; + } + + return 0; +} + +static int sbi_dt_cpu_init_topology(struct cpuidle_driver *drv, + struct sbi_cpuidle_data *data, + unsigned int state_count, int cpu) +{ + /* Currently limit the hierarchical topology to be used in OSI mode. */ + if (!sbi_cpuidle_use_osi) + return 0; + + data->dev = dt_idle_attach_cpu(cpu, "sbi"); + if (IS_ERR_OR_NULL(data->dev)) + return PTR_ERR_OR_ZERO(data->dev); + + /* + * Using the deepest state for the CPU to trigger a potential selection + * of a shared state for the domain, assumes the domain states are all + * deeper states. + */ + drv->states[state_count - 1].enter = sbi_enter_domain_idle_state; + drv->states[state_count - 1].enter_s2idle = + sbi_enter_s2idle_domain_idle_state; + sbi_cpuidle_use_cpuhp = true; + + return 0; +} + +static int sbi_cpuidle_dt_init_states(struct device *dev, + struct cpuidle_driver *drv, + unsigned int cpu, + unsigned int state_count) +{ + struct sbi_cpuidle_data *data = per_cpu_ptr(&sbi_cpuidle_data, cpu); + struct device_node *state_node; + struct device_node *cpu_node; + u32 *states; + int i, ret; + + cpu_node = of_cpu_device_node_get(cpu); + if (!cpu_node) + return -ENODEV; + + states = devm_kcalloc(dev, state_count, sizeof(*states), GFP_KERNEL); + if (!states) { + ret = -ENOMEM; + goto fail; + } + + /* Parse SBI specific details from state DT nodes */ + for (i = 1; i < state_count; i++) { + state_node = of_get_cpu_state_node(cpu_node, i - 1); + if (!state_node) + break; + + ret = sbi_dt_parse_state_node(state_node, &states[i]); + of_node_put(state_node); + + if (ret) + return ret; + + pr_debug("sbi-state %#x index %d\n", states[i], i); + } + if (i != state_count) { + ret = -ENODEV; + goto fail; + } + + /* Initialize optional data, used for the hierarchical topology. */ + ret = sbi_dt_cpu_init_topology(drv, data, state_count, cpu); + if (ret < 0) + return ret; + + /* Store states in the per-cpu struct. */ + data->states = states; + +fail: + of_node_put(cpu_node); + + return ret; +} + +static void sbi_cpuidle_deinit_cpu(int cpu) +{ + struct sbi_cpuidle_data *data = per_cpu_ptr(&sbi_cpuidle_data, cpu); + + dt_idle_detach_cpu(data->dev); + sbi_cpuidle_use_cpuhp = false; +} + +static int sbi_cpuidle_init_cpu(struct device *dev, int cpu) +{ + struct cpuidle_driver *drv; + unsigned int state_count = 0; + int ret = 0; + + drv = devm_kzalloc(dev, sizeof(*drv), GFP_KERNEL); + if (!drv) + return -ENOMEM; + + drv->name = "sbi_cpuidle"; + drv->owner = THIS_MODULE; + drv->cpumask = (struct cpumask *)cpumask_of(cpu); + + /* RISC-V architectural WFI to be represented as state index 0. */ + drv->states[0].enter = sbi_cpuidle_enter_state; + drv->states[0].exit_latency = 1; + drv->states[0].target_residency = 1; + drv->states[0].power_usage = UINT_MAX; + strcpy(drv->states[0].name, "WFI"); + strcpy(drv->states[0].desc, "RISC-V WFI"); + + /* + * If no DT idle states are detected (ret == 0) let the driver + * initialization fail accordingly since there is no reason to + * initialize the idle driver if only wfi is supported, the + * default archictectural back-end already executes wfi + * on idle entry. + */ + ret = dt_init_idle_driver(drv, sbi_cpuidle_state_match, 1); + if (ret <= 0) { + pr_debug("HART%ld: failed to parse DT idle states\n", + cpuid_to_hartid_map(cpu)); + return ret ? : -ENODEV; + } + state_count = ret + 1; /* Include WFI state as well */ + + /* Initialize idle states from DT. */ + ret = sbi_cpuidle_dt_init_states(dev, drv, cpu, state_count); + if (ret) { + pr_err("HART%ld: failed to init idle states\n", + cpuid_to_hartid_map(cpu)); + return ret; + } + + ret = cpuidle_register(drv, NULL); + if (ret) + goto deinit; + + cpuidle_cooling_register(drv); + + return 0; +deinit: + sbi_cpuidle_deinit_cpu(cpu); + return ret; +} + +static void sbi_cpuidle_domain_sync_state(struct device *dev) +{ + /* + * All devices have now been attached/probed to the PM domain + * topology, hence it's fine to allow domain states to be picked. + */ + sbi_cpuidle_pd_allow_domain_state = true; +} + +#ifdef CONFIG_DT_IDLE_GENPD + +static int sbi_cpuidle_pd_power_off(struct generic_pm_domain *pd) +{ + struct genpd_power_state *state = &pd->states[pd->state_idx]; + u32 *pd_state; + + if (!state->data) + return 0; + + if (!sbi_cpuidle_pd_allow_domain_state) + return -EBUSY; + + /* OSI mode is enabled, set the corresponding domain state. */ + pd_state = state->data; + sbi_set_domain_state(*pd_state); + + return 0; +} + +struct sbi_pd_provider { + struct list_head link; + struct device_node *node; +}; + +static LIST_HEAD(sbi_pd_providers); + +static int sbi_pd_init(struct device_node *np) +{ + struct generic_pm_domain *pd; + struct sbi_pd_provider *pd_provider; + struct dev_power_governor *pd_gov; + int ret = -ENOMEM, state_count = 0; + + pd = dt_idle_pd_alloc(np, sbi_dt_parse_state_node); + if (!pd) + goto out; + + pd_provider = kzalloc(sizeof(*pd_provider), GFP_KERNEL); + if (!pd_provider) + goto free_pd; + + pd->flags |= GENPD_FLAG_IRQ_SAFE | GENPD_FLAG_CPU_DOMAIN; + + /* Allow power off when OSI is available. */ + if (sbi_cpuidle_use_osi) + pd->power_off = sbi_cpuidle_pd_power_off; + else + pd->flags |= GENPD_FLAG_ALWAYS_ON; + + /* Use governor for CPU PM domains if it has some states to manage. */ + pd_gov = state_count > 0 ? &pm_domain_cpu_gov : NULL; + + ret = pm_genpd_init(pd, pd_gov, false); + if (ret) + goto free_pd_prov; + + ret = of_genpd_add_provider_simple(np, pd); + if (ret) + goto remove_pd; + + pd_provider->node = of_node_get(np); + list_add(&pd_provider->link, &sbi_pd_providers); + + pr_debug("init PM domain %s\n", pd->name); + return 0; + +remove_pd: + pm_genpd_remove(pd); +free_pd_prov: + kfree(pd_provider); +free_pd: + dt_idle_pd_free(pd); +out: + pr_err("failed to init PM domain ret=%d %pOF\n", ret, np); + return ret; +} + +static void sbi_pd_remove(void) +{ + struct sbi_pd_provider *pd_provider, *it; + struct generic_pm_domain *genpd; + + list_for_each_entry_safe(pd_provider, it, &sbi_pd_providers, link) { + of_genpd_del_provider(pd_provider->node); + + genpd = of_genpd_remove_last(pd_provider->node); + if (!IS_ERR(genpd)) + kfree(genpd); + + of_node_put(pd_provider->node); + list_del(&pd_provider->link); + kfree(pd_provider); + } +} + +static int sbi_genpd_probe(struct device_node *np) +{ + struct device_node *node; + int ret = 0, pd_count = 0; + + if (!np) + return -ENODEV; + + /* + * Parse child nodes for the "#power-domain-cells" property and + * initialize a genpd/genpd-of-provider pair when it's found. + */ + for_each_child_of_node(np, node) { + if (!of_find_property(node, "#power-domain-cells", NULL)) + continue; + + ret = sbi_pd_init(node); + if (ret) + goto put_node; + + pd_count++; + } + + /* Bail out if not using the hierarchical CPU topology. */ + if (!pd_count) + goto no_pd; + + /* Link genpd masters/subdomains to model the CPU topology. */ + ret = dt_idle_pd_init_topology(np); + if (ret) + goto remove_pd; + + return 0; + +put_node: + of_node_put(node); +remove_pd: + sbi_pd_remove(); + pr_err("failed to create CPU PM domains ret=%d\n", ret); +no_pd: + return ret; +} + +#else + +static inline int sbi_genpd_probe(struct device_node *np) +{ + return 0; +} + +#endif + +static int sbi_cpuidle_probe(struct platform_device *pdev) +{ + int cpu, ret; + struct cpuidle_driver *drv; + struct cpuidle_device *dev; + struct device_node *np, *pds_node; + + /* Detect OSI support based on CPU DT nodes */ + sbi_cpuidle_use_osi = true; + for_each_possible_cpu(cpu) { + np = of_cpu_device_node_get(cpu); + if (np && + of_find_property(np, "power-domains", NULL) && + of_find_property(np, "power-domain-names", NULL)) { + continue; + } else { + sbi_cpuidle_use_osi = false; + break; + } + } + + /* Populate generic power domains from DT nodes */ + pds_node = of_find_node_by_path("/cpus/power-domains"); + if (pds_node) { + ret = sbi_genpd_probe(pds_node); + of_node_put(pds_node); + if (ret) + return ret; + } + + /* Initialize CPU idle driver for each CPU */ + for_each_possible_cpu(cpu) { + ret = sbi_cpuidle_init_cpu(&pdev->dev, cpu); + if (ret) { + pr_debug("HART%ld: idle driver init failed\n", + cpuid_to_hartid_map(cpu)); + goto out_fail; + } + } + + /* Setup CPU hotplut notifiers */ + sbi_idle_init_cpuhp(); + + pr_info("idle driver registered for all CPUs\n"); + + return 0; + +out_fail: + while (--cpu >= 0) { + dev = per_cpu(cpuidle_devices, cpu); + drv = cpuidle_get_cpu_driver(dev); + cpuidle_unregister(drv); + sbi_cpuidle_deinit_cpu(cpu); + } + + return ret; +} + +static struct platform_driver sbi_cpuidle_driver = { + .probe = sbi_cpuidle_probe, + .driver = { + .name = "sbi-cpuidle", + .sync_state = sbi_cpuidle_domain_sync_state, + }, +}; + +static int __init sbi_cpuidle_init(void) +{ + int ret; + struct platform_device *pdev; + + /* + * The SBI HSM suspend function is only available when: + * 1) SBI version is 0.3 or higher + * 2) SBI HSM extension is available + */ + if ((sbi_spec_version < sbi_mk_version(0, 3)) || + sbi_probe_extension(SBI_EXT_HSM) <= 0) { + pr_info("HSM suspend not available\n"); + return 0; + } + + ret = platform_driver_register(&sbi_cpuidle_driver); + if (ret) + return ret; + + pdev = platform_device_register_simple("sbi-cpuidle", + -1, NULL, 0); + if (IS_ERR(pdev)) { + platform_driver_unregister(&sbi_cpuidle_driver); + return PTR_ERR(pdev); + } + + return 0; +} +device_initcall(sbi_cpuidle_init); From patchwork Thu Jun 10 05:22:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 458844 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=-21.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING, 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 5DEFDC48BE0 for ; Thu, 10 Jun 2021 05:23:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4C6DF613F1 for ; Thu, 10 Jun 2021 05:23:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230285AbhFJFZV (ORCPT ); Thu, 10 Jun 2021 01:25:21 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:11542 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230268AbhFJFZV (ORCPT ); Thu, 10 Jun 2021 01:25: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=1623302615; x=1654838615; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=Siicc7XFOS1KX69fJqIb8VDbnwqgai2SMf1SZ8neito=; b=S9fuwTgdLKOD0WG2aRlO0YrxN7mWdBL63uzGnt2ZiCXH6cH6u48v7+ki 1Gih9GcjZsdPpWU0QAsJIpTGdNWCyXQ5QufBKFDtJvf9R9DaHBZB8weXB 0kLxtl1sfi/9o8Pi42DdLIzNETC5bzBsSBbsmbX0oAZkfdVjdoxDz8z6U DZnwkyDH8KRd7y5jG3RqAGw9B1wM/Ni3uCDzraWckTgktDaOcVLoDCzl3 q8OPQcue/UUZ0WD9oMRNVBaDwk0cQcwzqrSOVjIadhytgziqvTNwp9zKJ JXSlLhxyTFr7WD3wEFRIZthr7tvx87at62vqNgs78lTSEku/jWgLyWD5M Q==; IronPort-SDR: 5fmBbYWy6Lnx2zBvLY9QqSboai13hESVYCUUmL6x1ds+6RAhBoO0ASkX0B+5vnWYrkO7t70My8 PxVpH+z/df3hok1kPjuuLsDJYshOnTb90krLkOHY5sywFABNoC7Ohivrd5d2G7gNxKcYiOXsNL 2Rjnxv6fHnYApSn9QGSz57TGF5/CUf52/NYDAbhmqhWB1ajqVwT/3S3lFrXbSjfeBpooH1ANPt 2quNo49Qbga7J0c2QQBnrMA+o6eo5JcxoCnWNiOCOyBAnBLWQwQDu/CAjkMVpYA7mdzTVYvjp/ JMw= X-IronPort-AV: E=Sophos;i="5.83,262,1616428800"; d="scan'208";a="275211821" Received: from mail-dm6nam12lp2170.outbound.protection.outlook.com (HELO NAM12-DM6-obe.outbound.protection.outlook.com) ([104.47.59.170]) by ob1.hgst.iphmx.com with ESMTP; 10 Jun 2021 13:23:32 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AM+a/6P2WvnT6atzBVtwQtH96ZSfqdYH6ZP+nmQQKPR6tkRH9CZEIebea+7KYSOJx8WjOEsLVCbjsFgiN6gnp94Zjf0SCzwgAXIP8oBOxpWlpJMuGx0A0MU9i7uvo4N72g4PWL0vbFa3KgfOd2b1NmQsZtMjqKQGw0FE7+hAXNOX/xkrHz1c9QqcjH2mghDbvnk+gzwSWwhJqxzyzzCLaveET8vxeorrH/j1jZgg8s9qmwC27n5YWau++AN93/54ADm0j3R7zdxGzEjxIE+c/bZxlw47pDNMrFHgdbEhdywNlHtFNZmzXTY6wim4/7Xg4UvcDasVuPAbZ9Pf94sHXQ== 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=t07KWB3DgouDnDX9SUBJZaHCvueWz2NBvwoi0csHskg=; b=VZoMiwlHBRm4dhi9uxHWjBqDA5ZyW0PFJKid77Ev4tjhH5QTjTlXZUNySNvnZTSwEXDykjAQdp7IVg15dXxxrsRX1cIAOGsAXWTUUDM7eBL/FzMh0/Jn0GZUFqBxwc0rpe8TY/clLHuab2Wy/LNzrbH7OqynxyWPD1LOKH4CKEIDLQ3QaAey0NRthO+O9q2PZTCctbIc1CC3K14bmSoXhPo6X4o5C4hq6mOxl84i1X3fEoAOWzWwMWdL8AsQaaj4iuQq4tx/1WktpbW7akoujuOTVXGJ+brWdeIjvL+b46O5RNzTYoo0V/VSZ3/JdFWk4T+El8w8KzYprucAJCYanA== 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=t07KWB3DgouDnDX9SUBJZaHCvueWz2NBvwoi0csHskg=; b=WmdV20p61z+RsTlpzxHCb+SDsLtsyg+hoQ/lPBh2S/hTKIp6wv3u1ArEZrxURoYerEqSFImnU/HzJrTTvlsJh1PpJjYHuwqyGTnPpPuZjHNuBwabWBrbOoLrBTT5/Zexinet2O0mUUbf+Mdchcsk4Foq8t4a+DAZabj0lZYHW2Q= Authentication-Results: dabbelt.com; dkim=none (message not signed) header.d=none; dabbelt.com; dmarc=none action=none header.from=wdc.com; Received: from CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) by CO6PR04MB7778.namprd04.prod.outlook.com (2603:10b6:303:13e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21; Thu, 10 Jun 2021 05:23:22 +0000 Received: from CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8]) by CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8%9]) with mapi id 15.20.4219.021; Thu, 10 Jun 2021 05:23:22 +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 , Rob Herring Subject: [PATCH v7 7/8] dt-bindings: Add common bindings for ARM and RISC-V idle states Date: Thu, 10 Jun 2021 10:52:20 +0530 Message-Id: <20210610052221.39958-8-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210610052221.39958-1-anup.patel@wdc.com> References: <20210610052221.39958-1-anup.patel@wdc.com> X-Originating-IP: [122.171.172.180] X-ClientProxiedBy: MA1PR01CA0182.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:d::8) To CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.171.172.180) by MA1PR01CA0182.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:d::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21 via Frontend Transport; Thu, 10 Jun 2021 05:23:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4a81fd74-5687-4b01-df4e-08d92bcfdd40 X-MS-TrafficTypeDiagnostic: CO6PR04MB7778: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JWHlU3E/QJ+RsCrPlX9ty+LC2BGhN86EZu8cDWhcgxlyZiJfOA9Wn9p96lpwIF69kXgHaN7mHSuGgvyoi+Cm6NHSMRMOenYDVcnEfNoNJRlyhHrM5u6rXx2vdmx2ErQjY9xTzvSJXJKHbJtry+AwAUcY4xG6MM4+kpURfAiYGDB1H7E/h2atoi0qh/O/5w8ihmlR0rcMVrb/8wAMCVhIg9tU68E1XkP56Lxj4ptma9+x4g5MFaduutEqPgPBQ8DopAOZFpWXAVwbkgkYAjaNIKxIJJ9+T8tVOW6pZXB1sOOlMZesAG6aSlz/EQpIuneOtfOz+gFEiwzgv2pxfcBwEw2QaUtWf46FNKJSEg4f2A82o+0P0BYnPuvFAXH+KzhkL92PLYRMkNZTMF/OvhoXIcn4qXuCLcpUW0yCNltMAFIlhLOnoUUlmL8omLGGDnb2DLLbHsbAN9ldfNPchxWGYpUxnNvv0HFOe5Yj31YKs5yVHZWbUxa3HTa0wvLrF3afcZfCLx8IhVPPukCU/BA8Gr5WKBxWuVAJbs0+dHN7c2gWbvDAuwWb3w4FPTiqgh5Ek0bYbw5AbwP6g7Ub6yjSp8bLMOKcNc9K2/TvQVNXxK3Xvyeif94FagEnIlhQCCLkt42rlW4Ymn6DBA9oxrMoEWudUqUU2TV7naI/4FsRyZSPTOyp+huuk1nyKFSVyBzKvw/9vg9hyx5oiHW/aS3fZHE6rfnHMyYumJEetQxmRj4qHuPPfpayMpoYRDbuNkKzsBEa5cLNrpo+a9SelIEQ1A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO6PR04MB7812.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(396003)(346002)(39860400002)(136003)(376002)(8936002)(110136005)(54906003)(44832011)(55016002)(5660300002)(7696005)(8676002)(316002)(83380400001)(8886007)(956004)(66946007)(66476007)(30864003)(4326008)(1076003)(478600001)(38350700002)(2616005)(36756003)(966005)(66556008)(26005)(16526019)(2906002)(7416002)(6666004)(38100700002)(186003)(86362001)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uzfwCp0M/7p7yiahGWad4Por2JiWFD4hQdiMqI/9k6I3ZLxviYN2xm9GJy/4+r29bBimLiHKglMy+FSEStXXVkks+Z4r3C1R8mE6GkpKoxmaf2XR5qLOzzdBonRffVR/9PlLLRsRyZEiYWFi8/bX+o1TtGtU4taYIqNMvY5WkRrsQlgUuwLnL9r+7ox7tNLQbR7S84FXk/ODJVe8vN969rZaZzEcZJuilNIulyN5ZLr0j6vAAVUUnsQrNGdZTEPtNoV6h8fhQG0ZCaLHvQTg5QFxk9XAE9DJyYmwvPKU8zALATT4h/QS8eiTAki9U7ow9dEhK0RCaKPRdt0eKPdtHY+Zw2FdW5A4EZiq31zUkPp9ZByWWYQfgxPyb2u+pl2Rn1dsbpktaEKJeScbFk/kw2o62cZCZ1ZBOZ3IK7DPSdRRlzjG5Ldssie4wAJSQ0YjOPQhvLo1IGhTwtNZaZMZSxzLImZ5xyO0DHAzlIKE24mbqsPdoG9B8jmwy9zWfOIFy3mc7wpC0T4Z9KZhdmhWb+rH1u0hJlCBF7hIhLu8SJ6G/Qjrw+QR7Ao2D8VRrxWDPOKuR95VBKeAFzDvm4Sf2K2sJ2B/XVkeLNp3p9yTKIiamSV5R58r34g4FRyQi+RqEjqf6ZKeKGfJ+UruAkNjRdc7PNE57lvURYXpnuqp9r2stWKj7+515oOPvfonNvOnI0U44PAS3mWdATzKjZzhX9pMuv66WUIN+7R+72l0Qn4kN9X75pUBizExGUPLbwt8BEEgVSkT0C+WByhU3kEAEItSj4Xn/C8Zg6l/mzqhWOGd6for78IUNIClGNyom9M1Duu1xCN5zR7N40S05Q62+LIuJAnA1U4Hpn2obMuBECTtva4ek+SDTfx4CEOdaKo5qFduPnpFZGWQnTfQkKGGDRIss2bnymcSRJFZ1RHxJyoHJ3jM86hOgOto05bgApFdjI1A6EPbi4vVGORUxFzBhdNAyVy6IMiZBtPcmuRaP+gdKpIaovOOFwQamdh1WdSPlol03h3nHMMTlbrR/VHzv8BFVQdWO9jrluhLcHDG9qwqvRIFI5LApyvMA6HBx4QmLqGeexypk1VPQojVZnSc4szDEikneKSjpBorIwo9Psk94l9EkGWBgG5cPYLtSTBPLXADqbQEXp7GHd8QjnqRlpRAg8JExCbcptxXxhrxLw0Nfy96qqd617LIwanuQ77BaetcHNx08xbcrvRiuqXFZTs71suoRZNHxfkazAWM7nZo7VmgDQ0qhJZZsNo/iHpB5WLbV/ZPmUIMTltdAvr9MknXvJaldPw9vMZU9W5xbnXQLLkCOJYIlXGdL8EgxMTF X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4a81fd74-5687-4b01-df4e-08d92bcfdd40 X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jun 2021 05:23:22.1439 (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: vPVBZkwoqxMvSDhna3bI1OLlharae6TbgL64/Pptg7n9G4bnHA4zN6Qo8eqo5BKZB0nNdRS3+TTnqhTV+tpH/w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7778 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The RISC-V CPU idle states will be described in under the /cpus/idle-states DT node in the same way as ARM CPU idle states. This patch adds common bindings documentation for both ARM and RISC-V idle states. Signed-off-by: Anup Patel Reviewed-by: Rob Herring --- .../bindings/arm/msm/qcom,idle-state.txt | 2 +- .../devicetree/bindings/arm/psci.yaml | 2 +- .../bindings/{arm => cpu}/idle-states.yaml | 228 ++++++++++++++++-- .../devicetree/bindings/riscv/cpus.yaml | 6 + 4 files changed, 219 insertions(+), 19 deletions(-) rename Documentation/devicetree/bindings/{arm => cpu}/idle-states.yaml (74%) diff --git a/Documentation/devicetree/bindings/arm/msm/qcom,idle-state.txt b/Documentation/devicetree/bindings/arm/msm/qcom,idle-state.txt index 6ce0b212ec6d..606b4b1b709d 100644 --- a/Documentation/devicetree/bindings/arm/msm/qcom,idle-state.txt +++ b/Documentation/devicetree/bindings/arm/msm/qcom,idle-state.txt @@ -81,4 +81,4 @@ Example: }; }; -[1]. Documentation/devicetree/bindings/arm/idle-states.yaml +[1]. Documentation/devicetree/bindings/cpu/idle-states.yaml diff --git a/Documentation/devicetree/bindings/arm/psci.yaml b/Documentation/devicetree/bindings/arm/psci.yaml index 8b77cf83a095..dd83ef278af0 100644 --- a/Documentation/devicetree/bindings/arm/psci.yaml +++ b/Documentation/devicetree/bindings/arm/psci.yaml @@ -101,7 +101,7 @@ properties: bindings in [1]) must specify this property. [1] Kernel documentation - ARM idle states bindings - Documentation/devicetree/bindings/arm/idle-states.yaml + Documentation/devicetree/bindings/cpu/idle-states.yaml patternProperties: "^power-domain-": diff --git a/Documentation/devicetree/bindings/arm/idle-states.yaml b/Documentation/devicetree/bindings/cpu/idle-states.yaml similarity index 74% rename from Documentation/devicetree/bindings/arm/idle-states.yaml rename to Documentation/devicetree/bindings/cpu/idle-states.yaml index 52bce5dbb11f..74466f160cb2 100644 --- a/Documentation/devicetree/bindings/arm/idle-states.yaml +++ b/Documentation/devicetree/bindings/cpu/idle-states.yaml @@ -1,25 +1,30 @@ # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) %YAML 1.2 --- -$id: http://devicetree.org/schemas/arm/idle-states.yaml# +$id: http://devicetree.org/schemas/cpu/idle-states.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: ARM idle states binding description +title: Idle states binding description maintainers: - Lorenzo Pieralisi + - Anup Patel description: |+ ========================================== 1 - Introduction ========================================== - ARM systems contain HW capable of managing power consumption dynamically, - where cores can be put in different low-power states (ranging from simple wfi - to power gating) according to OS PM policies. The CPU states representing the - range of dynamic idle states that a processor can enter at run-time, can be - specified through device tree bindings representing the parameters required to - enter/exit specific idle states on a given processor. + ARM and RISC-V systems contain HW capable of managing power consumption + dynamically, where cores can be put in different low-power states (ranging + from simple wfi to power gating) according to OS PM policies. The CPU states + representing the range of dynamic idle states that a processor can enter at + run-time, can be specified through device tree bindings representing the + parameters required to enter/exit specific idle states on a given processor. + + ========================================== + 2 - ARM idle states + ========================================== According to the Server Base System Architecture document (SBSA, [3]), the power states an ARM CPU can be put into are identified by the following list: @@ -43,8 +48,23 @@ description: |+ The device tree binding definition for ARM idle states is the subject of this document. + ========================================== + 3 - RISC-V idle states + ========================================== + + On RISC-V systems, the HARTs (or CPUs) [6] can be put in platform specific + suspend (or idle) states (ranging from simple WFI, power gating, etc). The + RISC-V SBI v0.3 (or higher) [7] hart state management extension provides a + standard mechanism for OS to request HART state transitions. + + The platform specific suspend (or idle) states of a hart can be either + retentive or non-rententive in nature. A retentive suspend state will + preserve HART registers and CSR values for all privilege modes whereas + a non-retentive suspend state will not preserve HART registers and CSR + values. + =========================================== - 2 - idle-states definitions + 4 - idle-states definitions =========================================== Idle states are characterized for a specific system through a set of @@ -211,10 +231,10 @@ description: |+ properties specification that is the subject of the following sections. =========================================== - 3 - idle-states node + 5 - idle-states node =========================================== - ARM processor idle states are defined within the idle-states node, which is + The processor idle states are defined within the idle-states node, which is a direct child of the cpus node [1] and provides a container where the processor idle states, defined as device tree nodes, are listed. @@ -223,7 +243,7 @@ description: |+ just supports idle_standby, an idle-states node is not required. =========================================== - 4 - References + 6 - References =========================================== [1] ARM Linux Kernel documentation - CPUs bindings @@ -238,9 +258,15 @@ description: |+ [4] ARM Architecture Reference Manuals http://infocenter.arm.com/help/index.jsp - [6] ARM Linux Kernel documentation - Booting AArch64 Linux + [5] ARM Linux Kernel documentation - Booting AArch64 Linux Documentation/arm64/booting.rst + [6] RISC-V Linux Kernel documentation - CPUs bindings + Documentation/devicetree/bindings/riscv/cpus.yaml + + [7] RISC-V Supervisor Binary Interface (SBI) + http://github.com/riscv/riscv-sbi-doc/riscv-sbi.adoc + properties: $nodename: const: idle-states @@ -253,7 +279,7 @@ properties: On ARM 32-bit systems this property is optional This assumes that the "enable-method" property is set to "psci" in the cpu - node[6] that is responsible for setting up CPU idle management in the OS + node[5] that is responsible for setting up CPU idle management in the OS implementation. const: psci @@ -265,8 +291,8 @@ patternProperties: as follows. The idle state entered by executing the wfi instruction (idle_standby - SBSA,[3][4]) is considered standard on all ARM platforms and therefore - must not be listed. + SBSA,[3][4]) is considered standard on all ARM and RISC-V platforms and + therefore must not be listed. In addition to the properties listed above, a state node may require additional properties specific to the entry-method defined in the @@ -275,7 +301,27 @@ patternProperties: properties: compatible: - const: arm,idle-state + oneOf: + - const: arm,idle-state + - const: riscv,idle-state + + arm,psci-suspend-param: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + power_state parameter to pass to the ARM PSCI suspend call. + + Device tree nodes that require usage of PSCI CPU_SUSPEND function + (i.e. idle states node with entry-method property is set to "psci") + must specify this property. + + riscv,sbi-suspend-param: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + suspend_type parameter to pass to the RISC-V SBI HSM suspend call. + + This property is required in idle state nodes of device tree meant + for RISC-V systems. For more details on the suspend_type parameter + refer the SBI specifiation v0.3 (or higher) [7]. local-timer-stop: description: @@ -317,6 +363,8 @@ patternProperties: description: A string used as a descriptive name for the idle state. + additionalProperties: false + required: - compatible - entry-latency-us @@ -658,4 +706,150 @@ examples: }; }; + - | + // Example 3 (RISC-V 64-bit, 4-cpu systems, two clusters): + + cpus { + #size-cells = <0>; + #address-cells = <1>; + + cpu@0 { + device_type = "cpu"; + compatible = "riscv"; + reg = <0x0>; + riscv,isa = "rv64imafdc"; + mmu-type = "riscv,sv48"; + cpu-idle-states = <&CPU_RET_0_0 &CPU_NONRET_0_0 + &CLUSTER_RET_0 &CLUSTER_NONRET_0>; + + cpu_intc0: interrupt-controller { + #interrupt-cells = <1>; + compatible = "riscv,cpu-intc"; + interrupt-controller; + }; + }; + + cpu@1 { + device_type = "cpu"; + compatible = "riscv"; + reg = <0x1>; + riscv,isa = "rv64imafdc"; + mmu-type = "riscv,sv48"; + cpu-idle-states = <&CPU_RET_0_0 &CPU_NONRET_0_0 + &CLUSTER_RET_0 &CLUSTER_NONRET_0>; + + cpu_intc1: interrupt-controller { + #interrupt-cells = <1>; + compatible = "riscv,cpu-intc"; + interrupt-controller; + }; + }; + + cpu@10 { + device_type = "cpu"; + compatible = "riscv"; + reg = <0x10>; + riscv,isa = "rv64imafdc"; + mmu-type = "riscv,sv48"; + cpu-idle-states = <&CPU_RET_1_0 &CPU_NONRET_1_0 + &CLUSTER_RET_1 &CLUSTER_NONRET_1>; + + cpu_intc10: interrupt-controller { + #interrupt-cells = <1>; + compatible = "riscv,cpu-intc"; + interrupt-controller; + }; + }; + + cpu@11 { + device_type = "cpu"; + compatible = "riscv"; + reg = <0x11>; + riscv,isa = "rv64imafdc"; + mmu-type = "riscv,sv48"; + cpu-idle-states = <&CPU_RET_1_0 &CPU_NONRET_1_0 + &CLUSTER_RET_1 &CLUSTER_NONRET_1>; + + cpu_intc11: interrupt-controller { + #interrupt-cells = <1>; + compatible = "riscv,cpu-intc"; + interrupt-controller; + }; + }; + + idle-states { + CPU_RET_0_0: cpu-retentive-0-0 { + compatible = "riscv,idle-state"; + riscv,sbi-suspend-param = <0x10000000>; + entry-latency-us = <20>; + exit-latency-us = <40>; + min-residency-us = <80>; + }; + + CPU_NONRET_0_0: cpu-nonretentive-0-0 { + compatible = "riscv,idle-state"; + riscv,sbi-suspend-param = <0x90000000>; + entry-latency-us = <250>; + exit-latency-us = <500>; + min-residency-us = <950>; + }; + + CLUSTER_RET_0: cluster-retentive-0 { + compatible = "riscv,idle-state"; + riscv,sbi-suspend-param = <0x11000000>; + local-timer-stop; + entry-latency-us = <50>; + exit-latency-us = <100>; + min-residency-us = <250>; + wakeup-latency-us = <130>; + }; + + CLUSTER_NONRET_0: cluster-nonretentive-0 { + compatible = "riscv,idle-state"; + riscv,sbi-suspend-param = <0x91000000>; + local-timer-stop; + entry-latency-us = <600>; + exit-latency-us = <1100>; + min-residency-us = <2700>; + wakeup-latency-us = <1500>; + }; + + CPU_RET_1_0: cpu-retentive-1-0 { + compatible = "riscv,idle-state"; + riscv,sbi-suspend-param = <0x10000010>; + entry-latency-us = <20>; + exit-latency-us = <40>; + min-residency-us = <80>; + }; + + CPU_NONRET_1_0: cpu-nonretentive-1-0 { + compatible = "riscv,idle-state"; + riscv,sbi-suspend-param = <0x90000010>; + entry-latency-us = <250>; + exit-latency-us = <500>; + min-residency-us = <950>; + }; + + CLUSTER_RET_1: cluster-retentive-1 { + compatible = "riscv,idle-state"; + riscv,sbi-suspend-param = <0x11000010>; + local-timer-stop; + entry-latency-us = <50>; + exit-latency-us = <100>; + min-residency-us = <250>; + wakeup-latency-us = <130>; + }; + + CLUSTER_NONRET_1: cluster-nonretentive-1 { + compatible = "riscv,idle-state"; + riscv,sbi-suspend-param = <0x91000010>; + local-timer-stop; + entry-latency-us = <600>; + exit-latency-us = <1100>; + min-residency-us = <2700>; + wakeup-latency-us = <1500>; + }; + }; + }; + ... diff --git a/Documentation/devicetree/bindings/riscv/cpus.yaml b/Documentation/devicetree/bindings/riscv/cpus.yaml index e534f6a7cfa1..482936630525 100644 --- a/Documentation/devicetree/bindings/riscv/cpus.yaml +++ b/Documentation/devicetree/bindings/riscv/cpus.yaml @@ -95,6 +95,12 @@ properties: - compatible - interrupt-controller + cpu-idle-states: + $ref: '/schemas/types.yaml#/definitions/phandle-array' + description: | + List of phandles to idle state nodes supported + by this hart (see ./idle-states.yaml). + required: - riscv,isa - interrupt-controller From patchwork Thu Jun 10 05:22:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 458168 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.8 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=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 3113EC48BD1 for ; Thu, 10 Jun 2021 05:23:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1979D613D9 for ; Thu, 10 Jun 2021 05:23:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230294AbhFJFZc (ORCPT ); Thu, 10 Jun 2021 01:25:32 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:11555 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230298AbhFJFZZ (ORCPT ); Thu, 10 Jun 2021 01:25:25 -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=1623302622; x=1654838622; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=1uLrgPfppmFH2vM6/L/JqMHBvAu4tkt7ZHOK+EuhRKU=; b=SZEUuBhFsCy91Tqn168dVWmzOYYrz1NQowfwxs043OoRbn2y4UenqbLd 7HOtx0lmiFBLKQAJQAWMzXfJds2NlsnrO4QCeNk7kD4xv6NT4SFb3Qaxo j5FRv44I7lk78Rdh6zgiwHrDS/ppk/U0VVckkYWM0EQu0jNmOT9FJhL2z LZHznO3qEHHioybpfabLX2qiyMhpJyTJhhTiSiveHQw35GiHTR5JW48PQ Efiyvo3nQlFbihzuUL8WjutnUaE9WXGcNqNQMWaHaVv7yEhm/HbkAkoSj gJajdnnZ9vI1DKofehxJHDFmPNfpkRxeYl1xWVAyk74S40Fc9s38hXHjz w==; IronPort-SDR: ZPkicLY17CKjyZW73V9En7wVxnnBzon7dWi6anhatNmJg4jtvYAIfIFbww8LiZMZNwHQcOk+Lk KSehGRgPPCtKCUiRJmF97QO8GVFZr0gz8YlXw8EbmBTJWjep5vIiE6rdip8SpiR8oJtd03cBbM EjQq+0tAzCvqtfxDUl2318K+rj56z1afwNnIVE2SYtGRgLwg++XWxna4HEX+aaHoj+XvhkRjyJ 1/rL7081dLcnabeEWBzZa26RtmE5GhwFVXgukFBaB99DhbD1vZj1P8JpXTwIcnW7EXCaCMbzKJ zwM= X-IronPort-AV: E=Sophos;i="5.83,262,1616428800"; d="scan'208";a="275211825" Received: from mail-dm6nam12lp2175.outbound.protection.outlook.com (HELO NAM12-DM6-obe.outbound.protection.outlook.com) ([104.47.59.175]) by ob1.hgst.iphmx.com with ESMTP; 10 Jun 2021 13:23:39 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MskaA3FTBIsS48IqpvTut/0NjVKv0QQmLSivlDO57D4XRXIaZUsoDGJ9sT8tA0ysjnrUt0sRa+m5T/3aUy/K49u6yosb65BurPG6tIE2eXsNuXvkK/cf89VTK90GZJcwSQslHVakGTPDrxJWpSnir+wu/zsnFt03I6HFi7ymx0y5kDs+qb1FxWjE6Mlp5+pItPVmkmxzNswO+anqbl1VbEwBA9gLa8AciDfS1o6UpBlb8Aez+QPaGH+4DJS0zLHGuU5A2aMfNEjiWG+LOSDm5QyVvmKN/Hlx9Aco3ZGhHovUq/tIx7jfjubb/Cpg0Gh6iOxqZS5TftSC/mq/YiIFlw== 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=rip7XFR0BFk/jcVrblzy2OjHhUZycRZYHU6/NmyDcb8=; b=gqrx5ir6LpS/BbLaw8SpMxnNQ8MMvG6hzsi5iN3yRxVd19oxgE4BoMJ3sfvg/+QtxSYGL/yV8wr60ed/SDuUVqjZcgtvpZvIG6Bj+eRNWKT44etpOXOhODcUXNsAm1v15uFIIMv4ISCUwpeNVvDWNbdwfe50uUHuQMfrD7g2OeXeVpug0ygMyzy1KSUtvjyziyEXlz1+4JAfHEcQBbTQ0Q+JT0CTyG8Hun8YE9SyAHKP2M3tqguUPhIj5WrQAuNTfCJXluVE2acW1n7AOo3OTCppC2dG8GjcsOdlYoN0VQCbbein0zWZj/Lm+eGaIR1Iq39Z0KuPu19ccsXfrXaECA== 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=rip7XFR0BFk/jcVrblzy2OjHhUZycRZYHU6/NmyDcb8=; b=DsbhytrE3l1AAbwa5PJx5r0ucL8Ps31/TWxV6SwclOCJlECHFvY87wwgFmdO/aZmHFes8sNRwmtJpufCbOe2TzM7C/qYMHm8Avxmk/CW4Yu6dTLyEcYGbrptxPOrYfUb+gA8ClxDtAFu6WQIpn4zOLhPesajMPB6Ba9xCOEx2rc= Authentication-Results: dabbelt.com; dkim=none (message not signed) header.d=none; dabbelt.com; dmarc=none action=none header.from=wdc.com; Received: from CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) by CO6PR04MB7778.namprd04.prod.outlook.com (2603:10b6:303:13e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21; Thu, 10 Jun 2021 05:23:27 +0000 Received: from CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8]) by CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::a153:b7f8:c87f:89f8%9]) with mapi id 15.20.4219.021; Thu, 10 Jun 2021 05:23:27 +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: [PATCH v7 8/8] RISC-V: Enable RISC-V SBI CPU Idle driver for QEMU virt machine Date: Thu, 10 Jun 2021 10:52:21 +0530 Message-Id: <20210610052221.39958-9-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210610052221.39958-1-anup.patel@wdc.com> References: <20210610052221.39958-1-anup.patel@wdc.com> X-Originating-IP: [122.171.172.180] X-ClientProxiedBy: MA1PR01CA0182.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:d::8) To CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.171.172.180) by MA1PR01CA0182.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:d::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21 via Frontend Transport; Thu, 10 Jun 2021 05:23:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 65dac918-0717-48da-fdfd-08d92bcfe04e X-MS-TrafficTypeDiagnostic: CO6PR04MB7778: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:849; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LJl/kSBCtZLK4vvMo9gTlfyNbuQxImThDfN5+/ewlEbEG42Bqq0Gtdf4z3UXVK0kba2eYntirfvZu+s33VLpXP1z3H2Nvzl8q0omAljtTGIMJHDPWUp6VCIpXwrCauFhUnBB98E9fGnCpn438iTGSUDMueHsF3svOYZ234f4oTsxw9ISx8JiA9Kl9tpqhYfeows9f/bF8sH90EWCxsYxOKWCYgjZeBvxqesHqwiSIHvN2TbUwi11zLQMdkHXtdbG7Xn9eeyrI4/bqVHflxlXvm7AlX04E03OjPTr/AZ1yCLYRFyfGMQ/nrCHjWr+6aweJZ6jzI6HSchUOgftaS/ncFYRJeRgkJ+/mfjYYMDRrIVrd8fLGapFZzQ0KmlDfDGfh7AAW1+1z1unckyssbCH+Gj6ZpZooZJJh50MhBNVUMcWoQf9LS0YCcrZbpe0ds41pFSS3qd6CNGSGbTWNiPhwfUPn7lCE3NrvfiI9+tWYeo5Z2cKYJJZ/GHEITqc/HrTKSEQgk9t3+gyLPK3M2CWG6rA0SJXu5XXvMXWyuFWJkV7WCUdHpUMO7ylUn72r7/gwLGd5/lLtC5+z4+wGBCANwadnq1MqhheQ23wdfOUh3RVnsM4E66Mp8vVDaY3kDssrfl34nzlikscSrshVaJciw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO6PR04MB7812.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(396003)(346002)(39860400002)(136003)(376002)(8936002)(110136005)(54906003)(44832011)(55016002)(5660300002)(7696005)(8676002)(316002)(8886007)(956004)(66946007)(66476007)(4326008)(1076003)(478600001)(38350700002)(2616005)(36756003)(66556008)(26005)(16526019)(2906002)(7416002)(38100700002)(186003)(86362001)(52116002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: n/jgfHwGsHrwXc383b48u6FH+tiF2VcIz34J6NYMjTq4gAXwO/1x7mH/V+02bb7Zx12ID0IxeYYvIt4Sz2WZerTguZDGLKNu8E6PV8lY0sUvOcqn6ic8Dfpd5j2hziyOI8XaBmKSyuehUlCLr5aeEZ0E2Lt4JQc2JfTaOxtCqmaKMsBGWLOsksq29OzoJwUiWO5F7sJ1nOMYlqPPBtFux9g2c8zA/d/ru/nu5IaHOrSqAemKtNFxsTWe/Y/x8TkPg2prtc+IZqoBaqVLC+2hkGMiltWKTzJhlSs40+cT2dWCSArob9JdnZcxoy3gO3nI4p2pM1GxObaj+yVSognASlb8e9DCnBKyj80I+GjsTY2RYxaxASgA/3HL4xFalKNtFZqdTIY6j/knmsnUZExI+DSBOzZLGHzldDbO4Pkmhz0nIZ1XTDTSYJkm9kZiTJ+2sD/vtx8KjOJbJBvxGnRp0txTg3RMEjtLmT5zFMWYpi9zZfGKligGzoMH3KMs4BhISjCpaKo3NehD3QPNENeECbZkZM11rLiRxGuwPGNPXrpDYmiO7oLQ1ZEbSJIszLbf58YuwMaQXZExm2drGfifeN2Ws+qU5nqxxy1t4YummucOoo/Qv5E8hC3BpHG3gP+o/ouIS2ipG7Z8ZW6ftrPzArfpciKO8z4U13Ij+RoCtM0GqnpA7gCuNgTr0g7Ep5dIdCL+16/RWBxXat0wRmSuFYPG0O/gdvlThqr98ZKBpQEpBDVq3go4knlGrGRTTw318k4bEMOoAYv4Ya+FihwhUJc6eX8hN+B6SSbSq9ki/Yet5qs24K08uF425+GfrCrWxs7ZPotvImSjRHrUsA+Q1hSj2E/3f9mgrO43tq3yC/bNWHIqAq29GQwwkOTPR+2VD6kzHgzLySLoZQkUKn67JpE+Zia2nj1N7/TpM3wrHAfl7DX+iCnMVTAeab1iholFFgaSTT2m40IkK3uyOhSfm56YN7jmwcPB0ho2rPu2rPCT4BfKBGVAlysfmM/lwu4mZncEWBDirzQqydni28G8duCPv6JCEjHT7In8G2CJoMq+Ln7UDZSdM75D/F+PZWqILlgmEqwDybnurlz0Oj82mrWtUC7CkvBkC87Nzk+7jLxeTQfqHcddw9jNDfE+9Hv1ttnXGqfDeuPiML+MPXeLJrgp6LIwAFOQig0/kXnLC7y/W+aSOb9VXmy9M5RuVddiBB4Yf5Z0PLODMM+ZqEHsMx9/q6IVZlkOiCiIXKespumhQBvlMwzAK3+kkN+n8uAT4Wg/cC1yT2wMbAbYekx/cbmqboVWgYlj5MhVwJiDd5ym3XnID3RI1BRDiHrTMfv9 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 65dac918-0717-48da-fdfd-08d92bcfe04e X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jun 2021 05:23:27.2667 (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: vh2xjQs/f38fCxsfV2bzfW7QwX83gmOEx8DmrAMrf1N4o4ZZmGAzNaF3+JMyjcXDdR3OHl/ZijwFH3YTKaq/Tw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7778 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org We enable RISC-V SBI CPU Idle driver for QEMU virt machine to test SBI HSM Supend on QEMU. Signed-off-by: Anup Patel --- arch/riscv/Kconfig.socs | 3 +++ arch/riscv/configs/defconfig | 1 + arch/riscv/configs/rv32_defconfig | 1 + 3 files changed, 5 insertions(+) diff --git a/arch/riscv/Kconfig.socs b/arch/riscv/Kconfig.socs index ed963761fbd2..3ae937121a77 100644 --- a/arch/riscv/Kconfig.socs +++ b/arch/riscv/Kconfig.socs @@ -27,6 +27,9 @@ config SOC_VIRT select GOLDFISH select RTC_DRV_GOLDFISH if RTC_CLASS select SIFIVE_PLIC + select PM_GENERIC_DOMAINS if PM + select PM_GENERIC_DOMAINS_OF if PM && OF + select RISCV_SBI_CPUIDLE if CPU_IDLE help This enables support for QEMU Virt Machine. diff --git a/arch/riscv/configs/defconfig b/arch/riscv/configs/defconfig index 57a24d40d43f..ed71f125cbc9 100644 --- a/arch/riscv/configs/defconfig +++ b/arch/riscv/configs/defconfig @@ -20,6 +20,7 @@ CONFIG_SOC_SIFIVE=y CONFIG_SOC_VIRT=y CONFIG_SMP=y CONFIG_HOTPLUG_CPU=y +CONFIG_PM=y CONFIG_CPU_IDLE=y CONFIG_JUMP_LABEL=y CONFIG_MODULES=y diff --git a/arch/riscv/configs/rv32_defconfig b/arch/riscv/configs/rv32_defconfig index 97d899df2445..0088d6989332 100644 --- a/arch/riscv/configs/rv32_defconfig +++ b/arch/riscv/configs/rv32_defconfig @@ -20,6 +20,7 @@ CONFIG_SOC_VIRT=y CONFIG_ARCH_RV32I=y CONFIG_SMP=y CONFIG_HOTPLUG_CPU=y +CONFIG_PM=y CONFIG_CPU_IDLE=y CONFIG_JUMP_LABEL=y CONFIG_MODULES=y