From: Peter Maydell <peter.maydell@linaro.org>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: Laurent Vivier <lvivier@redhat.com>,
Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
QEMU Trivial <qemu-trivial@nongnu.org>,
QEMU Developers <qemu-devel@nongnu.org>,
Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>,
qemu-arm <qemu-arm@nongnu.org>, Thomas Huth <thuth@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Aurelien Jarno <aurelien@aurel32.net>
Subject: Re: [PATCH 3/4] hw/pci-host/versatile: Add WINDOW_COUNT definition to replace magic '3'
Date: Sun, 11 Oct 2020 21:46:01 +0100 [thread overview]
Message-ID: <CAFEAcA8hbkrTo0VpLtjFDtXc5CL7zK+X8ppX==P9_+q_V8-pAw@mail.gmail.com> (raw)
In-Reply-To: <20201011194918.3219195-4-f4bug@amsat.org>
On Sun, 11 Oct 2020 at 20:49, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> Use self-explicit WINDOW_COUNT definition instead of a magic value.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> hw/pci-host/versatile.c | 28 ++++++++++++++--------------
> 1 file changed, 14 insertions(+), 14 deletions(-)
>
> diff --git a/hw/pci-host/versatile.c b/hw/pci-host/versatile.c
> index b4951023f4e..4d9565de4b1 100644
> --- a/hw/pci-host/versatile.c
> +++ b/hw/pci-host/versatile.c
> @@ -72,6 +72,8 @@ enum {
> PCI_VPB_IRQMAP_FORCE_OK,
> };
>
> +#define WINDOW_COUNT 3
> +
> struct PCIVPBState {
> PCIHostState parent_obj;
>
> @@ -86,18 +88,18 @@ struct PCIVPBState {
> * The offsets into pci_mem_space are controlled by the imap registers.
> */
> MemoryRegion pci_io_window;
> - MemoryRegion pci_mem_window[3];
> + MemoryRegion pci_mem_window[WINDOW_COUNT];
> PCIBus pci_bus;
> PCIDevice pci_dev;
>
> /* Constant for life of device: */
> int realview;
> - uint32_t mem_win_size[3];
> + uint32_t mem_win_size[WINDOW_COUNT];
> uint8_t irq_mapping_prop;
>
> /* Variable state: */
> - uint32_t imap[3];
> - uint32_t smap[3];
> + uint32_t imap[WINDOW_COUNT];
> + uint32_t smap[WINDOW_COUNT];
Strictly speaking, this is conflating two separate
things which both happen to be equal to three.
The versatile/realview PCI controller has:
* three memory windows in the system address space
- those are represented by the pci_mem_window[] array
- mem_win_size[] holds the size of each window
(which is fixed but varies between the different
implementations of this controller on different boards)
- the device IMAPn registers allow the guest to
configure the mapping from "a CPU access to an
address in window n" to "a PCI address on the PCI bus,
and our imap[] array holds those register values
* three PCI BARs which represent memory windows on the
PCI bus which bus-master PCI devices can use to
write back into the system address space
- the device SMAPn registers allow the guest to configure
the mapping from "a bus-master access to an address
on the PCI bus wherever the guest mapped BAR n"
to "a system address", and the smap[] array holds
those register values
There's no inherent reason why the number of PCI BARs
needs to be the same as the number of system address
space memory windows, so they shouldn't really share
the same constant.
(We don't actually implement the behaviour of the SMAP
registers and the BARs, because Linux always configures
the PCI controller to a 1:1 mapping of PCI space to
system address space. So we get away with just having
our implementation be "always do direct accesses".)
thanks
-- PMM
next prev parent reply other threads:[~2020-10-11 20:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-11 19:49 [PATCH 0/4] hw: Replace some magic by definitions Philippe Mathieu-Daudé
2020-10-11 19:49 ` [PATCH 1/4] hw: Replace magic value by PCI_NUM_PINS definition Philippe Mathieu-Daudé
2020-10-11 19:49 ` [PATCH 2/4] hw/pci-host/pam: Use ARRAY_SIZE() instead of magic value Philippe Mathieu-Daudé
2020-10-11 19:49 ` [PATCH 3/4] hw/pci-host/versatile: Add WINDOW_COUNT definition to replace magic '3' Philippe Mathieu-Daudé
2020-10-11 20:46 ` Peter Maydell [this message]
2020-10-12 13:01 ` Philippe Mathieu-Daudé
2020-10-11 19:49 ` [PATCH 4/4] tests/qtest: Replace magic value by NANOSECONDS_PER_SECOND definition Philippe Mathieu-Daudé
2020-10-12 6:58 ` Thomas Huth
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='CAFEAcA8hbkrTo0VpLtjFDtXc5CL7zK+X8ppX==P9_+q_V8-pAw@mail.gmail.com' \
--to=peter.maydell@linaro.org \
--cc=aleksandar.qemu.devel@gmail.com \
--cc=aleksandar.rikalo@syrmia.com \
--cc=aurelien@aurel32.net \
--cc=f4bug@amsat.org \
--cc=lvivier@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=thuth@redhat.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 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).