From nobody Wed Nov 19 05:52:26 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.218.47 as permitted sender) client-ip=209.85.218.47; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-f47.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.47 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1614680896; cv=none; d=zohomail.com; s=zohoarc; b=IuppF41vgshhnjPUVY7DUiDQIrfMpYJ72MHzgm/fY8OHdXY1KZ3+zrfAAs+bDUklOAhSz7MrMtKdbz7baZ9mKIeJqDQJ3MwxLWXQ8DQPsuw98zyi2iRf7ayJoi69hzJqE/sNZqXXelu3H+V0TBP4mVhY50YSjXd3a//9gZpOWIs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614680896; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=McvAeDL2KZLDlk5j6C9DReDRrG7DxVQ7/lNaBCKmKts=; b=O+9GhVtccieP+8awgBm5PNhHfPT1xOzTfNUUa0AY37MPFfSAXanXyQ/yrQOdG8Egz+ZAvD7C0HPK4AF66/gMFbVcM+zeUh1r0weJWqFPGANtHZEQTpz6Ect0Er/Rq5MSMfuuC3wD76pwI7IVUnEjf1DfbMsMD7gQn7Kjw9d9Au4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.47 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) by mx.zohomail.com with SMTPS id 1614680896973683.7958861342528; Tue, 2 Mar 2021 02:28:16 -0800 (PST) Received: by mail-ej1-f47.google.com with SMTP id mm21so33935039ejb.12 for ; Tue, 02 Mar 2021 02:28:16 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (68.red-83-57-175.dynamicip.rima-tde.net. [83.57.175.68]) by smtp.gmail.com with ESMTPSA id v8sm8806466edq.76.2021.03.02.02.28.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Mar 2021 02:28:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=McvAeDL2KZLDlk5j6C9DReDRrG7DxVQ7/lNaBCKmKts=; b=G6+H7LPveVxfZYZ4gAzuBUFPrN0eUG3vlxbvzuWjj9a5rM1GHBKzhzr7xM0a03Negb M7K7lvV84PeIbZuTo4kWojNmt50zInB7lqPRMqLKGUFlR9h5PwRFGYJvmYXSbDGXkbez 8JkR+MBODwLDJe2NGYoKuJh8jYdABi74jL5t0y+DiuRmp6kQ6YnTKWlN/d+rMzi/SPdc ZRBvTVv7yhTzlEgHn0IAjCUpicK5mYWfnFOs2OvxcajSzsXaYwf3Zr/hW8/1nOqDCreu bcrKPbr93FI215bxmZ/o4L96+mcy14rQcvP9eE7BR8sfdmnm6H8fnF6eiyY/3MD0Hsqx 1IVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=McvAeDL2KZLDlk5j6C9DReDRrG7DxVQ7/lNaBCKmKts=; b=KRww46uOA8hOaOvzOzCeN4vQh25AuEhjv1KLyvbOHbzWhgQ677JA5lwlswxpfYm+uI 8w9OqFFTmFt0b0ghvbd+HrV/5NWvokijBpl8bJdMZLRYRRZYS9jHmIgvN0x65JyB0AWI Y8cEJlGW91UALtwYXvwIe7oCtQ6O2cYzWLXUit+eDsJ5TV0xSqGtQjh2gcRw8fP9RoSa AS43JeXgVPYkbFnNsKBtv4rnTsCNJpkgO0KBeCxNLbE3+PWEGzgc8un5EXMtUg1DNV69 wc7MFskYJ73D9PympXlDICcxh4v70J/8wr4w/CcYVxYybwuyD9RKOTvQd0IwgBhoa908 SXFQ== X-Gm-Message-State: AOAM530XQGOrbzAEUDtzUm0cYcyZ8VXmUuMRWF7nJsBR1chapgLV/oUT mGfW0CPDNngozUJ/WKGrY6Y= X-Google-Smtp-Source: ABdhPJw//ziXTJz7Q/EFqJpyZ7pQZeJ1NZOZgWZypYXWr+13jH12R/7pcyIqxOe7iCzcxINofU5HJA== X-Received: by 2002:a17:906:73c2:: with SMTP id n2mr20178765ejl.224.1614680895260; Tue, 02 Mar 2021 02:28:15 -0800 (PST) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Yoshinori Sato , Chris Wulff , qemu-ppc@nongnu.org, Marcel Apfelbaum , Greg Kurz , qemu-riscv@nongnu.org, Richard Henderson , Peter Maydell , Michael Walle , Palmer Dabbelt , Sarah Harris , Anthony Green , Eduardo Habkost , Bastian Koppelmann , Laurent Vivier , "Edgar E. Iglesias" , Claudio Fontana , Artyom Tarasenko , qemu-s390x@nongnu.org, Thomas Huth , Paolo Bonzini , Cornelia Huck , Taylor Simpson , Alistair Francis , Michael Rolnik , David Hildenbrand , Aleksandar Rikalo , Stafford Horne , Jiaxun Yang , Marek Vasut , Mark Cave-Ayland , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, David Gibson , Sagar Karandikar , Guan Xuetao , Max Filippov , Aurelien Jarno Subject: [RFC PATCH 5/7] cpu: Declare cpu_has_work() in 'sysemu/tcg.h' Date: Tue, 2 Mar 2021 11:27:35 +0100 Message-Id: <20210302102737.1031287-6-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210302102737.1031287-1-f4bug@amsat.org> References: <20210302102737.1031287-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) We can only check if a vCPU has work with TCG. Move the cpu_has_work() prototype to "sysemu/tcg.h". Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- RFC: could another accelerator do that? can we rename this tcg_vcpu_has_work()? --- include/hw/core/cpu.h | 16 ---------------- include/sysemu/tcg.h | 11 +++++++++++ accel/tcg/cpu-exec.c | 7 +++++++ softmmu/cpus.c | 1 + 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 7f57e57464b..ed23ed9f5fb 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -670,22 +670,6 @@ CPUState *cpu_create(const char *typename); */ const char *parse_cpu_option(const char *cpu_option); =20 -/** - * cpu_has_work: - * @cpu: The vCPU to check. - * - * Checks whether the CPU has work to do. - * - * Returns: %true if the CPU has work, %false otherwise. - */ -static inline bool cpu_has_work(CPUState *cpu) -{ - CPUClass *cc =3D CPU_GET_CLASS(cpu); - - g_assert(cc->has_work); - return cc->has_work(cpu); -} - /** * qemu_cpu_is_self: * @cpu: The vCPU to check against. diff --git a/include/sysemu/tcg.h b/include/sysemu/tcg.h index c16c13c3c69..3d46b0a7a93 100644 --- a/include/sysemu/tcg.h +++ b/include/sysemu/tcg.h @@ -10,6 +10,7 @@ =20 #ifndef CONFIG_TCG #define tcg_enabled() 0 +#define cpu_has_work(cpu) false #else =20 void tcg_exec_init(unsigned long tb_size, int splitwx); @@ -26,6 +27,16 @@ extern bool tcg_allowed; extern bool mttcg_enabled; #define qemu_tcg_mttcg_enabled() (mttcg_enabled) =20 +/** + * cpu_has_work: + * @cpu: The vCPU to check. + * + * Checks whether the CPU has work to do. + * + * Returns: %true if the CPU has work, %false otherwise. + */ +bool cpu_has_work(CPUState *cpu); + #endif /* CONFIG_TCG */ =20 #endif diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 7e67ade35b9..b9ce36e59e2 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -447,6 +447,13 @@ static inline TranslationBlock *tb_find(CPUState *cpu, return tb; } =20 +bool cpu_has_work(CPUState *cpu) +{ + CPUClass *cc =3D CPU_GET_CLASS(cpu); + + return cc->has_work(cpu); +} + static inline bool cpu_handle_halt(CPUState *cpu) { if (cpu->halted) { diff --git a/softmmu/cpus.c b/softmmu/cpus.c index a7ee431187a..548ab9236f1 100644 --- a/softmmu/cpus.c +++ b/softmmu/cpus.c @@ -42,6 +42,7 @@ #include "sysemu/runstate.h" #include "sysemu/cpu-timers.h" #include "sysemu/whpx.h" +#include "sysemu/tcg.h" #include "hw/boards.h" #include "hw/hw.h" =20 --=20 2.26.2