qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori@us.ibm.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Juha Riihimäki" <juha.riihimaki@nokia.com>,
	"patches@linaro.org" <patches@linaro.org>,
	"Jan Kiszka" <jan.kiszka@siemens.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"Paul Brook" <paul@codesourcery.com>
Subject: Re: [Qemu-devel] [PATCH RFC 0/3] basic support for composing sysbus devices
Date: Fri, 10 Jun 2011 10:43:51 -0500	[thread overview]
Message-ID: <4DF23BB7.9050606@us.ibm.com> (raw)
In-Reply-To: <m3hb7xwx4z.fsf@blackfin.pond.sub.org>

On 06/10/2011 09:59 AM, Markus Armbruster wrote:
> Anthony Liguori<aliguori@us.ibm.com>  writes:
>
>> On 06/10/2011 03:13 AM, Markus Armbruster wrote:
>>> Jan Kiszka<jan.kiszka@siemens.com>   writes:
>>>> Resource management, e.g. IRQs. That will be useful for other types of
>>>> buses as well.
>>>
>>> A device should be able to say "I need to be connected to an IRQ line".
>>> Feels generic to me.
>>
>> More specifically, a device has input IRQs.  A device has no idea what
>> number the IRQ is tied to.
>>
>> Devices may also have output IRQs.  At the qdev layer, we should be
>> able to connect an arbitrary output IRQ to an arbitrary input IRQ.
>>
>> So the crux of the problem is that:
>>
>>   -device isa-serial,id=serial,irq=3
>>
>> Is very wrong.  It ought to look something more like
>>
>>   -device piix3,id=piix3 -device isa-serial,id=serial,irq=piix3.irq[3]
>
> As Jan pointed out, ISA is a counter-example: your "very wrong" claim is
> actually wrong there :)

The wrongness comes from the fact that "irq=3" assumes that somehow the 
ISA device can get an IRQ from an index.

If instead the example was:

  -device piix3,id=isa0
  -device isa-serial,id=serial,irq=3,bus=isa0

With the implication isa-serial could use the "3" index to get an IRQ 
from it's bus at realize, like:

void isa_serial_initfn()
{
     ISAController *bus = qdev_get_isa_controller(dev, "bus");
     connect_irq(dev->irq, bus->irq[qdev_get_int(dev, "irq")]);
}

That is at least conceptually okay but I don't think it's best.  If you 
want to go this route, I'd actually model DIP switches or ISA plug and 
play.  Usually devices would only allow you to choose between two of the 
5 IRQs available.

But personally, the modelling I mentioned in another part of the thread 
where you connect the IRQs directly to the device seems like a better 
compromise to me.

> An ISA device is always connected to all the ISA bus's interrupt lines.
> Device configuration determines how the device uses these lines.

That's 100% correct.  But the "ISA bus" is just a grouping of interfaces 
to another device.  We shouldn't treat that as any more special than any 
other type of connection between devices.

> The old (non-MSI) PCI interrupts are similar, I think.
>
> Of course, "ISA IRQ 4" can be anything, depending on how the device
> providing the ISA bus is wired up.
>
>> IRQ forwarding becomes very easy in this model because your composite
>> qdev device has a set of input IRQs and then routes the input IRQs to
>> the appropriate input IRQs of the sub devices.
>>
>> The trouble is that I don't think we have a reasonable way to refer to
>> properties of other devices and we don't have names for all devices.
>> I think if we fix the later problem, the former problem becomes
>> easier.
>
> We already connect devices to other resources, such as block, char and
> network host parts.  The way we do it may not be "pure", but it works:
> we define the plug as property, and connect it to its socket by saying
> PROP-NAME=SOCK-NAME.  Note that the connection is made by core qdev;
> device model code is oblivious of it.  It just uses it.

Yes.  The problem with this is namespaces.  What you are referring to as 
"SOCK-NAME" is interpreted based on the property type.  Ideally, we'd 
have a single namespace for everything.

>>                       They can be replaced by having fixed "slots".
>> For instance, if you had a way of having a PCIDevice * property, the
>> I440FX could have 32 PCIDevice * properties.  That's how you would add
>> to a bus (and notice that it conveniently solves bus addressing in a
>> robust fashion).
>
> Assumes that bus addresses are isomorphic to [0..N], doesn't it?
>
> Not really the case for USB: we use a string of the form %d(.%d)* there.

Couple points there.

1) I didn't mean to suggest that the name "irq[3]" implies anything.  I 
sort of thing it should be just treated as a string.  It could as well 
be "irq[foo]".  I'm not 100% here though.

2) USB addressing is expressing an implicit topology of HUBs.  I think 
it's better to model those HUBs explicitly and leave convenience to 
syntactic sugar.  For instance:

  -device usb-uhci,id=uhci0,ports=4,port0=hub0
  -device usb-hub,id=hub0,ports=4,port1=tablet0
  -device usb-tablet,id=tablet0

Which is the expansion of:

  -tablet address=0.1

> Not my idea.
>
> A bus is just a standardized container for slots.  A single device can
> provide multiple buses.  Killing buses just unwraps the slots.  You lose
> the grouping.

The grouping is still there by virtue of the fact that the slots are all 
part of the same device.

> What exactly is so very wrong about buses that they need to die?

They force a device tree.  The device model shouldn't be a tree, but a 
directed graph.  It's perfectly fine to have a type called PCIBus that 
I440FX extends, but qdev shouldn't have explicit knowledge of something 
called a "bus" IMHO.  Doing this forces a limited mechanism of 
connecting devices because it creates an artificial tree (by implying a 
parent/child relationship).  It makes composition difficult if not 
impossible.

Regards,

Anthony Liguori

> Honest, non-rhetorical question.

  reply	other threads:[~2011-06-10 15:44 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-08 11:33 [Qemu-devel] [PATCH RFC 0/3] basic support for composing sysbus devices Peter Maydell
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 [this message]
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=4DF23BB7.9050606@us.ibm.com \
    --to=aliguori@us.ibm.com \
    --cc=armbru@redhat.com \
    --cc=jan.kiszka@siemens.com \
    --cc=juha.riihimaki@nokia.com \
    --cc=patches@linaro.org \
    --cc=paul@codesourcery.com \
    --cc=peter.maydell@linaro.org \
    --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).