qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Markus Armbruster" <armbru@redhat.com>,
	"Anthony Liguori" <aliguori@us.ibm.com>,
	"Juha Riihimäki" <juha.riihimaki@nokia.com>,
	"Paul Brook" <paul@codesourcery.com>,
	patches@linaro.org
Subject: [Qemu-devel] [PATCH RFC 0/3] basic support for composing sysbus devices
Date: Wed,  8 Jun 2011 12:33:30 +0100	[thread overview]
Message-ID: <1307532813-27175-1-git-send-email-peter.maydell@linaro.org> (raw)

At the moment you can't really implement one sysbus device by saying
that it's composed of a set of other sysbus devices. This patch adds
new functions sysbus_pass_mmio() and sysbus_pass_one_irq() which
allow a sysbus device to delegate an MMIO or IRQ to another sysbus
device (The approach is inspired by the existing sysbus_pass_irq()
which lets a sysbus device delegate all its IRQs at once).

This works; the most obvious deficiency is that the subcomponent
device will still appear as its own device on the bus.

So: is this a reasonable solution to the problem, or an unacceptable
hack? Comments welcome :-)

The patchset includes a patch from Juha which implements resizing
and unmapping of sysbus MMIOs; this is sort of related but useful
on its own anyway [ie you're likely to see it again even if you
don't like patches 2 and 3 :-)]


Here's an example device init function that uses this:


static int omap3_hsusb_host_init(SysBusDevice *dev)
{
    OMAP3HSUSBHostState *s = FROM_SYSBUS(OMAP3HSUSBHostState, dev);
    SysBusDevice *ohci_busdev;

    /* Create the OHCI device which is our subcomponent */
    s->ohci_usb = qdev_create(dev->qdev.parent_bus, "sysbus-ohci");
    qdev_prop_set_uint32(s->ohci_usb, "num-ports", 3);
    qdev_prop_set_taddr(s->ohci_usb, "dma-offset", 0);
    qdev_init_nofail(s->ohci_usb);
    ohci_busdev = sysbus_from_qdev(s->ohci_usb);

    /* Our IRQ 0 is delegated to the OHCI; 1 and 2 we handle ourselves */
    sysbus_pass_one_irq(dev, ohci_busdev, 0);
    sysbus_init_irq(dev, &s->ehci_irq);
    sysbus_init_irq(dev, &s->tll_irq);
    /* MMIOs 0 and 1 created as usual and handled ourselves */
    sysbus_init_mmio(dev, 0x1000,
                     cpu_register_io_memory(omap3_hsusb_tll_readfn,
                                            omap3_hsusb_tll_writefn, s,
                                            DEVICE_NATIVE_ENDIAN));
    sysbus_init_mmio(dev, 0x400,
                     cpu_register_io_memory(omap3_hsusb_host_readfn,
                                            omap3_hsusb_host_writefn, s,
                                            DEVICE_NATIVE_ENDIAN));
    /* Resize the OHCI MMIO to fit our requirements, and expose it
     * as our MMIO 2
     */
    sysbus_mmio_resize(ohci_busdev, 0, 0x400);
    sysbus_pass_mmio(dev, ohci_busdev, 0);
    /* MMIO 3 is another normal case */
    sysbus_init_mmio(dev, 0x400,
                     cpu_register_io_memory(omap3_hsusb_ehci_readfn,
                                            omap3_hsusb_ehci_writefn, s,
                                            DEVICE_NATIVE_ENDIAN));
    vmstate_register(&dev->qdev, -1, &vmstate_omap3_hsusb_host, s);
    return 0;
}




Juha Riihimäki (1):
  sysbus: Add support for resizing and unmapping MMIOs

Peter Maydell (2):
  sysbus: Allow sysbus MMIO passthrough
  sysbus: Allow passthrough of single IRQ

 hw/sysbus.c |   72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/sysbus.h |    6 +++++
 2 files changed, 78 insertions(+), 0 deletions(-)

             reply	other threads:[~2011-06-08 11:56 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-08 11:33 Peter Maydell [this message]
2011-06-08 11:33 ` [Qemu-devel] [PATCH RFC 1/3] sysbus: Add support for resizing and unmapping MMIOs Peter Maydell
2011-06-08 11:33 ` [Qemu-devel] [PATCH RFC 2/3] sysbus: Allow sysbus MMIO passthrough Peter Maydell
2011-06-08 11:33 ` [Qemu-devel] [PATCH RFC 3/3] sysbus: Allow passthrough of single IRQ Peter Maydell
2011-06-08 12:29 ` [Qemu-devel] [PATCH RFC 0/3] basic support for composing sysbus devices Jan Kiszka
2011-06-09 16:40   ` Markus Armbruster
2011-06-09 17:03     ` Jan Kiszka
2011-06-10  8:13       ` Markus Armbruster
2011-06-10 12:51         ` Anthony Liguori
2011-06-10 13:10           ` Peter Maydell
2011-06-10 13:43             ` Jan Kiszka
2011-06-10 13:50               ` Peter Maydell
2011-06-10 14:22                 ` Markus Armbruster
2011-06-10 14:45                   ` Anthony Liguori
2011-06-10 14:34                 ` Anthony Liguori
2011-06-10 14:12               ` Anthony Liguori
2011-06-10 14:18                 ` Jan Kiszka
2011-06-10 14:31                   ` Anthony Liguori
2011-06-10 14:07             ` Anthony Liguori
2011-06-10 14:59           ` Markus Armbruster
2011-06-10 15:43             ` Anthony Liguori
2011-06-12 17:12               ` Avi Kivity
2011-06-12 19:21                 ` Anthony Liguori
2011-06-13  8:05                   ` Avi Kivity
2011-06-13 17:53                     ` Anthony Liguori
2011-06-13 20:59                   ` Blue Swirl
2011-06-14 13:21                     ` Anthony Liguori
2011-06-15 18:56                       ` Blue Swirl
2011-06-15 20:00                         ` Anthony Liguori
2011-06-15 20:20                           ` Blue Swirl
2011-06-20 15:23                             ` Paul Brook
2011-06-20 21:32                               ` Blue Swirl
2011-06-21  8:16                                 ` Avi Kivity
2011-06-27  2:26                                 ` Paul Brook
2011-06-13  9:57             ` Gleb Natapov
2011-06-10 16:28           ` Andreas Färber

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=1307532813-27175-1-git-send-email-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=aliguori@us.ibm.com \
    --cc=armbru@redhat.com \
    --cc=juha.riihimaki@nokia.com \
    --cc=patches@linaro.org \
    --cc=paul@codesourcery.com \
    --cc=qemu-devel@nongnu.org \
    /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;
as well as URLs for NNTP newsgroup(s).