Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1764110pxb; Wed, 9 Feb 2022 04:06:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJxPd1GdnmzvG9rqb9ci7O58Jlsnczv0OwclEbVlRbg80Yfe1DycSXdP+nBRou/uE1sUdgKu X-Received: by 2002:a05:6a00:894:: with SMTP id q20mr1959330pfj.79.1644408382904; Wed, 09 Feb 2022 04:06:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644408382; cv=none; d=google.com; s=arc-20160816; b=PPsLqrR9IZq2IPVcyoOrxduDjhB9RookWy8HCRGi9oJjXBUISrlPzN7IH70mn+8erq ITv1kVseqzwfqQv2C/9+6/9hh7OCSNRxGpYETrRxEAGWwwVaajsFX/KnzgkVvsfr8Ul9 xRLKF6sm/y07yGnBFar3LWvpil0r6rhKaSjL31YK36OTNVTDWZq4tgEButi8109G8Voq 7QDtTRCcq4MaHZP0RTSiaF12g7h61Q/z0AMK/mXZbZTGtZEB4b+VH7LeYpqFVau+OIsF BTgFmK2Q8maRB5DVvbaNYhuP9SExnNq2xsFj5Hcbh7GubxZbmUf/adavKoYIE1beJk8N Ld5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=yc3wXrnUWupyCqbpFC7nvL7VpgtsDwIsaVJEK5HMqtY=; b=uqr/UCoqiWPU40GWfpcTbF73K1dAdmmt2mwMdpSrfXMyJdE/VeI/hKpGPiqRGjICNq hoVc8NfzHApaDNUwJ4d515Gu6V5V6x3AV8i5AS2VSG0IGaKooQVPZi3aic9Kkuc9OBeE 76IXPKbNxmtKv4/QUsFZxGZwryw6p3vWYfbh98TyoVJE65Bb6TqKEWRKh2qr2uzzGY2/ XoloGgC2S3LB88s8wtFudZpUHIHoSsEiMmvtXsZ/UysZKSxH86QqExmLyvrfzknFXw43 IpXPDYE7sB3yQVJGoEUakN4XcLGoszq5NxpnDe0AKQASoGYr9JUUou/A27UqmBZDTxso IKNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RabgyLZ3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id y16si16598894pfi.371.2022.02.09.04.06.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 04:06:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RabgyLZ3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 468DDE0F9459; Wed, 9 Feb 2022 02:06:03 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245061AbiBHL04 (ORCPT + 99 others); Tue, 8 Feb 2022 06:26:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356156AbiBHKRw (ORCPT ); Tue, 8 Feb 2022 05:17:52 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 207FDC03FEC0; Tue, 8 Feb 2022 02:17:51 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8D5C761559; Tue, 8 Feb 2022 10:17:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ED064C340F5; Tue, 8 Feb 2022 10:17:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644315470; bh=B5kPKaKPj6WPHi2c1HyJFZySKtUKUS+F4wL45+EXYc8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=RabgyLZ3czHUYu9eQfVMsqKQjd28oIC2eAxgZIC/cMV5+hibcqoT2NuQmD7DOvK9P GnRyg8wnvdKLog6dXkCzWblnagSXKBQck0iCu0oHCN3Ua0XyfVEoxg+uWlBd/oAQDt rHBvl98IaSWDWY6FHyzInN0UsRrhTjDnogCM9Qa7l7kp94NkYHvumML5idokK2waW/ xrCoRrsEfriZZmjoX4JOgHOTZHMrPKXIz0qzqEElQ6EuLqleaKsW8xmLJSTvnFFVe3 xVd+g8G1mWmnWNc6aFYJwDtirwlqQ9A8ckL6chYsh34iLWS5JfJ/LSUQVthh0Q28q+ dxaweMMQtijaw== Received: by mail-vs1-f41.google.com with SMTP id l14so2786942vsm.3; Tue, 08 Feb 2022 02:17:49 -0800 (PST) X-Gm-Message-State: AOAM530nG/Fh3hSF6uA3ihqocqhnCuZ0SEksEqPZLmy0BjTIE2cURkX/ vJninW//Pc1E/WVzzq2f64W3MmC4YpB5OAOw3bw= X-Received: by 2002:a67:ea4e:: with SMTP id r14mr840479vso.51.1644315468769; Tue, 08 Feb 2022 02:17:48 -0800 (PST) MIME-Version: 1.0 References: <20220126114452.692512-1-apatel@ventanamicro.com> <20220126114452.692512-9-apatel@ventanamicro.com> In-Reply-To: From: Guo Ren Date: Tue, 8 Feb 2022 18:17:37 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v10 8/8] RISC-V: Enable RISC-V SBI CPU Idle driver for QEMU virt machine To: Anup Patel Cc: Anup Patel , Palmer Dabbelt , Paul Walmsley , Albert Ou , Daniel Lezcano , Ulf Hansson , "Rafael J . Wysocki" , Pavel Machek , Rob Herring , Sandeep Tripathy , Atish Patra , Alistair Francis , Liush , devicetree , linux-riscv , Linux Kernel Mailing List , "open list:THERMAL" , Linux ARM , kvm-riscv@lists.infradead.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 8, 2022 at 4:54 PM Anup Patel wrote: > > On Tue, Feb 8, 2022 at 12:16 PM Guo Ren wrote: > > > > Another question: > > > > Have you put "idle-states {" in qemu's DTS? or how do you test your patches? > > I usually do the following: > 1) Dump QEMU virt machine DTB > 2) Convert QEMU virt machine DTB into DTS > 3) Add "idle-states" in QEMU virt machine DTS > 4) Create QEMU virt machine DTB with "idle-states" > 5) Use the new QEMU virt machine DTB for testing this series. > > Here's one of the DTS files which I used for testing on QEMU virt machine: > > /dts-v1/; > > / { > #address-cells = <0x02>; > #size-cells = <0x02>; > compatible = "riscv-virtio"; > model = "riscv-virtio,qemu"; > > chosen { > linux,initrd-end = <0x8855d200>; > linux,initrd-start = <0x88200000>; > bootargs = "root=/dev/ram rw console=ttyS0 earlycon"; > stdout-path = "/soc/uart@10000000"; > }; > > memory@80000000 { > device_type = "memory"; > reg = <0x00 0x80000000 0x00 0x10000000>; > }; > > cpus { > #address-cells = <0x01>; > #size-cells = <0x00>; > timebase-frequency = <0x989680>; > > cpu@0 { > phandle = <0x07>; > device_type = "cpu"; > reg = <0x00>; > status = "okay"; > compatible = "riscv"; > riscv,isa = "rv64imafdcsu"; > mmu-type = "riscv,sv48"; > cpu-idle-states = <&CPU_NONRET_DEF>; > > interrupt-controller { > #interrupt-cells = <0x01>; > interrupt-controller; > compatible = "riscv,cpu-intc"; > phandle = <0x08>; > }; > }; > > cpu@1 { > phandle = <0x05>; > device_type = "cpu"; > reg = <0x01>; > status = "okay"; > compatible = "riscv"; > riscv,isa = "rv64imafdcsu"; > mmu-type = "riscv,sv48"; > cpu-idle-states = <&CPU_RET_DEF>; > > interrupt-controller { > #interrupt-cells = <0x01>; > interrupt-controller; > compatible = "riscv,cpu-intc"; > phandle = <0x06>; > }; > }; > > cpu@2 { > phandle = <0x03>; > device_type = "cpu"; > reg = <0x02>; > status = "okay"; > compatible = "riscv"; > riscv,isa = "rv64imafdcsu"; > mmu-type = "riscv,sv48"; > cpu-idle-states = <&CPU_NONRET_DEF>; > > interrupt-controller { > #interrupt-cells = <0x01>; > interrupt-controller; > compatible = "riscv,cpu-intc"; > phandle = <0x04>; > }; > }; > > cpu@3 { > phandle = <0x01>; > device_type = "cpu"; > reg = <0x03>; > status = "okay"; > compatible = "riscv"; > riscv,isa = "rv64imafdcsu"; > mmu-type = "riscv,sv48"; > cpu-idle-states = <&CPU_RET_DEF>; > > interrupt-controller { > #interrupt-cells = <0x01>; > interrupt-controller; > compatible = "riscv,cpu-intc"; > phandle = <0x02>; > }; > }; > > cpu-map { > > cluster0 { > > core0 { > cpu = <0x07>; > }; > > core1 { > cpu = <0x05>; > }; > > core2 { > cpu = <0x03>; > }; > > core3 { > cpu = <0x01>; > }; > }; > }; > > idle-states { > CPU_RET_DEF: cpu-retentive-default { > compatible = "riscv,idle-state"; > riscv,sbi-suspend-param = <0x00000000>; > entry-latency-us = <10>; > exit-latency-us = <10>; > min-residency-us = <100>; > }; > > CPU_NONRET_DEF: cpu-nonretentive-default { > compatible = "riscv,idle-state"; > riscv,sbi-suspend-param = <0x80000000>; > entry-latency-us = <100>; > exit-latency-us = <100>; > min-residency-us = <1000>; > }; > }; > }; > > soc { > #address-cells = <0x02>; > #size-cells = <0x02>; > compatible = "simple-bus"; > ranges; > > flash@20000000 { > bank-width = <0x04>; > reg = <0x00 0x20000000 0x00 0x2000000 0x00 0x22000000 0x00 > 0x2000000>; > compatible = "cfi-flash"; > }; > > rtc@101000 { > interrupts = <0x0b>; > interrupt-parent = <0x09>; > reg = <0x00 0x101000 0x00 0x1000>; > compatible = "google,goldfish-rtc"; > }; > > uart@10000000 { > interrupts = <0x0a>; > interrupt-parent = <0x09>; > clock-frequency = <0x384000>; > reg = <0x00 0x10000000 0x00 0x100>; > compatible = "ns16550a"; > }; > > poweroff { > value = <0x5555>; > offset = <0x00>; > regmap = <0x0a>; > compatible = "syscon-poweroff"; > }; > > reboot { > value = <0x7777>; > offset = <0x00>; > regmap = <0x0a>; > compatible = "syscon-reboot"; > }; > > test@100000 { > phandle = <0x0a>; > reg = <0x00 0x100000 0x00 0x1000>; > compatible = "sifive,test1\0sifive,test0\0syscon"; > }; > > pci@30000000 { > interrupt-map-mask = <0x1800 0x00 0x00 0x07>; > interrupt-map = <0x00 0x00 0x00 0x01 0x09 0x20 0x00 0x00 > 0x00 0x02 0x09 0x21 0x00 0x00 0x00 0x03 0x09 0x22 0x00 0x00 0x00 0x04 > 0x09 0x23 0x800 0x00 0x00 0x01 0x09 0x21 0x800 0x00 0x00 0x02 0x09 > 0x22 0x800 0x00 0x00 0x03 0x09 0x23 0x800 0x00 0x00 0x04 0x09 0x20 > 0x1000 0x00 0x00 0x01 0x09 0x22 0x1000 0x00 0x00 0x02 0x09 0x23 0x1000 > 0x00 0x00 0x03 0x09 0x20 0x1000 0x00 0x00 0x04 0x09 0x21 0x1800 0x00 > 0x00 0x01 0x09 0x23 0x1800 0x00 0x00 0x02 0x09 0x20 0x1800 0x00 0x00 > 0x03 0x09 0x21 0x1800 0x00 0x00 0x04 0x09 0x22>; > ranges = <0x1000000 0x00 0x00 0x00 0x3000000 0x00 0x10000 > 0x2000000 0x00 0x40000000 0x00 0x40000000 0x00 0x40000000>; > reg = <0x00 0x30000000 0x00 0x10000000>; > dma-coherent; > bus-range = <0x00 0xff>; > linux,pci-domain = <0x00>; > device_type = "pci"; > compatible = "pci-host-ecam-generic"; > #size-cells = <0x02>; > #interrupt-cells = <0x01>; > #address-cells = <0x03>; > }; > > virtio_mmio@10008000 { > interrupts = <0x08>; > interrupt-parent = <0x09>; > reg = <0x00 0x10008000 0x00 0x1000>; > compatible = "virtio,mmio"; > }; > > virtio_mmio@10007000 { > interrupts = <0x07>; > interrupt-parent = <0x09>; > reg = <0x00 0x10007000 0x00 0x1000>; > compatible = "virtio,mmio"; > }; > > virtio_mmio@10006000 { > interrupts = <0x06>; > interrupt-parent = <0x09>; > reg = <0x00 0x10006000 0x00 0x1000>; > compatible = "virtio,mmio"; > }; > > virtio_mmio@10005000 { > interrupts = <0x05>; > interrupt-parent = <0x09>; > reg = <0x00 0x10005000 0x00 0x1000>; > compatible = "virtio,mmio"; > }; > > virtio_mmio@10004000 { > interrupts = <0x04>; > interrupt-parent = <0x09>; > reg = <0x00 0x10004000 0x00 0x1000>; > compatible = "virtio,mmio"; > }; > > virtio_mmio@10003000 { > interrupts = <0x03>; > interrupt-parent = <0x09>; > reg = <0x00 0x10003000 0x00 0x1000>; > compatible = "virtio,mmio"; > }; > > virtio_mmio@10002000 { > interrupts = <0x02>; > interrupt-parent = <0x09>; > reg = <0x00 0x10002000 0x00 0x1000>; > compatible = "virtio,mmio"; > }; > > virtio_mmio@10001000 { > interrupts = <0x01>; > interrupt-parent = <0x09>; > reg = <0x00 0x10001000 0x00 0x1000>; > compatible = "virtio,mmio"; > }; > > plic@c000000 { > phandle = <0x09>; > riscv,ndev = <0x35>; > reg = <0x00 0xc000000 0x00 0x210000>; > interrupts-extended = <0x08 0x0b 0x08 0x09 0x06 0x0b 0x06 > 0x09 0x04 0x0b 0x04 0x09 0x02 0x0b 0x02 0x09>; > interrupt-controller; > compatible = "riscv,plic0"; > #interrupt-cells = <0x01>; > #address-cells = <0x00>; > }; > > clint@2000000 { > interrupts-extended = <0x08 0x03 0x08 0x07 0x06 0x03 0x06 > 0x07 0x04 0x03 0x04 0x07 0x02 0x03 0x02 0x07>; > reg = <0x00 0x2000000 0x00 0x10000>; > compatible = "riscv,clint0"; > }; > }; > }; Thx Anup, but it still couldn't work for testing suspend. # echo mem > /sys/power/state sh: write error: Function not implemented Why there is no ARCH_SUSPEND_POSSIBLE in the patch series? ref arm64's: commit 166936bace056dfc11452d794209f39a5e9b0fb4 Author: Lorenzo Pieralisi Date: Thu Nov 7 18:37:14 2013 +0000 arm64: kernel: add PM build infrastructure This patch adds the required makefile and kconfig entries to enable PM for arm64 systems. The kernel relies on the cpu_{suspend}/{resume} infrastructure to properly save the context for a CPU and put it to sleep, hence this patch adds the config option required to enable cpu_{suspend}/{resume} API. In order to rely on the CPU PM implementation for saving and restoring of CPU subsystems like GIC and PMU, the arch Kconfig must be also augmented to select the CONFIG_CPU_PM option when SUSPEND or CPU_IDLE kernel implementations are selected. > > Regards, > Anup -- Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/