All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Gerd Hoffmann <kraxel@redhat.com>
Subject: Realize methods realizing "sideways" in the composition tree
Date: Fri, 15 Jan 2021 16:38:42 +0100	[thread overview]
Message-ID: <87im7yi519.fsf@dusky.pond.sub.org> (raw)

Perhaps I'm slow on the uptake today...

We have

    typedef struct XHCIPciState {
        /*< private >*/
        PCIDevice parent_obj;
        /*< public >*/
(1)     XHCIState xhci;
        OnOffAuto msi;
        OnOffAuto msix;
    } XHCIPciState;

This is a PCI device that contains a (bus-less) TYPE_XHCI device, at
(1).

    static void xhci_instance_init(Object *obj)
    {
        XHCIPciState *s = XHCI_PCI(obj);
        /*
         * QEMU_PCI_CAP_EXPRESS initialization does not depend on QEMU command
         * line, therefore, no need to wait to realize like other devices
         */
        PCI_DEVICE(obj)->cap_present |= QEMU_PCI_CAP_EXPRESS;
(2)     object_initialize_child(obj, "xhci-core", &s->xhci, TYPE_XHCI);
        qdev_alias_all_properties(DEVICE(&s->xhci), obj);
    }

The .instance_init() method initializes the child as it should, at (2).

    static void usb_xhci_pci_realize(struct PCIDevice *dev, Error **errp)
    {
        int ret;
        Error *err = NULL;
        XHCIPciState *s = XHCI_PCI(dev);

        [a few dev->config[] modifications...]

(1)     object_property_set_link(OBJECT(&s->xhci), "host", OBJECT(s), NULL);
        s->xhci.intr_update = xhci_pci_intr_update;
        s->xhci.intr_raise = xhci_pci_intr_raise;
(2)     object_property_set_bool(OBJECT(&s->xhci), "realized", true, &err);
        if (err) {
            error_propagate(errp, err);
            return;
        }

The .realize() method realizes the child at (1).  It should use
qdev_realize() like we do everywhere else, since commit ce189ab230
"qdev: Convert bus-less devices to qdev_realize() with Coccinelle".

It sets a link property from the child back to the parent at (2).  Why
do we need a link?  Each QOM Object contains a pointer to its parent,
doesn't it?

Same for xhci_sysbus_realize().



             reply	other threads:[~2021-01-15 15:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-15 15:38 Markus Armbruster [this message]
2021-01-15 15:50 ` Realize methods realizing "sideways" in the composition tree Peter Maydell
2021-01-19 11:36   ` 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=87im7yi519.fsf@dusky.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=sai.pavan.boddu@xilinx.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.