Skip to content

RFC hw/qdev: Split 'wiring' phase from 'realize'

Philippe Mathieu-Daudé qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest7 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7hw/qdev: Introduce DeviceClass::[un]wire() handlershw/core/qdev.c include/hw/qdev-core.h+27 -20 replies
2/7hw/input/pckbd: Connect i8042 GPIOs once mouse/keyboard are realizedhw/input/pckbd.c+27 -110 replies
3/7hw/ide/cmd646: Configure IDE bus IRQs after realizationhw/ide/cmd646.c+11 -10 replies
4/7hw/ide/sii3112: Configure IDE bus IRQs after realizationhw/ide/sii3112.c+10 -00 replies
5/7hw/ide/via: Configure IDE bus IRQs after realizationhw/ide/via.c+10 -00 replies
6/7hw/intc/mips_gic: Initialize IRQ array once device is realizedhw/intc/mips_gic.c+9 -20 replies
7/7hw/misc/mac_via: Have VIA1 child access parent IRQ once realizedhw/misc/mac_via.c+8 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 0/7] hw/qdev: Split 'wiring' phase from 'realize'

Hi,

Various issues related to implementing dynamic machines have been documented in [1].

We are trying to understand what means "a qdev is realized". One explanation was "the device is guest visible"; however many devices are realized before being mapped, thus are not "guest visible". Some devices map / wire their IRQs before being realized (such ISA devices). There is a need for devices to be "automatically" mapped/wired (see [2]) such CLI-created devices, but this apply generically to dynamic machines.

Currently the device creation steps are expected to roughly be:

(external use) (QDev core) (Device Impl)
~~~~~~~~~~~~ ~~~~~~~~~ ~~~~~~~~~~~

                               INIT enter
                   ----->
                         +----------------------+
                         |    Allocate state    |
                         +----------------------+
                                                 ----->
                                                        +---------------------+
                                                        | INIT children       |
                                                        |                     |
                                                        | Alias children properties
                                                        |                     |
                                                        | Expose properties   |
                                INIT exit               +---------------------+
                   <-----------------------------------
 +----------------+
 | set properties |
 |                |
 | set ClkIn      |
 +----------------+          REALIZE enter
                   ---------------------------------->
                                                       +----------------------+
                                                       | Use config properties|
                                                       |                      |
                                                       | Realize children     |
                                                       |                      |
                                                       | Init GPIOs/IRQs      |
                                                       |                      |
                                                       | Init MemoryRegions   |
                                                       +----------------------+
                               REALIZE exit
                   <-----------------------------------                        ----  "realized" / "guest visible"
+-----------------+
| Explicit wiring:|
|   IRQs          |
|   I/O / Mem     |
|   ClkOut        |
+-----------------+             RESET enter
                    --------------------------------->
                                                       +----------------------+
                                                       | Reset default values |
                                                       +----------------------+

But as mentioned, various devices "wire" parts before they exit the "realize" step.
In order to clarify, I'm trying to enforce what can be done *before* and *after* realization.

*after* a device is expected to be stable (no more configurable) and fully usable.

To be able to use internal/auto wiring (such ISA devices) and keep the current external/explicit wiring, I propose to add an extra "internal wiring" step, happening after the REALIZE step as:

(external use) (QDev core) (Device Impl)
~~~~~~~~~~~~ ~~~~~~~~~ ~~~~~~~~~~~

                               INIT enter
                   ----->
                         +----------------------+
                         |    Allocate state    |
                         +----------------------+
                                                 ----->
                                                        +---------------------+
                                                        | INIT children       |
                                                        |                     |
                                                        | Alias children properties
                                                        |                     |
                                                        | Expose properties   |
                                INIT exit               +---------------------+
                   <-----------------------------------
 +----------------+
 | set properties |
 |                |
 | set ClkIn      |
 +----------------+          REALIZE enter
                   ---------------------------------->
                                                       +----------------------+
                                                       | Use config properties|
                                                       |                      |
                                                       | Realize children     |
                                                       |                      |
                                                       | Init GPIOs/IRQs      |
                                                       |                      |
                                                       | Init MemoryRegions   |
                                                       +----------------------+
                               REALIZE exit       <---
                         +----------------------+
                         | Internal auto wiring |
                         |   IRQs               |  (i.e. ISA bus)
                         |   I/O / Mem          |
                         |   ClkOut             |
                         +----------------------+
                    <---                                                       ----  "realized"
+-----------------+
| External wiring:|
|   IRQs          |
|   I/O / Mem     |
|   ClkOut        |
+-----------------+             RESET enter                                    ----  "guest visible"
                    --------------------------------->
                                                       +----------------------+
                                                       | Reset default values |
                                                       +----------------------+

The "realized" point is not changed. "guest visible" concept only occurs *after* wiring, just before the reset phase.

This series introduces the DeviceClass::wire handler within qdev core realization code, and convert devices using the implicit wiring to using that explicit handler.

QDev API assertions patches will be posted later as another series.

Thoughts?

Regards,

Phil.

[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/qemu-devel/[email protected]/

Cc Eduardo Habkost <[email protected]>
Cc Markus Armbruster <[email protected]>' --cc '
Cc Edgar E. Iglesias <[email protected]>'
Cc Richard Henderson <[email protected]>
Cc Mark Cave-Ayland <[email protected]>
Cc Thomas Huth <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Alexander Graf <[email protected]>
Cc Bernhard Beschow <[email protected]>
Cc Stefan Hajnoczi <[email protected]>
Cc Peter Maydell <[email protected]>
Cc Cédric Le Goater <[email protected]>
Cc Luc Michel <[email protected]>
Cc Zhao Liu <[email protected]>
Cc Gustavo Romero <[email protected]>

Philippe Mathieu-Daudé (7):
hw/qdev: Introduce DeviceClass::[un]wire() handlers hw/input/pckbd: Connect i8042 GPIOs once mouse/keyboard are realized hw/ide/cmd646: Configure IDE bus IRQs after realization hw/ide/sii3112: Configure IDE bus IRQs after realization hw/ide/via: Configure IDE bus IRQs after realization hw/intc/mips_gic: Initialize IRQ array once device is realized hw/misc/mac_via: Have VIA1 child access parent IRQ once realized

 include/hw/qdev-core.h |  8 +++++++-
 hw/core/qdev.c         | 21 ++++++++++++++++++++-
 hw/ide/cmd646.c        | 12 +++++++++++-
 hw/ide/sii3112.c       | 10 ++++++++++
 hw/ide/via.c           | 10 ++++++++++
 hw/input/pckbd.c       | 38 +++++++++++++++++++++++++++-----------
 hw/intc/mips_gic.c     | 11 +++++++++--
 hw/misc/mac_via.c      |  9 ++++++++-
 8 files changed, 102 insertions(+), 17 deletions(-)
Signature · 1 line
2.41.0