From: Peter Maydell <peter.maydell@linaro.org>
To: Andrew Baumann <Andrew.Baumann@microsoft.com>
Cc: "Rob Herring" <robh@kernel.org>,
"Grégory ESTRADE" <gregory.estrade@gmail.com>,
"Stefan Weil" <sw@weilnetz.de>,
"Peter Crosthwaite" <crosthwaite.peter@gmail.com>,
"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
"Peter Crosthwaite" <crosthwaitepeter@gmail.com>,
qemu-arm <qemu-arm@nongnu.org>,
"Paolo Bonzini" <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v4 4/8] bcm2835_peripherals: add rollup device for bcm2835 peripherals
Date: Tue, 26 Jan 2016 19:40:53 +0000 [thread overview]
Message-ID: <CAFEAcA9WBwOVLmU9FYsuBGXqLdty3MAjnCcpwr96-2XSiWiptQ@mail.gmail.com> (raw)
In-Reply-To: <BLUPR0301MB20347E506B5172A98D5377229ED80@BLUPR0301MB2034.namprd03.prod.outlook.com>
On 26 January 2016 at 19:12, Andrew Baumann
<Andrew.Baumann@microsoft.com> wrote:
>> From: Peter Crosthwaite [mailto:crosthwaitepeter@gmail.com]
>> Sent: Tuesday, 26 January 2016 00:03
>> On Mon, Jan 25, 2016 at 10:23 PM, Andrew Baumann
>> <Andrew.Baumann@microsoft.com> wrote:
>> >> > + /* Memory region for peripheral devices, which we export to our
>> >> parent */
>> >> > + memory_region_init_io(&s->peri_mr, obj, NULL, s, "bcm2835-
>> >> peripherals",
>> >> > + 0x1000000);
>> >>
>> >> Should this just be normal memory_region_init?
>> >
>> > I think so -- it's just a container region, and I probably copy and pasted the
>> API here. The two MR init APIs seem almost but not-quite identical when
>> NULL callbacks are used. Can you briefly explain the difference?
NULL callbacks are the same thing as memory_region_init_reservation(),
which is for defining a "you can't get here" part of the address space.
This is used only when KVM is enabled, by devices whose real implementation
of a bit of memory mapped IO is in the host kernel. The host kernel will
intercept accesses to that region and QEMU never sees accesses to them
(exception: emulated DMA, which is the only reason there's a behaviour
at all rather than an assertion). This is why such regions get marked as
mr->terminates: they really do have no "holes" in them.
So the general rules are:
* use a plain container (created via memory_region_init())
for almost any situation where you're creating something whose
behaviour is built up by adding together subregions
* use memory_region_init_io() with non-NULL ops for creating straightforward
"leaf" regions which have defined device behaviour
* similarly, memory_region_init_ram() for ram, etc
* use memory_region_init_reservation() or memory_region_init_io() with a
NULL ops pointer if you're the QEMU part of a KVM in-kernel
irqchip/etc.
* If you have a container memory region, but you need a "behaviour for
the bits that aren't covered by specific subregions" that's specific to
this device, then you have two choices:
(a) use a "background" subregion that covers the whole space and
has a lower priority than any of the other subregions
(b) create your container with one of the other memory_region_init
functions and use the IO callbacks/ram/etc to define the background
behaviour. Such an object will still support subregions being added.
I think (a) is generally cleaner, but the API permits adding
subregions to MRs other than pure containers for the benefit of
the odd few cases where (b) is done.
docs/memory.txt could probably use an update to:
(a) specifically mention the functions to use to create the various
regions listed in the 'Types of regions' section
(b) describe the 'reservation' kind of memory region
thanks
-- PMM
next prev parent reply other threads:[~2016-01-26 19:41 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-15 23:58 [Qemu-devel] [PATCH v4 0/8] Raspberry Pi 2 support Andrew Baumann
2016-01-15 23:58 ` [Qemu-devel] [PATCH v4 1/8] bcm2835_mbox: add BCM2835 mailboxes Andrew Baumann
2016-01-26 5:54 ` Peter Crosthwaite
2016-01-15 23:58 ` [Qemu-devel] [PATCH v4 2/8] bcm2835_property: add bcm2835 property channel Andrew Baumann
2016-01-26 6:03 ` Peter Crosthwaite
2016-01-15 23:58 ` [Qemu-devel] [PATCH v4 3/8] bcm2835_ic: add bcm2835 interrupt controller Andrew Baumann
2016-01-15 23:58 ` [Qemu-devel] [PATCH v4 4/8] bcm2835_peripherals: add rollup device for bcm2835 peripherals Andrew Baumann
2016-01-26 6:14 ` Peter Crosthwaite
2016-01-26 6:23 ` Andrew Baumann
2016-01-26 8:03 ` Peter Crosthwaite
2016-01-26 19:12 ` Andrew Baumann
2016-01-26 19:40 ` Peter Maydell [this message]
2016-01-15 23:58 ` [Qemu-devel] [PATCH v4 5/8] bcm2836_control: add bcm2836 ARM control logic Andrew Baumann
2016-01-29 4:37 ` Peter Crosthwaite
2016-01-29 4:42 ` Andrew Baumann
2016-01-15 23:58 ` [Qemu-devel] [PATCH v4 6/8] bcm2836: add bcm2836 soc device Andrew Baumann
2016-01-29 4:50 ` Peter Crosthwaite
2016-01-15 23:58 ` [Qemu-devel] [PATCH v4 7/8] arm/boot: move highbank secure board setup code to common routine Andrew Baumann
2016-01-29 7:11 ` Peter Crosthwaite
[not found] ` <1452902337-13844-9-git-send-email-Andrew.Baumann@microsoft.com>
2016-01-29 7:31 ` [Qemu-devel] [PATCH v4 8/8] raspi: add raspberry pi 2 machine Peter Crosthwaite
2016-01-29 21:50 ` Andrew Baumann
2016-01-29 22:22 ` Peter Crosthwaite
2016-01-29 22:28 ` Andrew Baumann
2016-01-29 22:40 ` Peter Crosthwaite
2016-01-29 22:43 ` Andrew Baumann
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=CAFEAcA9WBwOVLmU9FYsuBGXqLdty3MAjnCcpwr96-2XSiWiptQ@mail.gmail.com \
--to=peter.maydell@linaro.org \
--cc=Andrew.Baumann@microsoft.com \
--cc=crosthwaite.peter@gmail.com \
--cc=crosthwaitepeter@gmail.com \
--cc=gregory.estrade@gmail.com \
--cc=pbonzini@redhat.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=robh@kernel.org \
--cc=sw@weilnetz.de \
/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).