From patchwork Tue Oct 12 09:58:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 12551889 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2CF60C433F5 for ; Tue, 12 Oct 2021 10:00:24 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E6D9161040 for ; Tue, 12 Oct 2021 10:00:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E6D9161040 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AjEPFEQf8HmaqsNbNVKeXl0UlXUR9O02zWcz27+AxY8=; b=sPeQcPO69gdjpT 5WEvriPzPU2UGp0PM+zRqCPmodph34evwgFir7G9+Fbl0a+oAdIY55UiOOqjcm26VNKMa2cjERKXJ QEfgCOuuEJeECwsiOwtCacOPYgBfR5JFFDSYAzSSm1sdEpFTrFKYkDRmZWkWnD3LJPqAsbdmTzXWm QkygeW+WhszTFIAiqXGAi2LOVLK0dlK7KSJWDGB0x045CzzVLk17lE1PTtwQD6MtyNNMRlaJaLq4I Modj43TiWf0YTjeFblSrYQ+2a6xgmf4KfeeNUeRZhCtcXLfW2i5FG8zPjUA3lPJWTWvfPF21UhsKq 9GPcC1XA9iBUKB43qgOw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1maEZp-00CKBM-Q9; Tue, 12 Oct 2021 10:00:05 +0000 Received: from esa5.hgst.iphmx.com ([216.71.153.144]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1maEZK-00CK3A-Hc; Tue, 12 Oct 2021 09:59:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634032774; x=1665568774; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=QL5SiUTHGDyBIobnT+wZj/8BRPI6TtxelDdyMy14q+c=; b=DM1AC6sphoTpkvwedafOOq+a1rRTsdLL6KNWXGjB+p6WiQnderUq0TlX rqe4l0voI5HAT1c2bz6yuSG7X2QhDsiFR2vARzwgg8oAHznvs5feONOtc UJwfL6yFTgkdkZHmR9dcP7WhshoPInd5U2iQ+G4XwnhNvanDTy2lVVRHG nw8AbkhGvlTq7UbG4uPV4CXDCm13CfxBT38rkmghPHr1kOcJQe7bgNXCQ wS0mJ0q0lEi9xPkgP0M7s6/mNBMPt098S3/4+Hg2dajC0p3CAHJPzCkig mOH3SNsTZqdSR2hNcTnrh1sgMCwxMOjKRdy/HJNhSRaIe95mllcFuWTB+ Q==; X-IronPort-AV: E=Sophos;i="5.85,367,1624291200"; d="scan'208";a="182592127" Received: from mail-co1nam11lp2173.outbound.protection.outlook.com (HELO NAM11-CO1-obe.outbound.protection.outlook.com) ([104.47.56.173]) by ob1.hgst.iphmx.com with ESMTP; 12 Oct 2021 17:59:32 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AauZ2+xprgfuAEkzXz3USaqVXuDgHpGaXebCcE8HiZTuVf7CyltcUhObVHiD5zQVST91bimEamhc9ummW1UJWh9M00YAE2I8h/95rGoTcfzzFdoaDieVAvD1Y831+Gp4CQ+jGgaAaQYQM0ExUJmesI8o0Y0Ye1yZ+ntZ0tVr6hKpVO+liQeA8XflfVWFPHB1p72VdF0TEvrHt+ha+fOlFHG24D2uf9xXDd2joGASSyipzxkEd89Wo/K69fWSg0rifbPTWlVwRpKlYzUDTKv9JAbdXQz3Bw+SXzSO2BfFZvLIue09qNFu8o9nGfGpL2LiSYccbc8/8h+77djkSZGccQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uJ2YWN5WvnLO+KMdKCUMk6jyEKqzixV0Skrs6UOwavk=; b=WVouIupyEJFHx2VgnLF5nwFdFuVaV7s7GhLqLK+QYepCrLcthoh7feEYtHPbv4AvEfhWoY4tvpSB792AkRpYljJXzcaI8bTI8nO4wU3svnOUgxYl5VIy1umq61mNtSmQkCo5zGqVzQ1H3QsrBGHptVsJ2pOne4dEo34K/CWjw0OL+F9jHcsZhzYOSwar1LZ5JVEWD5h/AuyiOgYCgsBpuRX5713XM3Rom0LjL8uLWb0VqZ1mbS+Mf/MZRozlAWSf+/PM70+pS4quYjecXIujnDKU37fuGEg4Vmwribr35a4mYMGBeMv5QU7GXBfU0dr4yb4iY2T5v+VhYnxe5t2ZZg== 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=uJ2YWN5WvnLO+KMdKCUMk6jyEKqzixV0Skrs6UOwavk=; b=eBaBMK2qplQ7NW9u9LttFGn/NWclfHhRsB1JZSiXfKjj3W/8x32kxc4Gw67/pt/U7yNGGIdYVzVSIBY5LtuZzIIe1wruef+j1BOeeri+Q7MF/vBE8VIj7FyjfeqliUeJwuEa30V00h7FU/QAzVVUfGq5bZi+pmpkfMHLOyjlaxk= 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 CO6PR04MB8348.namprd04.prod.outlook.com (2603:10b6:303:137::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18; Tue, 12 Oct 2021 09:59:31 +0000 Received: from CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::8100:4308:5b21:8d97]) by CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::8100:4308:5b21:8d97%9]) with mapi id 15.20.4587.026; Tue, 12 Oct 2021 09:59:31 +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 v9 1/8] RISC-V: Enable CPU_IDLE drivers Date: Tue, 12 Oct 2021 15:28:50 +0530 Message-Id: <20211012095857.1314214-2-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211012095857.1314214-1-anup.patel@wdc.com> References: <20211012095857.1314214-1-anup.patel@wdc.com> X-ClientProxiedBy: MAXPR01CA0106.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::24) To CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) MIME-Version: 1.0 Received: from wdc.com (122.179.114.63) by MAXPR01CA0106.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.24 via Frontend Transport; Tue, 12 Oct 2021 09:59:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d57e06cd-85fb-465f-040b-08d98d66fc7b X-MS-TrafficTypeDiagnostic: CO6PR04MB8348: 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-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dXo8ah1zGDB5agRi3iofL0Vg2eyJnLGbS3BtguGjzuVQ+CuH7UH8kMW4NSNjHo/LV4XuBx39+XDP5G+59whtf5dPTIy7xaoy6RJ8ufyEDgZBXRT720ssvP2rnGXYjhHFd89UjnXXsJ38Yw1/OMEeIab/A3nXmhXSR7trMmVXYR+uaYRo/gsQj+Hu4nWy8J2TlfAeU/wHWglTF/6i+ooT8RoLKnhd6f6XiEGLlJPBJ2YRqoqX0l1G+VDFGrQhB0dOdgP9q/GGCuJIig6/FrEfHWYYJYAJtcK7hg089mxzj76U6R2EeJnON+VbK+rdmJH0NvXEFBJGpime7M0BEDKhasRpbYu7r6Cq8l9p4m3rKUFCYzlf3/IBshRS3qrTmOoAwrQXecIgAcOJc2JD/WgnQ4THGMusqQg6lZkvSIPLCik2eQEKKCghxrSGCQVWoNlZonyWuaFLUvFNZ6+H1d/afnTr6reQgoJouJKTeiEImCJjk1vGaA8+L09MXL3hXVTRocFBZYJXyn5QchtftJqpMw+LSTHpcaGXRB9SwadM8V/n8QMbfnyUgvVDUokKcVx3ijc4bIlVBT7hRU/8tKaeUZzzsGZTbUlaoPsnCU4SILRInJxiw60XRGTi+d9xxkud41MLP8Fy7GeMzJu0+vHDBc7hy1cpa+QcUbDjy9ajXGP8ZFtGodARIyIUy+/1ltoDrasvFv7STy0u4Ctnn8RRRA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO6PR04MB7812.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(8936002)(6666004)(1076003)(8676002)(316002)(110136005)(44832011)(7416002)(508600001)(8886007)(54906003)(4326008)(2906002)(956004)(2616005)(38100700002)(55016002)(26005)(7696005)(83380400001)(36756003)(52116002)(186003)(38350700002)(66946007)(86362001)(66556008)(66476007)(5660300002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Mo+nFOadJiQDZzyDiwQHWa+FsTdh/kStCpuvyxHaQiHE03ZenDQBXIPyl7+rJPVzkzPdOBMEsopLVt5w2VJ3RYDAVpD5GDbq1wpy4C73WLpEXycXNCcmiKbB4QLT327qI0zpygFfa4vOQMAyQLdSGtVnyVB2Gf0LNAZJl+DnqSva7kQlIeKB4NeAiseuSpRbFbAhb8hvWH1OKh8sB+7X+XOmwoU4P0gbzt4/xjahd6c3Xa090ZQBMVXniOYZo94JNZv0Z3RqRqkbr2oJHAbHprqkHve/HZpxX/H63g37hlUqygizsXd3JhjUigev/Oh5/cGBLxvlRsht4GwJASsnCHBKOV6Kgv6qN0EqZ4FXlPlmKafSB17qkaGOLfUMTCgNr/dO77uk46K1fUP2hYlzDO5v9Dval9XRoJZd6n8ikq1+yhM2IeWwuvUhQp5ep95Kv4JyC0PFEiJEnWo0C0fqb28N34+tUXikwRiVAietJi/1H2A03kQxl2RVqi3Rl5PAZeIC/JCyI3O9reYSwph81BLqpJSxGG6lU+fauCh0PWj3LzZ3SPOUoGZf1Gg/NuKEsy8TH86wG1qNUxNG/q7169EDnfmnyqr8kTRjUFIGLT6NaxPYnFbnS5gINzRQJ2oIrwVdTC2HwwJ60Lb6KQ+KIyvOeTsXDsK+5KyqrYKMyxILXdgD0pPflz3I4RFWoi5SueI0gkWyczlEoPm1LIbzs4e4EvhO7FcouDhBD8R6YCwSV5OrfRESTVUinxHcQ9RMx8vzCzw0luqXfLZodGSJPXvEUu9BxGa16g/TzO8ODlUk6RJHd9f2+fTxevG2vjBq36Qln75ZYk3abhhoDQDSK56hpOWI33pO1vGNCvKudNmIxvKAsmV0P45J7hO6saL/oFx/rqCuI//mdD47jjAwsPkPEw7IPpwOtDDNUi4a4Xzgnq/1EJvO2cQqk+x0wKsISj25ubITWEU3YkFu9G0aCrpVXVcpJHBOfhLI/ihm4iget0vUDGvikNt050aRvNOIIxa5rRD0QwnKjO+Zr6kcPCmhuETzMAdg3fbDDuMp0F3Jy+jgNxXbx+F0ZMKnKjJJZHnJ72KPzjL4SxidipRZSgpSceIIjBBCv++SAl35LLvr/o77BHN2NMYPjWSMyngbi1cYNhG8SPhnI/6TtJMBrHXCoohKWHYhL6V6J49C5ZekFEgUN/5oLYJBlSOLdkJUfTvNytHxzFOe8fTRYvifammwIRGdU2JNXXCVXegolWfz5ssIoQ5hr3bWnM/co1JngmWD3WJ0dbOwshBzWq5z6AOcsj/BU5tYixayjs+Y1HyhOcsRTaVnx8ZEyIKYn3YY X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: d57e06cd-85fb-465f-040b-08d98d66fc7b X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2021 09:59:31.2981 (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: nWA9KvNNuyRW/RpdH6spBEgkBJHelNuhvx/+c0KqVmLQ2en8XDAwyJmbN+5vbRFLN64UiEyWgHZOsU3zZ8+hOw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB8348 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211012_025934_643976_84E2941B X-CRM114-Status: GOOD ( 18.93 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.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 | 14 ++++++-------- arch/riscv/configs/rv32_defconfig | 7 +++---- arch/riscv/include/asm/cpuidle.h | 24 ++++++++++++++++++++++++ arch/riscv/kernel/process.c | 3 ++- 5 files changed, 42 insertions(+), 13 deletions(-) create mode 100644 arch/riscv/include/asm/cpuidle.h diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 3105e1beb980..7256ee3e8629 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -46,6 +46,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 @@ -562,3 +563,9 @@ menu "Power management options" source "kernel/power/Kconfig" endmenu + +menu "CPU Power Management" + +source "drivers/cpuidle/Kconfig" + +endmenu diff --git a/arch/riscv/configs/defconfig b/arch/riscv/configs/defconfig index 4ebc80315f01..9851ba671e90 100644 --- a/arch/riscv/configs/defconfig +++ b/arch/riscv/configs/defconfig @@ -2,6 +2,7 @@ CONFIG_SYSVIPC=y CONFIG_POSIX_MQUEUE=y CONFIG_NO_HZ_IDLE=y CONFIG_HIGH_RES_TIMERS=y +CONFIG_BPF_SYSCALL=y CONFIG_IKCONFIG=y CONFIG_IKCONFIG_PROC=y CONFIG_CGROUPS=y @@ -13,12 +14,13 @@ CONFIG_USER_NS=y CONFIG_CHECKPOINT_RESTORE=y CONFIG_BLK_DEV_INITRD=y CONFIG_EXPERT=y -CONFIG_BPF_SYSCALL=y +# CONFIG_SYSFS_SYSCALL is not set +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 @@ -68,14 +70,12 @@ 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 -CONFIG_FRAMEBUFFER_CONSOLE=y CONFIG_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_PLATFORM=y @@ -85,10 +85,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 @@ -139,5 +139,3 @@ CONFIG_RCU_EQS_DEBUG=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 434ef5b64599..725ca3332900 100644 --- a/arch/riscv/configs/rv32_defconfig +++ b/arch/riscv/configs/rv32_defconfig @@ -2,6 +2,7 @@ CONFIG_SYSVIPC=y CONFIG_POSIX_MQUEUE=y CONFIG_NO_HZ_IDLE=y CONFIG_HIGH_RES_TIMERS=y +CONFIG_BPF_SYSCALL=y CONFIG_IKCONFIG=y CONFIG_IKCONFIG_PROC=y CONFIG_CGROUPS=y @@ -13,12 +14,13 @@ CONFIG_USER_NS=y CONFIG_CHECKPOINT_RESTORE=y CONFIG_BLK_DEV_INITRD=y CONFIG_EXPERT=y -CONFIG_BPF_SYSCALL=y +# CONFIG_SYSFS_SYSCALL is not set 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,11 +69,9 @@ 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 -CONFIG_FRAMEBUFFER_CONSOLE=y CONFIG_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_PLATFORM=y @@ -130,4 +130,3 @@ CONFIG_RCU_EQS_DEBUG=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 03ac3aa611f5..504b496787aa 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 Tue Oct 12 09:58:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 12551891 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3FE38C433EF for ; Tue, 12 Oct 2021 10:00:47 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 06CDA60EE5 for ; Tue, 12 Oct 2021 10:00:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 06CDA60EE5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xpsa/cGaiG//psCmpZ9aaIW5hparHg9a/dj5oV10o7I=; b=YmlTpJcMAl6WU9 QSJD9+HKszcDNHx/HBHlbbnRCRBGnY7wIPMlKzSKcFJkQ45x8UaPuXLtnnyYZhw3fueScdTwdLZsy ZptT/WUuU1jkXEnJSvrR1P2r0AdDQoIKmiTGB/QIcpO7KCJGLAYXFmnrOUibmNOB6p4ItFlKbZAlI dhThfiRpfRRMiVEKs8a77hMiYbAMChi9M1asLZDPQk4Y7W/Z4eZbWS7a+LPSqkCgJGwgviVFrWzIA 4ZrWlIxEo9hTySCoZ6iAKEkIzXq4Xivs0E2Aakx1lUuXbvGZ4kk+4IKSW8Eyz4p3DX8URvYhxACU4 UumxS9x8ut9h93HOPYeg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1maEaB-00CKKQ-Oj; Tue, 12 Oct 2021 10:00:27 +0000 Received: from esa5.hgst.iphmx.com ([216.71.153.144]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1maEZQ-00CK3A-7l; Tue, 12 Oct 2021 09:59:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634032779; x=1665568779; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=xfiKKU2D92LxFD91PWDY3j4rlGe5f1xCNcR6FeJ7upY=; b=W3XMtLak3fmEWSr+if4hAzK7gZ7zcXJa9DJ0g6eOcggo1vZ8j2tZIQ5j R9bee3HKGoF3SnaDLynzpIROlCvxZiYMLPH+JC8riQZXJlmA83cUq2UGw kmJi6RkS7+aCzMzxjbn70C9Sb6bAeRYrzmw2y2/dLRSEIt7Wby6NWcRSF 5INsyBYpyNddWr897QV/7ZP7PEkdqnuQpC+736tZxFUzyI65ROs8/GE6Q SaCXODF7sp210JQ3Cca9JBumDPkLc8ad1fhIA0pNRDbQkZG//8EcpU4iq z+RDS/s6RSO8Dyol8I7ppLTlhMPvO72XAd/O/x0FjMVgxIIZVy+JavCL/ g==; X-IronPort-AV: E=Sophos;i="5.85,367,1624291200"; d="scan'208";a="182592142" Received: from mail-dm6nam12lp2176.outbound.protection.outlook.com (HELO NAM12-DM6-obe.outbound.protection.outlook.com) ([104.47.59.176]) by ob1.hgst.iphmx.com with ESMTP; 12 Oct 2021 17:59:37 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G7SeTaJNkEV0BfD6rK9JENI3Rnd41eK2TbY/Co20axnRUaQc5gWL1j2CVHEhKFTcdl72xgWSBw3W3D1R2weOg3dgWy97qFPBSPUiatrHseyf+8qaSOKjwNa9NbCyFsFOUJFa34bIDH4RS+5aCg3BilhVXvM7hC5fiepTZl8Gzy48TyHPEQCyHkIsRPiEzldwhF/URu3pVp7fZlChL9THQDL2lXLlCVJxKycYSRJJQWARZ9A2f/tGJ4ZsGZu1eClS+jVSLS0+EO1zYpZrGyAYX1XCQ54JbznWJn/vIXm3mva/GxH6tq7boYlNF7B5xtcfnKoRXuiGIZr6fbGPGShdBA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XB0r+rzkrWS+zQQTlAjsnrMWWHVWEZr99UXf0qaQoKI=; b=e0wB2v7yZ7kSNDRzpQDa87JGO4sUZTAmfdVXwQmjL4AlCJ+ss+KyADaz37cQ5W7TV6uUNMwafKj9XNwWTek73vk+XL/O9xHLXC3VI+k4kZaCHEbrVp5i7Xxabmzdn0Ra/IxrIcnb09c1UpSlRBp3klnhcVZ9A7gEHQEg2/2yLAAAtysD5ai2/rIypxn4M+xrZvRBFU1ZJKrO24GxzdxsNjQux5UpPGNv6OPpkrRLs5F02n8/jaZ9Dyyep7xJw1O2N05YtlCZo672gWP2dItm4kgJmiSXdzMyq1nRy1DuuFuc2ULafmfKhHiZcV+3OWKa6gXH5ZHPgB8iQnTJTC5xbA== 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=XB0r+rzkrWS+zQQTlAjsnrMWWHVWEZr99UXf0qaQoKI=; b=hxcvIFhyO6oScD3NQwh5+f6RiqPdJdaL4GOdcjsOIjIGYpIt0Z5TEY+hHj70ZWYfogRZWBkFXn6iPbhf06xssm4d7JyW6VSqWYQ/DB0VNUOyet9JCWGcPsr8KffdrLQS/9KaA/m8oJiTRzzpNH7VCiexpZ58lBTyRmMGpMsYuN4= 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 CO6PR04MB8348.namprd04.prod.outlook.com (2603:10b6:303:137::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18; Tue, 12 Oct 2021 09:59:36 +0000 Received: from CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::8100:4308:5b21:8d97]) by CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::8100:4308:5b21:8d97%9]) with mapi id 15.20.4587.026; Tue, 12 Oct 2021 09:59:36 +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 v9 2/8] RISC-V: Rename relocate() and make it global Date: Tue, 12 Oct 2021 15:28:51 +0530 Message-Id: <20211012095857.1314214-3-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211012095857.1314214-1-anup.patel@wdc.com> References: <20211012095857.1314214-1-anup.patel@wdc.com> X-ClientProxiedBy: MAXPR01CA0106.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::24) To CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) MIME-Version: 1.0 Received: from wdc.com (122.179.114.63) by MAXPR01CA0106.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.24 via Frontend Transport; Tue, 12 Oct 2021 09:59:31 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ace50fac-07c1-4c88-d7df-08d98d66ff78 X-MS-TrafficTypeDiagnostic: CO6PR04MB8348: 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-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bdGxC/yWIMa6lFUAqhXIdjkCfApgmyG/P2pKb/7Tx2hppSQQ+d50olqUOYkdK03Vc5RChIciQ8uFtxvKwY4R4B73dqDBGdo1E+OxEYJ1lWN5LWBRAHGzdrdn+P1llyoHfyd9tOjAkqENDHQwWpcDTFrmFQK9HqMXXFH8pTYROYA066o3YezYuKdEKmO4/MxdhDPMjHeRryCO3o21nPDXvnakdzLNYN1w6rAmKCMNEcULb2MxhggZLGpY09e6/EWfR9XnwEthHowFBMGdzgM0RFmvP6eHJwwPMJsJw10/hBcwaJHvMvXVcmXdQD73eZV4SAHIzjYtoVP6L5RdaguaIY/N3Y6J0TpUw+A+gllIhb60X9VVcNg4oARAsN7c4tvLynh9iZ1K9DKC7FkYVLZjWM9RXEdCoVNToolHGc8QB6h+6ImiUJbCxT1G50YnOA7B987pBOvkijzYo5rzjcbOudhW8HJRg+rVnzEi0XDazCGo0tdfvvEsVqHCiYTqKqiHRLeZJW+wQeyNU7R2s8axc/oodWhKml4QHSXd1N73yXrX6VtVm7gIws5tjoWEKGThYJege0ACAScdKbNaxIL749wsd//wu2sHL2QRLB80xs96if16iwIrk2hiYWnlpQzVxWnLnbjrJ7zCSRo3hBIH27pIznaVzfpJsg6zK79JkkRDLwUVzAAIsisC4/ig92FEyMmQrQStmlhiAgRRTZYhKA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO6PR04MB7812.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(8936002)(6666004)(1076003)(8676002)(316002)(110136005)(44832011)(7416002)(508600001)(8886007)(54906003)(4326008)(2906002)(956004)(2616005)(38100700002)(55016002)(26005)(7696005)(83380400001)(36756003)(52116002)(186003)(38350700002)(66946007)(86362001)(66556008)(66476007)(5660300002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: p2Ov4Pzly2CF5b0xytsWWl2G06zmAxd3TnnxTuyHjt2Fzfx15FwMgOykGIY1rcpt6hstdg5ivVvxek5x8P1WLycpc3maLhYhqNyJp1eo3wnWdHMIC60Gehh58DaiT/on6EOpqV36Ip8qJtq33Wc5ykkFSfC1MQ0YN3NhSpFjX6Wu30zybrca+G9MDIiy39xsdtIrvYfUh1p8efwBo3Z4owScOhP9WtONI0fE6gVNo04zsBhclMnXSfhdLrA5iOm4mH3H5bPDWntHqKJNSnqBmBJpFJM9xf279lIPTiK9SK2fQuj39Xuu8y8I/tZ6rxPK4vNd2DcO4eKMSbLIZufMBXdTorMR77RL+gzNLUlrzx5dlDDjZs9g/0feiZlYW3oKc7lbGmOqNcaTKbqbLGJYml6Hed/e9BUkl1HStS9uhQh3Ss6kTZtHZUeCxew9EhWACboQMwAujk4eNGeKTTKic7zaHZ6swoTmeqzpQsqlDocDkYwl8izUofoC6hbLINEQHl7Qy5ZLRe0LPMoP7TTbBoN3kjyvbpf5EjniYVEnx5o0MCch3+LHGE3Ssd47AgnCfn1nzeGPOqJWNUhki60yFB5u5FvkOkyY1x1EcBOv/5jrlUndZWaSWobyNxgSJZNgdTK2z4wa15JWYxy0Uz4WNYMceQ1V7/qax7pDuHQJblXFme4asSMGlvw258/HDCC4FgbLbibE6ebqV0T5HXDRUnbIhWR9N7Cn2jpLG6jRLXKC5orgXo6/+OPQ6A08zGrEhQVxcooxAhkUduCzSQb4BiZWmMWl6R0acBbu/Cj21TKAMAshLrUbIWC5Gpo0a7g5h1SZ+B8dkC6Cvwnu9/KpysGaOxQSG2RdzPqq0GLd/S9jxsfFOyYhJjsOyR+KjvGZ3isQU2plaHGzqddmhCBr0WKKuFRfqd2A0rSNjlPKe8A9nPQXn9tPmCjY6tNqBGlzseBcMkMFPYLe5IzR6hQy3H6x34R+keE0/Ko1l7Gg9T907SSUvLSlLq6Ssd7YTmI0g3CH1WxfKlpz0t4p55lXLmG7kq000bXwvAt3TMre3uCWL51Od4vc3WFY71aKjANFCSCpU/9r/gHcmYAwyerGoMLH+E+BXm7wAtgvu4qkRYB10tpA5jOR3h1GArspkcIqAkv0xW211CeGxjMfyJAjiO+JTY0FMktI2hIO4m8Hn8pmcR4ckHuTekF2fuQfQChZ88dvpZYeQKgQZYnspY2LLEiHNcfOcK/WHXHStbg523gO15MOj74uMyUQ8OfBbV8fUo9NTMJFFMqhemH5/e2cWrMtV9a/Jc6oBo2ORbqpYF9KWKTtYNjnBw+19x8xQ5Jx X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: ace50fac-07c1-4c88-d7df-08d98d66ff78 X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2021 09:59:36.5122 (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: tSeyfNKPXYVZf2Q+IKPaFDDRuyDk5vE7UVm2nW9pUNE0mkWNDQ4e0DKOmMC5e0NGc71kNFu9CzpuqW82riIlUw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB8348 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211012_025940_377694_828CD5D2 X-CRM114-Status: GOOD ( 13.30 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.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 fce5184b22c3..8ff8412db99f 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_map 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 Tue Oct 12 09:58:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 12551893 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65F29C433F5 for ; Tue, 12 Oct 2021 10:01:07 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2C89161040 for ; Tue, 12 Oct 2021 10:01:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2C89161040 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=zwS1Q+6LiDyvYUV/QCB+BjnPZL+dA8cdQntS6e1+15c=; b=LZZ0iQxkBOXfYc UciCTIU8POY1/pbpJ4+j413bXFYBO5c3T03rjvWATokCNEi6u3mYyHy57BVGl7jLzM0K1R7HF//jx 9W6BhcxWANrfrnsyssX1ENolFeyXXrZcGi5bM8oW/ZuhU+dZce3YEWq99nKdZvl5a2ziGJuiI7F8M a5ZkkcsrsDDQtj6AYy/SgwWvUU00wii4tL1JXHHNnb/zIkRmxC0wEGvUrjBG4fjmmLm2g4/6kZ5je ufcbnllvJ36FqLf2RzpF+mw5qQH1UsG+9WvozK5WHF8xCW3a8xFV79HPkvjNWGHo6GSF2GDaxNyH4 ykYK1JEuxfVwJdtPY5wA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1maEaf-00CKXX-29; Tue, 12 Oct 2021 10:00:57 +0000 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1maEZW-00CK6T-Hu; Tue, 12 Oct 2021 09:59:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634032786; x=1665568786; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=Z5nKpvhaZLHSAmj9tp9ZCQ+LFUkNITuAmDD6xERxspo=; b=Wjv/QInvhXmdVMgy9MuGlyl/x5SWK9rx3585OE//YC3KYyqO2z/y8GUg 8Mivza/giJTmIeJqRHRvLadYqW0XspjtfwU6sU2nqcwuZA/PHX6FFaKPg jvmbO3rjjGnFHuiSDJIuc7oyxifTh64p8h00haX2igqcdeAjy6/p0DxV4 7JDWtN70LgTTXHfG5eMa5rYrgIPf0BPzI2p8EIwi0kEbtBefUzpaf14kx pCukwIQcueExTyhomMYYGnCCOMwoef8kIlcPulKF9SlgGeLeTmSw6SBUl 5f2gKXIsgse77OnC9SdiAduC59g4j5arChP9WPnYse+T7xl7mxqSBQdhC g==; X-IronPort-AV: E=Sophos;i="5.85,367,1624291200"; d="scan'208";a="181612325" Received: from mail-co1nam11lp2177.outbound.protection.outlook.com (HELO NAM11-CO1-obe.outbound.protection.outlook.com) ([104.47.56.177]) by ob1.hgst.iphmx.com with ESMTP; 12 Oct 2021 17:59:43 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Nvgjxgc5IqbG8kyvgLsl+M4jKrcLbynsJc5gqbHvR9JdsBHNdznOvDavMp7ah3mmR/MUQF9Yr6D65hdtJEHxnjQNzGaWfgAkSXTcCJCrhQmsUJBSKDQhj8v9GkkKu/BMK71g+2nMAbaTqhrAyP0LS/YEg01Yg7YkdUBX4ELXu3pYxOX99QMFP7fXamL5itRbizNJ4fTRdkAMafXnVnhHpXTe++CCky+xwu1ytNubW9HAyhPZHMuRaXftESpmNsFbSp84gsBZoJvHYP6W2aSjS+VfjM0if//lTKKV5UlaRGNg+vfnfMLZTrifsX8qOeR72+Cj44/mwTwY+yeeNagRbA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BDupqxTCR6cE3vr0q9/GTcz1EhQ4kyzu+V6Mopyyaik=; b=ei5skft2EisApdpAJI6oOMqa+gBhhc2H8I6fn1WG8dpJsPVhR19VYOEhu4mbZSJXxjWxPwqhpH2Pq89nCaVK5ahR/VFyb8HuWmisiH7ZgwOcJPw2BL+VckHJzrsdxiOXu0ns1yUcWDiksy36YSIUwUBdFOC+Nh/NQxZnFU3miDcrlpywgsLfc3tPNE/z1mTSnyQxwSgjgLQ0mgZhckhdcpXzF2cKH/KCIO2ps3ZnoIW3++Kh3welbGvU5FX1iKWvQvxGm0hFwDVdRFZCzVjcIe1/S0/LDDmjKIDELv4tvMO62PKYc39YzbrmQm6ZMp2Ut+KsJolLHG/jTh2PqmwCKw== 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=BDupqxTCR6cE3vr0q9/GTcz1EhQ4kyzu+V6Mopyyaik=; b=yEejHAPpYbNF/YRZRCQsBFiUUDu6lI8Egu1RiYcI6oJq9LzDIk5V8Ez6ydH81MziOFCr9/tuVO9lwWMjtaBYG5UU5oIvXTWl/KOrhLikGkJVIkG2s2kNbGMcg4o0WoE0yx+oBs3pMe8XoAGot6uNcta1Qeb+LqL4rcWy9QbD9OY= 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 CO6PR04MB8348.namprd04.prod.outlook.com (2603:10b6:303:137::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18; Tue, 12 Oct 2021 09:59:42 +0000 Received: from CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::8100:4308:5b21:8d97]) by CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::8100:4308:5b21:8d97%9]) with mapi id 15.20.4587.026; Tue, 12 Oct 2021 09:59:41 +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 v9 3/8] RISC-V: Add arch functions for non-retentive suspend entry/exit Date: Tue, 12 Oct 2021 15:28:52 +0530 Message-Id: <20211012095857.1314214-4-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211012095857.1314214-1-anup.patel@wdc.com> References: <20211012095857.1314214-1-anup.patel@wdc.com> X-ClientProxiedBy: MAXPR01CA0106.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::24) To CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) MIME-Version: 1.0 Received: from wdc.com (122.179.114.63) by MAXPR01CA0106.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.24 via Frontend Transport; Tue, 12 Oct 2021 09:59:37 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 69ed93d0-9b4d-47cc-35cb-08d98d6702ad X-MS-TrafficTypeDiagnostic: CO6PR04MB8348: 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-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AFEJ9EFEpAq331Gu5V8jvfz7Dy42AadoUyyvAn6pv9Vv17kUqU1yu+dX69P6bMUEAn5soP9IUPriLSuUG+YQMj/KufycU9n/4mtNYP5qYfVQcOTDT+D4TRD2CO8uVSZKRgXQIvwfj9RI0I6FbpEuvTTbbn9VLAL9D2NQ8C7c8wnkTLJXe6JrjPD6BSuJ9uYui33T6a6Yz7oXVmFmZJW8F44f4tEDjomUHlan/7E4xzWFxQP+yeVn2Hy1IU5o5uB9bxH22v7taFdD9cYmB17ZN6+dOu7t4Xd4SsBEINN8bwdoTb9+alDvteMk4eONhCNvicu6+Vo7wK0cAtVzlgf+NcFqNw1bp38vhi068oJ+itTiMd6Vq2OYkgXxRzuEjcBUkV4MEbHygpiFmpULzvgapd/X/H5UR4daGA59zuG+9SPHZ/9rlk2J2LI5VdbE7L619D20wCjK7pKYy1KwV1/VJBNSM0cqtDCCUMcw9BUxe3Ki45dFCuCRvJENh3x7DrArDNmUqx6xaCT5tT3V9MImNBuUoxHIRDiU1r3loBxP8Gemj/E8gI5EIFaTZ45h/DlZWIEWhcrQ5GVy6gSNRlJg3hK8uV6AbvyST16kJhOQi9ln9yJS9JWK4ExCsvpJNltQHhawVkZY+1sXxnJvPS91ZDPvkD8iy/1swJj9L9W2VSRfNvzWXV308s2f3rtL9jfiZBGua9n1iSfuIXCpBm2/eg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO6PR04MB7812.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(8936002)(6666004)(1076003)(8676002)(316002)(110136005)(44832011)(7416002)(508600001)(8886007)(54906003)(4326008)(2906002)(956004)(2616005)(38100700002)(55016002)(26005)(7696005)(83380400001)(36756003)(52116002)(186003)(38350700002)(66946007)(86362001)(66556008)(66476007)(30864003)(15650500001)(5660300002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: eQR4s7bb2Mr3xa48UKBLiZiZbLgim+wH8Glv2W42PAoZgBtKSbGAO7ETPY7h2b0R/3mWAVQa+MEzAkadVSA9yzv2phdcdVAOF3PiRw5cCWqKiKYRczAb/g3ubGCua4IfKssWTYKh6v62CNkcH1BwhTHNgLMQFim11+sN9DZyx+2Wm2xJSORcJAyZ3ctkWfamSAulOqcooLvEBDCE8g661E05+/GqHvpZtpn1XvRsqb62LH4huh5Yhr2LB+7X7hqd7H2pM95U5kyuyDkXA1ZBw0Q5jqfmc4RHtiZ2ndW+SfwHTR47GkH/xGZyDxLaTfPSbt/eWmtAuTENJ477CMhmzaTSIY1h7Dexqjo9rIa86o/c0yOgRsxEEFrRsaDjJpaaxJDgsIEHxiG8J6UI+5PRzBCQlGBiCeXwiprEtATf9Ld386BFLcCJq4pyf3mTKsbnNm+xxHX+zkoYip1E/y0xZ/feGyvI3+I8/S2vtLGHzulQyf5F2wsnO+G/MiPZXl3aoBRpDXEnNR6uqzFGi1cOg1r0WCOvdldxnUznbU0JKphJTQqNCOtNIz1RBMrjuJVhs2iSKvW3HyypUnmi/c15EGkkxXHutcVtwiGZBjsaANDZzSh3TZxw7/nEFUzxBGQFKUMYbfNZ0KrniJJPl0Ej8KDO6UaSxvIKJCZQLVxWk9vvRvO1YlfWNN5DTLOrh3or79aAaSeIl18soXMFSBXebsTsnnGG0NaOb18IF2V/FtHI+Kq4AS9+9fNtsOsUopNtiBAVuh6+pnNBOVVBx2SwsMmiRRbF46+U0+pLuoDsmEwVpNDFLFZyplOe9POUwz/MuWfZlAS46UkA/WJVgobHPDil7d57Q8rwugTtdm7SCILeNRZhgANZcGweszJ1KibowVuuX11VP9J/mxGOImJTiEd4lpkT+dJ5d20OBoMZIQjUr3FLzVii350k4S+Ndxc6S3oZtqkmeIkBp0gzkRqIqEaGws4lEbCjqldpMhcPTDLGpiFoGHibvsGwE/dPtGowyAUSozGNOCEmN7xT0v2oXn4ebhGG4CgxYzT04pyDjC0yajOFbOFai2S/55221djHnfA94IWBaho1dIdiTp6+uLnPqWAPoa6loykICTIA9ChEvRu0hont5HWgik13H9VOGVyQ8OaZGWLT9LVHGsVsNM0vkixkA6zZRuDSo8frMdcLDPU+ONVuD/trW/Z7W7cYF/ay4VKnqd0dnFUz3jHj2bB0YhTdAZBzPk4iRzGpsJkUnYoOXZzmxL94aOZVw5TWRAk9EGda6Bqwb+vHikQeAAXTi1GwR1KzSHXjHjKGhqxIoTcIC7skPLjkj8mHmA3C X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 69ed93d0-9b4d-47cc-35cb-08d98d6702ad X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2021 09:59:41.8756 (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: XavPxIxumE8vQbtlGWRtPEB/4rpQBbxsoGnT9DIizGGI0vpAXhShhwh7dQCAuIjOI3Rt9oCb4Xm5rY2//9waEQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB8348 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211012_025946_722781_135D9F0B X-CRM114-Status: GOOD ( 24.11 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.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 3397ddac1a30..4320629c07c3 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 90f8ce64fa6f..5eae19971f47 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 8ff8412db99f..6cb6f6eec575 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 Tue Oct 12 09:58:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 12551895 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99BC8C433F5 for ; Tue, 12 Oct 2021 10:02:02 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 62D0961040 for ; Tue, 12 Oct 2021 10:02:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 62D0961040 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=nBWpcBNVIzhiANCOwutmsagzw1Gg0bgSDj4oMIL1c4c=; b=Jy0AOF1opAtdVl YyTRO/0H10E3nZtmdq5qU5qgeupZVgxETMX6SPL5tt+bxIIVlJQSI/b7vA6o8bI8Gw2zMxA01CCFq 3JqMBZ26VwhP9njnTYypqOsm/wafWbr+a/8UQBX5CoQGJtcLa9zhxxUjWsUL0Ix4jQdNOCRWK2p4o Su679R2dAhU+HegZB03cOxWt/Oi5IAH7b1em1iGeVmZmn++TRPTL92/nvqXws5rN5KZSjcioFJvy6 CR1tIoRYXWbAwFmeO61yaR7lj+KCVTTsVR6ipzQ6eWfaN8+bgyM8/QpM0jAPaVEeiPaHYNbrx8UBN Rms4+kv0Vg608dWwrFww==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1maEbZ-00CKt2-9Q; Tue, 12 Oct 2021 10:01:53 +0000 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1maEZZ-00CK6T-8v; Tue, 12 Oct 2021 09:59:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634032789; x=1665568789; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=UeD+FgLO9aIjFzdKrHDcrkqDgbjr4ljOtP7t6+n6Irg=; b=FuEcxMrF3gaA/TCgmljGQ7h4EBos84Y5hNAtsOXH7CLb6/xGReb3iBcs MknL1QrMs/QVWL3TyujoBAL16VwWvJ4x6Ca0camOJe/gg2glXBX4oz3pb 7H3lJAdWzaOPIirfu5EYuNiGzVa3RpkfHpiGseASX+yNmZOPZZu+5WUvp 4gocTCGcr2dxrYYoStb5XGdLo6CNufBoQHoIwXtDdetKKKLgFLqCoWX16 l/zIZKMWBUZf5YC/BhE2SB9sK5QU/5E1gHVa9JDWAgw1mGN5pR5JeVSvP ILy01TVz4oKngncw4lWcZwnD4unpXDifNenj+9QIvdVe6vIG9QglFuQzi A==; X-IronPort-AV: E=Sophos;i="5.85,367,1624291200"; d="scan'208";a="181612328" Received: from mail-co1nam11lp2171.outbound.protection.outlook.com (HELO NAM11-CO1-obe.outbound.protection.outlook.com) ([104.47.56.171]) by ob1.hgst.iphmx.com with ESMTP; 12 Oct 2021 17:59:48 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BkUX7hyLXdjMn+AHgD3M70Iquvyredsf3Hhv/kpUwt4Mnrt3TsCR4xvFYm+pSJGvtSHUIUWw98LwzvkoTHB1n6WQcOoSXZbnssTwzQ2p+wSKy4VozTIgzTjZr+Vhkjv7nED8cXVmP0XWDoFI2EI4VjeMCmDkufzJDPIilIBqVNDn+nUcLOK4edRwW4I4fL3D9HL/S64nZtitMYVYTQHXGkix25pztUshi2uQlUXTQ5tuRQ/363N8IyNRiV+tMIv+HnLYXm+JmR/z0WUmfqS/kwSXcqkLFbpG/lV9OhRofv/bzQe3CzlyUC4kGl2l55lgCwpEAJcZpB9tGvDfwHfV5A== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4QXaNsRGTyDgz2Sn7I2zPdXMtXIGlsEhVecpbL/TqiQ=; b=SrdrGgHHgs5EvUIi19rlQ9xZXL5Q/EeMmT7BtkaDMy2OMzZY+id6o+S6MBaLwyVF3bpZhSHZPFpx8APiOnX+eIso86w1GUk5PVGHpV/qRA6X1u8cFaWStzJuXKxFBHrnA6P90u/PSP97NaRNCsq80XRIZbanPlDoGBIG5Tcx75wP7a/co/WIJ0DwT5UBWREcUUuiANz0xHRh7wpLlI84j1UWgs7arGw+KjZu4SjFjWIqy0R9Q4dP/DeoxnKMqJk3pH2GznG0F9R0b+TXm6yPe9DV0vIFZAHba6d/cjPSuxTsDUVj6PBqeF+2A+iIGnFqCrJ0wA+OPE3WKo4pJJQKVg== 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=G70XHiCOnzbDwhf2UUqkTcCOROlDfUzuqgQ58nnfL2RB3DvXdYqPRbnRwkeKaD1mZ+UOqlwY3I15wmihTI7RMZCRhtnKBXMK2sM64NvIlq1WFgww2v9p9nBcjJEHVZx36F+uk5EybdT1fBXxlJV156NpGfv/ylbycABqAuD7gW4= 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 CO6PR04MB8348.namprd04.prod.outlook.com (2603:10b6:303:137::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18; Tue, 12 Oct 2021 09:59:47 +0000 Received: from CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::8100:4308:5b21:8d97]) by CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::8100:4308:5b21:8d97%9]) with mapi id 15.20.4587.026; Tue, 12 Oct 2021 09:59:47 +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 v9 4/8] RISC-V: Add SBI HSM suspend related defines Date: Tue, 12 Oct 2021 15:28:53 +0530 Message-Id: <20211012095857.1314214-5-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211012095857.1314214-1-anup.patel@wdc.com> References: <20211012095857.1314214-1-anup.patel@wdc.com> X-ClientProxiedBy: MAXPR01CA0106.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::24) To CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) MIME-Version: 1.0 Received: from wdc.com (122.179.114.63) by MAXPR01CA0106.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.24 via Frontend Transport; Tue, 12 Oct 2021 09:59:42 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5f893829-c263-4573-72de-08d98d6705d3 X-MS-TrafficTypeDiagnostic: CO6PR04MB8348: 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-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EQ1f04OA+Q6bmL3PPdwfvPZlvOv4oAoI7xO+HPksNdBTwJinG9UolV2bYdldg4TxALwGB34za4Nj0SlPtDCoDkaylF/l6cYRyqruxCQULzZ3FHO//rxRzymIGVYuTYCM5/XsgFXcqlvo8GXkOGcUNB7dW+8+3fA2fAgCCEHAj9kl3jY9U1xN/I6P0a5JI6uF30Gpy+6xj3frhf1r2bxEqRXgNIn73GEGfrqxGz9CQbJWpIjqK/rRwnctFltFcO9fk3WkhLeWEhAgeItZvRKJPhvqtaIVdm+R2ARd+RFVT9C9lbP+DYW5afXVfxhTIAXTWonyVM6tzPhGZVaRn92y3HBxgggwyH5PipmT0EAnKTyHPPqCENjkWOFrh08EfSnSqcKdIiQbVpfxW6l2RivI+KqFAfr2d2qPk3YTwtwxI/u3/Gqvdj4qe2AHypGjz5//5daq9uBLRmVeACJ66NRBseLexpkbFaA9il2Z87gSt9U7B5phM7WYXhhqz6bFaGi1cGx7Q0Tn0CKdmQsDhaXUmVGl5hH6C0ojTpETUy22iVQG7pq6Xkfqj8ELhcmx8gJhaZUfRiVnwa29bbTEh/coHi6OUPzf7aCiHTkDlq7s16e1sIixEug3/CmRHLRO7642Lv2BfwRf5yj/NQ3inWtUIaG3IzWfq3i/Jt/6ICZcJddu3If/82kHOPAgc3bmxnj16ZUNs17BKBhPaR5AlXH4OA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO6PR04MB7812.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(8936002)(6666004)(1076003)(8676002)(316002)(110136005)(44832011)(7416002)(508600001)(8886007)(54906003)(4326008)(2906002)(956004)(2616005)(38100700002)(55016002)(26005)(7696005)(83380400001)(36756003)(52116002)(186003)(38350700002)(66946007)(86362001)(66556008)(66476007)(15650500001)(5660300002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AanbN/TOTcAjn5JnAoAGLMlVzJbi08QMUVRD+MQj7rGaH81QNncbcqfsmfAErueOHiJYoyv0ESv4TNHI8FbgQV5K67iSkEX0fuZ7MEvVRqoGKD1v2x9b2R3hfXm/ckrbW/PWDZKg06ktW+YwUJRc9TidLgXSeSN0kQ1ADGMrzkSsDXIA4gML31wx3gA3gMFvALfkis9ZchOLP6hnz9Mkh+PM+1ZIK1Ia0jSUnA5uhG5q29D6Ti7cdNpnLRIwEBqlSydTj5YhI3xcbn18QekdU2jrMlBz+8rmyG8PBNxu0iQP3vipBBO9xKfV5yZgAmbm2kjoEdq82Uk9s9niZLtqGwBBsCaIADLdA3c3pi7OcYo2JGHC8s2XRO+YUyFoKXeZmOtc9KBJdvx/Ge4XiO37BvGwDVsrDE1BgMftrOilD5YEFEdw6m0hbN26E30u2hc26mQgvhlFcGM1RcwvkLuCZMYMwLA5/jeWw6hAYrNGA37VnbuCedMHlG1YXq2zNE9JqB0s4Esx95LF2rmOXc5YIqI4fCqSHnjeqjnyb4xLwyaRbtQEIu0neRjoc/RxRfy8Q4ZbJGSxjnoiSRnF49jNIBmo3W/aIBhSVjTq8OksHfvJOCgEwcCx4tWBLgVACwIFHFKsVokl1AcbO1GvlDI/OIByorykCpBhi/qfrV0KcTG/ZN2/Xpf+phrJzBO/cGykCziKXni68ShgCWambPKl40/JmSwxPehmjees61YkUM53Yz9QA/e3Kyp/e2bHO9VH7Uv5SEMRBq09zDVQP7kx8O9c1qhAne7h30/0Zh8zF/QJX6MqgozGsUDYPzMWNdlHZHBg1xOufKu2AamX3uDN38keR5VIavU5mLEaeWmFTE0IEIusPbTF1bktdreApJnExkYYv55EGD2NX93M5Ltzib7BizNPByJvYjFNHgUrYNSoQaSRyiE6zmvgh3n5n0gdosN0WC4/nHofGOABIcAUXAZ6u8pM5XIl12aVmMTabxYsUHl/BV4pUQh+FJD5WHVZ6fRUo7+ZECjDEbADrybkM6X6lwzDPXZZSakVOCvyT3yIzUNn2pq7i5rqJ+F36Cvia7qG6772J5DCgI3OH56veVInB62LK7ktifBByeJBDF6EyN4n51bc8db4qNktv6d7YCaMUZG2hik4+spP36d75keeLQfcEkWqcQNqagrLanrjHAm0LuhLo5UAN3m5Eu1vhSWz45RklqA8Xv9QKTbZ4tmPG3VuYDTLdMB+Ad+IXcfLwBsqkD068mw9bTLbbLtjeKcjge8s0YNqOCoCGWIjOIzyz9xEuf0jblxn+tQxNHHpP5ic/g96cR2XZt06e4mx X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5f893829-c263-4573-72de-08d98d6705d3 X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2021 09:59:46.9443 (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: sDtEJFhnlu1Al7/Vtl63Pq9UygQddmcg9LLcqY5R+F86N9XU1agOTImHK/zYFqh1uctSfFrGCMIN+plUB1IjYw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB8348 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211012_025949_455097_D8E1A5F2 X-CRM114-Status: GOOD ( 14.57 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.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 Tue Oct 12 09:58:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 12551913 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E1F7C433F5 for ; Tue, 12 Oct 2021 10:03:44 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 415A460724 for ; Tue, 12 Oct 2021 10:03:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 415A460724 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=a/qals9N6cua7hiI5QvDqepN6rOxfQC9lN5TfwtAw0U=; b=38b+m08H5BR5t8 aGpEuuK16ixnf68fFuWNg/nNphQOPCKlGZM1WwGOn+Ufe4IZMn7FzuL+Hmv08309Pti6mm+ODeDyr uFP92zVir5fJN/BWaELEHHEcNKO2Lb5fFfFd+x6oNnxMqUQie98iZFtbiccipEm9uFADgDb1LnJ97 r150bqqOaKQxeo4iyd3DqYocVOvqwH8oM8RytKQg19tmpmeHY+VDwa3UNRVjDPdL3oOF287MSI7At OdZpxsJinVjvV3/Il+fY7zYT1/eHma8Ox54tyEvTSyCIw82ZBkeAwEEkPCbSzejgzFNFSs0qxMt4V pDjLTep4Bbh9kpa28Qng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1maEd0-00CLSH-2a; Tue, 12 Oct 2021 10:03:22 +0000 Received: from esa5.hgst.iphmx.com ([216.71.153.144]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1maEZf-00CK8h-P8; Tue, 12 Oct 2021 09:59:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634032795; x=1665568795; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=rvE/g+CVNRd/cKXoslQvV3X4nr1n1UFoBX8EKfr0C3s=; b=QJ1Gv9LLjLfSwpRUK3QboDOy44nQbP6uGvVguBqAUyuBOKMMp5I5/QEv mAqrtDS728f89wJQBt1v81YmRtR2fC9N7JLUP15Ee5cISDZpSlKDZ85eN M/rYKXdpGvAQchmM1lNurKx7toJt3tnCrfKhgepGA+J/6FdNHmaTDjzOm 0kz8xCqHZmJsgiykGRHF91F0ArznHhd4IJOr6XvsZ3A89okNJx4M/EuX/ 9932ISnpir9jlmDL5V+YdGLJ6VEkGE3cYMBb1SR5rbaai7Idyxv9Ulvfd xyRP/at7tUflyEp2hYhYdBH1SCUhad3CvF2oKcrNI0ehUm+zeeWlCYsMM g==; X-IronPort-AV: E=Sophos;i="5.85,367,1624291200"; d="scan'208";a="182592173" Received: from mail-dm6nam12lp2177.outbound.protection.outlook.com (HELO NAM12-DM6-obe.outbound.protection.outlook.com) ([104.47.59.177]) by ob1.hgst.iphmx.com with ESMTP; 12 Oct 2021 17:59:53 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MSzUuxwlkAdasPvy2AH/vCZM+PiKAvfPq5KyVskYn15ScYYeOEoDxZOA9v8qqFv+c8h+XfPyYuFEBGyn9PM7FvK4mgDPkAe4AHdqHxE7ElYSe9HDg++zOXiOxwldzZvABfgWOCwzP1+WH30GcsUiET+AmwUV8J+mNIfymQ+pJenwIQld2zOC9zmKo+CuRG8KLYHBSetJBcWHLuSPpdduOJAjyQaFPOdrmlWO3osrkad9l2gP9sCE8Kw+d2KO69NnJHLsQgSA7EW/plRAuaGAjilNl0ofhI8I2fpfRSNVIPOF3eD4Pwj5peDdIaxRyyeVgz3SM2q4KW2vXNEKzoAbCQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XLvNkDJifV3Ha4j3JttH7s5CN1gObb1yVbFlM+bAAQ8=; b=EUIC/YZPNpdGaona9FbfYYeP1kRgokb8VHaPane6YlvicfYueUtYpUlavdn1/98luOS1k1rFxcg2FPwXtH3QKc0+M9oh77qncIFq/TXVzIsqGcsbA6qxNti1uAVEeJiMSB7omMrmTNMhLk9j4r8bcbVcXa1nLEo0aihqkFkQY2EedoxGQV25xqSieYaNQJTmbppURlnPzvxJvWzf7j76lg34xzgvO7zi+lYw+AJ/byjIv1lL0dmqmMJ39CFFYkXfExmo4m8h63I4PQ9uYHWj4JrRMhyJK0NqGoPiQ1mB3a70lxIYgEBn+jgbN7HzJJZK8BQIfwOKwuBELVFqrhlvgw== 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=XLvNkDJifV3Ha4j3JttH7s5CN1gObb1yVbFlM+bAAQ8=; b=vtFJt5PtWkFi86R0Nv9DiYwx+suwpEJgIx+r0GIMf2bpRRxsifMc5uZAC+D5MLi89IdwcjeU1EvjDiZMyrQAcsFTSMZhMiaJjXjl+cXOy65h4tsaVmom13rG1zOL/t8YmS9K4TW3SGLiZlHm6A/+sP1cNYy0YhQeW1wR7Ji0Geg= 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 CO6PR04MB8348.namprd04.prod.outlook.com (2603:10b6:303:137::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18; Tue, 12 Oct 2021 09:59:52 +0000 Received: from CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::8100:4308:5b21:8d97]) by CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::8100:4308:5b21:8d97%9]) with mapi id 15.20.4587.026; Tue, 12 Oct 2021 09:59:52 +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 v9 5/8] cpuidle: Factor-out power domain related code from PSCI domain driver Date: Tue, 12 Oct 2021 15:28:54 +0530 Message-Id: <20211012095857.1314214-6-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211012095857.1314214-1-anup.patel@wdc.com> References: <20211012095857.1314214-1-anup.patel@wdc.com> X-ClientProxiedBy: MAXPR01CA0106.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::24) To CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) MIME-Version: 1.0 Received: from wdc.com (122.179.114.63) by MAXPR01CA0106.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.24 via Frontend Transport; Tue, 12 Oct 2021 09:59:47 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c45a6b0f-42cd-4cb3-4aab-08d98d6708e2 X-MS-TrafficTypeDiagnostic: CO6PR04MB8348: 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-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: v8Wkmmoyi7N41mruPAFYYPSPBdTVT2mo+pnw0YX+RrnDdf4BxNqCfqPb/UiRS7raT7IijdgCTj/i79Gm2Sf2YPjDJUSrhg/gj8hCIWHxDj6ADfQEi3Du3qVe+fcJxlTze1m7kh2KmilVa/k0VPCvOxu9X4eaLk0zlwGJIH5MRoaxEh2A7s4XeHPHbhWGRUDAM5tK+F0wvimIIUc+IGVLzKS/H6TLSreEzuzwweFkb+iwD61wIqkSu3/tTqN/nROJFnEThgb5DHwjfG8W6PaoqsXnXK1a2rLAl8z1gb6A/K4aT6enqQLLK39/nL8Swg57Y09T4XencJSgIa/loaLVsBajfs+InyUhJ6s76EqhUYMuu072QFTjwpev7VVn5Pg3QV3RwWF+YEkdHCHEDJlFtfEDE4e2v+tRYbNa8dBSiCu/dluJ7QhyYXUPiSjGd/kk7Z/ldSTJZNY+wed//lPKKc3jf0p7aPfN6T13uWM6tat3ktllkwjqWh8S7yZwSzQjT2R1yzkVO/r6gVS2odvPjAJRdwn6WZb/QY7IJh0LRaOxBUi9j4Ma3nII4bjjIWcv8WEPHSbbwpifNodWK92YN/SHGV8qXBUcdQkbVIBLk5ucNtfUyzNy9iHY3Cvfo6dzxWfSjttCswy+F9h/UieFAHon0daXry9B4KtqtzB2KzV1mT034jC9NFfyd0KHk/KJWnMTVXtlTQlIKT1BHMVShg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO6PR04MB7812.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(8936002)(6666004)(1076003)(8676002)(316002)(110136005)(44832011)(7416002)(508600001)(8886007)(54906003)(4326008)(2906002)(956004)(2616005)(38100700002)(55016002)(26005)(7696005)(83380400001)(36756003)(52116002)(186003)(38350700002)(66946007)(86362001)(66556008)(66476007)(30864003)(5660300002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lMelOJmSjvVnw8rIXu+ovW75A33un9BEU1pa1ixHxgK3zM+T+g5jLZlCGotcSj6oUzWUewwS22LTW9ZbWuvOirlnpHo10D7ls5k65PMicygVDUgDQEwW7pzXojklybvtx5Fh0kttp1xz7OFfJ2XgI71T5nPPbRi+4mTnA8xKvJgHeyrkud67jElDIsnqLdD03JnXO2YLDcoibgSQ4F4OW+DsHB+KJcj4Bw04zMrmHZCqq88JyH9q3tQZHNC7KpoKKT9WSgM+m5v1vOWKtGOYfAiD0MXY/e6HghydNIVDpNzxi77UdlVfdu4020CviE3MsmfiwYFOO3NHtDOWK40ROlefJIMohlUtakYpfubOCX0GKO3kyoR33gBJBu5U2sAMcpBgVjNuPTbhi5QpjaJY74djV8je+BWqq3Rvfv7XllE+dmJUWjL7jBPpGYvBaXcLhbIXOxm4vZO9GE6CKQMIfKidQs/mvgsXl0BORfgOHZpE/BLf3O1Nz7I0z9MG1zTWcMa0A6R4gxEVp9iscIiLh0x5w48dWRaW3ZSLUxubsHbl4srXCCC3QKn3/IrtjAQ473EwNC+k8udAFZIvKqyKaKhQD2hjyAByHkm0BLfG0fJBmV7LZfn3KkHZmK5mCwcia4xEdVHGITVhdAvq4m9ZIwzYq+e4GK/H68rf8Mg+ZLoSoXKuhQvOVyJh1A8x1tqrrEVLmEYl5c3WTTzrzIS+XkUlL/m9GRW/0CbKtGCqle6xes4UG7O01cE3pRMgL5KoCHNxn9Va89loJmFbgKGiRfNymsLljyJY3MYArO03+uU7J6qtpOp2SRIw4Gid4jSWrjle5an6ol1xQFsb73bGPa/TnP33UwrBm1oz9jQVsvWyqDiXSwsbptcVdf9GlwuNrvf82EZjnNPwQilnzT7B4v0MLUacO2ZC5kZw2gsIg6yWkeWGLHzfDeo4jux3o+UkJMoDna/j9qV1t6dnsGzOUol4hEFiwwITMlnK3JiVHSUwHWJGRDGeLLLHDcDDIMBhLZlUyv3E8w+Nt8M8zBoOQbjZdT+oAANh7ZwnWg0Iirb9JsrJSX3Z/2W4pdrci8OMiLJMBPuOG/+W12W6e105lCExp+ULqhUx8XhybkMFEfVTzrZotxL5OmiTyF/JNRd4y7ay5hG26SkkrkWWBD/piiOPcmylRPgFWTqvnNIBkuOg/LA6iMCA28eThW7t6Kmn5N5w/h//V6gMvK1Xph1U0IvndUi7b1hTBByWeTBWe9Gh/0F5ASkONjbYdy11jdyK/gSgdzNrZ8zrgxyFVtO+3sKJkwuXBLOHNiwCJlTWem0BjFAl9HB6hNELPQCq5P6m X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: c45a6b0f-42cd-4cb3-4aab-08d98d6708e2 X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2021 09:59:52.2868 (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: i11WzYaddaG2yZSCEau1nvWTSd13QJTOsP6ZvP6YQGDiJNGp5l7Idi7C3jhdOOQPoZJH11e+Pyh2L26nIbYwXg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB8348 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211012_025955_894522_BE70CF4D X-CRM114-Status: GOOD ( 22.00 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.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 Tested-by: Heiko Stuebner --- 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 a4a0c2baaf27..c30b51511844 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4911,6 +4911,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 Tue Oct 12 09:58:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 12551915 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 575F2C433F5 for ; Tue, 12 Oct 2021 10:05:05 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 153C160698 for ; Tue, 12 Oct 2021 10:05:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 153C160698 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=F1N4irhibaGssM51JU8u/cvuCNovBdaxWwKgnCTSfmI=; b=nU6+ApRDTly4SP Y+JD3gRGxsMtzxDLlFLkVDoj6T00Wv5JvYQb958MyJSCeMLBdXr30YiR/u4ZELmFLGydLq/mDAown ei906pzEVFhf6mMexU18Oub2NAEGNtChOH0f95PIN19lbejj28uHWmpgEV6QpKtR6GnG4m/9sob3I 8bmL0k+A+mqFhYY6d2RMbeKzvlUYBi440B/uDHn4C00j2B5ZTwU24vfkjPm1q/Ks2FZfoTutSB9MO osHCCsJkWaf5CL7PNKdAylq8kdva7oxOGAicN/KG18hQzk9xzBHm5/K7xQ5OxMmQS0owkRCLU+aTJ wP03tNlNCKT7Dvodl3Lw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1maEeK-00CLxU-2H; Tue, 12 Oct 2021 10:04:44 +0000 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1maEZm-00CKAN-IE; Tue, 12 Oct 2021 10:00:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634032802; x=1665568802; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=ltZwFeuPdSQM3mzbWBTxKz/rhn9kUiMSIpK56xHnwBM=; b=CBhIxNiZRg7TiGTTN24FbB9U0vMHml3k9WTSozsVlGGPOkoYeMtLQn3m wNPWwGiAGOScvGO6Gk63HvK8fxp7QLOVfDb8HzTBUVxV50cH2sfZnEZ8d 37dJhVxIWJTV5RM7S8CVe5vuZSVgtV72ck65nHqdF3nA4EpA5y0Ch9cZL DHhVvFx8uZHfrxaRzIYwS3H8+4D5DbHTDzql5Mxmbm+pcpAaTYFKgFgAk LJOKEcs4+WRN9BC8+thYHMKy/CxqigpbV2io77h8h+y2+ErcAm9GrupWH 03y7HobhAZc5wUScatItRJORSfy6TehJ1IZpE207bvthDSiyrY8q6s1ui A==; X-IronPort-AV: E=Sophos;i="5.85,367,1624291200"; d="scan'208";a="181612348" Received: from mail-bn7nam10lp2101.outbound.protection.outlook.com (HELO NAM10-BN7-obe.outbound.protection.outlook.com) ([104.47.70.101]) by ob1.hgst.iphmx.com with ESMTP; 12 Oct 2021 17:59:59 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aFgsyW7WZf4MfvFeM4QDp2skOBG0eJjRPthEcTPbXZ7DXRHzIMKn1QvcITBCHw2AsGJKZyl2wTXtYa5qWrylW14M2FBr1NK6ZTXbnQMICE1XiI1mDOiyRW1AK2zgvLbuk28MoUf8EzOS/IFDfyScmP6OxNlsEAPhAdv/CAX5DG1AMtIVfMLuNWKRZzWS41tfo1fejjHX9mTU75Y0mxD+1MMLpNu/wlyPIJK/T8wqKPuXZrU6BMehn8kRKBhgLMZ4vZlo6sJbtM5i4wnUpnTpPApJJ8c62vQBwQzy7/x8jVSl91EdHjxMkCtD2v77nGc4MvXxN8BQjGnLJO+E0wgwjA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3h4w79NsRClr/GpMsNIEDiIi92AxAUc1530LsMGCB64=; b=heL6wDtvKQSXOZUUVKPvEIOSVnyeo+wF+Wz8d/O2ELn5Q1qbE04tF60aN3lxi0pHlBG9wRnQIDG865YrYWp85ObWzdBC4yRPHMUbcQ1oOLGLkFCZdFvCI9UuKp28S4UGzinxoPxMeZLQm6SilYfW/gi0sR7SWEt4SmWYGJUNVwjXf+Tw/Y6Zz7FWX/+cb58yn5sRITn+g9A1GuOmRWuW1zBkW4tO4ReZUW4kQR1wuv7r3BX4n6IknS3fN9lJzArucsqmbnT3/ziqJ16O/zrOkPOt069OQ+H90JrZh0tVCR8N2pOBhzR4SV8ibV+mx7imzarZK6Pom+bqR5SUgQJ2+g== 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=3h4w79NsRClr/GpMsNIEDiIi92AxAUc1530LsMGCB64=; b=QuIgr1CsJ4+3TuE/7P8r2TkEItXGtWcS1sw4CK2wKtA5TmuLobMtjzMUvROZN3jh9jNZcFA2LccTmvthsZJxnX5qi96Lc5/0da45UF/xeX0FD9T8VDaWNUwmXzrgaU8+EyVoXg8rqY/3wymJFl/Hr3h77EnBPpwt+fxXZNrkYjI= 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 CO6PR04MB8361.namprd04.prod.outlook.com (2603:10b6:303:140::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.20; Tue, 12 Oct 2021 09:59:57 +0000 Received: from CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::8100:4308:5b21:8d97]) by CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::8100:4308:5b21:8d97%9]) with mapi id 15.20.4587.026; Tue, 12 Oct 2021 09:59:57 +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 v9 6/8] cpuidle: Add RISC-V SBI CPU idle driver Date: Tue, 12 Oct 2021 15:28:55 +0530 Message-Id: <20211012095857.1314214-7-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211012095857.1314214-1-anup.patel@wdc.com> References: <20211012095857.1314214-1-anup.patel@wdc.com> X-ClientProxiedBy: MAXPR01CA0106.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::24) To CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) MIME-Version: 1.0 Received: from wdc.com (122.179.114.63) by MAXPR01CA0106.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.24 via Frontend Transport; Tue, 12 Oct 2021 09:59:52 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2dc1d978-eb03-46d1-9a7c-08d98d670bf6 X-MS-TrafficTypeDiagnostic: CO6PR04MB8361: 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-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5LNz8daI6z/imxGdU73T7m6rMsCOMQb4II+0JX5BalB1D3Gr7hxn9rgHjNJkw12IfB8QieVIr+S5fivhT/XpVTUIlSa2htxE4fa2QsZ3+iNnhyhkjsBu5FTlTSMvtfgkCbHECbG5pZalrwaxAASvBm1NdnABnPwOHg57pfZz6M490vfIjgD0pA0XBwFGdi3FoYA+VIEMTWAP22k3g8j5msdTQ0PM1MDli44KBPL+ZgBwMLPr+YOE8G2vPYeytocqNkwp+g59g2IM8Fn8Wdp7xdDUhaW6VX5dzHnZBWkUnEPJZFO8DnTA2yEOOjMdE9tjMsT+lH56ydR8C2JiX02sC50ePbeMJPTxV5wqMh6VWc+ztGlZ6dKScnIJNH9r2PHc2iyev4EmrHDMPtWQTi7ZkKQz/rKZcUGmWxluMexziIArMcWmbi5G3GZimUIgKNtm5PZBT77ifLZISgRrabRRMh7k8w2DNkuagxW22ayzAq8EhcYf5ydvd/gkqK/2AA3FXWMMAaQPDRoOxNPv/re/RbaFVfKmNizP1a66KVWdeLdNsqnECtV4KKuoFpjfoqELWUyCxVGKM+G6woCg4Ic4IahKqNvMVHHpwjJSfndQNWNt4DKv4ehlgxh7nNbAk9yBkS4ylipR4Nffm9WYcZyRgh8PZCm+FgNmcOQctbXMXng9gwyDdB1mWNvhG9yStEZ+ X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO6PR04MB7812.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(1076003)(54906003)(7696005)(8886007)(110136005)(4326008)(66946007)(86362001)(38350700002)(66556008)(38100700002)(66476007)(2906002)(316002)(55016002)(5660300002)(52116002)(508600001)(8936002)(83380400001)(26005)(186003)(956004)(2616005)(30864003)(7416002)(44832011)(8676002)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mvfZF8pOgkOMW0pwCxdsKG9J4Xvzqd6iQpVC35eklJLVFhWgTp+tn0JjP+SwJhXJOGfTmPBnOXZzmKrKxTweCoJxmr+/ciJ59QPTkQGJBqBIR9EpNyi322SY9IZinDdqyhhGh8W8DEF322EOoLLfalS2o9sCfuvMaAPiP50lbp4e+7emZgrC/bM/2eVeywXb2qXtcDb2XThUidr/6P69726B0Z45IEe5j3Xy2TOZByOINSkxw915uimuI4aiZdb7oV5txVIs8hCJbs0Abj8gLmDUlufSyG1Dv90R4SgAQbN/uBB5q2JuB1eSgzooaLCHTEa5xuJeq4Xm2LisYUB8LDBB3WtIAerKvExsotluDhdpY3j52mYK3aU4BZeXfliWJsTjNAPSl0nL3iTOE/A4mbbkPnlEroBCqiNENGOxIJiYUseOrYr+rKHcEKU0SZPxe7lbPIe0IZMkOniyADoEejJuSVKnW+GvRXejFknBj/+FQ4mujTPcJaRSeb12cMzdcEeC3//QtrDHJSvaMdxmDEPjVxNap3PZqOdWMxWIGM32yop4tlS16cFFAmNfePaOzHkgiDobhQK3WrXwnYmCkfLFmHilZF4aLkIzV5q/sW2ff0rLFdiKXv6hOXI77TtLx8oiEvjHLXTZHD7Xl3B0LnemjAsfbLu+6rsH8sDbrHol8FiSDX7npA7C3wIjUwX5w6VrG+WuQ8XMWJhHHj+AL9pVfQvZN2T1oIgNhLWVf/PZl19nyLhpE9pU9c7YXrNyIT8LhDlRXCrM44tdOpFFCvN7SuPcnd4BSTZv62UKPWnXpl9zdG4WlcY8uCJ2sOv8QyXTvdlZ0hehPo5JS0JC6O5GZS0Se2a9MF5NuVCTLvzueUwZtfMSAUMPCGUssIhkIeXprEuq2Yu5NULWsdw0MfXExTqV1iREJSuPLfghAIhm27iK6GqqlrET8o+iEY05mz1bpLgndQsl5czQwQv5RTpunSxl3S0wUcmBV8O9LpdaBkQ4A8S0igztj8BLUf6mMFRqsG4WIcn2bBPf8if6xTr/yPoE30p85uFZu1/vrDgtx6UhOBUWf0FJ3/U9jS0ccsodEXYlS2tjst3gP+g6Uz5HUXLLs4w7idZVBRZdAkXwtXHGfS1kGx2isaj84+enNjfmD9bJLbCgPSXENOvB2qPm9Yi1lv0uyWv1t22YsGdVliPT5169D7MHgIRt2UDxbeGR/3pTXbPg8GfFwYhw/PyLgHxpYzGiefW1Si1Sm91HEwE2DUeCz1RSrHZsbktwX1W9M/Deg62DqOA6H7Jo2rX8kvlHZK2dnYcKtd+vQGnq4AyDRod4nfI44klwhqei X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2dc1d978-eb03-46d1-9a7c-08d98d670bf6 X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2021 09:59:57.4252 (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: e1TJ7UqElGZ50pvQ8PWTU0/bulHfgABazfW7MqTtFkPMBkTaRILcndB4gI/wr+LaHYbKJfcNFsw8UUhSbDYiNw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB8361 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211012_030002_761537_BA4B0623 X-CRM114-Status: GOOD ( 24.20 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.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-riscv-sbi.c | 626 ++++++++++++++++++++++++++++ 5 files changed, 657 insertions(+) create mode 100644 drivers/cpuidle/Kconfig.riscv create mode 100644 drivers/cpuidle/cpuidle-riscv-sbi.c diff --git a/MAINTAINERS b/MAINTAINERS index c30b51511844..b297c395ad63 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4918,6 +4918,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: Maintained +F: drivers/cpuidle/cpuidle-riscv-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..d103342b7cfc 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-riscv-sbi.o diff --git a/drivers/cpuidle/cpuidle-riscv-sbi.c b/drivers/cpuidle/cpuidle-riscv-sbi.c new file mode 100644 index 000000000000..1f80e27c5cfb --- /dev/null +++ b/drivers/cpuidle/cpuidle-riscv-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-riscv-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 Tue Oct 12 09:58:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 12551917 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3ABE6C433F5 for ; Tue, 12 Oct 2021 10:05:52 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0372A60698 for ; Tue, 12 Oct 2021 10:05:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0372A60698 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=P+xNZ4MdnjbPu2vEnN4NrnS8edc1qzOZG6A/YZShwys=; b=Eep3AQykWLt9ki +G98777sey/uQf/ov8LVYDJzDEC2uF/lvqnkPUaYzHHsUn8bqrhLKSh5skYlUErAzU/wHDDGfMA4C zp1d+Ja7ViGlJwvX782IePAChpjm8nMTcx+Dd8kuvR8Io0aeS2xSgmGbIrAKEdy5paHQBdy64L7FN rDKZrVMxazOWYWwcTXmbN+yDhXAS35mJmeZgBkmfOHvLhbl6PlW66+2+wYzgjH0md/Le/0P04kOCB e0Ftazncg9zs5qLgmEol725D/OCaz0FTrGDtX5FqMPvabv0hfHITT/KIWG4pO1IfEErgqPzDrlNgG z3xf4LG00hdlE8RbAyeA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1maEf4-00CMDL-BS; Tue, 12 Oct 2021 10:05:30 +0000 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1maEZq-00CKAw-VM; Tue, 12 Oct 2021 10:00:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634032806; x=1665568806; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=dfUTtGja3BYY9Z7jIhwOnaT5xqXTYX1QiwVLp8l2kyI=; b=Vre4YAb0DwiyxL07z5D09cGY6lVt/GRU28NTGo35MaOBYx1t+MIRrJY9 4nF1mZkf4tW0QSHmqKKN/yhm1RT9O5563SNm1tJfCLroBL12cawMWWe/v BZDo/9ir7GqVUpO2a2zMaH/Phsg7PMtsfylvI9yv7MTJG9tWdq3pU1Ecu OoBR1Z/MHr8oFAuNYBRohQcnOpPPo8sPS5aJAguwK1V1Vn/ybpl52RA+5 R27VfZWhs/ccVYouMUDBFQI/N2r3TQtgUiCawbXwzwLSYPpUAL7dwYByw eAxba4GXnk7y2isVuCCoAqlRGVqCD8zPIjiyzh/s5EZDFCfmFTUrtjCbY w==; X-IronPort-AV: E=Sophos;i="5.85,367,1624291200"; d="scan'208";a="294312946" Received: from mail-co1nam11lp2168.outbound.protection.outlook.com (HELO NAM11-CO1-obe.outbound.protection.outlook.com) ([104.47.56.168]) by ob1.hgst.iphmx.com with ESMTP; 12 Oct 2021 18:00:04 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CeHlV3JJJSRs6PLB4qR2Cza3slb43+hAyXl47o9H2FHYfZATjnhm56du906/89wHhp0oxG6HXXLjfhGjmGJaOigrFHiQAv+lSrrY6C9oS4CGBOoCquW+gxzekL60yHgshVM18aWeLCR+e57VFdzsgJHUUGRKuOaXZC9b3fyMkUrM8LDM01cBOeyGocf2fqsl/tPPd4S7NHwRcbPbBkbn+3V7q4B6rBEMrThyjTq0zThj2KFO3oTv4pLHJm1Xy+luGThuhcUn0XruBd2K82+BCrswbeO0BMc8Sw9NnFjM46yuICo0cf4uzWwKwQwD3Ti21eAl16iJePIVKT/lqhbrSw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sPOK5HQbmkNWnvuotzfGuheTkjJSm/OQ2+vy3daIVHk=; b=OUqpRTVv72OaTCDyv0e574I1oB282p0h6fcSGu2kB9c6mUvH41Jr22WQT0t02lpG2xWkXhUvkZnLerI8ejVKTw4Wxy14zURICJ4u7c4kDvBe1KztY9QIJ2Bel47IezGWlSlQjMmQh8sih+014JiS3fO8Hp3utB/psHY3OuLUKOr+6gtrHocQ5DTWdZXHsGMr3xoBSsRFavTaIunhmfIPTyPVc4zLHkzaC/90StQlVNQwG8xCsnGyXKFc6Ype2JiaHY4tDFKxHMskmpvPuICJqcgDdC/AK2BmEHhBKxbkQGkO5Cq9/E3XLuTfVp7cJ73UAW+vC8TeilpxEdewYxXxXQ== 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=sPOK5HQbmkNWnvuotzfGuheTkjJSm/OQ2+vy3daIVHk=; b=LzxCwnJz2JDuR/RJT+4uWWoDjg+CnZUzWbsE/jcg40Hng6NOT41bLseVt1jXZGNHT7vhMnAUocPfFGo2PLZ4fBFta2JQsDuA46oLeGdvJyUf/GSOLupHF7cuoBdePkD4GfXPXH2v0Eht/Yd3u0T/2XnDPgoIFdETuqzRVV++YWA= 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 CO6PR04MB8347.namprd04.prod.outlook.com (2603:10b6:303:136::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18; Tue, 12 Oct 2021 10:00:02 +0000 Received: from CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::8100:4308:5b21:8d97]) by CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::8100:4308:5b21:8d97%9]) with mapi id 15.20.4587.026; Tue, 12 Oct 2021 10:00:02 +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 v9 7/8] dt-bindings: Add common bindings for ARM and RISC-V idle states Date: Tue, 12 Oct 2021 15:28:56 +0530 Message-Id: <20211012095857.1314214-8-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211012095857.1314214-1-anup.patel@wdc.com> References: <20211012095857.1314214-1-anup.patel@wdc.com> X-ClientProxiedBy: MAXPR01CA0106.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::24) To CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) MIME-Version: 1.0 Received: from wdc.com (122.179.114.63) by MAXPR01CA0106.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.24 via Frontend Transport; Tue, 12 Oct 2021 09:59:57 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 774b6d27-fbe1-4041-4ca4-08d98d670f29 X-MS-TrafficTypeDiagnostic: CO6PR04MB8347: 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-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wpDvSJQDvjz3cbiX9iCmNk16Sp5uHaB3N8HTRxXoDvIGUmrTLfzH6mPwbvfjqbr5FRQvcJvRDRA4rKnnjLAc1XKthGbB6ZwJDyYp+gS1HjxsXVouyc9KEJALOCfx+cobUIeUuZbZxmMR1Vek4HeMJg1HIKqcP6u21z3vIVUMY3neNhxRILXYslxUE47jAoPHA/Zj5PsuniON7Fud4h/ZVP8hr6dpspvbdsTMoiOs6mwJuXHFIzLKHjklIFCdndfZfd2Jg1a/nJsTg1vlyDyY3XxSclWoV9iqfeGn63HGl8Fu4Hc9ilGEStJpFnO52ihCvEsA/N8RatXUnZJLROUL8vJ3t2S3BInWus/qJZXOiDd3KMfOwEJt5YWE+nGTTI3xQ41yJ1mFP9sdRtPh/ek+uramPshI74utlgukwE+s1Ez096J8AF174fO3pyKF4xhqhDLby/mHa+GIC7XJHMjhBx3lDBEKMcpI5KjxHQROPRDKVziflW8o/kYImxj8sfIdsDZYR1CKyqrVmpOaH0/6/rA4Dg1HJSM6XcghtNT7dlKBX89UariZEvoNR13Z+B3UiDp0QJxKwgu1RkMw9QoWqIaCMXjBlrLdKOhJDAM4Q5m434764+nVxcgl+enVV97VI+yQ+Cqw5r4HZAZhPfoc+FFdItDZ1agGSIjrRWf9FaFGzsN8PCrVBUSCvkRDDpw/h7CD76OeiNzBRUit7LrHZ7eaW88Qi8Oh1z1iur/5ACt88upqiayo4yxlef3Ari1HAEttwGp2ZFvS80PQxBrXHpwkJZqLS2pYHiTx0wbdwcw/O/qfzQ5Mvcv+v2Do9BOy X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO6PR04MB7812.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(26005)(186003)(52116002)(1076003)(44832011)(2906002)(7696005)(86362001)(8936002)(5660300002)(7416002)(4326008)(66556008)(38350700002)(966005)(8676002)(36756003)(30864003)(66946007)(38100700002)(54906003)(55016002)(66476007)(83380400001)(110136005)(8886007)(508600001)(316002)(2616005)(956004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0i5VhjlcE3h3vsGqCbT6OH0JBKcvYQZrIqzRfkmcuZ7wvHSaD9eraOh6EvVLIke51JAS81IW04Ix/BBd3CwwOco7+g/RBSnjDO37MeacnKeFh4aS5CxiTUXiEm0yGo1Pdl96gfd9PQTfkYtaz9Hdk34unaaAEJmDrbEaY4B29GlUc2isza6yDOJch/FzHLrdrzSvf0TD4ljYjDk0YUe9NVG88ZSW4xUkJ/oa/hf1QmtZaKsgFoT7H7AnbVdDldynkiAnxA7RGxO0zXGSF//TKf8DJEvgWaRdcYG2GcDw1m7+4xTfd7lmU0EoEUBX8O+EUC70eDHrtUVRt8YcsuW1X30qe/FdoBM0slUBT0DR2gVVyM8Jonl6IF0P+/WPAwecCjhJCFOxhJap37gPEXrul5nndWPr9jZQioV/JWE9gkkbGu5LuBNzHF5iX2cMd89DLmBh4NtAqJyfYyjjXoFH59GGtzIqzzdueVkVJhOsFVD4nyGd99BAy4Sb/cWT3aOn6BhqrelY9yzUGmuWNRfkSysYbkBfVd6XYE9O4W3IwhPX1P2ctcfsbG5E3hBzPWtqonwMPb4p2E5pvOTxcCVbF3fQGwcWJM93N3AjQrq77dVQXv+QCgOcYPDRpC1CGNUADP86CPrV1uDzjb97g3bzC2PYKodruknJ9hnZ4VZTyEoesIcKYuUyRZ9CQVXhOr54l0NFnlhI1RDvoPlbFdJBAgrLYUNpPJbJX+/1B0qSPVIoEFbkWfcpS4ZOhaOVWF751P+BWD6ENcoXtDLxPiRpDol/TXPf5QZ30UQm/fgOIlfdP5EiLpealvWbfSMQGnKQXLSewIazFVdTKJneSXicCUdijX5kARCdgm19J55iQ/pm1xwz9JhCpedDcx++35O+/yBOSk1/vIO10MDTKtVuLN+DjRnX67asoMp2f6DTG0nx1VZGBM8u1gL1BG6YpsGfwNso5mNTy5R2Y6HuIgYKyyEEZxE5kS8T++Lj5ajnpuU7neG5poU6PA/QqnCJDfnvRf9jvU0SlKDJLun7zsE1dyxlYPsltCQZWw9ruF0JUdX7yxyzF/wFoE94ImUAPb23Iq7ks6QP6DP4HAJlr1R9xaID5kJYZDhKfAJvnVs473due/LewOfoKQZCwRH49FwGVekjxY2M1AQbBTOop2G+skTXDYPLvV6L0dJVT/0jKPWZg5KL4+hvoo33sXGJOGdjfmbXOQ1c8noZh//e3v/q3FdFBJzF48MeKzUCAIh9wwnK4bplHAGEdZ0IiRUAV78mrJsPRtjsEb/gMiUuMzskr98TXkPGihUw5dGHGbOnvpYgaByck20xen4czhm5WNcV X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 774b6d27-fbe1-4041-4ca4-08d98d670f29 X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2021 10:00:02.6074 (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: 51tmywv7n2mQYXI9XMPM+MBGlPt+GDRv0vT7LqgxmB1YQotcGfOisOm9a/xRIwJKYk+Ebpz/oAL66S51Gl2uxg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB8347 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211012_030007_072051_B6C40598 X-CRM114-Status: GOOD ( 18.13 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The RISC-V CPU idle states will be described in under the /cpus/idle-states DT node in the same way as ARM CPU idle states. This patch adds common bindings documentation for both ARM and RISC-V idle states. Signed-off-by: Anup Patel Reviewed-by: Rob Herring --- .../bindings/arm/msm/qcom,idle-state.txt | 2 +- .../devicetree/bindings/arm/psci.yaml | 2 +- .../bindings/{arm => cpu}/idle-states.yaml | 228 ++++++++++++++++-- .../devicetree/bindings/riscv/cpus.yaml | 6 + 4 files changed, 219 insertions(+), 19 deletions(-) rename Documentation/devicetree/bindings/{arm => cpu}/idle-states.yaml (74%) diff --git a/Documentation/devicetree/bindings/arm/msm/qcom,idle-state.txt b/Documentation/devicetree/bindings/arm/msm/qcom,idle-state.txt index 6ce0b212ec6d..606b4b1b709d 100644 --- a/Documentation/devicetree/bindings/arm/msm/qcom,idle-state.txt +++ b/Documentation/devicetree/bindings/arm/msm/qcom,idle-state.txt @@ -81,4 +81,4 @@ Example: }; }; -[1]. Documentation/devicetree/bindings/arm/idle-states.yaml +[1]. Documentation/devicetree/bindings/cpu/idle-states.yaml diff --git a/Documentation/devicetree/bindings/arm/psci.yaml b/Documentation/devicetree/bindings/arm/psci.yaml index 8b77cf83a095..dd83ef278af0 100644 --- a/Documentation/devicetree/bindings/arm/psci.yaml +++ b/Documentation/devicetree/bindings/arm/psci.yaml @@ -101,7 +101,7 @@ properties: bindings in [1]) must specify this property. [1] Kernel documentation - ARM idle states bindings - Documentation/devicetree/bindings/arm/idle-states.yaml + Documentation/devicetree/bindings/cpu/idle-states.yaml patternProperties: "^power-domain-": diff --git a/Documentation/devicetree/bindings/arm/idle-states.yaml b/Documentation/devicetree/bindings/cpu/idle-states.yaml similarity index 74% rename from Documentation/devicetree/bindings/arm/idle-states.yaml rename to Documentation/devicetree/bindings/cpu/idle-states.yaml index 52bce5dbb11f..f2969d4468b4 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 + enum: + - arm,idle-state + - 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 Tue Oct 12 09:58:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 12551919 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39EBFC433F5 for ; Tue, 12 Oct 2021 10:07:10 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ED7BA60724 for ; Tue, 12 Oct 2021 10:07:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org ED7BA60724 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=C6VFDxQAiBmkYcpG1FbQWedxEpFXoeO0D5+Fonzvg0k=; b=zrDM2SNQTBh+HU ykrjpzXUaL/UyB/SdBl5X8fbA9eJpz7eTAdSY5SpYcKJkcRz6bFklcFMbIL7t7ZRmPJaDCeqPzduY d34cQlyLscPQAIitztqKyfrPRaWMM3Ucj1rNrYWcc5HPCBWRUAj4Hg7w1ylbbxztdVfoSsU98vPfk J9Y6nkvxuI9uh7JdC1mo0RfR61vSOvPL6BXEy08zZtwZoWOqaosHZDJPCOi/YSrhEfJc4gOmoYVvN lGhkpnwq53kud61q2zj1he0fsEZVbk1Rrqgsp9gpwCHjokNlPJ2LAD2dKhlByCwH/8sr1//x3umBs opo3pbLC18a7EiPVUarQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1maEgG-00CMcQ-Ec; Tue, 12 Oct 2021 10:06:44 +0000 Received: from esa2.hgst.iphmx.com ([68.232.143.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1maEZx-00CKEd-L5; Tue, 12 Oct 2021 10:00:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1634032813; x=1665568813; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=k2hvQcTUKX+6sxrV25IFhR4qKjXN2bgw7X/NopnJJ14=; b=MLP4J3C3KYEW+WSjDQ2WDClTtz1NxsJFQx1Zm7xFt4LU76t4vtGWuKv7 6+Ghdi2dKeMOHBRY5SkHTxyLnI0CjUCXF+BuyJE25/9J0ZSX5cXr7Eb7D ZY+NGEHBJYeYFqDfCVK+QvYP+AQPv/qtIz+tfsWhpcZEjzjxpRu+B+ygx 1Dp4s5sGLjxv2Fepw75ysV4twL5DUicsZUIqQSYIF71KVk1sEpKQAguds 4+ELm8tOBRjlBdtqc0+lK4ZNf8IyQeAUt8cgc2PugZbPILVY+409MPHbK nVuPe19RuNaWMzmp5v9hS6eqCo6jB/woPW/yTYclZdPwzZNMSA1w3rDv3 g==; X-IronPort-AV: E=Sophos;i="5.85,367,1624291200"; d="scan'208";a="286442665" Received: from mail-bn7nam10lp2101.outbound.protection.outlook.com (HELO NAM10-BN7-obe.outbound.protection.outlook.com) ([104.47.70.101]) by ob1.hgst.iphmx.com with ESMTP; 12 Oct 2021 18:00:09 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nRH3sHiUrFPRaF0bYzzb5pSxaLLiou8liNedcYjJs3ONtNoWEv20VuXubPN5w2aYB1bAA8XIPO3ybo6EhJLcbTD7V2l+wWXibiZYcvhvwaqJn1vKw/thZxH/3/eiWEpuSHpyF0oqVxFVtlxy5UqUiCT3YSZCTCpl5hnwebFdVHrot/pbNqWduBYSHku1R1P0+whRfFkwIL7s3J8seN7R0Cr6PtrBJajKlbmjSdPl3yNsMraYGwCMd0q7maPhN60BTzUjuiaOHchzWtAARSTEhbVPKplijYJMjpnuOdJ/25IF3j7zCWwsKs1ClHMtLmYOFW3+ZbbkaDBk9fMNRk+SDg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kMsvanvwx35NMK9rrt2tW3ybr10Mh+Cf85ZllWDq76k=; b=LQMuEWxAcww6cY+k8sLjdbWNxhUpTDDzg5ankARpYhBaqJ1i/VwEQX7a9HFMAtPYiBjpAOa4PnTkMH9AKLu4JGYszPjFQsAMXSxSPYvYlITaH/gggQuXsMjgBaLSw2ovRHZlp9vN1IiWYlmlMAuo21iih+4iXxb6h4nolkb5Nt/chSen3aclLsD1XbzFYwSHXph4aewfLBhlNS4quVjq+bBGr2+c+l0gqx4ay1wMQPQ1pNouylpNnITI0LQYgcKnWfjv5z765oqFgvIs1LrW+tAtpvlPrlozkWHHR8xX5PdK9vfLFZ4ZfAoWITFJtdwxrPxWfoqGL1jB2xsP2V8UJQ== 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=kMsvanvwx35NMK9rrt2tW3ybr10Mh+Cf85ZllWDq76k=; b=hskOsAf235oanO+9suIZmvaHlfPcCRJfTK0dzGk3lthoD89PRNROlmIK7T1E4JfDHRJGAjxphfg3svZeggwj4RqwcQ0XVdAMpu5kcPiewPwZqci1dyxUJO3CGwtiBWAcAjUxxYcW2PJnHhpu6UDq+eawj+VtFiuXJC07Z/mhUKo= 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 CO6PR04MB8361.namprd04.prod.outlook.com (2603:10b6:303:140::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.20; Tue, 12 Oct 2021 10:00:07 +0000 Received: from CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::8100:4308:5b21:8d97]) by CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::8100:4308:5b21:8d97%9]) with mapi id 15.20.4587.026; Tue, 12 Oct 2021 10:00:07 +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 v9 8/8] RISC-V: Enable RISC-V SBI CPU Idle driver for QEMU virt machine Date: Tue, 12 Oct 2021 15:28:57 +0530 Message-Id: <20211012095857.1314214-9-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211012095857.1314214-1-anup.patel@wdc.com> References: <20211012095857.1314214-1-anup.patel@wdc.com> X-ClientProxiedBy: MAXPR01CA0106.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::24) To CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) MIME-Version: 1.0 Received: from wdc.com (122.179.114.63) by MAXPR01CA0106.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.24 via Frontend Transport; Tue, 12 Oct 2021 10:00:02 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7b719446-7cd0-4839-4a70-08d98d671220 X-MS-TrafficTypeDiagnostic: CO6PR04MB8361: 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-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: q/22UmI1PxU2Adf55wvZHU5I6qVnJeI7ufCosXTCbGJoImETRvg6FOMJbAemo+6DTftGct+wM9zlBhLm2BkG6y2fve6SW0b86QXvRI62IRyRb8itwEo1bhzyfQpof45PF5r5GiBaEg/Kjj1ObLCiZIvElzH1V+HMnX+IBhrvYVGfvRfbDoFCNTBJIFJfBPwYU/58cFaD6pCKRzk2gyDueTj55EtLfjov1GQKga0rDC2C9j02Z8HKy0JOlzHs4uOafqouRHXaI/5U7rMsW8XN0PfmU+5F2gpIb+6PNtKMEGvQ5gLuTIfxpAOKjEMcaTAZmboNjt63l41HYglvgDD9fAc/+RGtxVrx+7+LAr141te1rvYD0/0VzxdAmkhy+QGsXWIuFQA7TNbUEO0upvwTNhVdwKibOX+Wg6BcMU7ZqVxZsbziNJyinpx70X+xE1GzRkoIVUMW6oeqPQzXGnrMbkTYhrzgKoOCk4Etm4OIdlSvNzIgpvfGLhnppBXzH9+hsVXtQS4jRiSBXbEHeMzcUd94nWUfcPhN07mEd0FxovRRs03Zowz5r13i+PjucV06YfSeDJK7IqEMoI47Ad72JW0iUkWvUFfb7Ubb/rhThhndR02vKYOM6DCDSZqedWlJOKFuzMa6+NWr1kVFasxUkCk/08qYoXx6wHXZd8K1dKy6QG8sdTiBmQ+irrkamCDakUFuEca0rlVtKvc0TfcJGw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO6PR04MB7812.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(1076003)(54906003)(7696005)(8886007)(6666004)(110136005)(4326008)(66946007)(86362001)(38350700002)(66556008)(38100700002)(66476007)(2906002)(316002)(55016002)(5660300002)(52116002)(508600001)(8936002)(26005)(186003)(956004)(2616005)(7416002)(44832011)(8676002)(36756003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QrBUirihCl7td+RXBu6YGKS11mea95aUUvCfc22yvfYBcpShr5oVI/Ob7fQmG+SPwzXPVgj+oOSNBohr4tKa7hYPhfJbYAB8G7qXQRFop2BEnOVvJOWUgwRVoFobsU+udqkGw0qFigp4h0lssGQbO5Ssh0AEfQQlF7kMPO2ibx2M6cPoUTdEogxsoOQ37YfgxBMinhpsRHq00hazwmmc4ylXqD0WkmdojQmmNTyw03/KZ+vA1GoEB5jzKJ1KmF6OTgqayvxqmmveBEMfBGcRRF2uMb3b61cWkvAsXYuJQP7lsSLCOVfc+swkfYtu3LfcpeZMzy64xMXmWyfxVWwOvG2F98vC1nRvUFoVKE0if9z/IcQFsgiWhbndshdkMePPswKICFSquQsgzvE1QvXF6mJtwqOaE8eIutiDfrjXrJBoAAkGuy2MwzxnqV0zGFGQkaBA39mV+NnFtEEZlL/TmWTD5eRLcxXz/tzzktRrK5xwi4G4XpGyYL+lL60P4UlETrpdWGfkQsOaV4vCfR4PeT3nPDkdgEFDhFT9N8/sAHOnJed4InSBDwykAA+gLvVO+mKGiQPF5YrKXLd0nzw0DRniIFKoS+hOXqiOUxiSwZce04WivDgvDhx5mEVwaJVT+ynGkr9HN8TlMff9UWcR4ZIg/8Pr7mwESf4NRzfkej5jw4UpOCkTixSer/trIJrFccgHBITMhRXdJCtRbneN22JcSUmfN+eki53pFa5if009eExusrR19nEXtiL4YR+H0ZymdKaHA563K0jgR3QQ2gBbgbP1Mz9Bzfbsj9hYY9exz1WFYIOOjSKXokwLgZRBj14HHWxNHtYBwb78lOecHxxaC9vIrWd5LgCYvfvAPJTnLscmJ5Yz8TU79uDyJEwOSkys2/6aNDWz7b/+tho2ErqKBmhfzvZsMjEf4px9wLZGzr+boYYSqk8J6hX7gOq1Ncrfh5QO2hPTaAGbz0W/oUXiPPUTo4Slw3Fxtklr5apXPoW2sDexSH+Fe8VR1bEnJv7gu0mV31DD50l1+OQLsR+r2Usb1HcEfycsGeJob2IQw9ZG/KtGFunPCl0hrM7EgMt6J54dTTYhKA5FB2bC4vuonkOpfkd6h/qLwIZxRxV+S3eDRYB4V+WLvMt6VTAkgLqAXbdVGr95x5qoJdeYvxDxkBZIC7bRXq6aWhfhIzE4+tLnlBXZjCZpP51h7IJol8h0DKSdME1c9I0H+tpf/tdYsgVuez02L5SA0KUlwl/x1puDyHVHcM6uHj8B+CSOowLj7KSOXsPnc2WgQ8vFKhWLlS2yR4qRUrw6W4vxJrmhxfWF8RWq8BDaA3m+R7TZ X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7b719446-7cd0-4839-4a70-08d98d671220 X-MS-Exchange-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Oct 2021 10:00:07.6054 (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: mY5/TIWk7wPKrpanW4IJm06hhMvnlu5SkGuoXtVcJSurWuckGrS3UIa0fd3HYNfq9wQ96idILCWfj06qZMgW9Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB8361 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211012_030013_852002_0B148D3A X-CRM114-Status: GOOD ( 12.34 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.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 30676ebb16eb..56bafc3dad4c 100644 --- a/arch/riscv/Kconfig.socs +++ b/arch/riscv/Kconfig.socs @@ -28,6 +28,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 9851ba671e90..5ae71fa92c28 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 725ca3332900..31b5ca04939f 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