diff options
author | Damien Hedde | 2020-01-30 17:02:04 +0100 |
---|---|---|
committer | Peter Maydell | 2020-01-30 17:02:04 +0100 |
commit | e755e12759e91a013e417a438305b133ea3c2d19 (patch) | |
tree | 92ff35196775d1e82b52ef61c02dde54718afa67 /hw/core/qdev.c | |
parent | hw/core/qdev: handle parent bus change regarding resettable (diff) | |
download | qemu-e755e12759e91a013e417a438305b133ea3c2d19.tar.gz qemu-e755e12759e91a013e417a438305b133ea3c2d19.tar.xz qemu-e755e12759e91a013e417a438305b133ea3c2d19.zip |
hw/core/qdev: update hotplug reset regarding resettable
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 <damien.hedde@greensocs.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20200123132823.1117486-8-damien.hedde@greensocs.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/core/qdev.c')
-rw-r--r-- | hw/core/qdev.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 28fc93b107..7697f033b1 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; |