Bernhard Beschow <[email protected]> writes:

> SerialState currently inherits just from DeviceState and serial devices
> use SerialState as an "IP block". Since DeviceState doesn't have an API
> to provide MMIO regions or IRQs, all serial devices access attributes
> internal to SerialState directly. Fix this by having SerialState inherit
> from SysBusDevice.
>
> In addition, DeviceState doesn't participate in the reset framework
> while SysBusDevice does. This allows for implementing reset
> functionality more idiomatically.
>
> Signed-off-by: Bernhard Beschow <[email protected]>

We might be at a crossroads here.

Paul Brook designed qdev around "a device plugs into some bus, and may
provide buses".  To make this work, he added a main system bus to serve
as root of a single tree.

The parent of a device in that tree is the bus it plugs into, and the
parent of a bus is the device that provides it, except for the main
system bus, which has no parent.  "info qtree" shows this tree.

Note a machine had just this one system bus back then.

The system bus isn't something hardware people would call a bus.

The qtree is a qdev thing.  It is *not* the QOM composition tree ("info
qom-tree /").

We actually abandoned "a device plugs into some bus" a long time ago.
Moe on that below.

Qdev was later rebased onto QOM, as follows.

A bus QOM type is a subtype of "bus".

A device QOM type is a subtype of "device".

If a device type has a @bus_type, then it plugs into a bus of that QOM
type.  Such a concrete device is commonly[*] not a direct subtype of
"device".  Instead, it's a subtype of the abstract device that plugs
into that bus type.  Example: "isa-serial" is a direct subtype of
"isa-device", and it inherits its bus type "ISA" from there.

If a device has no @bus_type, it doesn't plug into any bus.  It doesn't
show up in "info qtree" (it does in "info qom-tree", of course).
Example: "serial" is a direct subtype of "device".

This lets us build devices from components without having to make up
buses to connect them.  Example: "isa-serial" has a direct QOM child of
type "serial".  Good!

Except infrastructure useful to such bus-less devices lives in sysbus,
where bus-less devices can't access it.  This tempts us to make devices
sysbus devices just to be able to use the infrastructure, and to create
additional sysbuses.

We can elect to go down this path further: make more sysbus devices.
Create more sysbuses.  If this is the right path, then bus-less devices
were a mistake, and we should consider eliminating them.

Or we can pick the other branch: put the infrastructure where bus-less
devices can use it.  If this is the right path, then sysbus is
obsolescent.

Or we can elect to muddle on without giving it much thought.  Always an
option :)


[...]


[*] Are there any exceptions?  I don't know.


Reply via email to