diff mbox series

[v5,3/6] hw/loongarch/virt: Fix error handling in cpu unplug

Message ID 20250320032158.1762751-4-maobibo@loongson.cn (mailing list archive)
State New
Headers show
Series target/loongarch: Fix some issues reported from coccinelle | expand

Commit Message

bibo mao March 20, 2025, 3:21 a.m. UTC
In function virt_cpu_unplug(), it will send cpu unplug message to
interrupt controller extioi and ipi irqchip. If there is problem in
this function, system should continue to run and keep state the same
before cpu is removed.

If error happends in cpu unplug stage, send cpu plug message to extioi
and ipi irqchip to restore to previous stage, and then return immediately.

Fixes: 2cd6857f6f5b (hw/loongarch/virt: Implement cpu unplug interface)
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
 hw/loongarch/virt.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c
index 5118f01e4b..8dd5d88c31 100644
--- a/hw/loongarch/virt.c
+++ b/hw/loongarch/virt.c
@@ -958,12 +958,16 @@  static void virt_cpu_unplug(HotplugHandler *hotplug_dev,
     hotplug_handler_unplug(HOTPLUG_HANDLER(lvms->extioi), dev, &err);
     if (err) {
         error_propagate(errp, err);
+        /* Send plug message to restore, discard error here */
+        hotplug_handler_plug(HOTPLUG_HANDLER(lvms->ipi), dev, NULL);
         return;
     }
 
     /* Notify acpi ged CPU removed */
     hotplug_handler_unplug(HOTPLUG_HANDLER(lvms->acpi_ged), dev, &err);
     if (err) {
+        hotplug_handler_plug(HOTPLUG_HANDLER(lvms->ipi), dev, NULL);
+        hotplug_handler_plug(HOTPLUG_HANDLER(lvms->extioi), dev, NULL);
         error_propagate(errp, err);
         return;
     }