[PATCH v4 01/17] accel/system: Introduce hwaccel_enabled() helper

Mohamed Mediouni posted 17 patches 3 months, 1 week ago
Maintainers: Cameron Esfahani <dirty@apple.com>, Roman Bolshakov <rbolshakov@ddn.com>, Phil Dennis-Jordan <phil@philjordan.eu>, Mads Ynddal <mads@ynddal.dk>, Sunil Muthuswamy <sunilmut@microsoft.com>, Mohamed Mediouni <mohamed@unpredictable.fr>, Peter Maydell <peter.maydell@linaro.org>, "Michael S. Tsirkin" <mst@redhat.com>, Igor Mammedov <imammedo@redhat.com>, Ani Sinha <anisinha@redhat.com>, Shannon Zhao <shannon.zhaosl@gmail.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Paolo Bonzini <pbonzini@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, Eduardo Habkost <eduardo@habkost.net>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Yanan Wang <wangyanan55@huawei.com>, Zhao Liu <zhao1.liu@intel.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Alexander Graf <agraf@csgraf.de>
There is a newer version of this series
[PATCH v4 01/17] accel/system: Introduce hwaccel_enabled() helper
Posted by Mohamed Mediouni 3 months, 1 week ago
From: Philippe Mathieu-Daudé <philmd@linaro.org>

hwaccel_enabled() return whether any hardware accelerator
is available.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
 include/system/hw_accel.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/include/system/hw_accel.h b/include/system/hw_accel.h
index fa9228d5d2..49556b026e 100644
--- a/include/system/hw_accel.h
+++ b/include/system/hw_accel.h
@@ -39,4 +39,17 @@ void cpu_synchronize_pre_loadvm(CPUState *cpu);
 void cpu_synchronize_post_reset(CPUState *cpu);
 void cpu_synchronize_post_init(CPUState *cpu);
 
+/**
+ * hwaccel_enabled:
+ *
+ * Returns: %true if a hardware accelerator is enabled, %false otherwise.
+ */
+static inline bool hwaccel_enabled(void)
+{
+    return hvf_enabled()
+        || kvm_enabled()
+        || nvmm_enabled()
+        || whpx_enabled();
+}
+
 #endif /* QEMU_HW_ACCEL_H */
-- 
2.39.5 (Apple Git-154)


Re: [PATCH v4 01/17] accel/system: Introduce hwaccel_enabled() helper
Posted by Claudio Fontana 3 months, 1 week ago
On 8/4/25 16:23, Mohamed Mediouni wrote:
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> 
> hwaccel_enabled() return whether any hardware accelerator
> is available.

Available or enabled?

Ciao,

Claudio



Re: [PATCH v4 01/17] accel/system: Introduce hwaccel_enabled() helper
Posted by Mohamed Mediouni 3 months, 1 week ago
> On 4. Aug 2025, at 18:00, Claudio Fontana <cfontana@suse.de> wrote:
> 
> On 8/4/25 16:23, Mohamed Mediouni wrote:
>> From: Philippe Mathieu-Daudé <philmd@linaro.org>
>> 
>> hwaccel_enabled() return whether any hardware accelerator
>> is available.
> 
> Available or enabled?
enabled

Took the patch from https://lore.kernel.org/qemu-devel/20250703105540.67664-47-philmd@linaro.org/

Should I edit the commit message locally or will be taken care of when it gets merged on that series?

Thank you,

Re: [PATCH v4 01/17] accel/system: Introduce hwaccel_enabled() helper
Posted by Philippe Mathieu-Daudé 3 months, 1 week ago
On 4/8/25 18:12, Mohamed Mediouni wrote:
> 
>> On 4. Aug 2025, at 18:00, Claudio Fontana <cfontana@suse.de> wrote:
>>
>> On 8/4/25 16:23, Mohamed Mediouni wrote:
>>> From: Philippe Mathieu-Daudé <philmd@linaro.org>
>>>
>>> hwaccel_enabled() return whether any hardware accelerator
>>> is available.
>>
>> Available or enabled?
> enabled

Oops indeed.

Orthogonal, but still not trivial to follow available (built in?) /
loaded (as module) / enabled (selected?) / usable (permissions OK)
logic (there is also another state, but I don't remember right now).

> 
> Took the patch from https://lore.kernel.org/qemu- 
> devel/20250703105540.67664-47-philmd@linaro.org/ <https:// 
> lore.kernel.org/qemu-devel/20250703105540.67664-47-philmd@linaro.org/>
> 
> Should I edit the commit message locally or will be taken care of when 
> it gets merged on that series?

I'll do it.

Thanks!