All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: "Cédric Le Goater" <clg@kaod.org>
Cc: "Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>,
	"Emmanuel Blot" <eblot@meta.com>,
	qemu-devel@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
	"Fabiano Rosas" <farosas@suse.de>,
	"Laurent Vivier" <lvivier@redhat.com>,
	"Peter Maydell" <peter.maydell@linaro.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>,
	qemu-arm@nongnu.org, "Corey Minyard" <cminyard@mvista.com>
Subject: Re: [PATCH v3 3/5] hw/i2c: parent slaves created with i2c_slave_create_simple
Date: Thu, 02 Jul 2026 09:05:26 +0200	[thread overview]
Message-ID: <87fr213m89.fsf@pond.sub.org> (raw)
In-Reply-To: <03dbf5a7-68c7-4cdd-895d-178088421f9b@kaod.org> ("Cédric Le Goater"'s message of "Wed, 1 Jul 2026 14:39:27 +0200")

Cédric Le Goater <clg@kaod.org> writes:

> On 7/1/26 08:29, Philippe Mathieu-Daudé wrote:
>> On 28/6/26 02:45, Emmanuel Blot wrote:
>>> 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.
>>
>> +Markus
>>
>> Personally I never liked the idea of having buses being parents
>> of the devices attached to them, 
>
> What was the problem ?
>
>> but maybe it is simpler this way.
>
> It is much simpler for functional tests when looking for board
> devices which don't have ids.

A QOM object must be the child of exactly one parent.  This defines the
QOM composition tree.  The link from parent to child is a property of
the parent, and therefore has a name that is unique within its parent.
An object's canonical QOM path is these names on the path from root to
object in the QOM composition tree separated by '/'.

For devices:

* If a device is plugged in with -device / device_add, and it has an ID,
  we make it a child of /machine/peripheral/ with name ID.  If it
  doesn't have an ID, we make it a child of /machine/peripheral-anon/
  with name device[N], where N counts up from zero.  The canonical QOM
  path /machine/peripheral/ID is stable.  The canonical QOM path
  /machine/peripheral-anon/device[N] isn't: it depends on the number of
  devices already there.

* If a device is part of another device, it should be its child.  The
  child's canonical QOM path is the parent's plus '/CHILD-NAME'.  Stable
  as long as the parent's path and the child name are.

* "Should" because we have a lot of code that fails to pick the parent.
  When such a device gets realized, we make it a child of
  /machine/unattached/ orphanage with name device[N], where N counts up
  from zero.  The canonical QOM path /machine/unattached/device[N]
  depends on the number of children already in the orphanage, which
  makes it unstable.

  Letting code get away with not picking a parent was a mistake.  I
  guess it "saved" us some thinking about what's part of what when
  converting existing devices to QOM.  In other words, it enabled sloppy
  hardware modeling.  We've been "saving" thinking ever since.

  I want /machine/unattached/ to be empty.  If an onboard device isn't
  part of another device, put it into /machine/ with a sensible name.

  Whether a device plugged into a bus is part of the device providing
  the bus is a hardware modeling question.

Now to the patch in question.  I understand it makes
i2c_slave_create_simple() pick a parent.  Many machines and devices use
that.  I examined its effect for machine anacapa-bmc with v5 of this
series using "info qom-tree".

The patch moves a bunch of devices from /machine/unattached to

    /machine/soc/i2c/bus[0]/aspeed.i2c.bus.0/0x70 (pca9546)
    /machine/soc/i2c/bus[0]/aspeed.i2c.bus.0/0xff (aspeed.i2c.slave)
    /machine/soc/i2c/bus[1]/aspeed.i2c.bus.1/0x70 (pca9546)
    /machine/soc/i2c/bus[1]/aspeed.i2c.bus.1/0xff (aspeed.i2c.slave)
    /machine/soc/i2c/bus[2]/aspeed.i2c.bus.2/0xff (aspeed.i2c.slave)
    /machine/soc/i2c/bus[3]/aspeed.i2c.bus.3/0xff (aspeed.i2c.slave)
    /machine/soc/i2c/bus[4]/aspeed.i2c.bus.4/0x70 (pca9548)
    /machine/soc/i2c/bus[4]/aspeed.i2c.bus.4/0xff (aspeed.i2c.slave)
    /machine/soc/i2c/bus[5]/aspeed.i2c.bus.5/0xff (aspeed.i2c.slave)
    /machine/soc/i2c/bus[6]/aspeed.i2c.bus.6/0xff (aspeed.i2c.slave)
    /machine/soc/i2c/bus[7]/aspeed.i2c.bus.7/0xff (aspeed.i2c.slave)
    /machine/soc/i2c/bus[8]/aspeed.i2c.bus.8/0x72 (pca9546)
    /machine/soc/i2c/bus[8]/aspeed.i2c.bus.8/0x72/i2c.0/0x22 (pca9552)
    /machine/soc/i2c/bus[8]/aspeed.i2c.bus.8/0x72/i2c.0/0x24 (pca9552)
    /machine/soc/i2c/bus[8]/aspeed.i2c.bus.8/0x72/i2c.1/0x22 (pca9552)
    /machine/soc/i2c/bus[8]/aspeed.i2c.bus.8/0x72/i2c.1/0x24 (pca9552)
    /machine/soc/i2c/bus[8]/aspeed.i2c.bus.8/0xff (aspeed.i2c.slave)
    /machine/soc/i2c/bus[9]/aspeed.i2c.bus.9/0xff (aspeed.i2c.slave)
    /machine/soc/i2c/bus[10]/aspeed.i2c.bus.10/0x71 (pca9548)
    /machine/soc/i2c/bus[10]/aspeed.i2c.bus.10/0x71/i2c.5/0x22 (pca9552)
    /machine/soc/i2c/bus[10]/aspeed.i2c.bus.10/0xff (aspeed.i2c.slave)
    /machine/soc/i2c/bus[11]/aspeed.i2c.bus.11/0x71 (pca9548)
    /machine/soc/i2c/bus[11]/aspeed.i2c.bus.11/0x71/i2c.5/0x22 (pca9552)
    /machine/soc/i2c/bus[11]/aspeed.i2c.bus.11/0xff (aspeed.i2c.slave)
    /machine/soc/i2c/bus[12]/aspeed.i2c.bus.12/0xff (aspeed.i2c.slave)
    /machine/soc/i2c/bus[13]/aspeed.i2c.bus.13/0x70 (pca9548)
    /machine/soc/i2c/bus[13]/aspeed.i2c.bus.13/0xff (aspeed.i2c.slave)
    /machine/soc/i2c/bus[14]/aspeed.i2c.bus.14/0xff (aspeed.i2c.slave)
    /machine/soc/i2c/bus[15]/aspeed.i2c.bus.15/0xff (aspeed.i2c.slave)

Is this a reasonable way to model the hardware?  I can't tell; I don't
know the hardware.  But it sure feels less unreasonable than the
/unattached/ crap!

[...]



  reply	other threads:[~2026-07-02  7:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260627-i2c-adc128d818-anacapa-v3-0-cfb94270a980@meta.com>
2026-06-29  9:35 ` [PATCH v3 0/5] hw/sensor: Add new device emulation for TI ADC128D818 Cédric Le Goater
     [not found] ` <20260627-i2c-adc128d818-anacapa-v3-1-cfb94270a980@meta.com>
2026-06-29 14:44   ` [PATCH v3 1/5] hw/sensor: adc128d818: add 12-bit 8-channel ADC device Philippe Mathieu-Daudé
     [not found] ` <20260627-i2c-adc128d818-anacapa-v3-2-cfb94270a980@meta.com>
2026-06-29 14:47   ` [PATCH v3 2/5] tests/qtest: adc128d818: add test suite Philippe Mathieu-Daudé
     [not found] ` <20260627-i2c-adc128d818-anacapa-v3-3-cfb94270a980@meta.com>
2026-07-01  6:29   ` [PATCH v3 3/5] hw/i2c: parent slaves created with i2c_slave_create_simple Philippe Mathieu-Daudé
2026-07-01 12:39     ` Cédric Le Goater
2026-07-02  7:05       ` Markus Armbruster [this message]
2026-07-03  9:48         ` Cédric Le Goater
2026-07-01 14:15     ` Markus Armbruster

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=87fr213m89.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=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@oss.qualcomm.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.