From: Bernhard Beschow <shentey@gmail.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Andrey Smirnov <andrew.smirnov@gmail.com>,
qemu-arm@nongnu.org, Bernhard Beschow <shentey@gmail.com>,
Guenter Roeck <linux@roeck-us.net>
Subject: [PATCH 04/10] hw/pci-host/designware: Distinguish stronger between viewport memory types
Date: Wed, 20 Aug 2025 23:19:26 +0200 [thread overview]
Message-ID: <20250820211932.27302-5-shentey@gmail.com> (raw)
In-Reply-To: <20250820211932.27302-1-shentey@gmail.com>
This is a preparation for implementing I/O space support. At the same
time, unimplemented memory types and guest errors are logged.
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
---
hw/pci-host/designware.c | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c
index 2a676c65a2..5ad7574924 100644
--- a/hw/pci-host/designware.c
+++ b/hw/pci-host/designware.c
@@ -44,7 +44,11 @@
#define DESIGNWARE_PCIE_ATU_VIEWPORT 0x900
#define DESIGNWARE_PCIE_ATU_REGION_INBOUND BIT(31)
#define DESIGNWARE_PCIE_ATU_CR1 0x904
-#define DESIGNWARE_PCIE_ATU_TYPE_MEM (0x0 << 0)
+#define DESIGNWARE_PCIE_ATU_TYPE_MEM 0x0
+#define DESIGNWARE_PCIE_ATU_TYPE_IO 0x2
+#define DESIGNWARE_PCIE_ATU_TYPE_CFG0 0x4
+#define DESIGNWARE_PCIE_ATU_TYPE_CFG1 0x5
+#define DESIGNWARE_PCIE_ATU_TYPE_MSG 0x10
#define DESIGNWARE_PCIE_ATU_CR2 0x908
#define DESIGNWARE_PCIE_ATU_ENABLE BIT(31)
#define DESIGNWARE_PCIE_ATU_LOWER_BASE 0x90C
@@ -268,6 +272,7 @@ static void designware_pcie_update_viewport(DesignwarePCIERoot *root,
const uint64_t target = viewport->target;
const uint64_t base = viewport->base;
const uint64_t size = (uint64_t)viewport->limit - base + 1;
+ const int iatu_type = viewport->cr[0];
const bool enabled = viewport->cr[1] & DESIGNWARE_PCIE_ATU_ENABLE;
if (memory_region_is_mapped(&viewport->mem)) {
@@ -276,7 +281,8 @@ static void designware_pcie_update_viewport(DesignwarePCIERoot *root,
object_unparent(OBJECT(&viewport->mem));
if (enabled) {
- if (viewport->cr[0] == DESIGNWARE_PCIE_ATU_TYPE_MEM) {
+ switch (iatu_type) {
+ case DESIGNWARE_PCIE_ATU_TYPE_MEM:
if (viewport->inbound) {
/*
* Configure MemoryRegion implementing PCI -> CPU memory
@@ -298,7 +304,10 @@ static void designware_pcie_update_viewport(DesignwarePCIERoot *root,
memory_region_add_subregion(get_system_memory(), base,
&viewport->mem);
}
- } else {
+ break;
+
+ case DESIGNWARE_PCIE_ATU_TYPE_CFG0:
+ case DESIGNWARE_PCIE_ATU_TYPE_CFG1:
if (!viewport->inbound) {
/*
* Configure MemoryRegion implementing access to configuration
@@ -321,6 +330,18 @@ static void designware_pcie_update_viewport(DesignwarePCIERoot *root,
(int)busnum, (int)devfn);
}
}
+ break;
+
+ case DESIGNWARE_PCIE_ATU_TYPE_IO:
+ case DESIGNWARE_PCIE_ATU_TYPE_MSG:
+ qemu_log_mask(LOG_UNIMP, "%s: Unimplemented iATU type %d", __func__,
+ iatu_type);
+ break;
+
+ default:
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: Illegal iATU type %d", __func__,
+ iatu_type);
+ break;
}
}
}
--
2.50.1
next prev parent reply other threads:[~2025-08-20 21:21 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-20 21:19 [PATCH 00/10] Designware PCIe host fixes Bernhard Beschow
2025-08-20 21:19 ` [PATCH 01/10] hw/pci-host/designware: Eliminate some helper variables Bernhard Beschow
2025-08-20 21:19 ` [PATCH 02/10] hw/pci-host/designware: Create viewport memory regions on demand Bernhard Beschow
2025-09-02 9:46 ` Peter Maydell
2025-08-20 21:19 ` [PATCH 03/10] hw/pci-host/designware: Determine PCIDevice of configuration region once Bernhard Beschow
2025-08-20 21:19 ` Bernhard Beschow [this message]
2025-08-20 21:19 ` [PATCH 05/10] hw/pci-host/designware: Implement I/O space Bernhard Beschow
2025-08-20 21:19 ` [PATCH 06/10] hw/pci-host/designware: Fix I/O range Bernhard Beschow
2025-09-02 9:53 ` Peter Maydell
2025-08-20 21:19 ` [PATCH 07/10] hw/pci-host/designware: Don't map PCI memory space into PCI inbound window Bernhard Beschow
2025-08-20 21:19 ` [PATCH 08/10] hw/pci-host/designware: Fix default inbound viewport mapping Bernhard Beschow
2025-08-20 21:19 ` [PATCH 09/10] hw/pci-host/designware: Implement device reset Bernhard Beschow
2025-08-20 21:19 ` [PATCH 10/10] hw/arm/fsl-imx8mp: Do not map PCI window as unimplemented Bernhard Beschow
2025-08-21 3:36 ` [PATCH 00/10] Designware PCIe host fixes Guenter Roeck
2025-08-21 10:24 ` Bernhard Beschow
2025-08-21 15:38 ` Guenter Roeck
2025-08-22 23:09 ` Guenter Roeck
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=20250820211932.27302-5-shentey@gmail.com \
--to=shentey@gmail.com \
--cc=andrew.smirnov@gmail.com \
--cc=linux@roeck-us.net \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.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).