All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] qdev for programmers writeup
Date: Mon, 11 Jul 2011 17:29:27 +0200	[thread overview]
Message-ID: <4E1B16D7.9020802@redhat.com> (raw)
In-Reply-To: <CAFEAcA98Dk4VfqGc202OPZs9Jk94UhoXu6CrcCTvB2PTMqEbJQ@mail.gmail.com>

On 07/11/2011 04:44 PM, Peter Maydell wrote:
>> That's true, but the only way to plug in those device models would be with C
>> code.  You cannot just play with -device to reconfigure them.
>
> I think the C source level reuse is more important and more useful
> than plugging stuff around with -device, because in practice messing
> about with the memory map of an embedded board isn't something people
> typically want to do, because the kernel will have more-or-less
> hardcoded where the devices are anyhow.

That's just because ARM doesn't (yet?) do device trees... :)

> (Also if you have one bus type
> per board then you're still very limited in what you can do with -device
> because you can't plug in some random other sysbus device anyway.)

I'm not talking about one bus type per board!  I'm talking about as few 
as possible board-specific root devices, and sharing buses between 
boards as much as possible.

> So if
> we want to allow runtime configurability of boards like that we need
> to do it by providing runtime configurability of sysbus devices.

But we already have properties as a runtime configurability mechanism, 
and the additional functionality provided by SysBus is exactly to bypass 
it.  In that sense SysBus is bad (if used widely as it is now).

It is also bad because SysBus takes device metainformation (number of 
IRQ lines, size of MMIO and PIO areas) and puts it into per-device 
structure.

> I think it would be better to think of GPIO as a special (simple)
> case of a generic desire to plug devices into each other (this is what
> SystemC calls a "port": basically an interface (API) defined so that
> two things can make calls to arbitrary callback functions on the other
> end of a connection). How ports are wired up is a property of the
> machine model, not a property of the device at either end

But in practice you tend to have tree-like relationships.  Even if it is 
just a two-level tree with a GPIO chip or interrupt controller at one 
end, and everything else at the other.

> Also, you want to be able to actually name your output pins, so
> at a board level you can talk about wiring up sd_controller.wprot,
> not sd_controller.gpio[3]... (Yes, this is to some extent "just syntax"
> but I really don't want to end up with machine level modelling looking
> like:

It _is_ really just syntax.  In my examples I used the raw values for 
GPIO pin numbers because that's what we have.  So, right now there is no 
way to use symbolic values, but nothing forbids adding one.  Or even 
automatically generating the QEMU .conf from something else.

If you are using C code, of course you have #defines/enums.

>> Well, it is clear that buses should be modelled after the way data flows.
>> But what is data?  If data is "what is being written", buses should be
>> modelled after the way memory transactions flow.  If data is "what is being
>> made available", buses are modelled more "after the way interrupts flow.
>> GPIO is a strange thing in the middle. :)
>
> Actually I think we should really be modelling buses only where the
> hardware actually has a bus, ie a coherent collection of signals
> between multiple devices such that you could in theory plug in
> different devices in different slots. The memory transaction
> related connections are much more buslike than interrupt wiring.

I'm not sure, perhaps the naming is bad.  Abstracting from the name for 
a moment, unifying interrupts/GPIO with the qbus concept seemed natural 
to me in most of the cases I looked at.  And it makes the handling of 
GPIO in qdev less schizophrenic; qdev seems to treat the qbus (whatever 
it is) as the One True Mechanism to join devices, and then adds GPIO on 
the side while providing no way to configure it.  If you try to match 
the qdev tree with the tree of qemu_irq, the design becomes a lot more 
coherent.

Paolo

  reply	other threads:[~2011-07-11 15:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-11 10:20 [Qemu-devel] qdev for programmers writeup Paolo Bonzini
2011-07-11 10:46 ` Peter Maydell
2011-07-11 12:48   ` Paolo Bonzini
2011-07-11 14:44     ` Peter Maydell
2011-07-11 15:29       ` Paolo Bonzini [this message]
2011-07-11 16:47         ` Peter Maydell
2011-07-12 15:22           ` Paolo Bonzini

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=4E1B16D7.9020802@redhat.com \
    --to=pbonzini@redhat.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 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.