All of lore.kernel.org
 help / color / mirror / Atom feed
* Resetting non-qdev children in a 3-phase reset device
@ 2021-04-09 18:13 Peter Maydell
  2021-04-18 20:16 ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 16+ messages in thread
From: Peter Maydell @ 2021-04-09 18:13 UTC (permalink / raw)
  To: QEMU Developers; +Cc: Damien Hedde, Philippe Mathieu-Daudé

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


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2021-04-26 11:16 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-09 18:13 Resetting non-qdev children in a 3-phase reset device Peter Maydell
2021-04-18 20:16 ` Philippe Mathieu-Daudé
2021-04-19  9:03   ` Peter Maydell
2021-04-22 13:21     ` Markus Armbruster
2021-04-22 14:20       ` Philippe Mathieu-Daudé
2021-04-23 23:06         ` Philippe Mathieu-Daudé
2021-04-23 23:28           ` Philippe Mathieu-Daudé
2021-04-24  5:28             ` Markus Armbruster
2021-04-24 13:04               ` Philippe Mathieu-Daudé
2021-04-24 13:15                 ` Philippe Mathieu-Daudé
2021-04-25 18:33                 ` Peter Maydell
2021-04-26  5:19                   ` Markus Armbruster
2021-04-26  9:09                     ` Peter Maydell
2021-04-26  9:23                   ` Philippe Mathieu-Daudé
2021-04-26  9:33                     ` Peter Maydell
2021-04-26 11:14                       ` Philippe Mathieu-Daudé

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.