From patchwork Wed Jun 9 12:27:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 458176 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, 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 32C7AC48BDF for ; Wed, 9 Jun 2021 12:27:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1CCDC61364 for ; Wed, 9 Jun 2021 12:27:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232413AbhFIM3m (ORCPT ); Wed, 9 Jun 2021 08:29:42 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:16006 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232285AbhFIM3k (ORCPT ); Wed, 9 Jun 2021 08:29:40 -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=1623241665; x=1654777665; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=Pu9Io5ABNyIwu1+haflsV13kIurdSAe5IlMVtkIEsvw=; b=Dn25EBC5nv9CqvmTzv4TXqqUEJ13SnoYpsA2tb9V78h1yKgb3pyLzFo8 kdDzrOcuNBOQ6IBN4zkt4EI38WJ1wRhbZol+oRPinZnQUpR5ag3tdpIaf aNuwJ8oGoSYyxwLxyjZNhzCP2EcURGwvKfjSlSnaDF6pYeToM6C7/+VmS 401Dd9VMOhd1WdQnjJG1F2Z7c10UI2cbIEjN9e6K2KQAvG/VdD9/scXd4 3dxlnR92QSUh0jCj5Xw7C5NvHln1uc47c+2Pyl5yiW6mvrejKmLbpBLjg 9PTKlIKdT78R63m4BuP2W6hMkRRZRvBxVK1RiGXMDnfKLi5mccB2S2oy1 Q==; IronPort-SDR: WVNf6wf1IFkdI1xOHY67LSmMhrIw9LAW/Tl2SqSY4iyNTw0xgiuSSLBhpPFGd1fI6NhKn/gg6y X9MYxmVOSqXiYc/l/4zF8rONujCTH2lH7UvoQ3M44VHr/dHIjLTW23XizsJevSTK3tQoUYa0Dk 2Rrp7/RMfHHuWD6/LBAXROSt5u8yJO3x7MKT+HyZI5Q9Qo9nikd97lF8OaHpW947MQLu5la4Ub Nk3wSrffsZdCmTs4vujN0lTpHoXLwrOiC6p1FtcSoZm5Ft+TDfrU+VbzUu0dyZJ0s1rnn35bfz dD4= X-IronPort-AV: E=Sophos;i="5.83,260,1616428800"; d="scan'208";a="176057718" Received: from mail-mw2nam10lp2109.outbound.protection.outlook.com (HELO NAM10-MW2-obe.outbound.protection.outlook.com) ([104.47.55.109]) by ob1.hgst.iphmx.com with ESMTP; 09 Jun 2021 20:27:44 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CYSpzmtnQ1128XYkeINRehlA4UMyEVdLz+VrCO8nHZ33HNBILtdN9G9ujK58LUo6QmG1REQORYYPe1puxjzOuRP9vvz/+dDD0KU1CaNrhYjbwGZaFYOBwLdVaLiUGeMIq9N8stgP6fVKQXC5b+YpQyC3fALznFssj5hN5/KMUnnCQ02CFSdFvOy4ac4kTLfGOFpYTpF1O2u9xCMSToVp8s4GEAFKNG853hu2b3VdW7tuNg0aR4Qu9tddayBpwzWQoMSIiLqfbB9MIWEjxdr6+fWNEciqysFQRleIfb5gMS4iIA7U8Gio2UcxWjGKchMN1QlMHIM3TPN7bw0Pu6l6ow== 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=DaIG8giJPucapmTKP7hd1yQCYJzViQc0As38Dt0HKizfrBxUUWM0PY1wuWHe21pNSMJ0veutHFuUXwLlqMPt3HDzIfTMUv9J0MRrV72zL8wdPb0pYNUE0gjIq8AePbGMYQla1y5JxTQ/YWFH8ZC8w7l8g+d3f7Ewf3h7ILmVaxQRK5h97PPSpZAcq+enWBggDYYkYwUasg/0ez89Qsl0WUFVDAD2YjrdcgzHjHTrsHZMVPNRivQ63gEyoahSFPapfKUSgSk5NRTc0xQ/YG8uy2veDBqJlRsBLWIfF5M4OZPSqWs6f1AjURM4UFPPrXtD91k7UlYNOboF7JZyHpM9lw== 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=gjjrL24dSyRWIKwyAO2R1zb4n4GLOPI62ZySlfi2T/xGdOZg55BAqy93z7uCrpEkrPLTcb60G01IZ2L3vjnrFPrQ/6mSJjGF/dGv/sXRp1P+zgYrKTqwbfXmDRRldWNwWJRcvNHp3HPDQWr45ZP+4+niarJJIYgTKdsSaSPiZqs= 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 CO6PR04MB7843.namprd04.prod.outlook.com (2603:10b6:5:35f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21; Wed, 9 Jun 2021 12:27:44 +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; Wed, 9 Jun 2021 12:27:44 +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 v6 1/8] RISC-V: Enable CPU_IDLE drivers Date: Wed, 9 Jun 2021 17:57:08 +0530 Message-Id: <20210609122715.3389-2-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210609122715.3389-1-anup.patel@wdc.com> References: <20210609122715.3389-1-anup.patel@wdc.com> X-Originating-IP: [122.172.176.125] X-ClientProxiedBy: MA1PR0101CA0033.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::19) 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.172.176.125) by MA1PR0101CA0033.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21 via Frontend Transport; Wed, 9 Jun 2021 12:27:39 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5b057f37-8e2f-4fda-0846-08d92b41fb3f X-MS-TrafficTypeDiagnostic: CO6PR04MB7843: 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: 1oavujgbm2iSFM4TAWVDNwTYuGKphe7kUhkW/BigT2WhuqEyv36vrUW2jwsfu82wNC/QZq/8BYaM5ipfmTuxo+sp+rOsv/XzVa8n8+TNfDZx1d6RqnPhUEoDyxh+dI7kMEAYYpeSG2WYfow6v7nF73jqQNq1WUzLw50r/Y8DIUS78oNHyTousZqsR0HN39reVc9JEiOpjk7fabw+QZOi17XptgCa+N1pT3hlb03r1YXUfgLsW8JqsFvIjm2Dg7PS6X3glfJQKysd4DAm15UfnnI+cyiOvSxJ5+dihyyYoBNk7aKwzkLwlX4al7IHl35rw5hiES1O3yOWVmQCrgTh3Zv/NCr89UaL3Zlf/4CRLa8+E7ZkboKdN8cSuQRt6ta1GBFwri6F+c4rQoVUQAoBLx9AhcxuKM05IcPO3h/CA/eNuY+CgYS3T9n+ltiM9oUafXMyhQwv8Dx/W+GqjGtmNifEr3aN7FkFOXi6sKItaH4qm8+0zgevK/7AssFsTShBhUd2nTcxmtFqSCpbjT5U610X7EpwQZX4LHmjmz+UkqrNe5IZM2Ml4zdWi8JROgcZNoQVeuFC0WkMf5sgqznXTL4/K942f+3WhCbXldhGY9QaALxHmPLiWu1Jd/6joMBPEzpOR2OSIIJ5v5W3pDBW/jEgIrRyxW6aWN9uqwvkiH4= 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)(346002)(39860400002)(396003)(366004)(136003)(376002)(7416002)(4326008)(8676002)(8886007)(83380400001)(478600001)(110136005)(956004)(316002)(86362001)(6666004)(44832011)(2616005)(38350700002)(52116002)(2906002)(55236004)(7696005)(26005)(8936002)(38100700002)(1076003)(55016002)(66476007)(66556008)(66946007)(36756003)(16526019)(186003)(5660300002)(54906003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dluenq+J4JMstodwL+wKWbPYDMb5JpD5ytua/6IuCiDIZIgNNVE7R/59eIj6OY7+78iGKL+1vKaz3JTAXxevAgKBLY6aZ1GUbeROQXPFg3Lrqse3GcOgis9ILDHf1XQvK8zteRKAXwz9failHwqax/LAoBRRsc+8em2kXz6btlW61mt16myWZX4nNM/QyCIvrVxUcP5Igjylk6/Rgu6X2ML2n3LNI1/M8oD3HzDD6GNq1vRzeNkaBvFSI7dvcAQeysqsQqrAdEjL+xxK8Yt+i1gTDyoww/rhj04DweUGIDc2esgq7DtpT+YiaiHXNjMkQaLAbLKnrykElv/iOzSbua/W9klVrstKWv+0wGbONaovR5zZOEL858pM/m6F1pqH4xzCxsnYF8a57+dxZH4F5ndZlTU1GImSoIOUpM62PjH/vIbPDdrTxN1pOd2lwNVLIxlZvHDJvU3s+uzDDIbH/oezNIXMu6p0myDegJDDKboLWJyM+ZRhzGTkKrZFF9za2EA7EQ7uKJBRXdnpYs7u9rcVjfQWyp+/YHtG9gk6gPz7iBRL1PPS87q70pGoxE6Qvzir23+XEm+W3iz+bSi3+qfapQGYOlVTlRT5uFca0nA+01A8XstpjNLY9FErEr4bD8j2uiaq6cVJSHu0MLjBlYCa/a0R+8zXcZ20HZZbMwi/k/YCnBo3yQElnv4JGpfEGyVe2/ciu8k9ehsAA6ero7JWcR3qgKIifBP77FOM+oZ1bIv9GuRG1oq3aWkIeO2K1nC55LAAQCvMtYCTFV/0kUlP11Ot/Ydg7IxrzezphL3AnsmegP0kblb7MVIEudFwqdKiNbvP8A4CcMGfq2MVEk2DdG8AWGXnnksnq2cWW3myNdj4dB31Fr5rhIWU+LN39Wawcl+WeUayDG+z89RSh52bhZfSXeB89BDPRo/QWy74xOwlYmWBIGd97yfUviF/6FhaprRF7jFE8lMrkuGIvD68gySGmCgmZTBlf5NIXb+yEn1KCDTDYRsSwC6AYn3Zl+C6WBMnJkZsGpqjChDMQYciBrxKWNp+We/bBh/9zYFgwS3XM38pWtsHcbWlrCM+H111vx24LqDAztSvjQPZmgi7KSKvbiycdfxuiIEprUkgL9HcVTZ5lCg5skpZHY+HlsyQFEdyP3Y+UIWTnc8bw8/wR8uNJBmCyKxWowfKI4+S8NTYNQ6y6cVjtxS4C2mjw2RNDEHc5VTdou3CBxVa7E5mAjCgRZ+FbQXn/r7DRrWP6jcqP8xRCKCfLoeW8T2rnMz754jyJg7vd8FmOeCSKL5ZHJN8HciYEJcVfU97YSaDPKw5cS4jrn8cFKRHObul X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5b057f37-8e2f-4fda-0846-08d92b41fb3f X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2021 12:27:44.1360 (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: 1w2vWowGjr9eTbzdZmXqkKRnal3E2yvLqUmI9XJ8h+bISpJTlY6Dr4MYfjqtoUnf+VJymhRpKWz5A3V4Td0b8w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7843 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 Wed Jun 9 12:27:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 457221 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, 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 04A83C48BD1 for ; Wed, 9 Jun 2021 12:27:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E35476136D for ; Wed, 9 Jun 2021 12:27:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232704AbhFIM3r (ORCPT ); Wed, 9 Jun 2021 08:29:47 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:39855 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232602AbhFIM3p (ORCPT ); Wed, 9 Jun 2021 08:29:45 -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=1623241671; x=1654777671; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=qMoC26aE1t/imsmMoQjUxEhGnzi1b1hiqgTM5NyeOBU=; b=lCv5jTU/vSx79683s1oy7AmNYl3Kvys7ZC1QF6LuDSMlwUuNKiGqDFJI IHw7jUVUa53XIQNUtTD9gBEOOAnhwIWc/s0ni14OTe/6+suLDtpt2TprJ AFx+/Q6B4V63j7MRUggariU1+aD5E+lO+ghoLoxiZ5C897HwlL4e/fhOM 1gzj8cfcJ8bu8b0k0N9dJXqEaKrZ+ZiQFhYcTAqU/HHl6dtD8sIgE2DS3 oOYBT6jD+rn2dEA+Oj5VO71pouF8X0Im8J4ZbWMH+p46yEhqiZhPBfklh cNnNPE3LdaBfpnhfi/Ldkg/tXRRy+XOqum9VnQH9gmZWgrNcLKOFTKehi w==; IronPort-SDR: tfsHaM0w8h+akyO/rFgRCf3KBtXuQQfcSjsumDjGmSqEyeBsIDZDklE8MQJvLUPb5RNIH6vZ44 eZbs44Ds1ZBbk8Htt7yGXKbOa6VPOI+kHaqlk9/8+hfRdO9LE+sxU86p79z4BwdQYw6Jj+swFx ytBuMcxzSAIK3sE1TCZU7iUmxCucUEdF+FZvDiVE7PtdAhuQjTb5roXKtpr51Z8dtGDLR4TdT0 fHU9n2ms0JcoOI7jCIm5kobjdkteAWHfCdAb5judzdgFGcSh7HacyBVpYleTcYmzLEarN+K798 jZY= X-IronPort-AV: E=Sophos;i="5.83,260,1616428800"; d="scan'208";a="170576507" Received: from mail-mw2nam10lp2108.outbound.protection.outlook.com (HELO NAM10-MW2-obe.outbound.protection.outlook.com) ([104.47.55.108]) by ob1.hgst.iphmx.com with ESMTP; 09 Jun 2021 20:27:50 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UJD1MsLucIOCfRuiRC+h8BWuFrY09jT+ZNGhL1sneEZKsYzqk92czclw5mMKMqWP5nGNF0l9rPpOJr6FYJs7TdbJ63NWnLLvdz68VCRiXo/sB4FaDoH7wc4kSHZvoWIDZ/NmNcnKVWI/QMTW9epOk0NozwDuHp7ie7tO+2R2n0hkLaZND5S6Q9ah59nMYJU59NQoPjMypbitJvlrkQQhQVxG2rIr5oim9+BvKWXI5I8nVsvXTutQAQpeiDWuv70NlfyJntdOGPP4mX45B1qGx+329tffAGkGgrsStYAoVqGxeBIlY+v0g8FPxoJT83MYp/xK02irscsong269eRT2g== 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=F3G+8zpfzRUgEa5AEBTL4JPi9sx2hy1GvyXQfO3U57je4Ak/d6P8gieoNQNHJ3yI0VVNgDAxWkTDJ9ytnD42qwvXZYXyUdM7bmJZR54OkZ/WO+U4B4ZaoAtpAwO5/CZ11Xkk4mUELjW6hIWw/ZuAniDxpJ3Hga2X3kBYBaAUBSfA1JLmxEYpLMQNtFs/5lHFgjMybYqiCyUVvnRh9wpdrrwj5XS2EveIPCUIc3MQeIT2PTjJXMxhoEWLewhRidBMTyDqQyx7iA2fzpdG4em4YOWG05/33TGZ3Q5Vdr4uGu+ftH84DTjNJdhxcjnOz3AFB6YHJx566yMnwEzFQ8NE6Q== 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=D0Nj55Fcgm2YDNXsQ1Ui2gykoRb0Du1rKNWcw+tWitHWRhZp6xSIqTiilywzEG7GuJfTgt0D33vfvTBh6PVT83kfR3Lg3RSVHwp1Aiu7EiQ9QKFzE4lhXYgxQHmRLBhHcPW1+6m5jNJU1k80MF16BP8eZhzC6T5WhYd2JSR7dPI= 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 CO6PR04MB7843.namprd04.prod.outlook.com (2603:10b6:5:35f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21; Wed, 9 Jun 2021 12:27:49 +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; Wed, 9 Jun 2021 12:27:49 +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 v6 2/8] RISC-V: Rename relocate() and make it global Date: Wed, 9 Jun 2021 17:57:09 +0530 Message-Id: <20210609122715.3389-3-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210609122715.3389-1-anup.patel@wdc.com> References: <20210609122715.3389-1-anup.patel@wdc.com> X-Originating-IP: [122.172.176.125] X-ClientProxiedBy: MA1PR0101CA0033.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::19) 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.172.176.125) by MA1PR0101CA0033.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21 via Frontend Transport; Wed, 9 Jun 2021 12:27:44 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d1cb98bf-aef5-4ba9-208b-08d92b41fe6a X-MS-TrafficTypeDiagnostic: CO6PR04MB7843: 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: CtJ7Fyilkn+FAzPhYYRMUiTv7fE0VxFRryfOVh0VOoyzsgrG9SXu0edZO9xxDe0SGW2GZ8md5ViN0X2+NNH8icmNqC9/JppVOc2ERrue6x8oatrQjOxfM0a1CDfZrqvvyB/LW5Y0Ch5K82I3SNbhcnfWGwRwCxdpFxOQuKM+zYh3AFtzaGUKA+9S3dTI2lqes5oAVykC2UiR1QNxUc9t76mfcJHRqtcn0v4MDaqh8kVj6SQX4JPLwe/iw6WdCjHitnMnFFA6GmC4vvjPn0SCQ09Xmjz7bSKsJHAkW83m6dtjR0+jVcZPMSsoMYkIB9V/QXPsZ4DAXRIXd7QJg2FLkkhvjEkvLa2lUmwsyg7WN14+4wNk/+Ets8zV851k3PbAT6fu6LvwGM7+Sj0ZEGwHS/t4+Q3c3FEvkLqmaD8dvoIyhOFf7Nh0c5W8jdYlAONWhZYz0+NC7Ymhvmyl42uwbHHFBB4SAf5PmEtICMzy0N4TjEFOcFIMDYcNwOzf7Ol2QtXA9Fr+G7bGNJGwRrJX7U0USKqxpxh5WVmQoBuXtSXqTnUSjHR382ha2l+uSu95OcoUWlKqfOH2TNVLn2WzawR9z6/ppdl67oVDVNv/rEEXkOqyz0qVJaKEAcccsCuyh5S1n8zRFBileQEJNXFYPQ== 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)(346002)(39860400002)(396003)(366004)(136003)(376002)(7416002)(4326008)(8676002)(8886007)(83380400001)(478600001)(110136005)(956004)(316002)(86362001)(6666004)(44832011)(2616005)(38350700002)(52116002)(2906002)(55236004)(7696005)(26005)(8936002)(38100700002)(1076003)(55016002)(66476007)(66556008)(66946007)(36756003)(16526019)(186003)(5660300002)(54906003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: g1g42yiLJYrS5gtP+/A5rctfnumkjrjAhW/FDQPnPyvGZwW95lfPayCfXd1E+RLY0nP4WrsBB1eMWWLtJRjRZcRMOVmO3JvX1+zTpmZa2+kon3QInLAXalo2ws8CvgPVxYSL1wpzH5sqcEYzOLlXoAP6ZEP/BD7Qi9JwW24B0UMkg/+GIPY5hSQy4VDmvXBK6np6bmTORjgTfg+Iv8AOOIGKubiYFr3jWaZ+VFirR4ewpoIZhx46O0DZqKL0VJIaw+vEtCKObqXf7BwGGuGtVDNY4R4IV+9dm4Gs8NRi0Bvc6GUxx58rsls0IAMY6dRNowKQMFaftX8jJSgZdABnNEdb2AJuN3r+IquO8GkQwDYJg3i8CJEiFaBz2LqtPWRoHh4RF5FmX3tp/EOpYnYzCJDGOy4C0Hq3ZDUhQXlZ95co5o/dBtkHnsV1DuPCplPEVvBb1TaDVR4aVgMWcKftwS0rYxqWskSEjHt2RE2I5oV/7Os89xgzr0kEcl5o+VrUmPX2jVeLxZ4mkgcH7ZV9f03rSbwLiLE2a8LsBEliAy99aV6cVR7uZJ4JWcp7xMYiXZv9RHr0/q1IHBzDJMbELl/BYQvxgxS34pTpMxyDyY8R0T+S76CZz5C/vMoL3n6yVua2bfYObg19WUkGqpztMlQEWZzhEBOXPdmcQtLxPYiNdnF2DnekfjSwJqAfaaaX7JUM322tdHY3tNhH7d+mg9tg1Zt8RuvLKRrOg6rh714AtwQ3cSOZ4nGZmwDtbqgN6kMQi9HD7pqrgOC/WZFce/X+3ave5nAu+z4ZZP+hb6zQOyhoeAARAaH+7BU6VQOstJz2ruf/+oXJirQjQB3P6qMt/HVoyeN+R6W4fxO3Bs7Css2webPjVzxfxR+SK73MDVO97vpZ3EYdAuNBG5hEGtzBKkkRQ8B8kwLqiUlW1prWC8P9Yw8qpZQ5szI+BtNaRZZOeonc8xWZUfB53pFteOLPrqgR7pL9KB6OzRfXzD6W/SnFC2w8+lBeRuMvdSdiY7g01wdystWoyn7VwdNtg9NDzZnPpdwTcYN2mDzRuadfgC5wptky60OjhgBLdUtWI6C1aNFOHE2NYBBlsatqEs3hIT7/jIB9/zafBuxl/oF+c+8yuDQC0tq2c7X3X/jH5Ly8PiiT413X+jBwoi/OGUweY6M8pyCdQjDAs94845FeowhtGTHK4II54w1vP3iwpV7QglQQnvY18a4/rQgk4WneBPqxfYVOZOhK30svTmsjRA1vsZsWgjEMcrSK8oKF/f6SNRtp9SIbYNgo2UNerBHWssrWw57XjqYTHkCOWls+kSee3lrdVkQXkRa8Rt5Y X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: d1cb98bf-aef5-4ba9-208b-08d92b41fe6a X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2021 12:27:49.4854 (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: k52SNAzSqtixTzYc8PqKLkO+QPc50lne7Oim6Q4E7MYlMvdJfavMXWB/MTSzNxzrUTN0mam6BUNKLTbpexfvzg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7843 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 Wed Jun 9 12:27:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 458175 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, 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 47EFCC48BD1 for ; Wed, 9 Jun 2021 12:28:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2A45C61351 for ; Wed, 9 Jun 2021 12:28:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232285AbhFIM3x (ORCPT ); Wed, 9 Jun 2021 08:29:53 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:16039 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233036AbhFIM3u (ORCPT ); Wed, 9 Jun 2021 08:29:50 -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=1623241674; x=1654777674; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=WRiii23Z6QzfuX16+FZ4tI7GR0aXkmDaWpjIGuDJwLM=; b=Av3DdaGW7DbYKigufHY4W2g3nOXyM67ftSO9EAIZvM1ClN8KVmDlZ5qD KOGYfbtDUAR9+2oUF2FjX5Kzh8fYqVmIv2Gx+0oqb83Z8EQVG4VdNTDmx hQ5ZWL2ftWpFmVlSgTlHYGHYxdmwpZW1YoX1gh7pAhFVmVQRas1nJUOdj RtdadMG1wIxT48vnCLNgZPOlig8yu9U+9keI6H/VsDxHpXEr/Wmfcmgiu XMbANmf5uZkvxtzbZ/Crfmgac9akP+bTLYsdaCI0KipGGN1AnsNO9mdGV JMyGwK7anROoZQMiPIFaCbdY2O2Y1ddgnPJtBQO+EbCeTQIydEMgY8l0b g==; IronPort-SDR: qfRcQNAnNiKjER39EdDhUMI7UE339klv/JWf0nKDc8HjYluBFQ+K13iHH6q7U/fLs9Xkqm+j6K wavr9Aop/z4C/WweYjJvwLzqXAQn8SLwrUh1FFiTjlTYBasAoGe9OQlj+ElazbwTKEBKrTfXZm qKMowLAQRiJMewXrshe2fEy4tC8P2hipEVFc3n2PnDYgGmPS1P8K245mS3KzNdtfV6arQcn6z1 XkJzow6sZbdXLgoFU47Obx/BuHnU7JhYMN33ox1RPhDi3V7QhrBR4W4+xmCMQPQo+LEVBOOfHp I2s= X-IronPort-AV: E=Sophos;i="5.83,260,1616428800"; d="scan'208";a="176057726" Received: from mail-mw2nam10lp2103.outbound.protection.outlook.com (HELO NAM10-MW2-obe.outbound.protection.outlook.com) ([104.47.55.103]) by ob1.hgst.iphmx.com with ESMTP; 09 Jun 2021 20:27:54 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Deh9z1I4mNys8hX1zj1OLzNYix4/Eeh9unWbML4e6tu4HUla6KEjOmIC0NLwLGa7li+tJ+VhD7TFn48JqEpXKkZtOUzeqnQ2rH+t3GuE232K9yR2tNJ8gM3s8fOfXFd196z+v+/5pv/XbCZtScB1yQHbq3zosoF2xyxwpKJpqlhyqv96hs8ywhiVz4/P5lfF+iglLfKEvYVsbuG6xQ//x7Og8bkKSjGEdmAg4lAwaIpJj09WUbcP8q0nQ2mxHaAP/hmNIkWf31JDODztcsERvocHjDNuaipAzRYpy2uRlnYwzoxYePoCPLScftvDYcBnq8IAgamYOSjhsgZVcUIFhg== 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=hSQEaWGPb1eYy5E7oUwSESqablv/acCoyfy/uUslCLA6FKxOsD5zo9+ZzegmEKdsfIerOyDwUIAz5EKz3PfnPQymTZOcKtHLULEOAT0vQz2mmaxp1PiTKG60moCCHJlI9PZJYt295cD1lPv+rgUB52/KqZ9Qr0MoCDBGpel5Q1/tcx04/Bwysbvfqp3FsaCLJodtwNNk3qfSLkJ3oQOCDcGepqy8YWSHnQ89jAP7Zpdoi5ornGW+gK9xuO/mvnEi7ke0XbIx8dP4BVzrldSCAMDBq3jEdkfEuLfm2HmXRRkeookpIGqGhsvye1ugEtyv+ScDWerNk0gSTeQMoaFctQ== 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=b1J4+pbuMaYXA5jFPU13UpuJSdfdTjsUpdjd9hPgOK7Q35OkNtIUF4BC0K+cy2w4l3syFmDoIboaMW7XV1LSvu48+cuWEXE6ktX99Lh20uYWtR6MxLU7nqVUb7qveg+/SP/3iFpQVt6zCj1MJ77gr8wB+pcNcZHKV9lG27O7Jvw= 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 CO6PR04MB7843.namprd04.prod.outlook.com (2603:10b6:5:35f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21; Wed, 9 Jun 2021 12:27:54 +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; Wed, 9 Jun 2021 12:27:54 +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 v6 3/8] RISC-V: Add arch functions for non-retentive suspend entry/exit Date: Wed, 9 Jun 2021 17:57:10 +0530 Message-Id: <20210609122715.3389-4-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210609122715.3389-1-anup.patel@wdc.com> References: <20210609122715.3389-1-anup.patel@wdc.com> X-Originating-IP: [122.172.176.125] X-ClientProxiedBy: MA1PR0101CA0033.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::19) 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.172.176.125) by MA1PR0101CA0033.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21 via Frontend Transport; Wed, 9 Jun 2021 12:27:49 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e1e411c5-b1e4-4c7a-839d-08d92b42019c X-MS-TrafficTypeDiagnostic: CO6PR04MB7843: 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: mbX21YGzuQI4QqqHYHX8iW2O3TvNDhW3VvKPS2CUUwIBG+Fhc2bGORPunzOvV3t8IfxLSdawCmL0trxk9OQUPROjUP4/VloYpudI7pjdHkfoTSd8r9b+pHvCMBi1XWbP3gVKaWgp8+JD465Ct40crUtyxMjlBscz3Sb2SHpCMg68bbkj65IWHq5w1C3ytmwxDwmBV4pgWkO8ggaRsB+0at0/hO3h1SusLxux/p6cg+jSwUYSHaKJZl7KYwX/aAnUawwVqcA+7dW+f4eGQMW9Ze66WUYE8gWr1zBk9jE+6ITWVSmpndShgfIQL5JjCz4yS2vF38ZcUY8Zp8EWpsDwBl5cE310z+NWD6yP94SBQgwZ2sPAvTymLssaopw2GkpZrWbjkEuAxmiGt+XKBkLvmkg8ya2pK0lhzjoj5PxUvxrEu+rr6VJOYd0SwOZmZPAg5T0OJq7KepmT4mTSZurjtstJMmJuW500DFmjAWkuDXcYZvBrGinCbb9N+G89YdCJhgq7YNTFRalsIWRm+ME9feVjVLdHas8kE8gaEmTutCZx/cP3olgczU2bvm+4uVzGpJhwL0DHfhJABDMSiAhCpNC/XzAlwlrc5ylwQG5++qyRdY4ywSZdmn6UBVH7d01lH5LOvpqYoywPIcL9+i0uRw== 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)(346002)(39860400002)(396003)(366004)(136003)(376002)(7416002)(4326008)(8676002)(8886007)(83380400001)(478600001)(30864003)(110136005)(956004)(316002)(86362001)(6666004)(44832011)(2616005)(38350700002)(52116002)(2906002)(55236004)(7696005)(15650500001)(26005)(8936002)(38100700002)(1076003)(55016002)(66476007)(66556008)(66946007)(36756003)(16526019)(186003)(5660300002)(54906003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gZazl/rDpGhPmbJu7Ke4td7IWlRjUkZ6LWH+7XLK7NemJXEVBCBvDyRGXDlaysv0h9yeQJilDA8CCA9y8vczO9EwR7c0krWdPRRuBMt+TLeIL6R+zaURtXXmY2v7wEj54/Yf/E2n1qRB2wn6NNNmjRQX5kyp9ZGUy+1RrvcTyW2+5abVefBarmwEUFF3VYSaKALfsimz+A1/MUIs6lab33hxSaPLLWPRNDP8lKcwkUZ3AEr4U2z9bszW/VUf7uI9+knUIenjXAM9TAtm9qOC0aPIFQrpWUTSkaMIHppqErpQ2KeUObBjlEtTAeWuwjBKveyAmLaFwEjpnfRjz4H9HXgp31TGoogcyJwV1XHrm9fDjxoifPnkOoHtAKzMzSjerns3j5Z7nLb6N83QA9yPaHNQbtVe4aIZnGGUGn0mnNSpeF+xSsWIyOTYhhJ5PZXRl2jwt7ebbDGVofHhZYX0LUoCcPBkv1FAORNxdH+poMfIvT3Ie2qos4eIUIvl6WV55xDqLcxU87nq9k44i7xJezcCTyekgmEtvacd6VTsDlYZ+S8Lyd466F0uvdjUVOaXZVJMIeRcglHaJgMWMbYRUeJyzw+jsqClnQc046FVsFu2AmxgxyAojGa/xUGCTrjHoGgGVLaOlPUQioEMvQtkj2Z8EggciThdkHTaarjxfj1FKzGDyhdjHZnfUKphV8K63LhwkLkK7SQ9VnndDHTgaXK+1GvAABsICLD4pARX5s5YhwPPmSVXVfMrijuyOt7MsnMYGkei/d6IZPhUNo6S5nwgv9atOLMxdd8l7YJCh5/vDkhW8bbFt1Icpp+vVKR0DrrEotCdFcw5lQjiIFpsEPScqigtUGWGSYeMR6Po8+1To6XYxPhN6OIPjCA45bfZ3EuX7PnAsbHRbIx1WChbduZ4QYWP5RLnP+4FRPUcXyLgjoYzAnkOwBfYuyTqHyHiYDzFjnaC2vyf2FWNT8jnWVW27XGZlTv4U4HgS50Ot5/CaJ244gPbiuSEYm9tGLEw6pjfou/oT3xmNPnWGuAIRggv9opE8+GJf4iaThx1Et0LTU09oCIo/YeuUAyHIosOEarnAsOtgpoEpxxeHF+cAaj48Y6+SOqhwGd6yKNBfkxcfKY27YdsxCgWLA0PJ1XsKMzzfJrdlhJ+eGqVKFxF2mUMsBFy/qitGWaJD114wSiOFgxNbKRIKUMVRRJXt9AwKILtO7Yf62bLxybQfEvZgeJ7H/0rwGBwhXoJ2GIabL9gQ296r8ua1MXzBguu9kyTaf/FzoPDBYpaje1UsnlksZoJ47lUqj+4/FWevaZko9JkOPAbWg/+XpABF9AkU7mc X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: e1e411c5-b1e4-4c7a-839d-08d92b42019c X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2021 12:27:54.6417 (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: 4gWuSFbhnHn75lVoxxmg9OjXtpJu2c/EXuowKVfVOvxBo4uK9W67e4Qbs+nbO9pl0AOGouRPJEDHwcJKGcXT+A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7843 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 Wed Jun 9 12:27:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 457220 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, 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 2CFA3C48BD1 for ; Wed, 9 Jun 2021 12:28:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 122E7613B1 for ; Wed, 9 Jun 2021 12:28:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233274AbhFIM37 (ORCPT ); Wed, 9 Jun 2021 08:29:59 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:54359 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233182AbhFIM34 (ORCPT ); Wed, 9 Jun 2021 08:29:56 -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=1623241683; x=1654777683; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=UeD+FgLO9aIjFzdKrHDcrkqDgbjr4ljOtP7t6+n6Irg=; b=iLE0r2r/X3zVTMBjudCkKhAn0B4liXzTHWycxbvCdMSqI3Y+yilf+8rU sCTJs70+k9xMsc3x6rkwhslKJ63/kedyn5WJevG2I685cXpUH0+EbCs7V YyF2yRce4bN7mE3PhWdyjFBCmNtL9oOr+hMY8UrAO6tqXh0Vf5gnee/GD JkvnMJfL1pF3yc2/yupsmFqhc4SM0AGkp5qJCO9ic2A9f96xC49UA3x3l EtyXZ4QL/mpVOcDsrDPUPu6e6kLVAFz3S4ahd9nN0LUrGjDCaNM9LFeAv 9v4JQzI5KyXKGCxkuusERLGX4PRktZirPJY5W7oISEhhxymTTyhh4MwBv Q==; IronPort-SDR: 7N2/xmiqv1OltcvYXSHRaV06Hv2/xgLUz4RWRtHWpPM3w9iqdwPIsf08EboG3Txh7hHKrp26ZY Vr4lxdL1yMUc2R3fsaV11ooBWpoprEKZglB9Y4CNwoA4lYa10UC3VwtcTtbTJB9s9qp+LFVAsG bFKx9YCXOSfIYcLZ7yHJaS8q32W6f6lasp+lMGmF0IbRnY+VZpiKf2i2KeGHFTmrSkWWYa5GGG yMuEPfs1Lk7LruSQhVtUknUh3KBVYzTyCoGvHUCRUioJsdeRXFe6W8GwJv6tvBUac82F1EDVVW 1H8= X-IronPort-AV: E=Sophos;i="5.83,260,1616428800"; d="scan'208";a="171847848" Received: from mail-mw2nam10lp2109.outbound.protection.outlook.com (HELO NAM10-MW2-obe.outbound.protection.outlook.com) ([104.47.55.109]) by ob1.hgst.iphmx.com with ESMTP; 09 Jun 2021 20:28:01 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RqDZVGczoCo6sxZ87DnK2OOqi9Fo4jp/eluePAzYMATMtvfqMS134miJqvBlBxPDiq4Dpp4P8fmrSyNxtUScoGr9a6Kc5rUUy3bTGCUgKCV+1fJtSUtPQtW3VSSF1Y/CRTva/mzg0HXSCaWQ9DWMnq9liJj+B058J26zAY7WF50y2wprkK0YxdZ+gNQ/Jl46wfhXOfaADcM49DB0TpXbxnd+EIQ1AahT7j1BQMMyu6ZtPE9quuCcjnBRUwwjQrOAfb1t5fC9jrg64v9QbCCnEnTot5mp8iqbm+5NnbAQk6VGFehXSswraUoQgoZCvXQqv/TQOK3f/Q6BUrK6QVpbtw== 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=AwZfy/WMDBeMao7vnfMla1g6K1BJzlHgeCDbMMglE4e+aou/RSu1xrHRFWSyy06VEaM/XhQ+Zgp0t6az3RKbq/N2zQG09zSC4pDQkEAlYQmD96FVJMJJUzjduMwMFZASMfjBe6+pDCXAC0mMtq+H6z0ajSYKWMZGd8ZPUn2S3onFKDy0MpDLqfTMKmkkGdZmDpZVNgNxdDACqozuhyT1i4m1M2Q8ZZ3B8U4yOjP8F2H/ulju6u1J+HC5ZaNE1t4T5tEysR90CjS3GMyB88J6pSKHIszocWkoLWHb9iqCqN2u86WR5aY9VL1j7OvjJR0dB1SnC+5Y+bWoNratiUp3hA== 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=y7JMSQlJXVAfWbG8TVRB0cMXwdo1iYl/qkq5LXy1g0BH6OSWBxcC1IQuXLJ1rzxwaMEDZ8Uvsed7oMOMmhiIjpq3KV//UzsEEuZah5cIsJg3q1mNkJAurcl9BAXO5FDOW8osdbyF5iqLvC03USB/48sde+/aXFSCnAeVIoK2tSk= 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 CO6PR04MB7843.namprd04.prod.outlook.com (2603:10b6:5:35f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21; Wed, 9 Jun 2021 12:28:00 +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; Wed, 9 Jun 2021 12:28:00 +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 v6 4/8] RISC-V: Add SBI HSM suspend related defines Date: Wed, 9 Jun 2021 17:57:11 +0530 Message-Id: <20210609122715.3389-5-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210609122715.3389-1-anup.patel@wdc.com> References: <20210609122715.3389-1-anup.patel@wdc.com> X-Originating-IP: [122.172.176.125] X-ClientProxiedBy: MA1PR0101CA0033.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::19) 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.172.176.125) by MA1PR0101CA0033.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21 via Frontend Transport; Wed, 9 Jun 2021 12:27:55 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 60d8c93f-66e0-4de5-6763-08d92b4204b3 X-MS-TrafficTypeDiagnostic: CO6PR04MB7843: 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: RHJ/7Ofpo0L0w1LEtfTPBso3uGMEMwRVem0hFK7n69Y0yXBW97jEpPBNYAl5tuPB8VCHz4vJ/bTz+LeCWlDJdAOt+8CJMHiou/RkH8Pu6I+gEzK+8wZYKZdEZUpgFZYwNJ6Mk7Jm3QkjLDrjcS8IEF1VVtxgsoB+Tz63wN55aQP+6Zjp2SNubOLdz+8AOELtc/XCdFzeCrPHee+EQU1d6LitMjWAakCmjizqIkha6y0vo4s0yp2zJTCmdepaQdvxzL0ztuS7whjs4EUHR/qThdjfPcnNw2lVghTTyX1fHCn6NJBcvWPNqT6fpdaDE187Cw1v23V2M60T2eYlVpzrjgABRCrU2+7wVFR++tbdio0F29+38Ijzxixlp+cl3Sce9/gtveOyTd4MgPYJUBQa0+pfIPFJaOPLI+LqV8xb3etidcXx2JnVTzpSlRCKnbw1upUTFFHsIF/dRGKEXHo1dQ/bnYhSK6s9Grbto1QlFvvgFNWQR7e4kKkPbNbe9nbCO+xaSzQ1xERIdQXPz9sM2VLdey9Qfslhuxy+X3zf2fLfD/RfIYAL0LJu/HsIC57HsHuUCZamBgoeUB+MsKEbDfv9QYNFpdhQxqxNkNMcI/GGW+jU6BAS7MHmJlONu2bpDQVuA1qOn/uTJX4AC1RBKw== 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)(346002)(39860400002)(396003)(366004)(136003)(376002)(7416002)(4326008)(8676002)(8886007)(83380400001)(478600001)(110136005)(956004)(316002)(86362001)(6666004)(44832011)(2616005)(38350700002)(52116002)(2906002)(55236004)(7696005)(15650500001)(26005)(8936002)(38100700002)(1076003)(55016002)(66476007)(66556008)(66946007)(36756003)(16526019)(186003)(5660300002)(54906003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VAjnGmjkcQmHtladAsrbGnudp63aR9G6a7e6IrnV9j71NtdVDhIxkaYyTkCCVjSHa7QAN8yizWuCM8McW4HseVNqC0qR6zIW42tEmuJDe3WpGH1k35xKHH1nt2wNbHw+kkGmZzg0hOnUAYFSn1rLq7Zk+fcwmBzVDnABIlB82SrNkDxBccaW6jrPkA62LlekHl5yraMkP7OUhFHVh3XOrp3Bj0DN5S0+N0RlRYPI949z5AVWOt965wwQkkeYtgTpEqJ+wzhJMtO4LZyANfb/aj5XV3Pmstwo0li/Ib0fXl0veOGTTIKuYssQbNP0K7Hc0IFh4mp3rQxokzBPQTZY7pZ/JseIjiCGnF6P15603wlRbGvfuxS/N194kCozNMxJ7WyV7KC/QBaHNTtK/q+Xg14V2xVL1vugHl2u34+AvhCMI9wh3ZGz3jt0G1+obc+aAmraqz+wUWJBboMY3XSoHstKsnhMRHSm1fH3XRfu5+FSYFiT00t9zYnDfPeOMm/PmCLodQMlK1Ee0iqgVqLwVA+KAFH9UhzgGa8orofnA6rHtRFUuHgtiWC7ogqepAgLnwjaTOr8Zc15QufwWMy9wc15jMrWyQoPgSxv5EWWB4CPQ0Ju3U7Lm30vg1WfFyJ+W/zb9IAR2uJm5Ceqdl304bPRdeAlyqIERiXHGqbLtPIMNRHN8SUGyz4aEUsXvbiaYCqYka12h9zjgsDo2s+17gGP+xFh1JuxWGFS2eXBkCK/h8z15/xHdRtANLMDlz9EeKzHxZVd7mVH7ixNh818Sspjhunn6+RgOZjBSI/OujV0sv8bTUEpeQKDWx0XmoCfCoZmS94Q1vorMheMS7fQGzMH3BNf6AV/0LKY2ijFfB8fp+dRJp7V+y8foBGhL2Mfu3DUEOabpfgiJ8hgLJzQh4yiR7/AvhMtCDif+ji44hY5cpnWdnY+1imT7XsRDgsswE2g6UJnRce+HfJPfzEskG6t91p4mjp189SsA3v9ZU3B9FfQhuE2KX40tX0Sz419K/ReXxgsRQwIZeb9+HmvX3LS/Pwz01vT6KFFYPDufZbRjkPIzUPfLI7FYMpHiPBgGq3OoL7uizYoQGUwAZMFFckpPN2w06vSeZfs+M5xbC39JfJJNvZ1O9AhgPbhNA9ft9iqrVKMif/BWlwmeEsQa/QumssGaDgM7q//1g8KG34xRSzG0Ooqp88jb8q8u2wEn/UMVdkfjzDbBUvOBjYy9z64c2ZC58XjEkkzO9kAUJPearRcXFU/VA5GoPYnzysqk+wMZNlZywOijZuCYJmTfK2+Elxy9orQfQFxudthPYAEQ6ECjFXkPBzhk+MnGw6S X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 60d8c93f-66e0-4de5-6763-08d92b4204b3 X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2021 12:27:59.8080 (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: f8Zw2rGZZVMeMSmgO9PczyMFGMijHObIDHDvbp/neIztsGH+sszsWhIaauvv7SF7jn03CMUSO0k/au/O0laCQQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7843 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 Wed Jun 9 12:27:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 458174 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, 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 69FBFC48BCD for ; Wed, 9 Jun 2021 12:28:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 46EDB613AD for ; Wed, 9 Jun 2021 12:28:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233182AbhFIMaF (ORCPT ); Wed, 9 Jun 2021 08:30:05 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:54359 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233066AbhFIMaB (ORCPT ); Wed, 9 Jun 2021 08:30:01 -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=1623241687; x=1654777687; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=nzy9pCl8zwYLJGc+tqg047HMq9wQYVcYuA1f89D7X7Y=; b=ovDHjpQxYEew2+6dwFfCuaSDKbAEP37TVY923FuxslX4l/oXmaIys0uk yEqal3IUkUcTihG2wq1kcb2TAtxAIBgvq2LgN7z7obTePWyMtj3fjmAaq MFKRjUK7sxjxzMF8Vml9CRwW7+xj8nbsuJtauo9OJUive19TYg1JsQa69 MMJBqMh3uNi0Jp/hDJ3tLDUZ4k2nDG4dIXL99NwXY1IU/88WtVSmw6C0e lsaPYqeUR/rI8yOVHaRCN71vQp/3h/QP+N06mETMXDDBIZk+xwY7c6WiK F89OLDxzq08xrYnjrWzTI6TUzcWioifcc2bwBWvf0d9nTW2b2gidYn2kx g==; IronPort-SDR: FvKoMe6UJ/q2so3vV7S0y3BFPDRpjTppQ1MRaHDotDnW+4cLWsJP+KbxJWIdduFMA+qKCq1ARP c+/15Y2zDt5/jXmOlSWcF6eoT4/CnyoCLqYHvpBQsFxNMA9FeL+FMa7UPGr4E7kzO4vDuLahcE fdZOFIK5lIjCnKwm4++R4WkNMp+9sYQP+8oJCiyOqf/74MnzfLeauAD10CbMaA3O2Y9aupoe4U +nT9/riFfsn7h19gspiqRf/sR31jcwD+DlsRu1ZSM15fv2Mad9j7F2TQyV7Ffj1Ob6t7vO2f2p G20= X-IronPort-AV: E=Sophos;i="5.83,260,1616428800"; d="scan'208";a="171847855" Received: from mail-mw2nam10lp2107.outbound.protection.outlook.com (HELO NAM10-MW2-obe.outbound.protection.outlook.com) ([104.47.55.107]) by ob1.hgst.iphmx.com with ESMTP; 09 Jun 2021 20:28:06 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RtgT3Hp3BczX52TfbxmdI95CFrk2SZxERxRYxHtW1gVbJAwJHH3LCc/gSyJhf3II1p7cTC9z377eRFq5DdNoq6c2IXs0X3Xx7OaXW612YY1uHaCRrpEeSWwiemQGVLenAfleo520kQX4vt6RAtVkYxbTJbqrZJOzl5Yv0A3GruJ+q90clkPr0SWwVwds0azk1eYDO71Kc87gSbVTpUlGK9vBqWnSkLcg+9ZKqdWpQ2MIjuG1Xu9f9l0SKwbggc++kb7WHaZd86+bM2sER85b9cYSs5cqUg7+W3j6Npe0L4ObIaGswxAGT6DiY8oWJkuHrBb3SPi26B1n/c6K888rNg== 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=QJLMtRl9o8R8GxzsSYRmpK92cVO+hkoQcUKTyuqjjdzkSNkZ9Opf+UInngeALasZwfo4YSEOVtg3e97OgPe0icHZ+efm30P4aHU7gT4jpBw6PFTzz2bRpEI1Wp569uBX9gee/EpdP8U8hlwIklNF+vwy4p2NtcWSN3Vk0plPIiFX2zO0vQJ8MyWqlGpoX33MIiWW0o9mTdpyO/vtm7560WFc/kAceZKPDv1LGbf0p4iKlKoYpefqinOqafirHkSvm7xiq7xxan/JKeUO5GQN0urhxOgt/h1rhc4W+HRlW1rOm6v0vvuWiawD8blJcXRnq6Btsbmpailg9yC16/vAeA== 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=C8AI7+VPNten9vGlizAu0vfhJaBvAEoi00KXqJVAhflGNLOU4B3suG6BLIzjmM2NjM6Dz+WIvwHBkhWttmVH+EB2ViP6WNjZFfNu5gt9728QdLz1LiWh9WiYaomF79XGP7YC7tJJQ6Kh3nEMcDS0pPW3B2hpb2rOq4bqsVFBZOc= 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 CO6PR04MB7843.namprd04.prod.outlook.com (2603:10b6:5:35f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21; Wed, 9 Jun 2021 12:28:05 +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; Wed, 9 Jun 2021 12:28:05 +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 v6 5/8] cpuidle: Factor-out power domain related code from PSCI domain driver Date: Wed, 9 Jun 2021 17:57:12 +0530 Message-Id: <20210609122715.3389-6-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210609122715.3389-1-anup.patel@wdc.com> References: <20210609122715.3389-1-anup.patel@wdc.com> X-Originating-IP: [122.172.176.125] X-ClientProxiedBy: MA1PR0101CA0033.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::19) 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.172.176.125) by MA1PR0101CA0033.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21 via Frontend Transport; Wed, 9 Jun 2021 12:28:00 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f3e3fb2a-fc9b-40f3-4465-08d92b4207c0 X-MS-TrafficTypeDiagnostic: CO6PR04MB7843: 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: MePUSvSpFgBlz+mnQe0l9bIg+FPNfaowS2kio+Eduz2m2hrpllZqkwFRg/Gv8PVYJU7iLKhqEaYXKf/+C5R3kXuNjuHcSMBYaeO1JcVG0R9S+aJ9BaMxUmO236OU7doSBoig28r90/2gsAoAlE/i7TsJ+DF1E58YiFgHe+RkvMxK+C9DQYal5B8T97c23ixYNFA+otO13C+X1C20uTTiyfisR1NjWzRPPjNdK9d0Dpxo69y3UX9FkfansJReJp5HPl0FNQKfOxJ8reFeDIcReRqGt/7H9k+/ChV2KQjZaCY4A8x8JfmxPTKPj9t1ESUwRgyzvv7HXXE7tCZ/Tj6s2zbSeUb4/yqX2O+WoUtyvKk16SLxvaDLR53FzzwvVFkzSfre159XRxeaKuHBhxq4FofUTuUwv+bCaKq/5QNUKHZafsZHOR2g3phEummMpnqnjwb7uDKX9UmhHaVTdgn6qxzieKIdyyBZU9+6Gdij4gLUndre15Xp+V5Xv3kJAs6Bq/ZAsYH+mD3C2HDk/aQ95Pu2HbCIhRgeIpYWlcfmYrwSQULD+j/beWyF7BT8uSHUQ2NKkapqnrx+DaOLeDaPMk+onq3UsMI4PDZBdg8gD5Wy1lm4vQEceeEeFskNYbe50kRG3MWhyNZHaxsLkXbOBQ== 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)(346002)(39860400002)(396003)(366004)(136003)(376002)(7416002)(4326008)(8676002)(8886007)(83380400001)(478600001)(30864003)(110136005)(956004)(316002)(86362001)(6666004)(44832011)(2616005)(38350700002)(52116002)(2906002)(55236004)(7696005)(26005)(8936002)(38100700002)(1076003)(55016002)(66476007)(66556008)(66946007)(36756003)(16526019)(186003)(5660300002)(54906003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AcQPtMHv9vQgNDq0q8tpHsOxTgzmC/Aj6GU4vIOaNFrCniNtJ6QRHJlXgGqqCvDlcXhN/zFvCHRqoJeExWuLUtelYVwFtNEFONSU9FEOO95wKOIX5WdYQ5TVBQl0nKaqGiAm7L3WetAt22iBJmq5eNGqFqvD8hy01WTg8Z9wXWj+0/6r+DAmO3GSm3GxsSq7fjFkRuMPRdEMPrx6G5Y97Ub3KaI547f29RL9MGE/giYjBt4N4ZBybxN42B1Iu7p3kGFFkrIl6Bk4WG0BFPIzXhIhgm+XFad444mi2LlKCNtcjSeUEz2hIs2auqtMIawI+x1BkmKriswa3vBBMUCRFeWuLCJx3FmrcYHn7MewLkmv7MhJQ3u4GOizRQLFeFjZvY3Y8eFV01f5B8PoHHDh6VtlZA1Ovj7WLIQZ18MPnFUWidEg4RcTyl7w1TRy0Z3OrhibglAVOEYXRAKnbBSzuN+PUyJcCerESJvKfKP7hypTN0IVaWjJRkeQdg7TqwUnWmRV0aZv98HSd0DlM59M0/fXPnps5VrqcVhFRCGH6KZzKhAGmhx2muuatUdkP0ZVNsUHyD2mQHaNntRO/CeOd0NKoP/oZG8sZ3WtTyzZIyKuhVMoiFTHM9pby8XYRR6dqvOyimu8vJSBzXl9pNLKO0tL2KyXsU6Njc9iNaJdiBunRfKCp8wxdaGCiH3nSmrHmTEjk+oA8a3TvEyHP2S+P/MxpFFEWErQZNHhyJMYpvx9qtH6Jqs3BDhFYLtQQOPo/cFYBnnrKLzzvIsIEXit+f4g+DMfG3Th6F1nbepT7hP3cQJxYPLRyLgRpz70mhqPEzpIgcejre4nabDHD4z13gJWTJVjUkc2Ds/YgqozaxlmpBjHSFC2JeBxiHuppO5N++IAwzju61WGfj77xtIF63rCjwit/8NUqQJP+7WI4PMmxpirKU8rTi8ql4TcsowBYGRr8No5sYMU/8B2hZiLyyBCT9C9Vf1SrcqsgHJ1zVxq4mnhlk6OH5gRSfsTK2KQYSU+kjVXL+eUXAzyQQaCvyLYclnLm2ggrRoDuwEVusifWnV4FvVv0mFSCtFzm1jWdaLT3tmNMVTEoTM8hwCzx4i8CgEsOtB9hpLkFBi0sCKtgBLPoWHQK7mDuiRGIFx2vqJfCKx9n/qP9yZc/wz/YIXJQjRStpoSSuZT3y08cgrkaZYnVwimxhPRwcF8+Ff9C4HmCCo7ZJEBbVuZhH1Bjp3M0j3+GE34x8t/akArPoX0p5G/zZ0Yom0MJJm6txER6lWayMc36NnXcPMLp1i2JDfYHQGEchMb2lpIYL6EWwlv2uDruIt1knbiiiWI6DhK X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: f3e3fb2a-fc9b-40f3-4465-08d92b4207c0 X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2021 12:28:04.9175 (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: 2h+CQhTZDJELzvT/hclBNae5lbkzuMMGKhrDlBos2s7mrtiqHEcdHk3+K4x7yOhqaPQUUR9jDVaNgZPfl18aKA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7843 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 Wed Jun 9 12:27:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 457219 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=-14.0 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,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 4876FC48BD1 for ; Wed, 9 Jun 2021 12:28:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2D1C0613AD for ; Wed, 9 Jun 2021 12:28:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233252AbhFIMaL (ORCPT ); Wed, 9 Jun 2021 08:30:11 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:39908 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233288AbhFIMaH (ORCPT ); Wed, 9 Jun 2021 08:30:07 -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=1623241692; x=1654777692; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=jxNSrEryjuEr8sDJcBYsY9HCSgDST5gnNG8YkzNiWj8=; b=ZARQ3EzQ3Whgo4bbOvOaqTYar9KaKetYO6xGSFj9nDNKhlmdzxqN+1Bu 5Zr8/PvBHdfqWO6NRcDgvsNbCnobu8OrEUMVdl9ZgMI7jQ7lXvS6+qLn1 gLD+bM2R1w4cdPSOm4yWStuvPaGGTxzPRs7XgQ92EXpGfG9F4+67UQPUM gMOrSIOH517Qgby18J0O8qkQHT63Y06KzWrEfD0hSPW0830+1ctmGBgiz FWr7AolhkNPo234ci9R4RcZJlJ/EQuaZmOu0fe2A4ld6OwwB3DeSXiQEb pb0+nxD2TsaJcdK9XEyXzwOFHT+TYAtrh9OtT2gsDLAiBomCxuWtOR81P w==; IronPort-SDR: 8BOaRDA8TW03vXZp3kq0OTxpl5PDf2/5Hrlfckp2PaZYBwujh5/GeZnEGxt5ek6Z29Rs5J/5wx KItrFQF7RQ/6ECtajWnBcx8OYLcUXl1g4ejgZuoBhH1E85lqe6Ks4cNTvR4jLYjU3SdcvqjBOd +vaY1HnRU6rc55ZTYqrcCj+iepinjObFOpVYiSPGDTZIbxxls2jB9uH0G4apmyc3EaWBtczwC8 X8OBxFuX+Wi/+QVneXX4KexJxsCMVasAINFZZAT4/P7mjz47aKefIzZF5CFBPraKMCxP4J7jeG ywc= X-IronPort-AV: E=Sophos;i="5.83,260,1616428800"; d="scan'208";a="170576612" Received: from mail-mw2nam10lp2109.outbound.protection.outlook.com (HELO NAM10-MW2-obe.outbound.protection.outlook.com) ([104.47.55.109]) by ob1.hgst.iphmx.com with ESMTP; 09 Jun 2021 20:28:11 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Qb5Zf9+Gxl406UuV6QX7WyrH7vxvV3McPvi4uMQbITjSVnj44dEvlv3uZjHVkn+pBO+V0+rkYEaK/C9UzuJtEasVHBnq0gRwsToC4mrcrMscGjUb01oMBD/b4wVBWQnvfFzOde2mGKYtQFLWlhgxrfRngeuxpAoq51FXu+Ho1zXba1Djv2831JhSarXuKL+fIvCch+HMRgcF2YaBd2AzzsUtvF4sBtkDy8tfRfPhBjlyNJjoRer3OFXrltHLF4EvcWUrNryacP7h3EhA88EnOCVUJmRnmoSupJiyqvY7TSDzvbalPakdaaEwfyjsDZIjSVrxXAE0/K0WG+fLJyLiuQ== 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=NjbfcLUzlylMcgCS4FcqVa/xev1x+vm+v995jlCNyyPdB8lr+1pqA9TuFG6bnDkGR9OBWeEnYw7FE8oS6VIhnBEJm2a+t/sEqax5kChSU8OfWE2h3NcuycKoNi3JoFjB53ImSzBKuzH2OYJakNIl67YjYT05f5ycXj866xBhaaz4t41RMXfz9Pm92HRmeo4Ug35A2g4J0BuEUcqd+65epZb+ZHBD3tvA0Z/4KMXSmaLCa9VGOAoarMkrluPgU58HRr3sDStUnTH9kxFSvw2k4/11RVq0cz+f6Fj2CbW8XqmhweR0NumDnHBekkyPvmH2oq1nJJcFoXdYHHRB1V0NUA== 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=kr1ac5h3U78XUXmAxeGufO7SzPdJeXhVhkkJsaLhEioKYncgXWW+gxAeddWzFda2KF8pw+SDHq2xV3kOBC7UILyZfK3wxojGPylyN9acsnrzfLWwv7C3pC8wEV1FQEt5XI2BNgzSG0XxzYRhyiNKCc4vBLZVnFzSrY+hfCNV2x8= 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 CO6PR04MB7843.namprd04.prod.outlook.com (2603:10b6:5:35f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21; Wed, 9 Jun 2021 12:28:10 +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; Wed, 9 Jun 2021 12:28:10 +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 v6 6/8] cpuidle: Add RISC-V SBI CPU idle driver Date: Wed, 9 Jun 2021 17:57:13 +0530 Message-Id: <20210609122715.3389-7-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210609122715.3389-1-anup.patel@wdc.com> References: <20210609122715.3389-1-anup.patel@wdc.com> X-Originating-IP: [122.172.176.125] X-ClientProxiedBy: MA1PR0101CA0033.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::19) 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.172.176.125) by MA1PR0101CA0033.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21 via Frontend Transport; Wed, 9 Jun 2021 12:28:05 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 62488fcd-594a-4d37-bcf0-08d92b420acd X-MS-TrafficTypeDiagnostic: CO6PR04MB7843: 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: PxmmMktUjyYuOPeRyYMve9RGwtrL5f86S4UPW0G+Txyx8WxQNCTtIX45aIbZNVoOaC8Am0repIHqmDVF1AL4iOEsp9tdV3Pqys4tMMiQdFM07oHa4+orvnjnDLn4EtD5Y4Vb16Mu9V+z5HYGatWPKDpl+Tjb4BgNAo/ZLTD6PnC/T1VglVPBLKFagi1hkTZfW1mQK69hg6V/glFvrt7oDFW44ELeypN2huVinzB+eBop/B5tYnvB5PSIxI9bddQpxcgsaCaEHcVS1sQnA6sExr42YyQ09FE1sIphCD0BJnCZlV+OTiuFYoOScbykFvY4LOeZilZlY7lhDGlvCtf5YaSPKzsxKl19cdOsaFIHA7lp2kIBFkvS4jVZmTbiQl/lBjUo5aolfguupBHQ/aFybn0QS2ZLyUWMW05A8A/w1GK1MPGOFAUYfKMQMtwk2NWr7St/YlXL6EHu8nSnyKkD+AAW7vs0IDQ2n64BZjrYjHjkLysvt3OezSRL4B8llKCE1Qn4lA444L/+CqsCQHItiadXPl2eLHEKqHmqBumgIuI5Fg94DlKwpz4sMu6F7v+Vdf61cIH05vVLxzmHHrxsVCOtf5R/WLnkdbxa31OFDPXTlvxobrdVSOG48/i+oGpzw/tUQG0LziSX2mXB9fo0fA== 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)(346002)(39860400002)(396003)(366004)(136003)(376002)(7416002)(4326008)(8676002)(8886007)(83380400001)(478600001)(30864003)(110136005)(956004)(316002)(86362001)(6666004)(44832011)(2616005)(38350700002)(52116002)(2906002)(55236004)(7696005)(26005)(8936002)(38100700002)(1076003)(55016002)(66476007)(66556008)(66946007)(36756003)(16526019)(186003)(5660300002)(54906003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fqO5Nso7nxbKAFR5cFSB8llccHFn3a1ZQVjb3vMsBglAK9PzmDdY2lIv9AL7g0HW6C0mhE85hrW8lENBucv1iCamkP1OESIgEVqtlLrmHxGk1raG/q3GmmEHUZwT/HV0GQyDDYif+R2N0kMA4XvbHppvlskDbAj9uRaXvLMxXWPO3yJF/MG+vUQx/92sGtB+fS5BSkXKe2qMZG04GefHUBIqP1WCPN1gB4h1Fn1zs8Cl5HS4vJfu39b9+Hz67wkIbgEp47Yrtp4DJAXw2PTohmQSuNqU3ul/thtGsLut583NZW3vs1Yt2Fhpbk09aGxs9LdX/1VCYqVHmril0CkM+rSZjCPfUqUHllSwb7As3G+WfnlHFc8hPZP7ABqATHviABeSSid12nXTM3w7tayZw2Vj8GhQDuThnytwp5XbJn5Jurvln+w4IbkdC9gyh047XGpF9kbjjHpMV21DKWidVt1vMVob5hNpcAEIs4FQaPikgsSzmh5V/b//24kefsNTgSAb6OQL6aeu2cw0CqbiO8jHr8Zh9n6/isN70GydeIKAUgG5ywoSmCyWmdhDWxuPSMlZNTncT8RpWXaDA9GqGPz51OGUqsLc/ABK1+2JpTzlUQK+yevMuSwvy1SDJHaAd+AIY/l2DsJEIKU109tnk62GLuMqxCsGZkfm9QxwQvQq1QO9S5XX1yK+72T/29D3/OqsScAgOQFnlDZxsMRePzFLh7uw97zEiKJJG/RjvxLtiF9g+nSWt3+GbXBafFNsMeoq6cRbuB/igOGaJPVDUj+ENOpB90ku6h9MRFESZcvqmP6XNYhxrwo6Nk3D7i/tqopyxekT+52mtLAjQIvbSPqp0g5jKPvUeMbMzkZCF4zfbUktz0NxSOZ1KeZiCUyTR049a4HwL73t5y3sIvMHcpEqbWM1C9Ws3v3UPAy149yHGaMDZ0bOiaO2rz9PZe2IYRLeoRbRIY8DdDSVR3LRiq3nXHbW5JG0GotEiv9Eme0AZiNFlvq1uBuCFH09fCEFkqepxpjF0y2tvnqdCf4Fj7M/0ijnLg7aEuk9h++qTK02n+J8T9e07C89hb0e9aCCqUTAz/P+rAfjX7jso5m2+lvOLS+YbbHtn5s5BOxG3auIz89ztxCBHzTJ2+9j0iOqvl3g17Yi1i9VNKvC4pWSMKZqpFwmrN95adueSC33QOOVJC6oop8U3tWc3sHLEQPzNYCrXSnEJWCCaHq39LZDpqXSJy97ONx4oOnz4GbPXY3oyTCsoFa4gS4CPySB64JOkeNK7h/M4UDf2GUC44vTWjdRHDI7201CFES7z0ZQfUzhuTF3mlNW8DrwAqarJLhc X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 62488fcd-594a-4d37-bcf0-08d92b420acd X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2021 12:28:10.2510 (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: tHBwIR0cBueS1/CLOgpMxtA0H+k41pVxXr3Io81oGhAEETln6p/QqybBAFszAi0RcJ921jkuovOm4lqEr6+y5Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7843 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 Wed Jun 9 12:27: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: 457218 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, 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 7FE6BC48BCD for ; Wed, 9 Jun 2021 12:28:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6CAF6613AD for ; Wed, 9 Jun 2021 12:28:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233438AbhFIMa1 (ORCPT ); Wed, 9 Jun 2021 08:30:27 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:39908 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233540AbhFIMaX (ORCPT ); Wed, 9 Jun 2021 08:30:23 -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=1623241709; x=1654777709; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=MeKl9jhPLjMFZAjDeIRMh39HlWEM175ktYhp3+Q4Yqc=; b=NrXjO5FHgVoare+BvRMBXnVu3rEgo2uEBla7A8ZgenjEhfUTYS+BEq/+ 3jI5HmhUXpeLdfbvSsC4Xk3OX3JpS+9igjBe28w4Ig95vLf23m0mi8i/5 dqRNPNYDu9+brEOa64eVWTbGSkrUai9LPjlfc0vj1ec2FXdLw7LJnQFjd DpjoydZd3xmgnu3V145TQXId0rxgFLnkPsJsiLjdErWDmx6GqWkqMC9yo gbDh0aQ55NQZP/Eu9PzPMZKhcSUIIFJT9v/LFJwKrIdb0Y9Wyi58TVF+/ DUwwsEOOt4/j1GUELYF5PHxg6GIpF2j2lj4h3mX7m3MS9XmsXCR0DtgTp g==; IronPort-SDR: IPu8eI64jEH8ToJlY4syHXO2IdpWUCX38FdnToLuiS8yV2acv0XvXsMN1O3kDrcSiBiMW2VM4/ 5hC+CzUHyRs4ZJdWQLEi6joSFam8zXP4C0NsflwIOX2bPcUn1+WVnEXhszbFH/6/HDU2FuiPIm k/FyRrxFIpOe7CC3KfzwAwVFfU0R2ccTPXxCqTLdJ72Vj3TVe4TBgcuac39hvqzeeBjAMK8KXd nxTWej+w6xDOk2oEMOL3CDxtkzOSi+m4MpP/Yr4zAkkGqOvbQ1Wg9QdkyZp55hUm7GnrDxvUqU gC0= X-IronPort-AV: E=Sophos;i="5.83,260,1616428800"; d="scan'208";a="170576635" Received: from mail-mw2nam10lp2103.outbound.protection.outlook.com (HELO NAM10-MW2-obe.outbound.protection.outlook.com) ([104.47.55.103]) by ob1.hgst.iphmx.com with ESMTP; 09 Jun 2021 20:28:17 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fjN/PpA1Gg0NYqgDcqtl3ferxkV2gDe734CmH03pwjnhMxBt1ysYIx+vU0tOTT2kt6M0V3G5qGJ+Dsw1Kpch911eu1W0M0p44putoClgV+eWIPy16R7kfIElirUVObr2I8Ik9fq5gIIc3EMzcRxmoagayxgBd2FbKPG7785WJT15YIqsK/ARH1JslerL0WGoOykBcZf8gvrV2WoaTS+oLUTRtjDZznlWNb/uhnKHGyOGMtlN2W0Y+MBs/k2Dkt9ypV+NFI5cFv8iySVYiKRtghBTOGRZr41uavYQD2fPGkfAEK2i4JnGApkZi4POqbS0uIfPLCgE4C50tRXZv2t1Yw== 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=Jdb7LYKd4zYfz891hXSsl1k21D0B8sMSIEAMlC4gzCs=; b=M/0x7ewdEeoO/dYKFneGi3sx8sfGRPBPFGbNzTUSCB6Z1Gtm/E1gZJw/YR89x3qrHHL0cap/y6ttM/1RQLT/K9YS7Cif+Rf7AdxfDUvwhqIgQtTsLHmU6KTTMjpZXXCyWZZjEMUPVixsHqGic1glUL34LiD92oEMiNKBRC5ISKD857xi1x09fIOVz8eU8yLuN4ulThrO2zVMqm4AsQBo8BogLqOcpziWMd5ClqlYE3Ns7Ip4r8AedWo5LEe4HqN3MOgDU72C+qVvtMjiWzplPPj+Civ0FFBmUqQgQzq0cFjId+x3yEyamSU9wj1vRXxtonmp0Afm7m/XlU/XiH0GHQ== 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=Jdb7LYKd4zYfz891hXSsl1k21D0B8sMSIEAMlC4gzCs=; b=GVXOaz5XQIodTnzbKY3VanZMa1asDbH+nEmkB5lcEO6zL63WuBxLmbQoFESmhnnhAnkN7WqPICAHfR4D1e9ZXfC5jZW64XCe3uTgNPxMLuKx1coE2KBL5Fmi+XM8dCoLXzYKmZGCgtvw7y7806NLKV4MmNb36z1yLO4A33i6goM= 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 CO6PR04MB7843.namprd04.prod.outlook.com (2603:10b6:5:35f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21; Wed, 9 Jun 2021 12:28:16 +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; Wed, 9 Jun 2021 12:28: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 , Rob Herring Subject: [PATCH v6 7/8] dt-bindings: Add common bindings for ARM and RISC-V idle states Date: Wed, 9 Jun 2021 17:57:14 +0530 Message-Id: <20210609122715.3389-8-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210609122715.3389-1-anup.patel@wdc.com> References: <20210609122715.3389-1-anup.patel@wdc.com> X-Originating-IP: [122.172.176.125] X-ClientProxiedBy: MA1PR0101CA0033.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::19) 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.172.176.125) by MA1PR0101CA0033.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21 via Frontend Transport; Wed, 9 Jun 2021 12:28:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b2d9397f-ecdd-461e-168a-08d92b420e64 X-MS-TrafficTypeDiagnostic: CO6PR04MB7843: 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: au/MonpQNF3UC5XA5KR6ybSio3+wdQ3569CItKmc3RCtUZHs6wntxeQ2yPAtYsjs9eSNz0SWKSo6g3EOhsxawuBWB2HXC/nU4o8AqC5jnH4KU6+bmwM1IbQc1Bpq8xE+XNVq1q42NCOV4Iglmia7E1AHM/ejyT0N/7jt+uGdhuqAtDNduAud/f0+frIdTOHYE914T1ju9XYY8fOmz7+W/JEVDzh3kROohLTNY5Zfa5DvTUiSSLECr9NaydcPOqD1X2muRXgOZqacQD0X8IC/BN0TSZ/XrDBgAhjhco7Vyw0yiCc1uwnlVW6BA2dte09cAvfIOnOyz3KmDPkZTiFUiRlPbGCQcot5J0D8HmRGGt4/Ewom/EvUHj6c4M/SSa6D6kc5w18yyEdVw358Sb4khiqM9X7sqxzdNHvAZitjQEg0nL4+NnzaXpvCUVdS/IUNUCHmaapnYxAZn3cvDbQFANcnWGG4bB544AK2O9+3/9RjpaKU9XpHluBCQwweq+epUeJOGpDdDuDAT6Dyp7h1zVyvGwl0PXGaa0ZErcm4mYIHbls0hlNAYaPbXySWf2TzERXWluuGEIyV/kOZWAMGJ6YdQInPef/3kjAYLab5ptWTl/hKabQwA5so10OtmCISc/v4C7Loxg+YL5Vo0jvWR/GL2fHAqKDGpMt2pDNIf/maVYUPB0689bxOq8QW72iLmo2x4c2W4QSSIDWNJjclkl3fIGDwNM09LRh4K1rNLxMB2012wBOY8FhzypZC2alleZnn6RI3JUd0rlYIkwoeaA== 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)(346002)(39860400002)(396003)(366004)(136003)(376002)(7416002)(4326008)(8676002)(8886007)(83380400001)(478600001)(30864003)(110136005)(956004)(316002)(86362001)(966005)(44832011)(2616005)(38350700002)(52116002)(2906002)(55236004)(7696005)(26005)(8936002)(38100700002)(1076003)(55016002)(66476007)(66556008)(66946007)(36756003)(16526019)(186003)(5660300002)(54906003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: glO9+8BUU7yBRIUIEQmc2zT31xsZnej2XFLOMUJsuU3Jdd6gEsEIWYnheBi1v9+ljCMOLqRVGHB4gNV715udkUItl3/Jf+nb78CV7yMtwnAa0rypzsODFbQdOtsziRpohocLGmmEU3b3+/0o1VjZNWqt8RdVewPw03Brqnngbz1FsCFNfxx7+Vez8rGzRkHlrwo9xY2AGR86tSWfnwtFGbAx0gssl2o5RxPF273uSvTPO6aFEhHpetMcpEaBvWN3myo31wGcJS2yaFyQlQG4jKUmE2H3G4H6I2V4CL4PVxvZh7++avY7BVcOGr7TpoFcDRRVBcaggtPMsYHx0GJm61wsbhjc33RSmjcl2+1kYTcgMUU2nawm4vA0swyfgvS8hbkr3BiPPH+OXetvpWZJEMyX6K5uF0tukiFzPfNE22ZPbDYMfIzViflxGy2lOkejbTkJj/rtsb39er+vEkiNQzuG4g56RlcjTL35nRLU7vv3+TGAckbUwOfSTiM/H5g2sYggLofYHu1HLOtwyLjZQ7tSB99E76FC0HQjTraqpAARlTZ+N+jOfvwVuJLmD+ecOPfSI2l9JaJF50uk1F9Doug5rdxxBLXThVRrMf1feTFk4HG8cOLXWMUeeqEagO1TMZT5Ig4uG3vmveGwGgf5dyHR65JDW620KaLY+7h2jcE9V6Lk2yjxZdOXJy+vtmBGmeU8fmEJCLD6+ZuTwhVH9/Wdpb3ChpPAMBRLyMC+cqW/tszFpZJoLt/8uQWMKN/92fc/iVTE+RmAl1WA2ablTGFsm68RTjkORGSeAhtrFJ3nzDffjQk5NcO+6IeiSU4jU12RgE89r5XbhhR9+tLLHCeTkstQWjnqdeE1A2If+9hQ/JipMk8o7XjHyNM6VsahsRU2zdnmQzuvt1HKDmDSJUFd1YjHrFvNOVa+LTXd5OuVMu123d6RnZCdFr7grDsxHQ1sa+Cv1M4KesP+nA6tq4xd389Qcc8N7MJmmD3CkfDmS4OaP4AR7dCKu0lxdkeu2PnhYN72R8+8YjuW2E9ZA53HNbAeHQBFDyPvp3ivKMllYHBU8f/t5lR224sRtq9hI2qLSNWjlUK45pLzoOeBL/BPDKIF4WT0FBKVJno1Rx8AI7gUB/MjzsM8hUeshTFdsokM+2nRFaSrI9KfREuxVg8MdjY16+lH/BwZrsTW4uPXvtWP6UbqRUglgKB/TPjTcVJYNDxwOqyvtnfzABvmbEXhsW5szz7YBTFwwNEheSeicvMo9l55tdCDMDfzB//rCA0D8dkJUw3loQW4n5z31IQ27pS37CE5R9hhF0DFnuBlrCdOBJe7J10lHrQnnA6Y X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: b2d9397f-ecdd-461e-168a-08d92b420e64 X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2021 12:28:16.0584 (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: GTdo3GN30JMRplDZhIIiF3tK6Zu9qrofDxFHVjvc7AopgNF+IJCISKZ1WV3sy2Rz3kTa3VVVIbO2aFfKpmirXA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7843 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 => cpu}/idle-states.yaml | 228 ++++++++++++++++-- .../devicetree/bindings/riscv/cpus.yaml | 6 + 2 files changed, 217 insertions(+), 17 deletions(-) rename Documentation/devicetree/bindings/{arm => cpu}/idle-states.yaml (74%) 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 Wed Jun 9 12:27: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: 458173 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, 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 69FD5C48BCF for ; Wed, 9 Jun 2021 12:28:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 55423613B1 for ; Wed, 9 Jun 2021 12:28:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233288AbhFIMa0 (ORCPT ); Wed, 9 Jun 2021 08:30:26 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:39931 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233224AbhFIMaX (ORCPT ); Wed, 9 Jun 2021 08:30:23 -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=1623241709; x=1654777709; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=1uLrgPfppmFH2vM6/L/JqMHBvAu4tkt7ZHOK+EuhRKU=; b=cV/Z9mbjmaZRatFehSQ66MmadUTN+Xy94ZCL0YHImT+LRQ1IU+DwX4VJ ipJyk2SwJOkTQc+adgWSU/P1SZafyeCRRBtXIa0/whjy9MXK4ph08vZ+E JAS3eRpvH9BdLWT8r1e/MjND3hspbv4k/AtDc6+ZLfa6GbxstnCgow1Am Ww+uYj0y0qMVZDe4O9gXtA6+M5fpj51feposkTeBIB2V9qC4Ou1aoqRHR bDUV4VEpiwIWJ1OXnkznENhIBpqf/s1cU7r2+SzaNXx54qWQppW7gVROd QRe+yHFx4IsqrpjHf/hle3FxTJADlzBCob0Yq7dWHBmaygGvFhdXF3zsA Q==; IronPort-SDR: mFiVePYHg/MEl6L+MSlzNJH/51zxxW3m0VAKTnwTgSdNgo5U6gVQBeRtk7PpMX00J2CQPdWV4S 8UyqKgkkLvCkcuV957t0m0fcTt52asjpTaETBlhjG5bQyqb1t6AgwsfaDPi3Lw+QpdI/dCfMYV ggzIZW3eHnFKn2lj+Bdpbx1NLqiy8mNl8dw8aPsHX81pINfykz95ZpT6A8gBEwhYIEByaMbd1F 8g6SNDwu3omcQjMqncfhLsafOK0IL+8Y+5aej4fKasgShZnUzIY0mVE3vPXkb+eZ056O8CJ+e5 jQM= X-IronPort-AV: E=Sophos;i="5.83,260,1616428800"; d="scan'208";a="170576660" Received: from mail-mw2nam10lp2103.outbound.protection.outlook.com (HELO NAM10-MW2-obe.outbound.protection.outlook.com) ([104.47.55.103]) by ob1.hgst.iphmx.com with ESMTP; 09 Jun 2021 20:28:22 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gUxkyylDtDIYsNS3Y4cGSFmnwzvqC+4Puio/GZz+AIT9jJUtIN1HGXlPH52XD1F/1+a8DRedQ5Yee0FZsub2kjo9EZXAv8BUCwKB4tPhr6sJA6nwZq3a0QBH39KSAnNoVtxbjentlyL74mGBuFzqEGjKrDF1b0wscCMowhXjKGFBIHBTWL8WnRn1pld/2EoVpBRZo8lA8CZr/EO3cI4YQWDnQQ61rQ/IOfcVQBIBNfryhHI2b78I0nNmupYAJWrAIs6Td1rKqgKggYgGVmi97b3EABcB/Lzf02TukJl0yvj+1cYuLm2HanUsKF35cfhDtikjBP2OFYrvS2W+IUPI8w== 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=Ri+mftxB6KnOD1VUT3VaHJvsEZlxOTxlJnHxEk5tXAMVh1Ys3sc5RZBR5obe8y7GlkpaDJzYpiFeabzKdNk53R6azHLjKBbPy8rRNkOrjP1gdiAG4cvVqasa6bvUIL0LvDRMQNny8HM5FCYSamHhl/RPYzRZP2xGR3+kzOVUYCPr0eZUCOWIT/MDn1KtyeqsSuFX4C9bOgBdZIOKmLvBgTiIBw8iDbdln11nUHnFjBTePWA9Ru7LuHyJCArbUtdM+gB0xrGxR59RCnHLdEkdHNInik2QigMmFChQbAQNsQ7t0ERUEKLcGftqyFwJHhBZixy3lrB+xKoudPYvn3MlDg== 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=dLezWy/o38fJTAhNSENeqak3nRJOM3yWB0tkVwJT6CkvRkjovEdTJB/vwuqNZK1fQn6G9PuwbakB++NuAqhhj4jp7xLMwLQxPOlzMAFjKLpa7KFdF52n7Wgc/pw4k+iC0iz963H1J1G4orCv3fBkFhIfC1j62V3r09PJcnbq6FA= 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 CO6PR04MB7843.namprd04.prod.outlook.com (2603:10b6:5:35f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21; Wed, 9 Jun 2021 12:28:21 +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; Wed, 9 Jun 2021 12:28:21 +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 v6 8/8] RISC-V: Enable RISC-V SBI CPU Idle driver for QEMU virt machine Date: Wed, 9 Jun 2021 17:57:15 +0530 Message-Id: <20210609122715.3389-9-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210609122715.3389-1-anup.patel@wdc.com> References: <20210609122715.3389-1-anup.patel@wdc.com> X-Originating-IP: [122.172.176.125] X-ClientProxiedBy: MA1PR0101CA0033.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::19) 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.172.176.125) by MA1PR0101CA0033.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21 via Frontend Transport; Wed, 9 Jun 2021 12:28:16 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7e15b2b1-0a88-40d0-e6bb-08d92b421174 X-MS-TrafficTypeDiagnostic: CO6PR04MB7843: 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: dXKEaYwQN7Z2VW+SKHFDvptiiyusoKrRPRxmTAsOjRmqKSYWCDDGGRqhIzfMo+FnY9a76LNLRlc7YgLftjtSnxX7HIsX3RwRbwiuQqXw6ovfTC0E7VF1N9qFxPM13rRzvmjtm1UYP8dUaOPRM2t4gc+Q0CBgNvvVEPGyiKvFlr5ktQD9O0VAuJzqLDVeTbC6+0lJEXlOXPlNYCDxiyhZFa83f1C2PZSAM2aRwL0M8AwajVhez4MKf17AEz7V1MSJ+kEniU8Rjm+3DRByIGdywUPM45/aWa+n0FVWrn/Zk4XK6LhJQVRmO5doxMdDCKqBsLLfdemU+IQTo22KB9gcSdhKgU70eSb6RAKT/ib4jsmz0cXzhpHNhDG0fL8u5H6RAUBC9nfHX1HbjAWzbFWyEiGIwVYp3ieQ3bIlPA9PmHZbuEp5YRMyYGWaqzes9r8WUiHXZ5MtBLWgiSj/kns7dHOuZcjkRRgT9AtcNOMQqJPThsAXbrylkG2jLR4ky+vFtS5Sqj8q1iDz8KDpgz727ngTsCdJu8tMaY5fd6xLUSB4v7ftiLfqsh51JXHe+JDuPKzxY9sbqI9SM6wb/ksKfp9EYu+aIroB9+CrughD87v65H9TwndrjxGWYnzqfIEAsCbbWMqd8gcUaA99bHfaDw== 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)(346002)(39860400002)(396003)(366004)(136003)(376002)(7416002)(4326008)(8676002)(8886007)(478600001)(110136005)(956004)(316002)(86362001)(44832011)(2616005)(38350700002)(52116002)(2906002)(55236004)(7696005)(26005)(8936002)(38100700002)(1076003)(55016002)(66476007)(66556008)(66946007)(36756003)(16526019)(186003)(5660300002)(54906003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8SfEfsUSpDqWnDH+QBknwXGh456NOjYaJdpC0v9ge1wHEIibwGXSv6uW4wmx1OZ/fGdm2EwQzQ09I/x/VB/wnxVWW+yjftfuWsJDib+oJk9eVdpUtSxNvFnrG2LdN3Os0F6SfXuKPCfWuReMgrbCCj02IdbREfbvBqFZi5E7sxoO0x20i/Fws3Z2dFIxLAH/ySOEho2SIJl1qdMcJFVhvTEj9aSSedi2Hd9vGipmrUkg2c7TI0pQRln1p37xFmjSA6J6PN2+fI5jy9Yxrg2xUVRHhQK9BXup0A5EnW7d1q22oVfPpf3V+9L+hd2T/PBK7ZNiv2q7B6SxASQZwDGDvuCA+EeFsGbK3crtQLSTNn3p8K+SBFC1a9cnHKhsaAPSN37Jk2+P6sCz5Fp0D2pHfQv0D0LdOMVwJH9lvxnkJRR5QW35WHmj7YC+uUZVLxh8gbtcDqrTQexcW03fvMUBWEGtb00/orKwRZPRvbJzIGrSZ1TqajrsonsGjxJ3Q0TZ20XABAcZppoa1QozUaVMYTokIslwb7Jr9jcOv8zruTVT1ViwgI0XrpMatwlwDfTVd7ah0GxBLB9UvuJY29MxMh7hRsXU7ODaBlzW/wwC7L0NrTTKUkQkB3gaB7B5LbzMo+RvnaJTrpiCkbu46xDkm9OamajX+5EIk8HWSbl8GtMwad1eaWP+RPddET81iBXpwdgeLXrAcL+mVypdTEjywBD1kC5YyRlMhPTuCaK49nxkJQC7qumFddvQVK8Du24KKkY+Gp6VpkTQPpzBsBu6/ZNayImCkITcgODtyRnwqFcSoJ8emLNZ3UcWZxe+PcbcuSV9GsO/9KlLvAtPz9GWnKWXV4qzylFMcLa0OkCOXCQpCGcWyTlqW8/kJRz33t1VsVI3DtJQitDGWdXbp6aNbU9p3nOSMB+yZ7O4+q2/PxNNHcCOQFAHg+NGhQ8vW0hH6AvLP4xoIqg847dDj/vpKEW7OqVnb+0E6FoEbgITW0Wqb7KXJPbwaN1T/Ru4xzzxTAP+lBmwp81PN2p5scKrN5XvunL8fq+B3PqxeHSaRYF3wmujudP9UJUyPmv/cbCMMTtIrSqzPY6mpL1wYma6n5z8kpN8FFoEVZjqxYBuD3rW1gj9LQ516E01Vbl++6qSCC6OvmqIGF506ubkd1Bh6IYXEayGvwlTZoZEZw+ptJrMc+XyyKZHYDKm5azwuYBLfw8RKhBllciqX9yh6VoL6pnpw7OXkzvSCgDuyixiJ+4noE9AdJYAJ+j5QAx7LR0Z1JpkTWwacW8uoCYt9NO3nVEi9Dx4grfich7CR0m9JAC5mJBaPFDVADox1YzHS7jf X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7e15b2b1-0a88-40d0-e6bb-08d92b421174 X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2021 12:28:21.1799 (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: H0OYOjlVvN2PkAmDygje8/Lz2C/nJEVN9hNLfAIS6HsSrtctDkhWcmIou8jUgCxn0NPQU4sMuguDuyJ6a+OKLw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7843 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