qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Huacai Chen" <chenhuacai@kernel.org>,
	"Jiaxun Yang" <jiaxun.yang@flygoat.com>
Subject: [PATCH 04/11] hw/mips/loongson3_virt: Pass CPU argument to get_cpu_freq_hz()
Date: Sun, 12 Jan 2025 22:58:28 +0100	[thread overview]
Message-ID: <20250112215835.29320-5-philmd@linaro.org> (raw)
In-Reply-To: <20250112215835.29320-1-philmd@linaro.org>

Pass the first vCPU as argument, allowing to remove
another &first_cpu global use.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/mips/loongson3_virt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/mips/loongson3_virt.c b/hw/mips/loongson3_virt.c
index 032ff92383e..078ad46174f 100644
--- a/hw/mips/loongson3_virt.c
+++ b/hw/mips/loongson3_virt.c
@@ -153,7 +153,7 @@ static const MemoryRegionOps loongson3_pm_ops = {
 
 #define DEF_LOONGSON3_FREQ (800 * 1000 * 1000)
 
-static uint64_t get_cpu_freq_hz(void)
+static uint64_t get_cpu_freq_hz(const MIPSCPU *cpu)
 {
 #ifdef CONFIG_KVM
     int ret;
@@ -164,7 +164,7 @@ static uint64_t get_cpu_freq_hz(void)
     };
 
     if (kvm_enabled()) {
-        ret = kvm_vcpu_ioctl(first_cpu, KVM_GET_ONE_REG, &freq_reg);
+        ret = kvm_vcpu_ioctl(CPU(cpu), KVM_GET_ONE_REG, &freq_reg);
         if (ret >= 0) {
             return freq * 2;
         }
@@ -635,7 +635,7 @@ static void mips_loongson3_virt_init(MachineState *machine)
      * Please use -L to set the BIOS path and -bios to set bios name.
      */
 
-    loaderparams.cpu_freq = get_cpu_freq_hz();
+    loaderparams.cpu_freq = get_cpu_freq_hz(cpus[0]);
     loaderparams.ram_size = ram_size;
     if (kernel_filename) {
         loaderparams.kernel_filename = kernel_filename;
-- 
2.47.1



  parent reply	other threads:[~2025-01-12 22:00 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-12 21:58 [PATCH 00/11] hw/mips/loongson3: Remove uses of &first_cpu global Philippe Mathieu-Daudé
2025-01-12 21:58 ` [PATCH 01/11] hw/mips/loongson3_virt: Factor generic_cpu_reset() out Philippe Mathieu-Daudé
2025-01-15  5:02   ` Richard Henderson
2025-01-12 21:58 ` [PATCH 02/11] hw/mips/loongson3_virt: Keep reference of vCPUs in machine_init() Philippe Mathieu-Daudé
2025-01-15  5:18   ` Richard Henderson
2025-01-15 20:32     ` Philippe Mathieu-Daudé
2025-01-15 23:02       ` Richard Henderson
2025-01-12 21:58 ` [PATCH 03/11] hw/mips/loongson3_virt: Have fw_conf_init() access local loaderparams Philippe Mathieu-Daudé
2025-01-15  5:09   ` Richard Henderson
2025-01-12 21:58 ` Philippe Mathieu-Daudé [this message]
2025-01-15  5:09   ` [PATCH 04/11] hw/mips/loongson3_virt: Pass CPU argument to get_cpu_freq_hz() Richard Henderson
2025-01-12 21:58 ` [PATCH 05/11] hw/mips/loongson3_bootp: Include missing headers Philippe Mathieu-Daudé
2025-01-15  5:10   ` Richard Henderson
2025-01-12 21:58 ` [PATCH 06/11] hw/mips/loongson3: Propagate cpu_count to init_loongson_params() Philippe Mathieu-Daudé
2025-01-15  5:13   ` Richard Henderson
2025-01-12 21:58 ` [PATCH 07/11] hw/mips/loongson3_virt: Propagate cpu_count to init_boot_param() Philippe Mathieu-Daudé
2025-01-15  5:13   ` Richard Henderson
2025-01-12 21:58 ` [PATCH 08/11] hw/mips/loongson3_bootp: Propagate processor_id to init_cpu_info() Philippe Mathieu-Daudé
2025-01-15  5:15   ` Richard Henderson
2025-01-12 21:58 ` [PATCH 09/11] hw/mips/loongson3_virt: Propagate processor_id to init_loongson_params() Philippe Mathieu-Daudé
2025-01-15  5:16   ` Richard Henderson
2025-01-12 21:58 ` [PATCH 10/11] hw/mips/loongson3_virt: Propagate %processor_id to init_boot_param() Philippe Mathieu-Daudé
2025-01-15  5:17   ` Richard Henderson
2025-01-12 21:58 ` [PATCH 11/11] hw/mips/loongson3_bootp: Move to common_ss[] Philippe Mathieu-Daudé
2025-01-15  5:17   ` Richard Henderson

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=20250112215835.29320-5-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=chenhuacai@kernel.org \
    --cc=jiaxun.yang@flygoat.com \
    --cc=qemu-devel@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).