From: Markus Armbruster <armbru@redhat.com>
To: Bernhard Beschow <shentey@gmail.com>
Cc: qemu-devel@nongnu.org, "Helge Deller" <deller@gmx.de>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Steven Lee" <steven_lee@aspeedtech.com>,
"Cédric Le Goater" <clg@kaod.org>, "Troy Lee" <leetroy@gmail.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Mark Cave-Ayland" <mark.caveayland@nutanix.com>,
qemu-arm@nongnu.org, "Jamin Lin" <jamin_lin@aspeedtech.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Andrew Jeffery" <andrew@codeconstruct.com.au>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Joel Stanley" <joel@jms.id.au>
Subject: QOM parent type "sys-bus-device" vs. "device" (was: [PATCH v2 12/13] hw/char/serial: Inherit from SysBusDevice)
Date: Wed, 04 Mar 2026 13:25:06 +0100 [thread overview]
Message-ID: <87ikbbixy5.fsf_-_@pond.sub.org> (raw)
In-Reply-To: <20260303222143.142741-13-shentey@gmail.com> (Bernhard Beschow's message of "Tue, 3 Mar 2026 23:21:42 +0100")
Bernhard Beschow <shentey@gmail.com> 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 <shentey@gmail.com>
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.
next prev parent reply other threads:[~2026-03-04 12:26 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-03 22:21 [PATCH v2 00/13] TYPE_SERIAL cleanup Bernhard Beschow
2026-03-03 22:21 ` [PATCH v2 01/13] hw/arm/Kconfig: Fix serial selection for NPCM8XX Bernhard Beschow
2026-03-03 22:21 ` [PATCH v2 02/13] hw/arm/aspeed_ast27x0-{ssp, tsp}: Do not access SerialMM internals directly Bernhard Beschow
2026-03-04 15:19 ` Philippe Mathieu-Daudé
2026-03-03 22:21 ` [PATCH v2 03/13] util/fifo8: Make all read-only methods const-correct Bernhard Beschow
2026-03-03 22:21 ` [PATCH v2 04/13] hw/char/serial: Remove explicit cast from void pointer Bernhard Beschow
2026-03-03 22:21 ` [PATCH v2 05/13] hw/char/serial: Prefer fifo8 methods over open-coding Bernhard Beschow
2026-03-03 22:21 ` [PATCH v2 06/13] hw/char/serial: Reuse fifo8_num_used() Bernhard Beschow
2026-03-03 22:21 ` [PATCH v2 07/13] hw/char/serial: Remove stale comment Bernhard Beschow
2026-03-03 22:21 ` [PATCH v2 08/13] hw/char/serial: Add constants for Line Control Register Bernhard Beschow
2026-03-03 22:21 ` [PATCH v2 09/13] hw/char/serial: Remove redundant reset Bernhard Beschow
2026-03-03 22:21 ` [PATCH v2 10/13] hw/char/serial: Avoid implicit conversion when tracing Bernhard Beschow
2026-03-04 15:21 ` Philippe Mathieu-Daudé
2026-03-03 22:21 ` [PATCH v2 11/13] hw/char/serial: Keep MemoryRegionOps private Bernhard Beschow
2026-03-03 22:56 ` BALATON Zoltan
2026-03-04 1:33 ` BALATON Zoltan
2026-03-04 8:45 ` Bernhard Beschow
2026-03-04 8:38 ` Bernhard Beschow
2026-03-05 10:03 ` Peter Maydell
2026-03-05 22:48 ` Bernhard Beschow
2026-03-03 22:21 ` [PATCH v2 12/13] hw/char/serial: Inherit from SysBusDevice Bernhard Beschow
2026-03-04 12:25 ` Markus Armbruster [this message]
2026-03-04 13:54 ` QOM parent type "sys-bus-device" vs. "device" (was: [PATCH v2 12/13] hw/char/serial: Inherit from SysBusDevice) Peter Maydell
2026-03-04 14:37 ` BALATON Zoltan
2026-03-05 9:25 ` QOM parent type "sys-bus-device" vs. "device" Markus Armbruster via qemu development
2026-03-05 9:30 ` Peter Maydell
2026-03-05 11:00 ` Markus Armbruster
2026-03-05 10:07 ` [PATCH v2 12/13] hw/char/serial: Inherit from SysBusDevice Peter Maydell
2026-03-05 17:53 ` Bernhard Beschow
2026-03-03 22:21 ` [PATCH v2 13/13] hw/char/serial: Plug into reset framework Bernhard Beschow
2026-03-05 10:07 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ikbbixy5.fsf_-_@pond.sub.org \
--to=armbru@redhat.com \
--cc=andrew@codeconstruct.com.au \
--cc=clg@kaod.org \
--cc=deller@gmx.de \
--cc=jamin_lin@aspeedtech.com \
--cc=joel@jms.id.au \
--cc=leetroy@gmail.com \
--cc=marcandre.lureau@redhat.com \
--cc=mark.caveayland@nutanix.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=shentey@gmail.com \
--cc=steven_lee@aspeedtech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox