All of lore.kernel.org
 help / color / mirror / Atom feed
From: Haibo Xu <haibo.xu@linaro.org>
To: drjones@redhat.com, richard.henderson@linaro.org
Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, philmd@redhat.com,
	qemu-devel@nongnu.org, Haibo Xu <haibo.xu@linaro.org>
Subject: [PATCH v2 08/12] hw/arm/virt: Move kvm pmu setup to virt_cpu_post_init
Date: Tue,  8 Sep 2020 08:13:26 +0000	[thread overview]
Message-ID: <7982854bb6cdb90390ea3f3c39c2801ef84fd2e5.1599549462.git.haibo.xu@linaro.org> (raw)
In-Reply-To: <cover.1599549462.git.haibo.xu@linaro.org>

From: Andrew Jones <drjones@redhat.com>

Move the KVM PMU setup part of fdt_add_pmu_nodes() to
virt_cpu_post_init(), which is a more appropriate location. Now
fdt_add_pmu_nodes() is also named more appropriately, because it
no longer does anything but fdt node creation.

No functional change intended.

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 hw/arm/virt.c | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 2ffcb073af..6bacfb668d 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -521,21 +521,12 @@ static void fdt_add_gic_node(VirtMachineState *vms)
 
 static void fdt_add_pmu_nodes(const VirtMachineState *vms)
 {
-    CPUState *cpu;
-    ARMCPU *armcpu;
+    ARMCPU *armcpu = ARM_CPU(first_cpu);
     uint32_t irqflags = GIC_FDT_IRQ_FLAGS_LEVEL_HI;
 
-    CPU_FOREACH(cpu) {
-        armcpu = ARM_CPU(cpu);
-        if (!arm_feature(&armcpu->env, ARM_FEATURE_PMU)) {
-            return;
-        }
-        if (kvm_enabled()) {
-            if (kvm_irqchip_in_kernel()) {
-                kvm_arm_pmu_set_irq(cpu, PPI(VIRTUAL_PMU_IRQ));
-            }
-            kvm_arm_pmu_init(cpu);
-        }
+    if (!arm_feature(&armcpu->env, ARM_FEATURE_PMU)) {
+        assert(!object_property_get_bool(OBJECT(armcpu), "pmu", NULL));
+        return;
     }
 
     if (vms->gic_version == VIRT_GIC_VERSION_2) {
@@ -544,7 +535,6 @@ static void fdt_add_pmu_nodes(const VirtMachineState *vms)
                              (1 << vms->smp_cpus) - 1);
     }
 
-    armcpu = ARM_CPU(qemu_get_cpu(0));
     qemu_fdt_add_subnode(vms->fdt, "/pmu");
     if (arm_feature(&armcpu->env, ARM_FEATURE_V8)) {
         const char compat[] = "arm,armv8-pmuv3";
@@ -1674,11 +1664,23 @@ static void finalize_gic_version(VirtMachineState *vms)
 
 static void virt_cpu_post_init(VirtMachineState *vms)
 {
-    bool aarch64;
+    bool aarch64, pmu;
+    CPUState *cpu;
 
     aarch64 = object_property_get_bool(OBJECT(first_cpu), "aarch64", NULL);
+    pmu = object_property_get_bool(OBJECT(first_cpu), "pmu", NULL);
 
-    if (!kvm_enabled()) {
+    if (kvm_enabled()) {
+        CPU_FOREACH(cpu) {
+            if (pmu) {
+                assert(arm_feature(&ARM_CPU(cpu)->env, ARM_FEATURE_PMU));
+                if (kvm_irqchip_in_kernel()) {
+                    kvm_arm_pmu_set_irq(cpu, PPI(VIRTUAL_PMU_IRQ));
+                }
+                kvm_arm_pmu_init(cpu);
+            }
+        }
+    } else {
         if (aarch64 && vms->highmem) {
             int requested_pa_size = 64 - clz64(vms->highest_gpa);
             int pamax = arm_pamax(ARM_CPU(first_cpu));
-- 
2.17.1



  parent reply	other threads:[~2020-09-08  8:17 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-08  8:13 [PATCH v2 00/12] target/arm: Add vSPE support to KVM guest Haibo Xu
2020-09-08  8:13 ` [PATCH v2 01/12] update Linux headers with new vSPE macros Haibo Xu
2020-09-08  8:13 ` [PATCH v2 02/12] target/arm/kvm: spe: Add helper to detect SPE when using KVM Haibo Xu
2020-09-08 10:43   ` Andrew Jones
2020-09-08  8:13 ` [PATCH v2 03/12] target/arm/cpu: spe: Add an option to turn on/off vSPE support Haibo Xu
2020-09-08 10:51   ` Andrew Jones
2020-09-08  8:13 ` [PATCH v2 04/12] target/arm: spe: Only enable SPE from 5.2 compat machines Haibo Xu
2020-09-08 10:52   ` Andrew Jones
2020-09-08  8:13 ` [PATCH v2 05/12] target/arm/kvm: spe: Unify device attr operation helper Haibo Xu
2020-09-08 10:56   ` Andrew Jones
2020-09-09  2:39     ` Haibo Xu
2020-09-08  8:13 ` [PATCH v2 06/12] target/arm/kvm: spe: Add device init and set_irq operations Haibo Xu
2020-09-08 10:58   ` Andrew Jones
2020-09-08  8:13 ` [PATCH v2 07/12] hw/arm/virt: Move post cpu realize check into its own function Haibo Xu
2020-09-08 11:03   ` Andrew Jones
2020-09-09  6:54     ` Haibo Xu
2020-09-08  8:13 ` Haibo Xu [this message]
2020-09-08 11:07   ` [PATCH v2 08/12] hw/arm/virt: Move kvm pmu setup to virt_cpu_post_init Andrew Jones
2020-09-08  8:13 ` [PATCH v2 09/12] hw/arm/virt: spe: Add SPE fdt binding for virt machine Haibo Xu
2020-09-08 11:16   ` Andrew Jones
2020-09-09  7:51     ` Haibo Xu
2020-09-09  9:34       ` Andrew Jones
2020-09-10  0:31         ` Haibo Xu
2020-09-08  8:13 ` [PATCH v2 10/12] target/arm/cpu: spe: Enable spe to work with host cpu Haibo Xu
2020-09-08 11:32   ` Andrew Jones
2020-09-09  8:35     ` Haibo Xu
2020-09-08  8:13 ` [PATCH v2 11/12] target/arm/kvm: spe: Enable userspace irqchip support Haibo Xu
2020-09-08 11:34   ` Andrew Jones
2020-09-09  3:12     ` Haibo Xu
2020-09-08  8:13 ` [PATCH v2 12/12] target/arm: spe: Add corresponding doc and test Haibo Xu
2020-09-08 11:41   ` Andrew Jones
2020-09-09  3:19     ` Haibo Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7982854bb6cdb90390ea3f3c39c2801ef84fd2e5.1599549462.git.haibo.xu@linaro.org \
    --to=haibo.xu@linaro.org \
    --cc=drjones@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@redhat.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.