[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 15/26] hw/core/qdev: update hotplug reset regarding resettable
From: |
Peter Maydell |
Subject: |
[PULL 15/26] hw/core/qdev: update hotplug reset regarding resettable |
Date: |
Thu, 30 Jan 2020 16:15:22 +0000 |
From: Damien Hedde <address@hidden>
This commit make use of the resettable API to reset the device being
hotplugged when it is realized. Also it ensures it is put in a reset
state coherent with the parent it is plugged into.
Note that there is a difference in the reset. Instead of resetting
only the hotplugged device, we reset also its subtree (switch to
resettable API). This is not expected to be a problem because
sub-buses are just realized too. If a hotplugged device has any
sub-buses it is logical to reset them too at this point.
The recently added should_be_hidden and PCI's partially_hotplugged
mechanisms do not interfere with realize operation:
+ In the should_be_hidden use case, device creation is
delayed.
+ The partially_hotplugged mechanism prevents a device to be
unplugged and unrealized from qdev POV and unrealized.
Signed-off-by: Damien Hedde <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Tested-by: Philippe Mathieu-Daudé <address@hidden>
Message-id: address@hidden
Signed-off-by: Peter Maydell <address@hidden>
---
include/hw/resettable.h | 11 +++++++++++
hw/core/qdev.c | 15 ++++++++++++++-
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/include/hw/resettable.h b/include/hw/resettable.h
index 96073354fd6..5e215d94e42 100644
--- a/include/hw/resettable.h
+++ b/include/hw/resettable.h
@@ -153,6 +153,17 @@ struct ResettableState {
bool exit_phase_in_progress;
};
+/**
+ * resettable_state_clear:
+ * Clear the state. It puts the state to the initial (zeroed) state required
+ * to reuse an object. Typically used in realize step of base classes
+ * implementing the interface.
+ */
+static inline void resettable_state_clear(ResettableState *state)
+{
+ memset(state, 0, sizeof(ResettableState));
+}
+
/**
* resettable_reset:
* Trigger a reset on an object @obj of type @type. @obj must implement
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 28fc93b1074..7697f033b19 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -909,6 +909,12 @@ static void device_set_realized(Object *obj, bool value,
Error **errp)
}
}
+ /*
+ * Clear the reset state, in case the object was previously unrealized
+ * with a dirty state.
+ */
+ resettable_state_clear(&dev->reset);
+
QLIST_FOREACH(bus, &dev->child_bus, sibling) {
object_property_set_bool(OBJECT(bus), true, "realized",
&local_err);
@@ -917,7 +923,14 @@ static void device_set_realized(Object *obj, bool value,
Error **errp)
}
}
if (dev->hotplugged) {
- device_legacy_reset(dev);
+ /*
+ * Reset the device, as well as its subtree which, at this point,
+ * should be realized too.
+ */
+ resettable_assert_reset(OBJECT(dev), RESET_TYPE_COLD);
+ resettable_change_parent(OBJECT(dev), OBJECT(dev->parent_bus),
+ NULL);
+ resettable_release_reset(OBJECT(dev), RESET_TYPE_COLD);
}
dev->pending_deleted_event = false;
--
2.20.1
- [PULL 09/26] add device_legacy_reset function to prepare for reset api change, (continued)
- [PULL 09/26] add device_legacy_reset function to prepare for reset api change, Peter Maydell, 2020/01/30
- [PULL 08/26] hw/arm/raspi: Remove obsolete use of -smp to set the soc 'enabled-cpus', Peter Maydell, 2020/01/30
- [PULL 10/26] hw/core/qdev: add trace events to help with resettable transition, Peter Maydell, 2020/01/30
- [PULL 12/26] hw/core: add Resettable support to BusClass and DeviceClass, Peter Maydell, 2020/01/30
- [PULL 14/26] hw/core/qdev: handle parent bus change regarding resettable, Peter Maydell, 2020/01/30
- [PULL 13/26] hw/core/resettable: add support for changing parent, Peter Maydell, 2020/01/30
- [PULL 16/26] hw/core: deprecate old reset functions and introduce new ones, Peter Maydell, 2020/01/30
- [PULL 19/26] hw/s390x/ipl: replace deprecated qdev_reset_all registration, Peter Maydell, 2020/01/30
- [PULL 22/26] hw/arm/virt: Add missing 5.0 options call to 4.2 options, Peter Maydell, 2020/01/30
- [PULL 11/26] hw/core: create Resettable QOM interface, Peter Maydell, 2020/01/30
- [PULL 15/26] hw/core/qdev: update hotplug reset regarding resettable,
Peter Maydell <=
- [PULL 21/26] target/arm/kvm: trivial: Clean up header documentation, Peter Maydell, 2020/01/30
- [PULL 25/26] target/arm/kvm: Implement virtual time adjustment, Peter Maydell, 2020/01/30
- [PULL 20/26] hw/intc/arm_gicv3_kvm: Stop wrongly programming GICR_PENDBASER.PTZ bit, Peter Maydell, 2020/01/30
- [PULL 18/26] vl: replace deprecated qbus_reset_all registration, Peter Maydell, 2020/01/30
- [PULL 17/26] docs/devel/reset.rst: add doc about Resettable interface, Peter Maydell, 2020/01/30
- [PULL 23/26] target/arm/kvm64: kvm64 cpus have timer registers, Peter Maydell, 2020/01/30
- [PULL 26/26] target/arm/cpu: Add the kvm-no-adjvtime CPU property, Peter Maydell, 2020/01/30
- [PULL 24/26] tests/arm-cpu-features: Check feature default values, Peter Maydell, 2020/01/30
- Re: [PULL 00/26] target-arm queue, Peter Maydell, 2020/01/30