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 09/10] hw/pci-host/designware: Implement device reset
Date: Wed, 20 Aug 2025 23:19:31 +0200 [thread overview]
Message-ID: <20250820211932.27302-10-shentey@gmail.com> (raw)
In-Reply-To: <20250820211932.27302-1-shentey@gmail.com>
Fixes the memory mapping to be cleared during reset, like real hardware would
do.
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
---
hw/pci-host/designware.c | 33 ++++++++++++++++++++++-----------
1 file changed, 22 insertions(+), 11 deletions(-)
diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c
index d71133a456..2dd4937e52 100644
--- a/hw/pci-host/designware.c
+++ b/hw/pci-host/designware.c
@@ -442,11 +442,6 @@ static void designware_pcie_root_realize(PCIDevice *dev, Error **errp)
DesignwarePCIERoot *root = DESIGNWARE_PCIE_ROOT(dev);
DesignwarePCIEHost *host = designware_pcie_root_to_host(root);
PCIBridge *br = PCI_BRIDGE(dev);
- /*
- * Dummy values used for initial configuration of MemoryRegions
- * that belong to a given viewport
- */
- const hwaddr dummy_offset = 0;
br->bus_name = "dw-pcie";
@@ -484,6 +479,26 @@ static void designware_pcie_root_realize(PCIDevice *dev, Error **errp)
DesignwarePCIEViewport *viewport = &root->viewports[i][j];
viewport->name = names[i][j];
viewport->inbound = i == DESIGNWARE_PCIE_VIEWPORT_INBOUND;
+ }
+ }
+
+ memory_region_init_io(&root->msi.iomem, OBJECT(root),
+ &designware_pci_host_msi_ops,
+ root, "pcie-msi", 0x4);
+ memory_region_add_subregion(&host->pci.memory, 0, &root->msi.iomem);
+}
+
+static void designware_pcie_root_reset(DeviceState *dev)
+{
+ DesignwarePCIERoot *root = DESIGNWARE_PCIE_ROOT(dev);
+ DesignwarePCIEViewport *viewport;
+
+ pci_bridge_reset(dev);
+
+ for (int i = 0; i < ARRAY_SIZE(root->viewports); i++) {
+ for (int j = 0; j < DESIGNWARE_PCIE_NUM_VIEWPORTS; j++) {
+ viewport = &root->viewports[i][j];
+
viewport->base = 0x0000000000000000ULL;
viewport->target = 0x0000000000000000ULL;
viewport->limit = UINT32_MAX;
@@ -494,17 +509,13 @@ static void designware_pcie_root_realize(PCIDevice *dev, Error **errp)
}
}
- memory_region_init_io(&root->msi.iomem, OBJECT(root),
- &designware_pci_host_msi_ops,
- root, "pcie-msi", 0x4);
/*
* We initially place MSI interrupt I/O region at address 0 and
* disable it. It'll be later moved to correct offset and enabled
* in designware_pcie_root_update_msi_mapping() as a part of
* initialization done by guest OS
*/
- memory_region_add_subregion(&host->pci.memory, dummy_offset,
- &root->msi.iomem);
+ memory_region_set_address(&root->msi.iomem, 0);
memory_region_set_enabled(&root->msi.iomem, false);
}
@@ -602,7 +613,7 @@ static void designware_pcie_root_class_init(ObjectClass *klass,
k->config_read = designware_pcie_root_config_read;
k->config_write = designware_pcie_root_config_write;
- device_class_set_legacy_reset(dc, pci_bridge_reset);
+ device_class_set_legacy_reset(dc, designware_pcie_root_reset);
/*
* PCI-facing part of the host bridge, not usable without the
* host-facing part, which can't be device_add'ed, yet.
--
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 ` [PATCH 04/10] hw/pci-host/designware: Distinguish stronger between viewport memory types Bernhard Beschow
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 ` Bernhard Beschow [this message]
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-10-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).