From: Markus Armbruster <armbru@redhat.com>
To: Emmanuel Blot <emmanuel.blot@free.fr>
Cc: qemu-devel@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@mailo.com>,
"Fabiano Rosas" <farosas@suse.de>,
"Laurent Vivier" <lvivier@redhat.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Cédric Le Goater" <clg@kaod.org>,
"Steven Lee" <steven_lee@aspeedtech.com>,
"Troy Lee" <leetroy@gmail.com>,
"Jamin Lin" <jamin_lin@aspeedtech.com>,
"Kane Chen" <kane_chen@aspeedtech.com>,
"Andrew Jeffery" <andrew@codeconstruct.com.au>,
"Joel Stanley" <joel@jms.id.au>,
"Alexander Hansen" <alexander.hansen@9elements.com>,
"William de Abreu Pinho" <williampinho@meta.com>,
"Emmanuel Blot" <eblot@meta.com>,
qemu-arm@nongnu.org, "Corey Minyard" <cminyard@mvista.com>
Subject: Re: [PATCH v5 6/8] hw/i2c: parent slaves created with i2c_slave_create_simple
Date: Fri, 10 Jul 2026 17:25:26 +0200 [thread overview]
Message-ID: <87pl0uyihl.fsf@pond.sub.org> (raw)
In-Reply-To: <20260701-i2c-adc128d818-anacapa-v5-6-fe8292d86b38@free.fr> (Emmanuel Blot's message of "Wed, 01 Jul 2026 19:28:36 +0200")
Emmanuel Blot <emmanuel.blot@free.fr> writes:
> Slaves created with i2c_slave_create_simple() were left unparented and
> showed up under /machine/unattached with no stable QOM path. Add each
> slave as a QOM child of its bus, named after its I2C address, so it has
> a deterministic and addressable QOM path.
Could use an example.
Doesn't tell which machines are affected.
To find affected machines, I captured output of "info qom-tree" by running
$ echo -e 'info qom-tree\nq' | qemu-system-TARGET -M MACHINE -S -display none -monitor stdio
for all targets and all their machine types.
This fails on my box for a number of machines: misses some image file,
needs Xen, ... These are
an5206
boston
boston-aia
canon-a1100
leon3_generic
loongson3-virt
mcf5208evb
microchip-icicle-kit
niagara
nitro
q800
sx1
sx1-v1
xenfv-4.2
xenpv
xenpvh
Testing them manually would be possible. Not by me.
Of the ones that run, output differs for
anacapa-bmc
ast1030-evb
ast1040-evb
ast1060-evb
ast2500-evb
ast2600-evb
ast2700a1-evb
ast2700a2-evb
ast2700fc
bletchley-bmc
bpim2u
catalina-bmc
cubieboard
fby35-bmc
fuji-bmc
g220a-bmc
gb200nvl-bmc
kudo-bmc
lm3s811evb
mpc8544ds
npcm750-evb
npcm845-evb
palmetto-bmc
powernv10-rainier
ppce500
quanta-gsj
quanta-q71l-bmc
rainier-bmc
realview-eb
realview-eb-mpcore
realview-pb-a8
realview-pbx-a9
romulus-bmc
sam460ex
supermicro-x11spi-bmc
supermicrox11-bmc
tiogapass-bmc
tt-atlantis
versatileab
versatilepb
vexpress-a15
vexpress-a9
witherspoon-bmc
yosemitev2-bmc
Looking for one with a short diff, I found realview-eb:
/device[26] (versatile_i2c)
/arm_sbcon_i2c[0] (memory-region)
/i2c (i2c-bus)
- /device[27] (ds1338)
+ /0x68 (ds1338)
/device[2] (realview_gic)
/gic (arm_gic)
/gic_cpu[0] (memory-region)
The QOM path of this ds1338 device changes from
/machine/unattached/device[27]
to
/machine/unattached/device[26]/0x68
The new path still isn't stable, because the parent's path isn't. This
caveat should be noted in the commit message.
An example of successful stabilization is tt-atlantis, where the QOM
paths of ds1338 and tmp105 change from
/machine/unattached/device[21]
/machine/unattached/device[22]
to
/machine/i2c[0]/i2c-bus/0x6f
/machine/i2c[4]/i2c-bus/0x48
> Signed-off-by: Emmanuel Blot <emmanuel.blot@free.fr>
> ---
> hw/i2c/core.c | 3 +++
> include/hw/i2c/i2c.h | 7 +++++--
> 2 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/hw/i2c/core.c b/hw/i2c/core.c
> index 54f6bdca88..0bbce45d48 100644
> --- a/hw/i2c/core.c
> +++ b/hw/i2c/core.c
> @@ -382,6 +382,9 @@ I2CSlave *i2c_slave_create_simple(I2CBus *bus, const char *name, uint8_t addr)
> {
> I2CSlave *dev = i2c_slave_new(name, addr);
>
> + g_autofree char *childname = g_strdup_printf("0x%02x", addr);
Is the hex address a satisfactory child name?
> + object_property_add_child(OBJECT(bus), childname, OBJECT(dev));
> +
> i2c_slave_realize_and_unref(dev, bus, &error_abort);
>
> return dev;
> diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h
> index dd5930f4b5..dc557bbf3f 100644
> --- a/include/hw/i2c/i2c.h
> +++ b/include/hw/i2c/i2c.h
> @@ -166,13 +166,16 @@ bool i2c_scan_bus(I2CBus *bus, uint8_t address, bool broadcast,
> I2CSlave *i2c_slave_new(const char *name, uint8_t addr);
>
> /**
> - * Create and realize an I2C slave device on the heap.
> + * Create and realize an I2C slave device on the heap, add the device as a
> + * child of its parent bus.
> + *
> * @bus: I2C bus to put it on
> * @name: I2C slave device type name
> * @addr: I2C address of the slave when put on a bus
> *
> * Create the device state structure, initialize it, put it on the
> - * specified @bus, and drop the reference to it (the device is realized).
> + * specified @bus, parent it, and drop the reference to it (the device is
> + * realized).
> */
> I2CSlave *i2c_slave_create_simple(I2CBus *bus, const char *name, uint8_t addr);
next prev parent reply other threads:[~2026-07-10 15:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-01 17:28 [PATCH v5 0/8] hw/sensor: Add new device emulation for TI ADC128D818 Emmanuel Blot
2026-07-01 17:28 ` [PATCH v5 1/8] hw/sensor: adc128d818: add 12-bit 8-channel ADC device Emmanuel Blot
2026-07-01 17:28 ` [PATCH v5 2/8] tests/qtest: adc128d818: add test harness and register access Emmanuel Blot
2026-07-01 17:28 ` [PATCH v5 3/8] tests/qtest: adc128d818: test voltage and temperature conversion Emmanuel Blot
2026-07-01 17:28 ` [PATCH v5 4/8] tests/qtest: adc128d818: test limit interrupts Emmanuel Blot
2026-07-01 17:28 ` [PATCH v5 5/8] tests/qtest: adc128d818: test operating modes and power control Emmanuel Blot
2026-07-01 17:28 ` [PATCH v5 6/8] hw/i2c: parent slaves created with i2c_slave_create_simple Emmanuel Blot
2026-07-06 7:14 ` Cédric Le Goater
2026-07-10 15:25 ` Markus Armbruster [this message]
2026-07-10 16:05 ` Peter Maydell
2026-07-01 17:28 ` [PATCH v5 7/8] hw/arm: anacapa: add ADC128D818 devices Emmanuel Blot
2026-07-01 17:28 ` [PATCH v5 8/8] test/functional: anacapa: test ADC128D818 Emmanuel Blot
2026-07-06 8:06 ` Cédric Le Goater
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=87pl0uyihl.fsf@pond.sub.org \
--to=armbru@redhat.com \
--cc=alexander.hansen@9elements.com \
--cc=andrew@codeconstruct.com.au \
--cc=clg@kaod.org \
--cc=cminyard@mvista.com \
--cc=eblot@meta.com \
--cc=emmanuel.blot@free.fr \
--cc=farosas@suse.de \
--cc=jamin_lin@aspeedtech.com \
--cc=joel@jms.id.au \
--cc=kane_chen@aspeedtech.com \
--cc=leetroy@gmail.com \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@mailo.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=steven_lee@aspeedtech.com \
--cc=williampinho@meta.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 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.