[Qemu-devel] [PATCH v4 09/10] hw/core/: add warm reset helpers for devices and buses

Damien Hedde posted 10 patches 6 years, 5 months ago
Maintainers: Richard Henderson <rth@twiddle.net>, Fam Zheng <fam@euphon.net>, David Gibson <david@gibson.dropbear.id.au>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Gerd Hoffmann <kraxel@redhat.com>, Thomas Huth <thuth@redhat.com>, Collin Walling <walling@linux.ibm.com>, David Hildenbrand <david@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, John Snow <jsnow@redhat.com>, Cornelia Huck <cohuck@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Eduardo Habkost <ehabkost@redhat.com>, "Cédric Le Goater" <clg@kaod.org>, Dmitry Fleytman <dmitry.fleytman@gmail.com>, Christian Borntraeger <borntraeger@de.ibm.com>, Halil Pasic <pasic@linux.ibm.com>
There is a newer version of this series
[Qemu-devel] [PATCH v4 09/10] hw/core/: add warm reset helpers for devices and buses
Posted by Damien Hedde 6 years, 5 months ago
This add helpers to trigger warm reset and to retrieve the
reset current reset type.

Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
---
 hw/core/bus.c          | 11 +++++++++++
 hw/core/qdev.c         | 11 +++++++++++
 include/hw/qdev-core.h | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 56 insertions(+)

diff --git a/hw/core/bus.c b/hw/core/bus.c
index 3be65ad041..b245fd6937 100644
--- a/hw/core/bus.c
+++ b/hw/core/bus.c
@@ -74,11 +74,22 @@ void bus_cold_reset(BusState *bus)
     resettable_reset(OBJECT(bus), RESET_TYPE_COLD);
 }
 
+void bus_warm_reset(BusState *bus)
+{
+    resettable_reset(OBJECT(bus), RESET_TYPE_WARM);
+}
+
 bool bus_is_resetting(BusState *bus)
 {
     return resettable_is_resetting(OBJECT(bus));
 }
 
+bool bus_test_reset_type(BusState *bus, ResetType type)
+{
+    ResetType cur_type = resettable_get_type(OBJECT(bus));
+    return (cur_type & type);
+}
+
 static ResetState *bus_get_reset_state(Object *obj)
 {
     BusState *bus = BUS(obj);
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 1638bc9f3b..9095f2b9c1 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -281,11 +281,22 @@ void device_cold_reset(DeviceState *dev)
     resettable_reset(OBJECT(dev), RESET_TYPE_COLD);
 }
 
+void device_warm_reset(DeviceState *dev)
+{
+    resettable_reset(OBJECT(dev), RESET_TYPE_WARM);
+}
+
 bool device_is_resetting(DeviceState *dev)
 {
     return resettable_is_resetting(OBJECT(dev));
 }
 
+bool device_test_reset_type(DeviceState *dev, ResetType type)
+{
+    ResetType cur_type = resettable_get_type(OBJECT(dev));
+    return (cur_type & type);
+}
+
 static ResetState *device_get_reset_state(Object *obj)
 {
     DeviceState *dev = DEVICE(obj);
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 2976121fbc..eb11f0f801 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -422,18 +422,52 @@ void device_cold_reset(DeviceState *dev);
  */
 void bus_cold_reset(BusState *bus);
 
+/**
+ * device_warm_reset:
+ * Trigger a warm reset of the device @dev.
+ *
+ * Use the Resettable interface (see hw/interface.h); it also reset the
+ * device's qdev/qbus subtree.
+ */
+void device_warm_reset(DeviceState *dev);
+
+/**
+ * bus_warm_reset:
+ * Trigger a warm reset of the bus @bus.
+ *
+ * Use the Resettable interface (see hw/interface.h); it also reset the
+ * bus's qdev/qbus subtree.
+ */
+void bus_warm_reset(BusState *bus);
+
 /**
  * device_is_resetting:
  * Return true if the device @dev is currently being reset.
  */
 bool device_is_resetting(DeviceState *dev);
 
+/**
+ * device_test_reset_type:
+ * Return true if the device @dev is currently under reset type
+ * @type.
+ * Only valid if device_is_resetting() is true
+ */
+bool device_test_reset_type(DeviceState *dev, ResetType type);
+
 /**
  * bus_is_resetting:
  * Return true if the bus @bus is currently being reset.
  */
 bool bus_is_resetting(BusState *bus);
 
+/**
+ * bus_test_reset_type:
+ * Return true if the bus @bus is currently under reset type
+ * @type.
+ * Only valid if device_is_resetting() is true
+ */
+bool bus_test_reset_type(BusState *bus, ResetType type);
+
 /* This should go away once we get rid of the NULL bus hack */
 BusState *sysbus_get_default(void);
 
-- 
2.22.0