I wanted to convert the hw/misc/mps2-scc.c device from old-style to 3-phase reset as a prerequisite for another change to the device, but I ran into a problem because currently it has some TYPE_DEVICE QOM child objects, the LEDs. Because TYPE_DEVICE don't live in the qbus hierarchy, the device resets them manually in its DeviceClass::reset method:
for (i = 0; i < ARRAY_SIZE(s->led); i++) { device_cold_reset(DEVICE(s->led[i])); } This makes converting to 3-phase reset awkward. The obvious "natural" approach would be to say "in this device's phase X, invoke phase X for these objects", but we have no API for that. (The functions which would do it, resettable_phase_enter() etc, are static inside resettable.c.) Ignoring the phasing and trying to just call device_cold_reset() in the 'enter' phase results in an assertion failure, because we trip the assert(!enter_phase_in_progress) in resettable_assert_reset(), which doesn't expect us to be triggering a reset inside a reset. Ideally one would want to be able to add the LEDs to the list of things which are children of this object for purposes of reset (so they are iterated as part of the resettable_child_foreach() logic and their phases are automatically invoked at the right point). But for a subclass of DeviceState that's device_reset_child_foreach() and it only iterates any qbus children of this device. Any clever ideas? Maybe some mechanism for marking "these things which are my QOM children I want to be reset when I am reset (so make them reset children of me and don't reset them as part of the qbus-tree-walking)" would be useful. I do think that in a lot of cases we want to be doing something closer to "reset along the QOM tree". I really do need to spend some time working out what the right thing with reset is and how we might get from where we are now to there... thanks -- PMM