Support PCIe RC to AST2600 and AST2700
Subsystems (2)
v3 cover Support PCIe RC to AST2600 and AST2700
v1:
1. Add PCIe PHY, CFG, and MMIO window support for AST2600.
Note: Only supports RC_H.
2. Add PCIe PHY, CFG, and MMIO window support for AST2700.
Note: Supports 3 RCs.
v2:
1. Introduce a new root port device.
2. For AST2600 RC_H, add the root device at 80:00.0 and a root port at 80.08.0 to match the real hardware topology, allowing users to attach PCIe devices at the root port.
3. For AST2700, add a root port at 00.00.0 for each PCIe root complex to match the real hardware topology, allowing users to attach PCIe devices at the root port.
v3:
1. Fix review issues.
2. update functional test for the e1000e network card.
3. update license header
4. Adding "Based on previous work from Cedric Le Goater, with Jamin's summary implementation.
Dependencies
QEMU version:
https://github.com/qemu/qemu/commit/f0007b7f03e2d7fc33e71c3a582f2364c51a226b
This patch series depends on the following patch series:
1. hw/arm/aspeed Move ast2700-evb alias to ast2700a1-evb
https://patchwork.kernel.org/project/qemu-devel/patch/[email protected]/
2. tests/functional/arm: Update test images for ASPEED chips
https://patchwork.kernel.org/project/qemu-devel/cover/[email protected]/
3. tests/functional/arm: Add OTP functional test
https://patchwork.kernel.org/project/qemu-devel/cover/[email protected]/
Testing the PCIe Root Complex model with the e1000e PCIe device
AST2600 test environment
Test image: ASPEED SDK v09.07
Download
https://github.com/AspeedTech-BMC/openbmc/releases/download/v09.07/ast2600-default-obmc.tar.gz
When booted, lspci should show one root device at 80:00.0 and a root port at 80:08.0, matching the expected hardware topology:
``` root@ast2600-default:~# lspci 80:00.0 Host bridge: ASPEED Technology, Inc. Device 2600 80:08.0 PCI bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge ```
The e1000e driver is included in this image. Attach the e1000e device on bus pcie.0 with the following command line:
``` -device e1000e,netdev=net0,bus=pcie.0 \ -netdev user,id=net0,hostfwd=:127.0.0.1:3222-:22,hostname=qemu0 \ ```
After boot, lspci should show the e1000e device enumerated at 81:00.0:
``` root@ast2600-default:~# lspci 80:00.0 Host bridge: ASPEED Technology, Inc. Device 2600 80:08.0 PCI bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge 81:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection ```
The e1000e driver should probe successfully, and a new Ethernet interface should appear:
```
root@ast2600-default:~# ifconfig
eth4 Link encap:Ethernet HWaddr 52:54:00:12:34:5A
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::5054:ff:fe12:345a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:25 errors:0 dropped:0 overruns:0 frame:0
TX packets:57 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:5524 (5.3 KiB) TX bytes:8488 (8.2 KiB)
Interrupt:81 Memory:70040000-70060000
```AST2700 test environment
Test image: ASPEED SDK v09.07
Download
https://github.com/AspeedTech-BMC/openbmc/releases/download/v09.07/ast2700-default-obmc.tar.gz
By default, the ASPEED SDK only enables PCIe root complex 2 (RC2). If you want to test all three PCIe root complexes, please use the customized image provided here:
https://github.com/jamin-aspeed/openbmc/releases/download/qemu-test-0907/ast2700-default-pcie-qemu.tar.xz
When booted, lspci should show one root port at 00:00.0 on the pcie.2 bus. The domain for PCIe RC2 is 0002, which matches the expected hardware topology:
``` root@ast2700-default:~# lspci 0002:00:00.0 PCI bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge ```
The e1000e driver is included in this image. Attach the e1000e device to bus pcie.2 using the following command line:
``` -device e1000e,netdev=net0,bus=pcie.2 \ -netdev user,id=net0,hostfwd=:127.0.0.1:3222-:22,hostname=qemu0 \ ```
After boot, lspci should show the e1000e device enumerated at 0002:01:00.0:
``` root@ast2700-default:~# lspci 0002:00:00.0 PCI bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge 0002:01:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection ```
The e1000e driver should probe successfully, and a new Ethernet interface should appear:
```
root@ast2700-default:~# ifconfig
eth2 Link encap:Ethernet HWaddr 52:54:00:12:34:56
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::5054:ff:fe12:3456/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:21 errors:0 dropped:0 overruns:0 frame:0
TX packets:48 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:5388 (5.2 KiB) TX bytes:8244 (8.0 KiB)
Interrupt:42 Memory:a0040000-a0060000
``` Jamin Lin (14):
hw/pci/pci_ids: Add PCI vendor ID for ASPEED hw/pci-host/aspeed: Add AST2600 PCIe PHY model hw/pci-host/aspeed: Add AST2600 PCIe config space and host bridge hw/pci-host/aspeed: Add AST2600 PCIe Root Device support hw/pci-host/aspeed: Add AST2600 PCIe Root Port and make address
configurable
hw/pci-host/aspeed: Add MSI support and per-RC IOMMU address space hw/arm/aspeed: Wire up PCIe devices in SoC model hw/arm/aspeed_ast2600: Add PCIe RC support (RC_H only) hw/pci-host/aspeed: Add AST2700 PCIe PHY hw/pci-host/aspeed: Add AST2700 PCIe config with dedicated H2X blocks hw/pci-host/aspeed: Disable Root Device and place Root Port at 00:00.0
to AST2700
hw/arm/aspeed_ast27x0: Introduce 3 PCIe RCs for AST2700 tests/functional/arm/test_aspeed_ast2600: Add PCIe and network test tests/functional/aarch64/aspeed_ast2700: Add PCIe and network tests
include/hw/arm/aspeed_soc.h | 14 + include/hw/pci-host/aspeed_pcie.h | 137 +++ include/hw/pci/pci_ids.h | 2 + hw/arm/aspeed_ast2600.c | 79 ++ hw/arm/aspeed_ast27x0.c | 76 ++ hw/pci-host/aspeed_pcie.c | 1009 +++++++++++++++++ hw/arm/Kconfig | 3 + hw/pci-host/Kconfig | 4 + hw/pci-host/meson.build | 1 + hw/pci-host/trace-events | 11 + .../functional/aarch64/test_aspeed_ast2700.py | 19 + .../aarch64/test_aspeed_ast2700fc.py | 13 + tests/functional/arm/test_aspeed_ast2600.py | 20 + 13 files changed, 1388 insertions(+) create mode 100644 include/hw/pci-host/aspeed_pcie.h create mode 100644 hw/pci-host/aspeed_pcie.c
Signature · 1 line
2.43.0
PATCH v3 1/14 hw/pci/pci_ids: Add PCI vendor ID for ASPEED
--- include/hw/pci/pci_ids.h | 2 ++ 1 file changed, 2 insertions(+)
include/hw/pci/pci_ids.h +2 -0
@@ -291,4 +291,6 @@#define PCI_VENDOR_ID_NVIDIA 0x10de +#define PCI_VENDOR_ID_ASPEED 0x1A03 +#endif
Signature · 1 line
2.43.0
PATCH v3 2/14 hw/pci-host/aspeed: Add AST2600 PCIe PHY model
In reply to Jamin Lin viaThis patch introduces an initial ASPEED PCIe PHY/host controller model to support the AST2600 SoC. It provides a simple register block with MMIO read/write callbacks, integration into the build system, and trace events for debugging.
Key changes:
1. PCIe PHY MMIO read/write callbacks
Implemented aspeed_pcie_phy_read() and aspeed_pcie_phy_write() to handle 32-bit register accesses.
2. Build system and Kconfig integration
Added CONFIG_PCI_EXPRESS_ASPEED in hw/pci-host/Kconfig and meson rules.
Updated ASPEED_SOC in hw/arm/Kconfig to imply PCI_DEVICES and select PCI_EXPRESS_ASPEED.
3. Trace events for debug
New tracepoints aspeed_pcie_phy_read and aspeed_pcie_phy_write allow monitoring MMIO accesses.
4. Register space and defaults (AST2600 reference)
Expose a 0x100 register space, as documented in the AST2600 datasheet. On reset, set default values:
PEHR_ID: Vendor ID = ASPEED, Device ID = 0x1150 PEHR_CLASS_CODE = 0x06040006
PEHR_DATALINK = 0xD7040022
PEHR_LINK: bit[5] set to 1 to indicate link up.
This provides a skeleton device for the AST2600 platform. It enables firmware to detect the PCIe link as up by default and allows future extension.
This commit is the starting point of the series to introduce ASPEED PCIe Root Complex (RC) support. Based on previous work from Cédric Le Goater, the following commits in this series extend and refine the implementation:
- Add a PCIe Root Port so that devices can be attached without requiring an extra bridge.
- Restrict the Root Port device instantiation to the AST2600 platform.
- Integrate aspeed_cfg_translate_write() to support both AST2600 and AST2700.
- Add MSI support and a preliminary RC IOMMU address space.
- Fix issues with MSI interrupt clearing.
- Extend support to the AST2700 SoC.
- Drop the AST2600 RC_L support.
- Introduce PCIe RC functional tests covering both AST2600 and AST2700.
--- include/hw/pci-host/aspeed_pcie.h | 42 ++++++++ hw/pci-host/aspeed_pcie.c | 157 ++++++++++++++++++++++++++++++ hw/arm/Kconfig | 3 + hw/pci-host/Kconfig | 4 + hw/pci-host/meson.build | 1 + hw/pci-host/trace-events | 4 + 6 files changed, 211 insertions(+) create mode 100644 include/hw/pci-host/aspeed_pcie.h create mode 100644 hw/pci-host/aspeed_pcie.c
include/hw/pci-host/aspeed_pcie.h new file +42 -0
@@ -0,0 +1,42 @@ +/* +* ASPEED PCIe Host Controller +* +* Copyright (C) 2025 ASPEED Technology Inc. +* Copyright (c) 2022 Cédric Le Goater <[email protected]> +* +* Authors: +* Cédric Le Goater <[email protected]> +* Jamin Lin <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* Based on previous work from Cédric Le Goater. +* Modifications extend support for the ASPEED AST2600 and AST2700 platforms. +*/ + +#ifndef ASPEED_PCIE_H +#define ASPEED_PCIE_H + +#include "hw/sysbus.h" +#include "hw/pci/pci_bridge.h" +#include "hw/pci/pcie_host.h" +#include "qom/object.h" + +#define TYPE_ASPEED_PCIE_PHY "aspeed.pcie-phy" +OBJECT_DECLARE_TYPE (AspeedPCIEPhyState, AspeedPCIEPhyClass,ASPEED_PCIE_PHY ); + +struct AspeedPCIEPhyState { +SysBusDevice parent_obj; + +MemoryRegion mmio; +uint32_t *regs; +uint32_t id; +}; + +struct AspeedPCIEPhyClass { +SysBusDeviceClass parent_class; + +uint64_t nr_regs; +}; + +#endif /* ASPEED_PCIE_H */
hw/pci-host/aspeed_pcie.c new file +157 -0
157 lines not on this page · raw message
hw/arm/Kconfig +3 -0
@@ -541,6 +541,7 @@ config ASPEED_SOC bool default y depends on TCG && ARM + imply PCI_DEVICES select DS1338 select FTGMAC100 select I2C
@@ -561,6 +562,8 @@ config ASPEED_SOC select MAX31785 select FSI_APB2OPB_ASPEED select AT24C + select PCI_EXPRESS + select PCI_EXPRESS_ASPEED config MPS2 bool
hw/pci-host/Kconfig +4 -0
@@ -46,6 +46,10 @@ config PCI_I440FX select PCI select PAM +config PCI_EXPRESS_ASPEED + bool + select PCI_EXPRESS + config PCI_EXPRESS_Q35 bool select PCI_EXPRESS
hw/pci-host/meson.build +1 -0
@@ -2,6 +2,7 @@ pci_ss = ss.source_set() pci_ss.add(when: 'CONFIG_PAM', if_true: files('pam.c')) pci_ss.add(when: 'CONFIG_PCI_BONITO', if_true: files('bonito.c')) pci_ss.add(when: 'CONFIG_GT64120', if_true: files('gt64120.c')) +pci_ss.add(when: 'CONFIG_PCI_EXPRESS_ASPEED', if_true: files('aspeed_pcie.c')) pci_ss.add(when: 'CONFIG_PCI_EXPRESS_DESIGNWARE', if_true: files('designware.c')) pci_ss.add(when: 'CONFIG_PCI_EXPRESS_GENERIC_BRIDGE', if_true: files('gpex.c')) pci_ss.add(when: ['CONFIG_PCI_EXPRESS_GENERIC_BRIDGE', 'CONFIG_ACPI'], if_true: files('gpex-acpi.c'))
hw/pci-host/trace-events +4 -0
@@ -1,5 +1,9 @@ # See docs/devel/tracing.rst for syntax documentation. +# aspeed_pcie.c +aspeed_pcie_phy_read(uint32_t id, uint64_t addr, uint32_t value) "%d: addr 0x%" PRIx64 " value 0x%" PRIx32 +aspeed_pcie_phy_write(uint32_t id, uint64_t addr, uint32_t value) "%d: addr 0x%" PRIx64 " value 0x%" PRIx32 + # bonito.c bonito_spciconf_small_access(uint64_t addr, unsigned size) "PCI config address is smaller then 32-bit, addr: 0x%"PRIx64", size: %u"
Signature · 1 line
2.43.0
Re: [SPAM] [PATCH v3 02/14] hw/pci-host/aspeed: Add AST2600 PCIe PHY model
Quoted 211 lines · Jamin Lin
This patch introduces an initial ASPEED PCIe PHY/host controller model to support the AST2600 SoC. It provides a simple register block with MMIO read/write callbacks, integration into the build system, and trace events for debugging.
Key changes:
1. PCIe PHY MMIO read/write callbacks
Implementedaspeed_pcie_phy_read()andaspeed_pcie_phy_write()to handle 32-bit register accesses.2. Build system and
Kconfigintegration
AddedCONFIG_PCI_EXPRESS_ASPEEDin hw/pci-host/Kconfig and meson rules.
UpdatedASPEED_SOCin hw/arm/Kconfig to implyPCI_DEVICESand selectPCI_EXPRESS_ASPEED.3. Trace events for debug
New tracepointsaspeed_pcie_phy_readandaspeed_pcie_phy_writeallow monitoring MMIO accesses.4. Register space and defaults (AST2600 reference)
Expose a 0x100 register space, as documented in the AST2600 datasheet. On reset, set default values: PEHR_ID: Vendor ID = ASPEED, Device ID = 0x1150 PEHR_CLASS_CODE = 0x06040006 PEHR_DATALINK = 0xD7040022 PEHR_LINK: bit[5] set to 1 to indicate link up.This provides a skeleton device for the AST2600 platform. It enables firmware to detect the PCIe link as up by default and allows future extension.
This commit is the starting point of the series to introduce ASPEED PCIe Root Complex (RC) support. Based on previous work from Cédric Le Goater, the following commits in this series extend and refine the implementation:
- Add a PCIe Root Port so that devices can be attached without requiring an extra bridge.
- Restrict the Root Port device instantiation to the AST2600 platform.
- Integrateaspeed_cfg_translate_write()to support both AST2600 and AST2700.
- Add MSI support and a preliminary RC IOMMU address space.
- Fix issues with MSI interrupt clearing.
- Extend support to the AST2700 SoC.
- Drop the AST2600RC_Lsupport.
- Introduce PCIe RC functional tests covering both AST2600 and AST2700.Signed-off-by Jamin Lin <[email protected]>--- include/hw/pci-host/aspeed_pcie.h | 42 ++++++++ hw/pci-host/aspeed_pcie.c | 157 ++++++++++++++++++++++++++++++ hw/arm/Kconfig | 3 + hw/pci-host/Kconfig | 4 + hw/pci-host/meson.build | 1 + hw/pci-host/trace-events | 4 + 6 files changed, 211 insertions(+)create mode 100644
include/hw/pci-host/aspeed_pcie.hcreate mode 100644hw/pci-host/aspeed_pcie.cinclude/hw/pci-host/aspeed_pcie.h new file +42
-0@@ -0,0 +1,42 @@ +/* +* ASPEED PCIe Host Controller +* +* Copyright (C) 2025 ASPEED Technology Inc. +* Copyright (c) 2022 Cédric Le Goater <[email protected]> +* +* Authors: +* Cédric Le Goater <[email protected]> +* Jamin Lin <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* Based on previous work from Cédric Le Goater. +* Modifications extend support for the ASPEED AST2600 and AST2700 platforms. +*/ + +#ifndef ASPEED_PCIE_H +#define ASPEED_PCIE_H + +#include "hw/sysbus.h" +#include "hw/pci/pci_bridge.h" +#include "hw/pci/pcie_host.h" +#include "qom/object.h" + +#define TYPE_ASPEED_PCIE_PHY "aspeed.pcie-phy" +OBJECT_DECLARE_TYPE (AspeedPCIEPhyState, AspeedPCIEPhyClass,ASPEED_PCIE_PHY ); + +struct AspeedPCIEPhyState { +SysBusDevice parent_obj; + +MemoryRegion mmio; +uint32_t *regs; +uint32_t id; +}; + +struct AspeedPCIEPhyClass { +SysBusDeviceClass parent_class; + +uint64_t nr_regs; +}; + +#endif /* ASPEED_PCIE_H */ hw/pci-host/aspeed_pcie.c new file +98
-0@@ -0,0 +1,157 @@ +/* +* ASPEED PCIe Host Controller +* +* Copyright (C) 2025 ASPEED Technology Inc. +* Copyright (c) 2022 Cédric Le Goater <[email protected]> +* +* Authors: +* Cédric Le Goater <[email protected]> +* Jamin Lin <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* Based on previous work from Cédric Le Goater. +* Modifications extend support for the ASPEED AST2600 and AST2700 platforms. +*/ + +#include "qemu/osdep.h" +#include "qemu/log.h" +#include "qapi/error.h" +#include "hw/qdev-properties.h" +#include "hw/registerfields.h" +#include "hw/irq.h" +#include "hw/pci/pci_host.h" +#include "hw/pci-host/aspeed_pcie.h" +#include "hw/pci/msi.h" +#include "trace.h" + +/* +* PCIe PHY +* +* PCIe Host Controller (PCIEH) +*/ + +/* AST2600 */ +REG32(PEHR_ID, 0x00) + FIELD(PEHR_ID, DEV, 16, 16) +REG32(PEHR_CLASS_CODE, 0x04) +REG32(PEHR_DATALINK, 0x10) +REG32(PEHR_PROTECT, 0x7C) + FIELD(PEHR_PROTECT, LOCK, 0, 8) +REG32(PEHR_LINK, 0xC0) + FIELD(PEHR_LINK, STS, 5, 1) + +#define ASPEED_PCIE_PHY_UNLOCK 0xA8 + +static uint64_t aspeed_pcie_phy_read (void *opaque,hwaddr addr, +unsigned int size) +{ +AspeedPCIEPhyState *s =ASPEED_PCIE_PHY (opaque); +uint32_t reg = addr >>2 ; +uint32_t value =0 ; + + value = s->regs[reg]; + +trace_aspeed_pcie_phy_read (s->id, addr, value); + +return value; +} + +static void aspeed_pcie_phy_write (void *opaque,hwaddr addr,uint64_t data, +unsigned int size) +{ +AspeedPCIEPhyState *s =ASPEED_PCIE_PHY (opaque); +uint32_t reg = addr >>2 ; + +trace_aspeed_pcie_phy_write (s->id, addr, data); + +switch (reg) { +case R_PEHR_PROTECT : + data &=R_PEHR_PROTECT_LOCK_MASK ; + s->regs[reg] = !!(data ==ASPEED_PCIE_PHY_UNLOCK ); +break ; +default : + s->regs[reg] = data; +break ; + } +} + +static const MemoryRegionOps aspeed_pcie_phy_ops = { + .read = aspeed_pcie_phy_read, + .write = aspeed_pcie_phy_write, + .endianness =DEVICE_LITTLE_ENDIAN , + .valid = { + .min_access_size =1 , + .max_access_size =4 , + }, +}; + +static void aspeed_pcie_phy_reset (DeviceState *dev) +{ +AspeedPCIEPhyState *s =ASPEED_PCIE_PHY (dev); +AspeedPCIEPhyClass *apc =ASPEED_PCIE_PHY_GET_CLASS (s); + +memset (s->regs,0 , apc->nr_regs <<2 ); + + s->regs[R_PEHR_ID ] = + (0x1150 <<R_PEHR_ID_DEV_SHIFT ) |PCI_VENDOR_ID_ASPEED ; + s->regs[R_PEHR_CLASS_CODE ] =0x06040006 ;
hw/pci-host/aspeed_pcie.c line 108
Quoted 10 lines
hw/pci-host/aspeed_pcie.c new file +10
-0+ s->regs[R_PEHR_DATALINK ] =0xD7040022 ; + s->regs[R_PEHR_LINK ] =R_PEHR_LINK_STS_MASK ; +} + +static void aspeed_pcie_phy_realize (DeviceState *dev,Error **errp) +{ +AspeedPCIEPhyState *s =ASPEED_PCIE_PHY (dev); +AspeedPCIEPhyClass *apc =ASPEED_PCIE_PHY_GET_CLASS (s); +SysBusDevice *sbd =SYS_BUS_DEVICE (dev); + g_autofree char *name;
g_autofree variables should defined when declared. So,
g_autofree char *name = g_strdup_printf(TYPE_ASPEED_PCIE_PHY ".regs.%d", s->id);
I can do that if there are no major issues in the series.
Thanks,
C.
Quoted 111 lines
hw/pci-host/aspeed_pcie.c new file +49
-0+ + s->regs =g_new (uint32_t, apc->nr_regs); + name =g_strdup_printf (TYPE_ASPEED_PCIE_PHY ".regs.%d" , s->id); +memory_region_init_io (&s->mmio,OBJECT (s), &aspeed_pcie_phy_ops, s, name, + apc->nr_regs <<2 ); +sysbus_init_mmio (sbd, &s->mmio); +} + +static void aspeed_pcie_phy_unrealize (DeviceState *dev) +{ +AspeedPCIEPhyState *s =ASPEED_PCIE_PHY (dev); + +g_free (s->regs); + s->regs =NULL ; +} + +static const Property aspeed_pcie_phy_props[] = { +DEFINE_PROP_UINT32 ("id" , AspeedPCIEPhyState, id,0 ), +}; + +static void aspeed_pcie_phy_class_init (ObjectClass *klass,const void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); +AspeedPCIEPhyClass *apc =ASPEED_PCIE_PHY_CLASS (klass); + + dc->desc ="ASPEED PCIe Phy" ; + dc->realize = aspeed_pcie_phy_realize; + dc->unrealize = aspeed_pcie_phy_unrealize; +device_class_set_legacy_reset (dc, aspeed_pcie_phy_reset); +device_class_set_props (dc, aspeed_pcie_phy_props); + + apc->nr_regs =0x100 >>2 ; +} + +static const TypeInfo aspeed_pcie_phy_info = { + .name =TYPE_ASPEED_PCIE_PHY , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (AspeedPCIEPhyState), + .class_init = aspeed_pcie_phy_class_init, + .class_size =sizeof (AspeedPCIEPhyClass), +}; + +static void aspeed_pcie_register_types (void ) +{ +type_register_static (&aspeed_pcie_phy_info); +} + +type_init (aspeed_pcie_register_types); +hw/arm/Kconfig +3
-0@@ -541,6 +541,7 @@ config ASPEED_SOC bool default y depends on TCG && ARM + imply PCI_DEVICES select DS1338 select FTGMAC100 select I2C@@ -561,6 +562,8 @@ config ASPEED_SOC select MAX31785 select FSI_APB2OPB_ASPEED select AT24C + select PCI_EXPRESS + select PCI_EXPRESS_ASPEED config MPS2 boolhw/pci-host/Kconfig +4
-0@@ -46,6 +46,10 @@ config PCI_I440FX select PCI select PAM +config PCI_EXPRESS_ASPEED + bool + select PCI_EXPRESS + config PCI_EXPRESS_Q35 bool select PCI_EXPRESShw/pci-host/meson.build +1
-0@@ -2,6 +2,7 @@ pci_ss = ss.source_set() pci_ss.add(when: 'CONFIG_PAM', if_true: files('pam.c')) pci_ss.add(when: 'CONFIG_PCI_BONITO', if_true: files('bonito.c')) pci_ss.add(when: 'CONFIG_GT64120', if_true: files('gt64120.c')) +pci_ss.add(when: 'CONFIG_PCI_EXPRESS_ASPEED', if_true: files('aspeed_pcie.c')) pci_ss.add(when: 'CONFIG_PCI_EXPRESS_DESIGNWARE', if_true: files('designware.c')) pci_ss.add(when: 'CONFIG_PCI_EXPRESS_GENERIC_BRIDGE', if_true: files('gpex.c')) pci_ss.add(when: ['CONFIG_PCI_EXPRESS_GENERIC_BRIDGE', 'CONFIG_ACPI'], if_true: files('gpex-acpi.c'))hw/pci-host/trace-events +4
-0@@ -1,5 +1,9 @@ # See docs/devel/tracing.rst for syntax documentation. +# aspeed_pcie.c +aspeed_pcie_phy_read(uint32_t id, uint64_t addr, uint32_t value) "%d: addr 0x%" PRIx64 " value 0x%" PRIx32 +aspeed_pcie_phy_write(uint32_t id, uint64_t addr, uint32_t value) "%d: addr 0x%" PRIx64 " value 0x%" PRIx32 + # bonito.c bonito_spciconf_small_access(uint64_t addr, unsigned size) "PCI config address is smaller then 32-bit, addr: 0x%"PRIx64", size: %u"
RE: [SPAM] [PATCH v3 02/14] hw/pci-host/aspeed: Add AST2600 PCIe PHY model
Hi Cédric
Quoted 234 lines
Subject: Re: [SPAM] [PATCH v3 02/14] hw/pci-host/aspeed: Add AST2600 PCIe PHY model
Quoted 5 lines · Jamin Lin
This patch introduces an initial ASPEED PCIe PHY/host controller model to support the AST2600 SoC. It provides a simple register block with MMIO read/write callbacks, integration into the build system, and trace events for debugging.
Quoted 8 lines
Key changes:
1. PCIe PHY MMIO read/write callbacks
Implementedaspeed_pcie_phy_read()andaspeed_pcie_phy_write()to handle 32-bit register accesses.2. Build system and
Kconfigintegration
AddedCONFIG_PCI_EXPRESS_ASPEEDin hw/pci-host/Kconfig andmeson
Quoted 2 lines
rules.
UpdatedASPEED_SOCin hw/arm/Kconfig to implyPCI_DEVICESandselect
Quoted 4 lines
PCI_EXPRESS_ASPEED.3. Trace events for debug
New tracepointsaspeed_pcie_phy_readandaspeed_pcie_phy_writeallow
Quoted 4 lines
monitoring MMIO accesses.
4. Register space and defaults (AST2600 reference)
Expose a 0x100 register space, as documented in the AST2600datasheet.
Quoted 6 lines
On reset, set default values: PEHR_ID: Vendor ID = ASPEED, Device ID = 0x1150 PEHR_CLASS_CODE = 0x06040006 PEHR_DATALINK = 0xD7040022 PEHR_LINK: bit[5] set to 1 to indicate link up.Quoted 7 lines
This provides a skeleton device for the AST2600 platform. It enables firmware to detect the PCIe link as up by default and allows future extension.
This commit is the starting point of the series to introduce ASPEED PCIe Root Complex (RC) support. Based on previous work from Cédric Le Goater, the following commits in this series extend and refine the
implementation:
Quoted 5 lines
- Add a PCIe Root Port so that devices can be attached without requiring an extra bridge.
- Restrict the Root Port device instantiation to the AST2600 platform.
- Integrateaspeed_cfg_translate_write()to support both AST2600 andAST2700.
Quoted 10 lines
- Add MSI support and a preliminary RC IOMMU address space.
- Fix issues with MSI interrupt clearing.
- Extend support to the AST2700 SoC.
- Drop the AST2600RC_Lsupport.
- Introduce PCIe RC functional tests covering both AST2600 and AST2700.Signed-off-by Jamin Lin <[email protected]>--- include/hw/pci-host/aspeed_pcie.h | 42 ++++++++ hw/pci-host/aspeed_pcie.c | 157++++++++++++++++++++++++++++++
Quoted 19 lines
hw/arm/Kconfig | 3 + hw/pci-host/Kconfig | 4 + hw/pci-host/meson.build | 1 + hw/pci-host/trace-events | 4 + 6 files changed, 211 insertions(+)create mode 100644
include/hw/pci-host/aspeed_pcie.hcreate mode 100644hw/pci-host/aspeed_pcie.cinclude/hw/pci-host/aspeed_pcie.h new file +4
-0@@ -0,0 +1,42 @@ +/* +* ASPEED PCIe Host Controller +* +* Copyright (C) 2025 ASPEED Technology Inc. include/hw/pci-host/aspeed_pcie.h line 14
Quoted 10 lines
include/hw/pci-host/aspeed_pcie.h new file +10
-0+* Copyright (c) 2022 Cédric Le Goater <[email protected]> +* +* Authors: +* Cédric Le Goater <[email protected]> +* Jamin Lin <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* Based on previous work from Cédric Le Goater. +* Modifications extend support for the ASPEED AST2600 and AST2700 platforms.
Quoted 38 lines
include/hw/pci-host/aspeed_pcie.h new file +29
-0+*/ + +#ifndef ASPEED_PCIE_H +#define ASPEED_PCIE_H + +#include "hw/sysbus.h" +#include "hw/pci/pci_bridge.h" +#include "hw/pci/pcie_host.h" +#include "qom/object.h" + +#define TYPE_ASPEED_PCIE_PHY "aspeed.pcie-phy" +OBJECT_DECLARE_TYPE (AspeedPCIEPhyState, AspeedPCIEPhyClass, +ASPEED_PCIE_PHY ); + +struct AspeedPCIEPhyState { +SysBusDevice parent_obj; + +MemoryRegion mmio; +uint32_t *regs; +uint32_t id; +}; + +struct AspeedPCIEPhyClass { +SysBusDeviceClass parent_class; + +uint64_t nr_regs; +}; + +#endif /* ASPEED_PCIE_H */ hw/pci-host/aspeed_pcie.c new renamed from hw/pci-host/aspeed_pcie.c +0
-0file mode 100644 index 0000000000..110c963779
hw/pci-host/aspeed_pcie.c new file +4
-0@@ -0,0 +1,157 @@ +/* +* ASPEED PCIe Host Controller +* +* Copyright (C) 2025 ASPEED Technology Inc. hw/pci-host/aspeed_pcie.c line 14
Quoted 10 lines
hw/pci-host/aspeed_pcie.c new file +10
-0+* Copyright (c) 2022 Cédric Le Goater <[email protected]> +* +* Authors: +* Cédric Le Goater <[email protected]> +* Jamin Lin <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* Based on previous work from Cédric Le Goater. +* Modifications extend support for the ASPEED AST2600 and AST2700 platforms.
Quoted 35 lines
hw/pci-host/aspeed_pcie.c new file +35
-0+*/ + +#include "qemu/osdep.h" +#include "qemu/log.h" +#include "qapi/error.h" +#include "hw/qdev-properties.h" +#include "hw/registerfields.h" +#include "hw/irq.h" +#include "hw/pci/pci_host.h" +#include "hw/pci-host/aspeed_pcie.h" +#include "hw/pci/msi.h" +#include "trace.h" + +/* +* PCIe PHY +* +* PCIe Host Controller (PCIEH) +*/ + +/* AST2600 */ +REG32(PEHR_ID, 0x00) + FIELD(PEHR_ID, DEV, 16, 16) +REG32(PEHR_CLASS_CODE, 0x04) +REG32(PEHR_DATALINK, 0x10) +REG32(PEHR_PROTECT, 0x7C) + FIELD(PEHR_PROTECT, LOCK, 0, 8) +REG32(PEHR_LINK, 0xC0) + FIELD(PEHR_LINK, STS, 5, 1) + +#define ASPEED_PCIE_PHY_UNLOCK 0xA8 + +static uint64_t aspeed_pcie_phy_read (void *opaque,hwaddr addr, +unsigned int size) { +AspeedPCIEPhyState *s =ASPEED_PCIE_PHY (opaque); +uint32_t reg = addr >>2 ;hw/pci-host/aspeed_pcie.c
Quoted 10 lines
hw/pci-host/aspeed_pcie.c new file +10
-0+uint32_t value =0 ; + + value = s->regs[reg]; + +trace_aspeed_pcie_phy_read (s->id, addr, value); + +return value; +} + +static void aspeed_pcie_phy_write(void *opaque, hwaddr addr, uint64_tdata,
Quoted 34 lines
hw/pci-host/aspeed_pcie.c new file +34
-0+ unsigned int size) { +AspeedPCIEPhyState *s =ASPEED_PCIE_PHY (opaque); +uint32_t reg = addr >>2 ; + +trace_aspeed_pcie_phy_write (s->id, addr, data); + +switch (reg) { +case R_PEHR_PROTECT : + data &=R_PEHR_PROTECT_LOCK_MASK ; + s->regs[reg] = !!(data ==ASPEED_PCIE_PHY_UNLOCK ); +break ; +default : + s->regs[reg] = data; +break ; + } +} + +static const MemoryRegionOps aspeed_pcie_phy_ops = { + .read = aspeed_pcie_phy_read, + .write = aspeed_pcie_phy_write, + .endianness =DEVICE_LITTLE_ENDIAN , + .valid = { + .min_access_size =1 , + .max_access_size =4 , + }, +}; + +static void aspeed_pcie_phy_reset (DeviceState *dev) { +AspeedPCIEPhyState *s =ASPEED_PCIE_PHY (dev); +AspeedPCIEPhyClass *apc =ASPEED_PCIE_PHY_GET_CLASS (s); + +memset (s->regs,0 , apc->nr_regs <<2 ); + + s->regs[R_PEHR_ID] =hw/pci-host/aspeed_pcie.c line 108
Quoted 10 lines
hw/pci-host/aspeed_pcie.c new file +10
-0+ (0x1150 <<R_PEHR_ID_DEV_SHIFT ) |PCI_VENDOR_ID_ASPEED ; + s->regs[R_PEHR_CLASS_CODE ] =0x06040006 ; + s->regs[R_PEHR_DATALINK ] =0xD7040022 ; + s->regs[R_PEHR_LINK ] =R_PEHR_LINK_STS_MASK ; } + +static void aspeed_pcie_phy_realize (DeviceState *dev,Error **errp) { +AspeedPCIEPhyState *s =ASPEED_PCIE_PHY (dev); +AspeedPCIEPhyClass *apc =ASPEED_PCIE_PHY_GET_CLASS (s); +SysBusDevice *sbd =SYS_BUS_DEVICE (dev); + g_autofree char *name;
g_autofreevariables should defined when declared. So,
Quoted 3 lines
g_autofreechar *name = g_strdup_printf(TYPE_ASPEED_PCIE_PHY
".regs.%d",s->id);
Thanks for your review and suggestion.
Will fix it.
Jamin
Quoted 123 lines
I can do that if there are no major issues in the series.
Thanks,
C.
hw/pci-host/aspeed_pcie.c
Quoted 4 lines
hw/pci-host/aspeed_pcie.c new file +4
-0+ + s->regs =g_new (uint32_t, apc->nr_regs); + name =g_strdup_printf (TYPE_ASPEED_PCIE_PHY ".regs.%d" , s->id); + memory_region_init_io(&s->mmio, OBJECT(s), &aspeed_pcie_phy_ops,s, name,
Quoted 82 lines
hw/pci-host/aspeed_pcie.c new file +41
-0+ apc->nr_regs << 2); +sysbus_init_mmio (sbd, &s->mmio); +} + +static void aspeed_pcie_phy_unrealize (DeviceState *dev) { +AspeedPCIEPhyState *s =ASPEED_PCIE_PHY (dev); + +g_free (s->regs); + s->regs =NULL ; +} + +static const Property aspeed_pcie_phy_props[] = { +DEFINE_PROP_UINT32 ("id" , AspeedPCIEPhyState, id,0 ), }; + +static void aspeed_pcie_phy_class_init (ObjectClass *klass,const void +*data) { +DeviceClass *dc =DEVICE_CLASS (klass); +AspeedPCIEPhyClass *apc =ASPEED_PCIE_PHY_CLASS (klass); + + dc->desc ="ASPEED PCIe Phy" ; + dc->realize = aspeed_pcie_phy_realize; + dc->unrealize = aspeed_pcie_phy_unrealize; +device_class_set_legacy_reset (dc, aspeed_pcie_phy_reset); +device_class_set_props (dc, aspeed_pcie_phy_props); + + apc->nr_regs =0x100 >>2 ; +} + +static const TypeInfo aspeed_pcie_phy_info = { + .name =TYPE_ASPEED_PCIE_PHY , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (AspeedPCIEPhyState), + .class_init = aspeed_pcie_phy_class_init, + .class_size =sizeof (AspeedPCIEPhyClass), }; + +static void aspeed_pcie_register_types (void ) { +type_register_static (&aspeed_pcie_phy_info); +} + +type_init (aspeed_pcie_register_types); +hw/arm/Kconfig index renamed from hw/arm/Kconfig +0
-0
3baa6c6c74..b44b85f436100644hw/arm/Kconfig +3
-0@@ -541,6 +541,7 @@ config ASPEED_SOC bool default y depends on TCG && ARM + imply PCI_DEVICES select DS1338 select FTGMAC100 select I2C@@ -561,6 +562,8 @@ config ASPEED_SOC select MAX31785 select FSI_APB2OPB_ASPEED select AT24C + select PCI_EXPRESS + select PCI_EXPRESS_ASPEED config MPS2 boolhw/pci-host/Kconfig index renamed from hw/pci-host/Kconfig +0
-0
9824fa188d..8cbb8304a3100644hw/pci-host/Kconfig +4
-0@@ -46,6 +46,10 @@ config PCI_I440FX select PCI select PAM +config PCI_EXPRESS_ASPEED + bool + select PCI_EXPRESS + config PCI_EXPRESS_Q35 bool select PCI_EXPRESShw/pci-host/meson.build index renamed from hw/pci-host/meson.build +0
-0
937a0f72ac..86b754d0b0100644hw/pci-host/meson.build pci_ss = ss.source_set() · line 7
Quoted 6 lines
hw/pci-host/meson.build +2
-0@@ -2,6 +2,7 @@ pci_ss = ss.source_set() pci_ss.add(when: 'CONFIG_PAM', if_true: files('pam.c')) pci_ss.add(when: 'CONFIG_PCI_BONITO', if_true: files('bonito.c')) pci_ss.add(when: 'CONFIG_GT64120', if_true: files('gt64120.c')) +pci_ss.add(when: 'CONFIG_PCI_EXPRESS_ASPEED', if_true: +files('aspeed_pcie.c')) pci_ss.add(when: 'CONFIG_PCI_EXPRESS_DESIGNWARE', if_true:files('designware.c'))
hw/pci-host/meson.build pci_ss = ss.source_set() · line 8
Quoted 1 line
hw/pci-host/meson.build +0
-0pci_ss.add(when: 'CONFIG_PCI_EXPRESS_GENERIC_BRIDGE', if_true:files('gpex.c'))
Quoted 7 lines
pci_ss.add(when: ['
CONFIG_PCI_EXPRESS_GENERIC_BRIDGE',
'CONFIG_ACPI'],if_true: files('gpex-acpi.c')) diff --git a/hw/pci-host/trace-events b/hw/pci-host/trace-events index 0a816b9aa1..3438516756 100644hw/pci-host/trace-events
Quoted 10 lines
hw/pci-host/trace-events +6
-0@@ -1,5 +1,9 @@ # See docs/devel/tracing.rst for syntax documentation. +# aspeed_pcie.c +aspeed_pcie_phy_read(uint32_t id, uint64_t addr, uint32_t value) "%d: +addr 0x%" PRIx64 " value 0x%" PRIx32 aspeed_pcie_phy_write(uint32_t +id, uint64_t addr, uint32_t value) "%d: addr 0x%" PRIx64 " value 0x%" +PRIx32 + # bonito.c bonito_spciconf_small_access(uint64_t addr, unsigned size) "PCI configaddress is smaller then 32-bit, addr: 0x%"PRIx64", size: %u"
Quoted 1 line
PATCH v3 3/14 hw/pci-host/aspeed: Add AST2600 PCIe config space and host bridge
In reply to Jamin Lin viaIntroduce PCIe config and host bridge model for the AST2600 platform.
This patch adds support for the H2X (AHB to PCIe Bus Bridge) controller with a 0x100 byte register space. The register layout is shared between two root complexes: 0x00–0x7f is common, 0x80–0xbf for RC_L, and 0xc0–0xff for RC_H. Only RC_H is modeled in this implementation.
The RC_H bus uses bus numbers in the 0x80–0xff range instead of the standard root bus 0x00. To allow the PCI subsystem to discover devices, the host bridge logic remaps the root bus number back to 0x00 whenever the configured bus number matches the "bus-nr" property.
New MMIO callbacks are added for the H2X config space:
- aspeed_pcie_cfg_read() and aspeed_pcie_cfg_write() handle register accesses.
- aspeed_pcie_cfg_readwrite() provides configuration read/write support.
- aspeed_pcie_cfg_translate_write() handles PCIe byte-enable semantics for write operations.
The reset handler initializes the H2X register block with default values as defined in the AST2600 datasheet.
Additional changes:
- Implement ASPEED PCIe root complex (TYPE_ASPEED_PCIE_RC).
- Wire up interrupt propagation via aspeed_pcie_rc_set_irq().
- Add tracepoints for config read/write and INTx handling.
--- include/hw/pci-host/aspeed_pcie.h | 59 +++++ hw/pci-host/aspeed_pcie.c | 418 ++++++++++++++++++++++++++++++ hw/pci-host/trace-events | 4 + 3 files changed, 481 insertions(+)
include/hw/pci-host/aspeed_pcie.h +59 -0
@@ -22,6 +22,65 @@#include "hw/pci/pcie_host.h" #include "qom/object.h" +typedef struct AspeedPCIECfgTxDesc { +uint32_t desc0; +uint32_t desc1; +uint32_t desc2; +uint32_t desc3; +uint32_t wdata; +uint32_t rdata_reg; +}AspeedPCIECfgTxDesc ; + +typedef struct AspeedPCIERcRegs { +uint32_t int_en_reg; +uint32_t int_sts_reg; +}AspeedPCIERcRegs ; + +typedef struct AspeedPCIERegMap { +AspeedPCIERcRegs rc; +}AspeedPCIERegMap ; + +#define TYPE_ASPEED_PCIE_RC "aspeed.pcie-rc" +OBJECT_DECLARE_SIMPLE_TYPE (AspeedPCIERcState,ASPEED_PCIE_RC ); + +struct AspeedPCIERcState { +PCIExpressHost parent_obj; + +MemoryRegion mmio_window; +MemoryRegion io_window; +MemoryRegion mmio; +MemoryRegion io; + +uint32_t bus_nr; +char name[16 ]; +qemu_irq irq; +}; + +/* Bridge between AHB bus and PCIe RC. */ +#define TYPE_ASPEED_PCIE_CFG "aspeed.pcie-cfg" +OBJECT_DECLARE_TYPE (AspeedPCIECfgState, AspeedPCIECfgClass,ASPEED_PCIE_CFG ); + +struct AspeedPCIECfgState { +SysBusDevice parent_obj; + +MemoryRegion mmio; +uint32_t *regs; +uint32_t id; + +const AspeedPCIERcRegs *rc_regs; +AspeedPCIERcState rc; +}; + +struct AspeedPCIECfgClass { +SysBusDeviceClass parent_class; + +const AspeedPCIERegMap *reg_map; +const MemoryRegionOps *reg_ops; + +uint64_t rc_bus_nr; +uint64_t nr_regs; +}; +#define TYPE_ASPEED_PCIE_PHY "aspeed.pcie-phy"OBJECT_DECLARE_TYPE (AspeedPCIEPhyState, AspeedPCIEPhyClass,ASPEED_PCIE_PHY );
hw/pci-host/aspeed_pcie.c +418 -0
430 lines not on this page · raw message
hw/pci-host/trace-events +4 -0
@@ -1,6 +1,10 @@ # See docs/devel/tracing.rst for syntax documentation. # aspeed_pcie.c +aspeed_pcie_rc_intx_set_irq(uint32_t id, int num, int level) "%d: num %d set IRQ leve %d" +aspeed_pcie_cfg_read(uint32_t id, uint64_t addr, uint32_t value) "%d: addr 0x%" PRIx64 " value 0x%" PRIx32 +aspeed_pcie_cfg_write(uint32_t id, uint64_t addr, uint32_t value) "%d: addr 0x%" PRIx64 " value 0x%" PRIx32 +aspeed_pcie_cfg_rw(uint32_t id, const char *dir, uint8_t bus, uint8_t devfn, uint64_t addr, uint64_t data) "%d: %s bus:0x%x devfn:0x%x addr 0x%" PRIx64 " data 0x%" PRIx64 aspeed_pcie_phy_read(uint32_t id, uint64_t addr, uint32_t value) "%d: addr 0x%" PRIx64 " value 0x%" PRIx32 aspeed_pcie_phy_write(uint32_t id, uint64_t addr, uint32_t value) "%d: addr 0x%" PRIx64 " value 0x%" PRIx32
Signature · 1 line
2.43.0
Re: [SPAM] [PATCH v3 03/14] hw/pci-host/aspeed: Add AST2600 PCIe config space and host bridge
Quoted 140 lines · Jamin Lin
Introduce PCIe config and host bridge model for the AST2600 platform.
This patch adds support for the H2X (AHB to PCIe Bus Bridge) controller with a
0x100byte register space. The register layout is shared between two root complexes: 0x00–0x7f is common, 0x80–0xbf forRC_L, and 0xc0–0xff forRC_H. OnlyRC_His modeled in this implementation.The
RC_Hbus uses bus numbers in the 0x80–0xff range instead of the standard root bus0x00. To allow the PCI subsystem to discover devices, the host bridge logic remaps the root bus number back to0x00whenever the configured bus number matches the "bus-nr" property.New MMIO callbacks are added for the H2X config space:
-aspeed_pcie_cfg_read()andaspeed_pcie_cfg_write()handle register accesses.
-aspeed_pcie_cfg_readwrite()provides configuration read/write support.
-aspeed_pcie_cfg_translate_write()handles PCIe byte-enable semantics for write operations.The reset handler initializes the H2X register block with default values as defined in the AST2600 datasheet.
Additional changes:
- Implement ASPEED PCIe root complex (TYPE_ASPEED_PCIE_RC).
- Wire up interrupt propagation viaaspeed_pcie_rc_set_irq().
- Add tracepoints for config read/write and INTx handling.Signed-off-by Jamin Lin <[email protected]>--- include/hw/pci-host/aspeed_pcie.h | 59 +++++ hw/pci-host/aspeed_pcie.c | 418 ++++++++++++++++++++++++++++++ hw/pci-host/trace-events | 4 + 3 files changed, 481 insertions(+)include/hw/pci-host/aspeed_pcie.h +58
-0@@ -22,6 +22,65 @@#include "hw/pci/pcie_host.h" #include "qom/object.h" +typedef struct AspeedPCIECfgTxDesc { +uint32_t desc0; +uint32_t desc1; +uint32_t desc2; +uint32_t desc3; +uint32_t wdata; +uint32_t rdata_reg; +}AspeedPCIECfgTxDesc ; + +typedef struct AspeedPCIERcRegs { +uint32_t int_en_reg; +uint32_t int_sts_reg; +}AspeedPCIERcRegs ; + +typedef struct AspeedPCIERegMap { +AspeedPCIERcRegs rc; +}AspeedPCIERegMap ; + +#define TYPE_ASPEED_PCIE_RC "aspeed.pcie-rc" +OBJECT_DECLARE_SIMPLE_TYPE (AspeedPCIERcState,ASPEED_PCIE_RC ); + +struct AspeedPCIERcState { +PCIExpressHost parent_obj; + +MemoryRegion mmio_window; +MemoryRegion io_window; +MemoryRegion mmio; +MemoryRegion io; + +uint32_t bus_nr; +char name[16 ]; + qemu_irq irq;> +}; + +/* Bridge between AHB bus and PCIe RC. */ +#define TYPE_ASPEED_PCIE_CFG "aspeed.pcie-cfg" +OBJECT_DECLARE_TYPE (AspeedPCIECfgState, AspeedPCIECfgClass,ASPEED_PCIE_CFG ); + +struct AspeedPCIECfgState { +SysBusDevice parent_obj; + +MemoryRegion mmio; +uint32_t *regs; +uint32_t id; + +const AspeedPCIERcRegs *rc_regs; +AspeedPCIERcState rc; +}; + +struct AspeedPCIECfgClass { +SysBusDeviceClass parent_class; + +const AspeedPCIERegMap *reg_map; +const MemoryRegionOps *reg_ops; + +uint64_t rc_bus_nr; +uint64_t nr_regs; +}; +#define TYPE_ASPEED_PCIE_PHY "aspeed.pcie-phy"OBJECT_DECLARE_TYPE (AspeedPCIEPhyState, AspeedPCIEPhyClass,ASPEED_PCIE_PHY );hw/pci-host/aspeed_pcie.c +29
-0@@ -25,6 +25,422 @@#include "hw/pci/msi.h" #include "trace.h" +/* +* PCIe Root Complex (RC) +*/ + +static void aspeed_pcie_rc_set_irq (void *opaque,int irq,int level) +{ +AspeedPCIERcState *rc = (AspeedPCIERcState *) opaque; +AspeedPCIECfgState *cfg = +container_of (rc, AspeedPCIECfgState, rc); +bool intx; + +assert (irq <PCI_NUM_PINS ); + +if (level) { + cfg->regs[cfg->rc_regs->int_sts_reg] |=BIT (irq); + }else { + cfg->regs[cfg->rc_regs->int_sts_reg] &= ~BIT (irq); + } + + intx = !!(cfg->regs[cfg->rc_regs->int_sts_reg] & + cfg->regs[cfg->rc_regs->int_en_reg]); +trace_aspeed_pcie_rc_intx_set_irq (cfg->id, irq, intx); +qemu_set_irq (rc->irq, intx); +} + +static int aspeed_pcie_rc_map_irq (PCIDevice *pci_dev,int irq_num) +{ +return irq_num %PCI_NUM_PINS ; +}
hw/pci-host/aspeed_pcie.c line 66
Quoted 10 lines
hw/pci-host/aspeed_pcie.c +10
-0+ +static void aspeed_pcie_rc_realize (DeviceState *dev,Error **errp) +{ +PCIExpressHost *pex =PCIE_HOST_BRIDGE (dev); +AspeedPCIERcState *rc =ASPEED_PCIE_RC (dev); +AspeedPCIECfgState *cfg = +container_of (rc, AspeedPCIECfgState, rc); +PCIHostState *pci =PCI_HOST_BRIDGE (dev); +SysBusDevice *sbd =SYS_BUS_DEVICE (dev); + g_autofree char *name;
g_autofree variables should be assigned when declared.
hw/pci-host/aspeed_pcie.c line 79
Quoted 13 lines
hw/pci-host/aspeed_pcie.c +13
-0+ +/* PCI configuration space */ +pcie_host_mmcfg_init (pex,PCIE_MMCFG_SIZE_MAX ); +sysbus_init_mmio (sbd, &pex->mmio); + +/* MMIO and IO region */ +memory_region_init (&rc->mmio,OBJECT (rc),"mmio" ,UINT64_MAX ); +memory_region_init (&rc->io,OBJECT (rc),"io" ,0x10000 ); + + name =g_strdup_printf ("pcie.%d.mmio_window" , cfg->id); +memory_region_init_io (&rc->mmio_window,OBJECT (rc), &unassigned_io_ops, +OBJECT (rc), name,UINT64_MAX ); + name =g_strdup_printf ("pcie.%d.ioport_window" , cfg->id);
This is going to leak memory .
Quoted 300 lines
hw/pci-host/aspeed_pcie.c +300
-0+memory_region_init_io (&rc->io_window,OBJECT (rc), &unassigned_io_ops, +OBJECT (rc), name,0x10000 ); + +memory_region_add_subregion (&rc->mmio_window,0 , &rc->mmio); +memory_region_add_subregion (&rc->io_window,0 , &rc->io); +sysbus_init_mmio (sbd, &rc->mmio_window); +sysbus_init_mmio (sbd, &rc->io_window); + +sysbus_init_irq (sbd, &rc->irq); + name =g_strdup_printf ("pcie.rc%d" , cfg->id); + pci->bus =pci_register_root_bus (dev, name, aspeed_pcie_rc_set_irq, + aspeed_pcie_rc_map_irq, rc, &rc->mmio, + &rc->io,0 ,4 ,TYPE_PCIE_BUS ); + pci->bus->flags |=PCI_BUS_EXTENDED_CONFIG_SPACE ; +} + +static const char *aspeed_pcie_rc_root_bus_path (PCIHostState *host_bridge, +PCIBus *rootbus) +{ +AspeedPCIERcState *rc =ASPEED_PCIE_RC (host_bridge); +AspeedPCIECfgState *cfg = +container_of (rc, AspeedPCIECfgState, rc); + +snprintf (rc->name,sizeof (rc->name),"%04x:%02x" , cfg->id, rc->bus_nr); + +return rc->name; +} + +static const Property aspeed_pcie_rc_props[] = { +DEFINE_PROP_UINT32 ("bus-nr" , AspeedPCIERcState, bus_nr,0 ), +}; + +static void aspeed_pcie_rc_class_init (ObjectClass *klass,const void *data) +{ +PCIHostBridgeClass *hc =PCI_HOST_BRIDGE_CLASS (klass); +DeviceClass *dc =DEVICE_CLASS (klass); + + dc->desc ="ASPEED PCIe RC" ; + dc->realize = aspeed_pcie_rc_realize; + dc->fw_name ="pci" ; +set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); + + hc->root_bus_path = aspeed_pcie_rc_root_bus_path; +device_class_set_props (dc, aspeed_pcie_rc_props); + + msi_nonbroken = true; +} + +static const TypeInfo aspeed_pcie_rc_info = { + .name =TYPE_ASPEED_PCIE_RC , + .parent =TYPE_PCIE_HOST_BRIDGE , + .instance_size =sizeof (AspeedPCIERcState), + .class_init = aspeed_pcie_rc_class_init, +}; + +/* +* PCIe Config +* +* AHB to PCIe Bus Bridge (H2X) +* +* On the AST2600: +* NOTE: rc_l is not supported by this model. +* - Registers 0x00 - 0x7F are shared by both PCIe0 (rc_l) and PCIe1 (rc_h). +* - Registers 0x80 - 0xBF are specific to PCIe0. +* - Registers 0xC0 - 0xFF are specific to PCIe1. +*/ + +/* AST2600 */ +REG32(H2X_CTRL, 0x00) + FIELD(H2X_CTRL, CLEAR_RX, 4, 1) +REG32(H2X_TX_CLEAR, 0x08) + FIELD(H2X_TX_CLEAR, IDLE, 0, 1) +REG32(H2X_RDATA, 0x0C) +REG32(H2X_TX_DESC0, 0x10) +REG32(H2X_TX_DESC1, 0x14) +REG32(H2X_TX_DESC2, 0x18) +REG32(H2X_TX_DESC3, 0x1C) +REG32(H2X_TX_DATA, 0x20) +REG32(H2X_TX_STS, 0x24) + FIELD(H2X_TX_STS, IDLE, 31, 1) + FIELD(H2X_TX_STS, RC_L_TX_COMP, 24, 1) + FIELD(H2X_TX_STS, RC_H_TX_COMP, 25, 1) + FIELD(H2X_TX_STS, TRIG, 0, 1) +REG32(H2X_RC_H_CTRL, 0xC0) +REG32(H2X_RC_H_INT_EN, 0xC4) +REG32(H2X_RC_H_INT_STS, 0xC8) + SHARED_FIELD(H2X_RC_INT_INTDONE, 4, 1) + SHARED_FIELD(H2X_RC_INT_INTX, 0, 4) +REG32(H2X_RC_H_RDATA, 0xCC) + +#define TLP_FMTTYPE_CFGRD0 0x04/* Configuration Read Type 0 */ +#define TLP_FMTTYPE_CFGWR0 0x44/* Configuration Write Type 0 */ +#define TLP_FMTTYPE_CFGRD1 0x05/* Configuration Read Type 1 */ +#define TLP_FMTTYPE_CFGWR1 0x45/* Configuration Write Type 1 */ + +#define PCIE_CFG_FMTTYPE_MASK (x) (((x) >> 24) & 0xff) +#define PCIE_CFG_BYTE_EN (x) ((x) & 0xf) + +static const AspeedPCIERegMap aspeed_regmap = { + .rc = { + .int_en_reg =R_H2X_RC_H_INT_EN , + .int_sts_reg =R_H2X_RC_H_INT_STS , + }, +}; + +static uint64_t aspeed_pcie_cfg_read (void *opaque,hwaddr addr, +unsigned int size) +{ +AspeedPCIECfgState *s =ASPEED_PCIE_CFG (opaque); +uint32_t reg = addr >>2 ; +uint32_t value =0 ; + + value = s->regs[reg]; + +trace_aspeed_pcie_cfg_read (s->id, addr, value); + +return value; +} + +static void aspeed_pcie_cfg_translate_write (uint8_t byte_en,uint32_t *addr, +uint64_t *val,int *len) +{ +uint64_t packed_val =0 ; +int first_bit =-1 ; +int index =0 ; +int i; + + *len =ctpop8 (byte_en); + +if (*len ==0 || *len >4 ) { +qemu_log_mask (LOG_GUEST_ERROR ,"%s: invalid byte enable: 0x%x\n" , + __func__, byte_en); +return ; + } + +/* Special case: full 4-byte write must be 4-byte aligned */ +if (byte_en ==0x0f ) { +if ((*addr &0x3 ) !=0 ) { +qemu_log_mask (LOG_GUEST_ERROR , +"%s: 4-byte write not 4-byte aligned: addr=0x%x\n" , + __func__, *addr); +return ; + } + *val &=0xffffffffULL ; +return ; + } + +for (i =0 ; i <4 ; i++) { +if (byte_en & (1 << i)) { +if (first_bit <0 ) { + first_bit = i; + } + packed_val |= ((*val >> (i *8 )) &0xff ) << (index *8 ); + index++; + } + } + + *addr += first_bit; + *val = packed_val; +} + +static void aspeed_pcie_cfg_readwrite (AspeedPCIECfgState *s, +const AspeedPCIECfgTxDesc *desc) +{ +AspeedPCIERcState *rc = &s->rc; +PCIHostState *pci; +uint32_t cfg_addr; +PCIDevice *pdev; +uint32_t offset; +uint8_t byte_en; +bool is_write; +uint8_t devfn; +uint64_t val; +uint8_t bus; +int len; + + val = ~0 ; + is_write = !!(desc->desc0 &BIT (30 )); + cfg_addr = desc->desc2; + + bus = (cfg_addr >>24 ) &0xff ; + devfn = (cfg_addr >>16 ) &0xff ; + offset = cfg_addr &0xffc ; + + pci =PCI_HOST_BRIDGE (rc); + +/* +* On the AST2600, the RC_H bus number range from 0x80 to 0xFF, with the +* root device and root port assigned to bus 0x80 instead of the standard +* 0x00. To allow the PCI subsystem to correctly discover devices on the +* root bus, bus 0x80 is remapped to 0x00. +*/ +if (bus == rc->bus_nr) { + bus =0 ; + } + + pdev =pci_find_device (pci->bus, bus, devfn); +if (!pdev) { + s->regs[desc->rdata_reg] = ~0 ; + goto out; + } + +switch (PCIE_CFG_FMTTYPE_MASK (desc->desc0)) { +case TLP_FMTTYPE_CFGWR0 : +case TLP_FMTTYPE_CFGWR1 : + byte_en =PCIE_CFG_BYTE_EN (desc->desc1); + val = desc->wdata; +aspeed_pcie_cfg_translate_write (byte_en, &offset, &val, &len); +pci_host_config_write_common (pdev, offset,pci_config_size (pdev), + val, len); +break ; +case TLP_FMTTYPE_CFGRD0 : +case TLP_FMTTYPE_CFGRD1 : + val =pci_host_config_read_common (pdev, offset, +pci_config_size (pdev),4 ); + s->regs[desc->rdata_reg] = val; +break ; +default : +qemu_log_mask (LOG_GUEST_ERROR ,"%s: invalid CFG type. DESC0=0x%x\n" , + __func__, desc->desc0); + } + +out: +trace_aspeed_pcie_cfg_rw (s->id, is_write ?"write" :"read" , bus, devfn, + cfg_addr, val); +} + +static void aspeed_pcie_cfg_write (void *opaque,hwaddr addr,uint64_t data, +unsigned int size) +{ +AspeedPCIECfgState *s =ASPEED_PCIE_CFG (opaque); +AspeedPCIECfgTxDesc desc; +uint32_t reg = addr >>2 ; +uint32_t rc_reg; + +trace_aspeed_pcie_cfg_write (s->id, addr, data); + +switch (reg) { +case R_H2X_CTRL : +if (data &R_H2X_CTRL_CLEAR_RX_MASK ) { + s->regs[R_H2X_RDATA ] = ~0 ; + } +break ; +case R_H2X_TX_CLEAR : +if (data &R_H2X_TX_CLEAR_IDLE_MASK ) { + s->regs[R_H2X_TX_STS ] &= ~R_H2X_TX_STS_IDLE_MASK ; + } +break ; +case R_H2X_TX_STS : +if (data &R_H2X_TX_STS_TRIG_MASK ) { + desc.desc0 = s->regs[R_H2X_TX_DESC0 ]; + desc.desc1 = s->regs[R_H2X_TX_DESC1 ]; + desc.desc2 = s->regs[R_H2X_TX_DESC2 ]; + desc.desc3 = s->regs[R_H2X_TX_DESC3 ]; + desc.wdata = s->regs[R_H2X_TX_DATA ]; + desc.rdata_reg =R_H2X_RC_H_RDATA ; +aspeed_pcie_cfg_readwrite (s, &desc); + rc_reg = s->rc_regs->int_sts_reg; + s->regs[rc_reg] |=H2X_RC_INT_INTDONE_MASK ; + s->regs[R_H2X_TX_STS ] |= +BIT (R_H2X_TX_STS_RC_H_TX_COMP_SHIFT ); + s->regs[R_H2X_TX_STS ] |=R_H2X_TX_STS_IDLE_MASK ; + } +break ; +/* preserve INTx status */ +case R_H2X_RC_H_INT_STS : +if (data &H2X_RC_INT_INTDONE_MASK ) { + s->regs[R_H2X_TX_STS ] &= ~R_H2X_TX_STS_RC_H_TX_COMP_MASK ; + } + s->regs[reg] &= ~data |H2X_RC_INT_INTX_MASK ; +break ; +default : + s->regs[reg] = data; +break ; + } +} + +static const MemoryRegionOps aspeed_pcie_cfg_ops = { + .read = aspeed_pcie_cfg_read, + .write = aspeed_pcie_cfg_write, + .endianness =DEVICE_LITTLE_ENDIAN , + .valid = { + .min_access_size =1 , + .max_access_size =4 , + }, +}; + +static void aspeed_pcie_cfg_instance_init (Object *obj) +{ +AspeedPCIECfgState *s =ASPEED_PCIE_CFG (obj); + +object_initialize_child (obj,"rc" , &s->rc,TYPE_ASPEED_PCIE_RC ); + +return ; +} + +static void aspeed_pcie_cfg_reset (DeviceState *dev) +{ +AspeedPCIECfgState *s =ASPEED_PCIE_CFG (dev); +AspeedPCIECfgClass *apc =ASPEED_PCIE_CFG_GET_CLASS (s);
hw/pci-host/aspeed_pcie.c line 389
Quoted 10 lines
hw/pci-host/aspeed_pcie.c +10
-0+ +memset (s->regs,0 , apc->nr_regs <<2 ); +} + +static void aspeed_pcie_cfg_realize (DeviceState *dev,Error **errp) +{ +SysBusDevice *sbd =SYS_BUS_DEVICE (dev); +AspeedPCIECfgState *s =ASPEED_PCIE_CFG (dev); +AspeedPCIECfgClass *apc =ASPEED_PCIE_CFG_GET_CLASS (s); + g_autofree char *name;
name should be assigned.
Thanks,
C.
Quoted 81 lines
hw/pci-host/aspeed_pcie.c +56
-0+ + s->rc_regs = &apc->reg_map->rc; + s->regs =g_new (uint32_t, apc->nr_regs); + name =g_strdup_printf (TYPE_ASPEED_PCIE_CFG ".regs.%d" , s->id); +memory_region_init_io (&s->mmio,OBJECT (s), apc->reg_ops, s, name, + apc->nr_regs <<2 ); +sysbus_init_mmio (sbd, &s->mmio); + +object_property_set_int (OBJECT (&s->rc),"bus-nr" , + apc->rc_bus_nr, + &error_abort); +if (!sysbus_realize (SYS_BUS_DEVICE (&s->rc), errp)) { +return ; + } +} + +static void aspeed_pcie_cfg_unrealize (DeviceState *dev) +{ +AspeedPCIECfgState *s =ASPEED_PCIE_CFG (dev); + +g_free (s->regs); + s->regs =NULL ; +} + +static const Property aspeed_pcie_cfg_props[] = { +DEFINE_PROP_UINT32 ("id" , AspeedPCIECfgState, id,0 ), +}; + +static void aspeed_pcie_cfg_class_init (ObjectClass *klass,const void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); +AspeedPCIECfgClass *apc =ASPEED_PCIE_CFG_CLASS (klass); + + dc->desc ="ASPEED PCIe Config" ; + dc->realize = aspeed_pcie_cfg_realize; + dc->unrealize = aspeed_pcie_cfg_unrealize; +device_class_set_legacy_reset (dc, aspeed_pcie_cfg_reset); +device_class_set_props (dc, aspeed_pcie_cfg_props); + + apc->reg_ops = &aspeed_pcie_cfg_ops; + apc->reg_map = &aspeed_regmap; + apc->nr_regs =0x100 >>2 ; + apc->rc_bus_nr =0x80 ; +} + +static const TypeInfo aspeed_pcie_cfg_info = { + .name =TYPE_ASPEED_PCIE_CFG , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_init = aspeed_pcie_cfg_instance_init, + .instance_size =sizeof (AspeedPCIECfgState), + .class_init = aspeed_pcie_cfg_class_init, + .class_size =sizeof (AspeedPCIECfgClass), +}; +/* * PCIe PHY * @@ -150,6 +566,8 @@ static const TypeInfo aspeed_pcie_phy_info = {static void aspeed_pcie_register_types (void ) { +type_register_static (&aspeed_pcie_rc_info); +type_register_static (&aspeed_pcie_cfg_info);type_register_static (&aspeed_pcie_phy_info); }hw/pci-host/trace-events +4
-0@@ -1,6 +1,10 @@ # See docs/devel/tracing.rst for syntax documentation. # aspeed_pcie.c +aspeed_pcie_rc_intx_set_irq(uint32_t id, int num, int level) "%d: num %d set IRQ leve %d" +aspeed_pcie_cfg_read(uint32_t id, uint64_t addr, uint32_t value) "%d: addr 0x%" PRIx64 " value 0x%" PRIx32 +aspeed_pcie_cfg_write(uint32_t id, uint64_t addr, uint32_t value) "%d: addr 0x%" PRIx64 " value 0x%" PRIx32 +aspeed_pcie_cfg_rw(uint32_t id, const char *dir, uint8_t bus, uint8_t devfn, uint64_t addr, uint64_t data) "%d: %s bus:0x%x devfn:0x%x addr 0x%" PRIx64 " data 0x%" PRIx64 aspeed_pcie_phy_read(uint32_t id, uint64_t addr, uint32_t value) "%d: addr 0x%" PRIx64 " value 0x%" PRIx32 aspeed_pcie_phy_write(uint32_t id, uint64_t addr, uint32_t value) "%d: addr 0x%" PRIx64 " value 0x%" PRIx32
RE: [SPAM] [PATCH v3 03/14] hw/pci-host/aspeed: Add AST2600 PCIe config space and host bridge
Hi Cédric
Quoted 151 lines
Subject: Re: [SPAM] [PATCH v3 03/14] hw/pci-host/aspeed: Add AST2600 PCIe config space and host bridge
Quoted 6 lines · Jamin Lin
Introduce PCIe config and host bridge model for the AST2600 platform.
This patch adds support for the H2X (AHB to PCIe Bus Bridge) controller with a
0x100byte register space. The register layout is shared between two root complexes: 0x00–0x7f is common, 0x80–0xbf forRC_L, and 0xc0–0xff forRC_H. OnlyRC_His modeled in thisimplementation.
Quoted 21 lines
The
RC_Hbus uses bus numbers in the 0x80–0xff range instead of the standard root bus0x00. To allow the PCI subsystem to discover devices, the host bridge logic remaps the root bus number back to0x00whenever the configured bus number matches the "bus-nr" property.New MMIO callbacks are added for the H2X config space:
-aspeed_pcie_cfg_read()andaspeed_pcie_cfg_write()handle register accesses.
-aspeed_pcie_cfg_readwrite()provides configuration read/write support.
-aspeed_pcie_cfg_translate_write()handles PCIe byte-enable semantics for write operations.The reset handler initializes the H2X register block with default values as defined in the AST2600 datasheet.
Additional changes:
- Implement ASPEED PCIe root complex (TYPE_ASPEED_PCIE_RC).
- Wire up interrupt propagation viaaspeed_pcie_rc_set_irq().
- Add tracepoints for config read/write and INTx handling.Quoted 4 lines
Signed-off-by Jamin Lin <[email protected]>--- include/hw/pci-host/aspeed_pcie.h | 59 +++++ hw/pci-host/aspeed_pcie.c | 418++++++++++++++++++++++++++++++
Quoted 114 lines
hw/pci-host/trace-events | 4 + 3 files changed, 481 insertions(+)include/hw/pci-host/aspeed_pcie.h +59
-0@@ -22,6 +22,65 @@#include "hw/pci/pcie_host.h" #include "qom/object.h" +typedef struct AspeedPCIECfgTxDesc { +uint32_t desc0; +uint32_t desc1; +uint32_t desc2; +uint32_t desc3; +uint32_t wdata; +uint32_t rdata_reg; +}AspeedPCIECfgTxDesc ; + +typedef struct AspeedPCIERcRegs { +uint32_t int_en_reg; +uint32_t int_sts_reg; +}AspeedPCIERcRegs ; + +typedef struct AspeedPCIERegMap { +AspeedPCIERcRegs rc; +}AspeedPCIERegMap ; + +#define TYPE_ASPEED_PCIE_RC "aspeed.pcie-rc" +OBJECT_DECLARE_SIMPLE_TYPE (AspeedPCIERcState,ASPEED_PCIE_RC ); + +struct AspeedPCIERcState { +PCIExpressHost parent_obj; + +MemoryRegion mmio_window; +MemoryRegion io_window; +MemoryRegion mmio; +MemoryRegion io; + +uint32_t bus_nr; +char name[16 ]; + qemu_irq irq;> +}; + +/* Bridge between AHB bus and PCIe RC. */ #define +TYPE_ASPEED_PCIE_CFG "aspeed.pcie-cfg" +OBJECT_DECLARE_TYPE (AspeedPCIECfgState, AspeedPCIECfgClass, +ASPEED_PCIE_CFG ); + +struct AspeedPCIECfgState { +SysBusDevice parent_obj; + +MemoryRegion mmio; +uint32_t *regs; +uint32_t id; + +const AspeedPCIERcRegs *rc_regs; +AspeedPCIERcState rc; +}; + +struct AspeedPCIECfgClass { +SysBusDeviceClass parent_class; + +const AspeedPCIERegMap *reg_map; +const MemoryRegionOps *reg_ops; + +uint64_t rc_bus_nr; +uint64_t nr_regs; +}; +#define TYPE_ASPEED_PCIE_PHY "aspeed.pcie-phy"OBJECT_DECLARE_TYPE (AspeedPCIEPhyState, AspeedPCIEPhyClass,ASPEED_PCIE_PHY );hw/pci-host/aspeed_pcie.c +31
-0@@ -25,6 +25,422 @@#include "hw/pci/msi.h" #include "trace.h" +/* +* PCIe Root Complex (RC) +*/ + +static void aspeed_pcie_rc_set_irq (void *opaque,int irq,int level) +{ +AspeedPCIERcState *rc = (AspeedPCIERcState *) opaque; +AspeedPCIECfgState *cfg = +container_of (rc, AspeedPCIECfgState, rc); +bool intx; + +assert (irq <PCI_NUM_PINS ); + +if (level) { + cfg->regs[cfg->rc_regs->int_sts_reg] |=BIT (irq); + }else { + cfg->regs[cfg->rc_regs->int_sts_reg] &= ~BIT (irq); + } + + intx = !!(cfg->regs[cfg->rc_regs->int_sts_reg] & + cfg->regs[cfg->rc_regs->int_en_reg]); +trace_aspeed_pcie_rc_intx_set_irq (cfg->id, irq, intx); +qemu_set_irq (rc->irq, intx); +} + +static int aspeed_pcie_rc_map_irq (PCIDevice *pci_dev,int irq_num) { +return irq_num %PCI_NUM_PINS ; +} + +static void aspeed_pcie_rc_realize (DeviceState *dev,Error **errp) { +PCIExpressHost *pex =PCIE_HOST_BRIDGE (dev);
Quoted 9 lines
hw/pci-host/aspeed_pcie.c line 66
Quoted 6 lines
hw/pci-host/aspeed_pcie.c +6
-0+AspeedPCIERcState *rc =ASPEED_PCIE_RC (dev); +AspeedPCIECfgState *cfg = +container_of (rc, AspeedPCIECfgState, rc); +PCIHostState *pci =PCI_HOST_BRIDGE (dev); +SysBusDevice *sbd =SYS_BUS_DEVICE (dev); + g_autofree char *name;
g_autofreevariables should be assigned when declared.
Thanks for your review and suggestion.
Will fix it.
Quoted 12 lines
hw/pci-host/aspeed_pcie.c
Quoted 11 lines
hw/pci-host/aspeed_pcie.c +11
-0+ +/* PCI configuration space */ +pcie_host_mmcfg_init (pex,PCIE_MMCFG_SIZE_MAX ); +sysbus_init_mmio (sbd, &pex->mmio); + +/* MMIO and IO region */ +memory_region_init (&rc->mmio,OBJECT (rc),"mmio" ,UINT64_MAX ); +memory_region_init (&rc->io,OBJECT (rc),"io" ,0x10000 ); + + name =g_strdup_printf ("pcie.%d.mmio_window" , cfg->id); + memory_region_init_io(&rc->mmio_window, OBJECT(rc),
&unassigned_io_ops,
Quoted 4 lines
hw/pci-host/aspeed_pcie.c line 79
Quoted 2 lines
hw/pci-host/aspeed_pcie.c +2
-0+ OBJECT(rc), name, UINT64_MAX); + name =g_strdup_printf ("pcie.%d.ioport_window" , cfg->id);This is going to leak memory .
Will fix it.
Quoted 313 lines
hw/pci-host/aspeed_pcie.c line 78
Quoted 2 lines
hw/pci-host/aspeed_pcie.c +1
-0+ memory_region_init_io(&rc->io_window, OBJECT(rc),
&unassigned_io_ops,hw/pci-host/aspeed_pcie.c
Quoted 11 lines
hw/pci-host/aspeed_pcie.c +11
-0+ OBJECT(rc), name, 0x10000); + +memory_region_add_subregion (&rc->mmio_window,0 , &rc->mmio); +memory_region_add_subregion (&rc->io_window,0 , &rc->io); +sysbus_init_mmio (sbd, &rc->mmio_window); +sysbus_init_mmio (sbd, &rc->io_window); + +sysbus_init_irq (sbd, &rc->irq); + name =g_strdup_printf ("pcie.rc%d" , cfg->id); + pci->bus = pci_register_root_bus(dev, name, aspeed_pcie_rc_set_irq, + aspeed_pcie_rc_map_irq, rc,
&rc->mmio,hw/pci-host/aspeed_pcie.c line 90
Quoted 1 line
hw/pci-host/aspeed_pcie.c +1
-0+ &rc->io, 0, 4,
TYPE_PCIE_BUS);hw/pci-host/aspeed_pcie.c line 93
Quoted 3 lines
hw/pci-host/aspeed_pcie.c +3
-0+ pci->bus->flags |=PCI_BUS_EXTENDED_CONFIG_SPACE ; } + +static const char *aspeed_pcie_rc_root_bus_path(PCIHostState
*host_bridge,hw/pci-host/aspeed_pcie.c line 97
Quoted 1 line
hw/pci-host/aspeed_pcie.c +1
-0+ PCIBus *rootbus){
Quoted 89 lines
hw/pci-host/aspeed_pcie.c +89
-0+AspeedPCIERcState *rc =ASPEED_PCIE_RC (host_bridge); +AspeedPCIECfgState *cfg = +container_of (rc, AspeedPCIECfgState, rc); + +snprintf (rc->name,sizeof (rc->name),"%04x:%02x" , cfg->id, + rc->bus_nr); + +return rc->name; +} + +static const Property aspeed_pcie_rc_props[] = { +DEFINE_PROP_UINT32 ("bus-nr" , AspeedPCIERcState, bus_nr,0 ), }; + +static void aspeed_pcie_rc_class_init (ObjectClass *klass,const void +*data) { +PCIHostBridgeClass *hc =PCI_HOST_BRIDGE_CLASS (klass); +DeviceClass *dc =DEVICE_CLASS (klass); + + dc->desc ="ASPEED PCIe RC" ; + dc->realize = aspeed_pcie_rc_realize; + dc->fw_name ="pci" ; +set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); + + hc->root_bus_path = aspeed_pcie_rc_root_bus_path; +device_class_set_props (dc, aspeed_pcie_rc_props); + + msi_nonbroken = true; +} + +static const TypeInfo aspeed_pcie_rc_info = { + .name =TYPE_ASPEED_PCIE_RC , + .parent =TYPE_PCIE_HOST_BRIDGE , + .instance_size =sizeof (AspeedPCIERcState), + .class_init = aspeed_pcie_rc_class_init, }; + +/* +* PCIe Config +* +* AHB to PCIe Bus Bridge (H2X) +* +* On the AST2600: +* NOTE: rc_l is not supported by this model. +* - Registers 0x00 - 0x7F are shared by both PCIe0 (rc_l) and PCIe1 (rc_h). +* - Registers 0x80 - 0xBF are specific to PCIe0. +* - Registers 0xC0 - 0xFF are specific to PCIe1. +*/ + +/* AST2600 */ +REG32(H2X_CTRL, 0x00) + FIELD(H2X_CTRL, CLEAR_RX, 4, 1) +REG32(H2X_TX_CLEAR, 0x08) + FIELD(H2X_TX_CLEAR, IDLE, 0, 1) +REG32(H2X_RDATA, 0x0C) +REG32(H2X_TX_DESC0, 0x10) +REG32(H2X_TX_DESC1, 0x14) +REG32(H2X_TX_DESC2, 0x18) +REG32(H2X_TX_DESC3, 0x1C) +REG32(H2X_TX_DATA, 0x20) +REG32(H2X_TX_STS, 0x24) + FIELD(H2X_TX_STS, IDLE, 31, 1) + FIELD(H2X_TX_STS, RC_L_TX_COMP, 24, 1) + FIELD(H2X_TX_STS, RC_H_TX_COMP, 25, 1) + FIELD(H2X_TX_STS, TRIG, 0, 1) +REG32(H2X_RC_H_CTRL, 0xC0) +REG32(H2X_RC_H_INT_EN, 0xC4) +REG32(H2X_RC_H_INT_STS, 0xC8) + SHARED_FIELD(H2X_RC_INT_INTDONE, 4, 1) + SHARED_FIELD(H2X_RC_INT_INTX, 0, 4) +REG32(H2X_RC_H_RDATA, 0xCC) + +#define TLP_FMTTYPE_CFGRD0 0x04/* Configuration Read Type 0 */ +#define TLP_FMTTYPE_CFGWR0 0x44/* Configuration Write Type 0 */ +#define TLP_FMTTYPE_CFGRD1 0x05/* Configuration Read Type 1 */ +#define TLP_FMTTYPE_CFGWR1 0x45/* Configuration Write Type 1 */ + +#define PCIE_CFG_FMTTYPE_MASK (x) (((x) >> 24) & 0xff) #define +PCIE_CFG_BYTE_EN(x) ((x) & 0xf) + +static const AspeedPCIERegMap aspeed_regmap = { + .rc = { + .int_en_reg =R_H2X_RC_H_INT_EN , + .int_sts_reg =R_H2X_RC_H_INT_STS , + }, +}; + +static uint64_t aspeed_pcie_cfg_read (void *opaque,hwaddr addr, +unsigned int size) { +AspeedPCIECfgState *s =ASPEED_PCIE_CFG (opaque); +uint32_t reg = addr >>2 ;hw/pci-host/aspeed_pcie.c
Quoted 10 lines
hw/pci-host/aspeed_pcie.c +10
-0+uint32_t value =0 ; + + value = s->regs[reg]; + +trace_aspeed_pcie_cfg_read (s->id, addr, value); + +return value; +} + +static void aspeed_pcie_cfg_translate_write(uint8_t byte_en, uint32_t*addr,
hw/pci-host/aspeed_pcie.c line 194
Quoted 1 line
hw/pci-host/aspeed_pcie.c +1
-0+uint64_t *val, int*len)
hw/pci-host/aspeed_pcie.c
Quoted 10 lines
hw/pci-host/aspeed_pcie.c +10
-0+{ +uint64_t packed_val =0 ; +int first_bit =-1 ; +int index =0 ; +int i; + + *len =ctpop8 (byte_en); + +if (*len ==0 || *len >4 ) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid byte enable:0x%x\n",
hw/pci-host/aspeed_pcie.c
Quoted 9 lines
hw/pci-host/aspeed_pcie.c +9
-0+ __func__, byte_en); +return ; + } + +/* Special case: full 4-byte write must be 4-byte aligned */ +if (byte_en ==0x0f ) { +if ((*addr &0x3 ) !=0 ) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: 4-byte write not 4-byte aligned:addr=0x%x\n",
Quoted 38 lines
hw/pci-host/aspeed_pcie.c +38
-0+ __func__, *addr); +return ; + } + *val &=0xffffffffULL ; +return ; + } + +for (i =0 ; i <4 ; i++) { +if (byte_en & (1 << i)) { +if (first_bit <0 ) { + first_bit = i; + } + packed_val |= ((*val >> (i *8 )) &0xff ) << (index *8 ); + index++; + } + } + + *addr += first_bit; + *val = packed_val; +} + +static void aspeed_pcie_cfg_readwrite (AspeedPCIECfgState *s, +const AspeedPCIECfgTxDesc +*desc) { +AspeedPCIERcState *rc = &s->rc; +PCIHostState *pci; +uint32_t cfg_addr; +PCIDevice *pdev; +uint32_t offset; +uint8_t byte_en; +bool is_write; +uint8_t devfn; +uint64_t val; +uint8_t bus; +int len; + + val = ~0 ; + is_write = !!(desc->desc0 &BIT (30 ));hw/pci-host/aspeed_pcie.c
Quoted 10 lines
hw/pci-host/aspeed_pcie.c +10
-0+ cfg_addr = desc->desc2; + + bus = (cfg_addr >>24 ) &0xff ; + devfn = (cfg_addr >>16 ) &0xff ; + offset = cfg_addr &0xffc ; + + pci =PCI_HOST_BRIDGE (rc); + +/* +* On the AST2600, the RC_H bus number range from 0x80 to 0xFF, with the
hw/pci-host/aspeed_pcie.c line 262
Quoted 1 line
hw/pci-host/aspeed_pcie.c +1
-0+* root device and root port assigned to bus 0x80 instead of the standard
hw/pci-host/aspeed_pcie.c line 263
Quoted 1 line
hw/pci-host/aspeed_pcie.c +1
-0+* 0x00. To allow the PCI subsystem to correctly discover devices on the
Quoted 9 lines
hw/pci-host/aspeed_pcie.c +9
-0+* root bus, bus 0x80 is remapped to 0x00. +*/ +if (bus == rc->bus_nr) { + bus =0 ; + } + + pdev =pci_find_device (pci->bus, bus, devfn); +if (!pdev) { + s->regs[desc->rdata_reg] = ~0 ;hw/pci-host/aspeed_pcie.c
Quoted 10 lines
hw/pci-host/aspeed_pcie.c +10
-0+ goto out; + } + +switch (PCIE_CFG_FMTTYPE_MASK (desc->desc0)) { +case TLP_FMTTYPE_CFGWR0 : +case TLP_FMTTYPE_CFGWR1 : + byte_en =PCIE_CFG_BYTE_EN (desc->desc1); + val = desc->wdata; +aspeed_pcie_cfg_translate_write (byte_en, &offset, &val, &len); + pci_host_config_write_common(pdev, offset,
pci_config_size(pdev),hw/pci-host/aspeed_pcie.c
Quoted 6 lines
hw/pci-host/aspeed_pcie.c +6
-0+ val, len); +break ; +case TLP_FMTTYPE_CFGRD0 : +case TLP_FMTTYPE_CFGRD1 : + val = pci_host_config_read_common(pdev, offset, + pci_config_size(pdev),4);
hw/pci-host/aspeed_pcie.c
Quoted 4 lines
hw/pci-host/aspeed_pcie.c +4
-0+ s->regs[desc->rdata_reg] = val; +break ; +default : + qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid CFG type.DESC0=0x%x\n",
hw/pci-host/aspeed_pcie.c
Quoted 5 lines
hw/pci-host/aspeed_pcie.c +5
-0+ __func__, desc->desc0); + } + +out: + trace_aspeed_pcie_cfg_rw(s->id, is_write ? "write" : "read", bus,devfn,
hw/pci-host/aspeed_pcie.c line 300
Quoted 3 lines
hw/pci-host/aspeed_pcie.c +3
-0+ cfg_addr, val); } + +static void aspeed_pcie_cfg_write(void *opaque, hwaddr addr, uint64_tdata,
Quoted 29 lines
hw/pci-host/aspeed_pcie.c +29
-0+ unsigned int size) { +AspeedPCIECfgState *s =ASPEED_PCIE_CFG (opaque); +AspeedPCIECfgTxDesc desc; +uint32_t reg = addr >>2 ; +uint32_t rc_reg; + +trace_aspeed_pcie_cfg_write (s->id, addr, data); + +switch (reg) { +case R_H2X_CTRL : +if (data &R_H2X_CTRL_CLEAR_RX_MASK ) { + s->regs[R_H2X_RDATA ] = ~0 ; + } +break ; +case R_H2X_TX_CLEAR : +if (data &R_H2X_TX_CLEAR_IDLE_MASK ) { + s->regs[R_H2X_TX_STS ] &= ~R_H2X_TX_STS_IDLE_MASK ; + } +break ; +case R_H2X_TX_STS : +if (data &R_H2X_TX_STS_TRIG_MASK ) { + desc.desc0 = s->regs[R_H2X_TX_DESC0 ]; + desc.desc1 = s->regs[R_H2X_TX_DESC1 ]; + desc.desc2 = s->regs[R_H2X_TX_DESC2 ]; + desc.desc3 = s->regs[R_H2X_TX_DESC3 ]; + desc.wdata = s->regs[R_H2X_TX_DATA ]; + desc.rdata_reg =R_H2X_RC_H_RDATA ; +aspeed_pcie_cfg_readwrite (s, &desc); + rc_reg = s->rc_regs->int_sts_reg;hw/pci-host/aspeed_pcie.c
Quoted 10 lines
hw/pci-host/aspeed_pcie.c +10
-0+ s->regs[rc_reg] |=H2X_RC_INT_INTDONE_MASK ; + s->regs[R_H2X_TX_STS ] |= +BIT (R_H2X_TX_STS_RC_H_TX_COMP_SHIFT ); + s->regs[R_H2X_TX_STS ] |=R_H2X_TX_STS_IDLE_MASK ; + } +break ; +/* preserve INTx status */ +case R_H2X_RC_H_INT_STS : +if (data &H2X_RC_INT_INTDONE_MASK ) { + s->regs[R_H2X_TX_STS] &=~R_H2X_TX_STS_RC_H_TX_COMP_MASK;
Quoted 32 lines
hw/pci-host/aspeed_pcie.c +32
-0+ } + s->regs[reg] &= ~data |H2X_RC_INT_INTX_MASK ; +break ; +default : + s->regs[reg] = data; +break ; + } +} + +static const MemoryRegionOps aspeed_pcie_cfg_ops = { + .read = aspeed_pcie_cfg_read, + .write = aspeed_pcie_cfg_write, + .endianness =DEVICE_LITTLE_ENDIAN , + .valid = { + .min_access_size =1 , + .max_access_size =4 , + }, +}; + +static void aspeed_pcie_cfg_instance_init (Object *obj) { +AspeedPCIECfgState *s =ASPEED_PCIE_CFG (obj); + +object_initialize_child (obj,"rc" , &s->rc,TYPE_ASPEED_PCIE_RC ); + +return ; +} + +static void aspeed_pcie_cfg_reset (DeviceState *dev) { +AspeedPCIECfgState *s =ASPEED_PCIE_CFG (dev); +AspeedPCIECfgClass *apc =ASPEED_PCIE_CFG_GET_CLASS (s); + +memset (s->regs,0 , apc->nr_regs <<2 ); }
Quoted 8 lines
hw/pci-host/aspeed_pcie.c line 389
Quoted 6 lines
hw/pci-host/aspeed_pcie.c +6
-0+ +static void aspeed_pcie_cfg_realize (DeviceState *dev,Error **errp) { +SysBusDevice *sbd =SYS_BUS_DEVICE (dev); +AspeedPCIECfgState *s =ASPEED_PCIE_CFG (dev); +AspeedPCIECfgClass *apc =ASPEED_PCIE_CFG_GET_CLASS (s); + g_autofree char *name;name should be assigned.
Will fix it.
Quoted 92 lines
Thanks,
C.
Quoted 68 lines
hw/pci-host/aspeed_pcie.c +53
-0+ + s->rc_regs = &apc->reg_map->rc; + s->regs =g_new (uint32_t, apc->nr_regs); + name =g_strdup_printf (TYPE_ASPEED_PCIE_CFG ".regs.%d" , s->id); +memory_region_init_io (&s->mmio,OBJECT (s), apc->reg_ops, s, name, + apc->nr_regs <<2 ); +sysbus_init_mmio (sbd, &s->mmio); + +object_property_set_int (OBJECT (&s->rc),"bus-nr" , + apc->rc_bus_nr, + &error_abort); +if (!sysbus_realize (SYS_BUS_DEVICE (&s->rc), errp)) { +return ; + } +} + +static void aspeed_pcie_cfg_unrealize (DeviceState *dev) { +AspeedPCIECfgState *s =ASPEED_PCIE_CFG (dev); + +g_free (s->regs); + s->regs =NULL ; +} + +static const Property aspeed_pcie_cfg_props[] = { +DEFINE_PROP_UINT32 ("id" , AspeedPCIECfgState, id,0 ), }; + +static void aspeed_pcie_cfg_class_init (ObjectClass *klass,const void +*data) { +DeviceClass *dc =DEVICE_CLASS (klass); +AspeedPCIECfgClass *apc =ASPEED_PCIE_CFG_CLASS (klass); + + dc->desc ="ASPEED PCIe Config" ; + dc->realize = aspeed_pcie_cfg_realize; + dc->unrealize = aspeed_pcie_cfg_unrealize; +device_class_set_legacy_reset (dc, aspeed_pcie_cfg_reset); +device_class_set_props (dc, aspeed_pcie_cfg_props); + + apc->reg_ops = &aspeed_pcie_cfg_ops; + apc->reg_map = &aspeed_regmap; + apc->nr_regs =0x100 >>2 ; + apc->rc_bus_nr =0x80 ; +} + +static const TypeInfo aspeed_pcie_cfg_info = { + .name =TYPE_ASPEED_PCIE_CFG , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_init = aspeed_pcie_cfg_instance_init, + .instance_size =sizeof (AspeedPCIECfgState), + .class_init = aspeed_pcie_cfg_class_init, + .class_size =sizeof (AspeedPCIECfgClass), }; +/* * PCIe PHY * @@ -150,6 +566,8 @@ static const TypeInfo aspeed_pcie_phy_info = {static void aspeed_pcie_register_types (void ) { +type_register_static (&aspeed_pcie_rc_info); +type_register_static (&aspeed_pcie_cfg_info);type_register_static (&aspeed_pcie_phy_info); }hw/pci-host/trace-events index renamed from hw/pci-host/trace-events +0
-03438516756..2584ea56e2 100644
hw/pci-host/trace-events line 4
Quoted 4 lines
hw/pci-host/trace-events +1
-0@@ -1,6 +1,10 @@ # See docs/devel/tracing.rst for syntax documentation. # aspeed_pcie.c +aspeed_pcie_rc_intx_set_irq(uint32_t id, int num, int level) "%d: num %dset IRQ leve %d"
hw/pci-host/trace-events
Quoted 7 lines
hw/pci-host/trace-events +6
-0+aspeed_pcie_cfg_read(uint32_t id, uint64_t addr, uint32_t value) "%d: +addr 0x%" PRIx64 " value 0x%" PRIx32 aspeed_pcie_cfg_write(uint32_t +id, uint64_t addr, uint32_t value) "%d: addr 0x%" PRIx64 " value 0x%" +PRIx32 aspeed_pcie_cfg_rw(uint32_t id, const char *dir, uint8_t bus, +uint8_t devfn, uint64_t addr, uint64_t data) "%d: %s bus:0x%x +devfn:0x%x addr 0x%" PRIx64 " data 0x%" PRIx64 aspeed_pcie_phy_read(uint32_t id, uint64_t addr, uint32_t value) "%d:addr 0x%" PRIx64 " value 0x%" PRIx32
Quoted 3 lines
aspeed_pcie_phy_write(uint32_t id, uint64_t addr, uint32_t value)
"%d: addr 0x%" PRIx64 " value 0x%" PRIx32
PATCH v3 4/14 hw/pci-host/aspeed: Add AST2600 PCIe Root Device support
In reply to Jamin Lin viaIntroduce a PCIe Root Device for AST2600 platform.
The AST2600 root complex exposes a PCIe root device at bus 80, devfn 0. This root device is implemented as a child of the PCIe RC and modeled as a host bridge PCI function (class_id = PCI_CLASS_BRIDGE_HOST).
Key changes:
- Add a new device type "aspeed.pcie-root-device".
- Instantiate the root device as part of AspeedPCIERcState.
- Initialize it during RC realize() and attach it to the root bus.
- Mark the root device as non-user-creatable.
- Add RC boolean property "has-rd" to control whether the Root Device is created (platforms can enable/disable it as needed).
Note: Only AST2600 implements this PCIe root device. AST2700 does not provide one.
--- include/hw/pci-host/aspeed_pcie.h | 11 ++++++ hw/pci-host/aspeed_pcie.c | 56 +++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+)
include/hw/pci-host/aspeed_pcie.h +11 -0
@@ -40,6 +40,13 @@ typedef struct AspeedPCIERegMap {AspeedPCIERcRegs rc; } AspeedPCIERegMap; +#define TYPE_ASPEED_PCIE_ROOT_DEVICE "aspeed.pcie-root-device" +OBJECT_DECLARE_SIMPLE_TYPE (AspeedPCIERootDeviceState,ASPEED_PCIE_ROOT_DEVICE ); + +struct AspeedPCIERootDeviceState { +PCIBridge parent_obj; +}; +#define TYPE_ASPEED_PCIE_RC "aspeed.pcie-rc"OBJECT_DECLARE_SIMPLE_TYPE (AspeedPCIERcState,ASPEED_PCIE_RC );
@@ -53,7 +60,10 @@ struct AspeedPCIERcState {uint32_t bus_nr;char name[16 ]; +bool has_rd;qemu_irq irq; + +AspeedPCIERootDeviceState root_device; };/* Bridge between AHB bus and PCIe RC. */
@@ -79,6 +89,7 @@ struct AspeedPCIECfgClass {uint64_t rc_bus_nr;uint64_t nr_regs; +bool rc_has_rd; };#define TYPE_ASPEED_PCIE_PHY "aspeed.pcie-phy"
hw/pci-host/aspeed_pcie.c +56 -0
92 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v3 5/14 hw/pci-host/aspeed: Add AST2600 PCIe Root Port and make address configurable
In reply to Jamin Lin viaIntroduce an ASPEED PCIe Root Port and wire it under the RC. The root port is modeled as TYPE_ASPEED_PCIE_ROOT_PORT (subclass of TYPE_PCIE_ROOT_PORT).
Key changes:
- Add TYPE_ASPEED_PCIE_ROOT_PORT (PCIESlot-based) with vendor/device IDs and AER capability offset.
- Extend AspeedPCIERcState to embed a root_port instance and a configurable rp_addr.
- Add "rp-addr" property to the RC to place the root port at a specific devfn on the root bus.
- Set the root port's "chassis" property to ensure a unique chassis per RC.
- Extend AspeedPCIECfgClass with rc_rp_addr defaulting to PCI_DEVFN(8,0).
Rationale:
- AST2600 places the root port at 80:08.0 (bus 0x80, dev 8, fn 0).
- AST2700 must place the root port at 00:00.0, and it supports three RCs. Each root port must therefore be uniquely identifiable; uses the PCIe "chassis" ID for that.
- Providing a configurable "rp-addr" lets platforms select the correct devfn per SoC family, while the "chassis" property ensures uniqueness across multiple RC instances on AST2700.
--- include/hw/pci-host/aspeed_pcie.h | 11 +++++++ hw/pci-host/aspeed_pcie.c | 50 +++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+)
include/hw/pci-host/aspeed_pcie.h +11 -0
@@ -20,6 +20,7 @@#include "hw/sysbus.h" #include "hw/pci/pci_bridge.h" #include "hw/pci/pcie_host.h" +#include "hw/pci/pcie_port.h" #include "qom/object.h" typedef struct AspeedPCIECfgTxDesc {
@@ -40,6 +41,13 @@ typedef struct AspeedPCIERegMap {AspeedPCIERcRegs rc; } AspeedPCIERegMap; +#define TYPE_ASPEED_PCIE_ROOT_PORT "aspeed.pcie-root-port" +OBJECT_DECLARE_SIMPLE_TYPE(AspeedPCIERootPortState, ASPEED_PCIE_ROOT_PORT) + +typedef struct AspeedPCIERootPortState { +PCIESlot parent_obj; +}AspeedPCIERootPortState ; +#define TYPE_ASPEED_PCIE_ROOT_DEVICE "aspeed.pcie-root-device"OBJECT_DECLARE_SIMPLE_TYPE (AspeedPCIERootDeviceState,ASPEED_PCIE_ROOT_DEVICE );
@@ -58,12 +66,14 @@ struct AspeedPCIERcState {MemoryRegion mmio;MemoryRegion io; +uint32_t rp_addr;uint32_t bus_nr;char name[16 ];bool has_rd;qemu_irq irq;AspeedPCIERootDeviceState root_device; +AspeedPCIERootPortState root_port; };/* Bridge between AHB bus and PCIe RC. */
@@ -87,6 +97,7 @@ struct AspeedPCIECfgClass {const AspeedPCIERegMap *reg_map;const MemoryRegionOps *reg_ops; +uint32_t rc_rp_addr;uint64_t rc_bus_nr;uint64_t nr_regs;bool rc_has_rd;
hw/pci-host/aspeed_pcie.c +50 -0
101 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v3 6/14 hw/pci-host/aspeed: Add MSI support and per-RC IOMMU address space
In reply to Jamin Lin viaAdd MSI support to the ASPEED PCIe RC/Config model and introduce a per-RC "IOMMU root" address space to correctly route MSI writes.
On AST2700 all RCs use the same MSI address, and the MSI target is PCI system memory (not normal DRAM). If the MSI window were mapped into real system RAM, an endpoint's write could be observed by other RCs and spuriously trigger their interrupts. To avoid this, each RC now owns an isolated IOMMU root AddressSpace that contains a small MSI window and a DRAM alias region for normal DMA.
The MSI window captures writes and asserts the RC IRQ. MSI status bits are tracked in new H2X RC_H registers (R_H2X_RC_H_MSI_EN{0,1} and R_H2X_RC_H_MSI_STS{0,1}). Clearing all status bits drops the IRQ. The default MSI address is set to 0x1e77005c and can be overridden via the msi-addr property.
This keeps MSI traffic contained within each RC while preserving normal DMA to system DRAM. It enables correct MSI/MSI-X interrupt delivery when multiple RCs use the same MSI target address.
--- include/hw/pci-host/aspeed_pcie.h | 10 +++ hw/pci-host/aspeed_pcie.c | 129 ++++++++++++++++++++++++++++++ hw/pci-host/trace-events | 3 + 3 files changed, 142 insertions(+)
include/hw/pci-host/aspeed_pcie.h +10 -0
@@ -35,6 +35,8 @@ typedef struct AspeedPCIECfgTxDesc {typedef struct AspeedPCIERcRegs {uint32_t int_en_reg;uint32_t int_sts_reg; +uint32_t msi_sts0_reg; +uint32_t msi_sts1_reg; }AspeedPCIERcRegs ; typedef struct AspeedPCIERegMap {
@@ -61,11 +63,18 @@ OBJECT_DECLARE_SIMPLE_TYPE(AspeedPCIERcState, ASPEED_PCIE_RC);struct AspeedPCIERcState {PCIExpressHost parent_obj; +MemoryRegion iommu_root; +AddressSpace iommu_as; +MemoryRegion dram_alias; +MemoryRegion *dram_mr;MemoryRegion mmio_window; +MemoryRegion msi_window;MemoryRegion io_window;MemoryRegion mmio;MemoryRegion io; +uint64_t dram_base; +uint32_t msi_addr;uint32_t rp_addr;uint32_t bus_nr;char name[16 ];
@@ -97,6 +106,7 @@ struct AspeedPCIECfgClass {const AspeedPCIERegMap *reg_map;const MemoryRegionOps *reg_ops; +uint32_t rc_msi_addr;uint32_t rc_rp_addr;uint64_t rc_bus_nr;uint64_t nr_regs;
hw/pci-host/aspeed_pcie.c +129 -0
189 lines not on this page · raw message
hw/pci-host/trace-events +3 -0
@@ -2,6 +2,9 @@ # aspeed_pcie.c aspeed_pcie_rc_intx_set_irq(uint32_t id, int num, int level) "%d: num %d set IRQ leve %d" +aspeed_pcie_rc_msi_notify(uint32_t id, uint64_t addr, uint64_t data) "%d: 0x%" PRIx64 " data 0x%" PRIx64 +aspeed_pcie_rc_msi_set_irq(uint32_t id, uint64_t unm, int level) "%d: num 0x%" PRIx64 " set IRQ level %d" +aspeed_pcie_rc_msi_clear_irq(uint32_t id, int level) "%d: clear IRQ level %d" aspeed_pcie_cfg_read(uint32_t id, uint64_t addr, uint32_t value) "%d: addr 0x%" PRIx64 " value 0x%" PRIx32 aspeed_pcie_cfg_write(uint32_t id, uint64_t addr, uint32_t value) "%d: addr 0x%" PRIx64 " value 0x%" PRIx32 aspeed_pcie_cfg_rw(uint32_t id, const char *dir, uint8_t bus, uint8_t devfn, uint64_t addr, uint64_t data) "%d: %s bus:0x%x devfn:0x%x addr 0x%" PRIx64 " data 0x%" PRIx64
Signature · 1 line
2.43.0
PATCH v3 7/14 hw/arm/aspeed: Wire up PCIe devices in SoC model
In reply to Jamin Lin viaAdd PCIe controller and PHY instances to the Aspeed SoC state and device enum. This prepares the SoC model to host PCIe Root Complexes and their associated PHYs.
Although the AST2600 supports only a single Root Complex, the AST2700 provides three Root Complexes. For this reason, the model defines arrays of three PCIe config/PHY objects and enumerates three PCIe device IDs so that both SoCs can be represented consistently.
--- include/hw/arm/aspeed_soc.h | 13 +++++++++++++ 1 file changed, 13 insertions(+)
include/hw/arm/aspeed_soc.h +13 -0
@@ -37,6 +37,7 @@#include "qom/object.h" #include "hw/misc/aspeed_lpc.h" #include "hw/misc/unimp.h" +#include "hw/pci-host/aspeed_pcie.h" #include "hw/misc/aspeed_peci.h" #include "hw/fsi/aspeed_apb2opb.h" #include "hw/char/serial-mm.h"
@@ -49,6 +50,7 @@#define ASPEED_MACS_NUM 4#define ASPEED_UARTS_NUM 13#define ASPEED_JTAG_NUM 2 +#define ASPEED_PCIE_NUM 3struct AspeedSoCState {DeviceState parent;
@@ -87,6 +89,8 @@ struct AspeedSoCState {AspeedSDHCIState sdhci;AspeedSDHCIState emmc;AspeedLPCState lpc; +AspeedPCIECfgState pcie[ASPEED_PCIE_NUM ]; +AspeedPCIEPhyState pcie_phy[ASPEED_PCIE_NUM ];AspeedPECIState peci;SerialMM uart[ASPEED_UARTS_NUM ];Clock *sysclk;
@@ -254,6 +258,15 @@ enum {ASPEED_DEV_LPC ,ASPEED_DEV_IBT ,ASPEED_DEV_I2C , +ASPEED_DEV_PCIE0 , +ASPEED_DEV_PCIE1 , +ASPEED_DEV_PCIE2 , +ASPEED_DEV_PCIE_PHY0 , +ASPEED_DEV_PCIE_PHY1 , +ASPEED_DEV_PCIE_PHY2 , +ASPEED_DEV_PCIE_MMIO0 , +ASPEED_DEV_PCIE_MMIO1 , +ASPEED_DEV_PCIE_MMIO2 ,ASPEED_DEV_PECI ,ASPEED_DEV_ETH1 , ASPEED_DEV_ETH2,
Signature · 1 line
2.43.0
PATCH v3 8/14 hw/arm/aspeed_ast2600: Add PCIe RC support (RC_H only)
In reply to Jamin Lin viaWire up the PCIe Root Complex in the AST2600 SoC model.
According to the AST2600 firmware driver, only the RC_H controller is supported. RC_H uses PCIe PHY1 at 0x1e6ed200 and the PCIe config (H2X) register block at 0x1e770000. The RC_H MMIO window is mapped at 0x70000000–0x80000000. RC_L is not modeled. The RC_H interrupt is wired to IRQ 168. Only RC_H is realized and connected to the SoC interrupt controller.
The SoC integration initializes PCIe PHY1, instantiates a single RC instance, wires its MMIO regions, and connects its interrupt. An alias region is added to map the RC MMIO space into the guest physical address space.
This provides enough functionality for firmware and guest drivers to discover and use the AST2600 RC_H Root Complex while leaving RC_L unimplemented.
--- hw/arm/aspeed_ast2600.c | 79 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+)
hw/arm/aspeed_ast2600.c +79 -0
@@ -48,11 +48,13 @@ static const hwaddr aspeed_soc_ast2600_memmap[] = { [ASPEED_DEV_XDMA] = 0x1E6E7000, [ASPEED_DEV_ADC] = 0x1E6E9000, [ASPEED_DEV_DP] = 0x1E6EB000, + [ASPEED_DEV_PCIE_PHY1] = 0x1E6ED200, [ASPEED_DEV_SBC] = 0x1E6F2000, [ASPEED_DEV_EMMC_BC] = 0x1E6f5000, [ASPEED_DEV_VIDEO] = 0x1E700000, [ASPEED_DEV_SDHCI] = 0x1E740000, [ASPEED_DEV_EMMC] = 0x1E750000, + [ASPEED_DEV_PCIE0] = 0x1E770000, [ASPEED_DEV_GPIO] = 0x1E780000, [ASPEED_DEV_GPIO_1_8V] = 0x1E780800, [ASPEED_DEV_RTC] = 0x1E781000,
@@ -79,6 +81,7 @@ static const hwaddr aspeed_soc_ast2600_memmap[] = { [ASPEED_DEV_FSI1] = 0x1E79B000, [ASPEED_DEV_FSI2] = 0x1E79B100, [ASPEED_DEV_I3C] = 0x1E7A0000, + [ASPEED_DEV_PCIE_MMIO1] = 0x70000000, [ASPEED_DEV_SDRAM] = 0x80000000, };
@@ -127,6 +130,7 @@ static const int aspeed_soc_ast2600_irqmap[] = { [ASPEED_DEV_LPC] = 35, [ASPEED_DEV_IBT] = 143, [ASPEED_DEV_I2C] = 110, /* 110 -> 125 */ + [ASPEED_DEV_PCIE0] = 168, [ASPEED_DEV_PECI] = 38, [ASPEED_DEV_ETH1] = 2, [ASPEED_DEV_ETH2] = 3,
@@ -191,6 +195,10 @@ static void aspeed_soc_ast2600_init(Object *obj)snprintf (typename,sizeof (typename),"aspeed.i2c-%s" , socname);object_initialize_child (obj,"i2c" , &s->i2c, typename); +object_initialize_child (obj,"pcie-cfg" , &s->pcie[0 ],TYPE_ASPEED_PCIE_CFG ); +object_initialize_child (obj,"pcie-phy[*]" , &s->pcie_phy[0 ], +TYPE_ASPEED_PCIE_PHY ); +object_initialize_child (obj,"peci" , &s->peci,TYPE_ASPEED_PECI );snprintf (typename,sizeof (typename),"aspeed.fmc-%s" , socname);
@@ -285,6 +293,72 @@ static uint64_t aspeed_calc_affinity(int cpu)return (0xf <<ARM_AFF1_SHIFT ) | cpu; } +/* +* PCIe Root Complex (RC) +* +* H2X register space (single block 0x00-0xFF): +* 0x00-0x7F : shared by RC_L (PCIe0) and RC_H (PCIe1) +* 0x80-0xBF : RC_L only +* 0xC0-0xFF : RC_H only +* +* Model scope / limitations: +* - Firmware supports RC_H only; this QEMU model does not support RC_L. +* - RC_H uses PHY1 and the MMIO window [0x70000000, 0x80000000] +* (aka MMIO1). +* +* Indexing convention (this model): +* - Expose a single logical instance at index 0. +* - pcie[0] -> hardware RC_H (PCIe1) +* - phy[0] -> hardware PHY1 +* - mmio.0 -> guest address range MMIO1: 0x70000000-0x80000000 +* - RC_L / PCIe0 is not created and mapped. +*/ +static bool aspeed_soc_ast2600_pcie_realize (DeviceState *dev,Error **errp) +{ +Aspeed2600SoCState *a =ASPEED2600_SOC (dev); +AspeedSoCState *s =ASPEED_SOC (dev); +AspeedSoCClass *sc =ASPEED_SOC_GET_CLASS (s); + g_autofree char *name = NULL; +MemoryRegion *mmio_alias; +MemoryRegion *mmio_mr; +qemu_irq irq; + +if (!sysbus_realize (SYS_BUS_DEVICE (&s->pcie_phy[0 ]), errp)) { +return false; + } +aspeed_mmio_map (s,SYS_BUS_DEVICE (&s->pcie_phy[0 ]),0 , + sc->memmap[ASPEED_DEV_PCIE_PHY1 ]); + +object_property_set_int (OBJECT (&s->pcie[0 ]),"dram-base" , + sc->memmap[ASPEED_DEV_SDRAM ], + &error_abort); +object_property_set_link (OBJECT (&s->pcie[0 ]),"dram" ,OBJECT (s->dram_mr), + &error_abort); +if (!sysbus_realize (SYS_BUS_DEVICE (&s->pcie[0 ]), errp)) { +return false; + } +aspeed_mmio_map (s,SYS_BUS_DEVICE (&s->pcie[0 ]),0 , + sc->memmap[ASPEED_DEV_PCIE0 ]); + + irq =qdev_get_gpio_in (DEVICE (&a->a7mpcore), + sc->irqmap[ASPEED_DEV_PCIE0 ]); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->pcie[0 ].rc),0 , irq); + + name =g_strdup_printf ("aspeed.pcie-mmio.0" ); + + mmio_alias =g_new0 (MemoryRegion,1 ); + mmio_mr =sysbus_mmio_get_region (SYS_BUS_DEVICE (&s->pcie[0 ].rc),1 ); + +memory_region_init_alias (mmio_alias,OBJECT (&s->pcie[0 ].rc), name, + mmio_mr, sc->memmap[ASPEED_DEV_PCIE_MMIO1 ], +0x10000000 ); +memory_region_add_subregion (s->memory, + sc->memmap[ASPEED_DEV_PCIE_MMIO1 ], + mmio_alias); + +return true; +} +static void aspeed_soc_ast2600_realize (DeviceState *dev,Error **errp) {int i;
@@ -438,6 +512,11 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)sysbus_connect_irq (SYS_BUS_DEVICE (&s->peci),0 ,aspeed_soc_get_irq (s,ASPEED_DEV_PECI )); +/* PCIe Root Complex (RC) */ +if (!aspeed_soc_ast2600_pcie_realize (dev, errp)) { +return ; + } +/* FMC, The number of CS is set at the board level */ object_property_set_link (OBJECT (&s->fmc),"dram" ,OBJECT (s->dram_mr), &error_abort);
Signature · 1 line
2.43.0
Re: [SPAM] [PATCH v3 08/14] hw/arm/aspeed_ast2600: Add PCIe RC support (RC_H only)
Quoted 114 lines · Jamin Lin
Wire up the PCIe Root Complex in the AST2600 SoC model.
According to the AST2600 firmware driver, only the
RC_Hcontroller is supported.RC_Huses PCIe PHY1 at0x1e6ed200and the PCIe config (H2X) register block at0x1e770000. TheRC_HMMIO window is mapped at 0x70000000–0x80000000.RC_Lis not modeled. TheRC_Hinterrupt is wired to IRQ 168. OnlyRC_His realized and connected to the SoC interrupt controller.The SoC integration initializes PCIe PHY1, instantiates a single RC instance, wires its MMIO regions, and connects its interrupt. An alias region is added to map the RC MMIO space into the guest physical address space.
This provides enough functionality for firmware and guest drivers to discover and use the AST2600
RC_HRoot Complex while leavingRC_Lunimplemented.Signed-off-by Jamin Lin <[email protected]>--- hw/arm/aspeed_ast2600.c | 79 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+)hw/arm/aspeed_ast2600.c +50
-0@@ -48,11 +48,13 @@ static const hwaddr aspeed_soc_ast2600_memmap[] = { [ASPEED_DEV_XDMA] = 0x1E6E7000, [ASPEED_DEV_ADC] = 0x1E6E9000, [ASPEED_DEV_DP] = 0x1E6EB000, + [ASPEED_DEV_PCIE_PHY1] = 0x1E6ED200, [ASPEED_DEV_SBC] = 0x1E6F2000, [ASPEED_DEV_EMMC_BC] = 0x1E6f5000, [ASPEED_DEV_VIDEO] = 0x1E700000, [ASPEED_DEV_SDHCI] = 0x1E740000, [ASPEED_DEV_EMMC] = 0x1E750000, + [ASPEED_DEV_PCIE0] = 0x1E770000, [ASPEED_DEV_GPIO] = 0x1E780000, [ASPEED_DEV_GPIO_1_8V] = 0x1E780800, [ASPEED_DEV_RTC] = 0x1E781000,@@ -79,6 +81,7 @@ static const hwaddr aspeed_soc_ast2600_memmap[] = { [ASPEED_DEV_FSI1] = 0x1E79B000, [ASPEED_DEV_FSI2] = 0x1E79B100, [ASPEED_DEV_I3C] = 0x1E7A0000, + [ASPEED_DEV_PCIE_MMIO1] = 0x70000000, [ASPEED_DEV_SDRAM] = 0x80000000, };@@ -127,6 +130,7 @@ static const int aspeed_soc_ast2600_irqmap[] = { [ASPEED_DEV_LPC] = 35, [ASPEED_DEV_IBT] = 143, [ASPEED_DEV_I2C] = 110, /* 110 -> 125 */ + [ASPEED_DEV_PCIE0] = 168, [ASPEED_DEV_PECI] = 38, [ASPEED_DEV_ETH1] = 2, [ASPEED_DEV_ETH2] = 3,@@ -191,6 +195,10 @@ static void aspeed_soc_ast2600_init(Object *obj)snprintf (typename,sizeof (typename),"aspeed.i2c-%s" , socname);object_initialize_child (obj,"i2c" , &s->i2c, typename); +object_initialize_child (obj,"pcie-cfg" , &s->pcie[0 ],TYPE_ASPEED_PCIE_CFG ); +object_initialize_child (obj,"pcie-phy[*]" , &s->pcie_phy[0 ], +TYPE_ASPEED_PCIE_PHY ); +object_initialize_child (obj,"peci" , &s->peci,TYPE_ASPEED_PECI );snprintf (typename,sizeof (typename),"aspeed.fmc-%s" , socname);@@ -285,6 +293,72 @@ static uint64_t aspeed_calc_affinity(int cpu)return (0xf <<ARM_AFF1_SHIFT ) | cpu; } +/* +* PCIe Root Complex (RC) +* +* H2X register space (single block 0x00-0xFF): +* 0x00-0x7F : shared by RC_L (PCIe0) and RC_H (PCIe1) +* 0x80-0xBF : RC_L only +* 0xC0-0xFF : RC_H only +* +* Model scope / limitations: +* - Firmware supports RC_H only; this QEMU model does not support RC_L. +* - RC_H uses PHY1 and the MMIO window [0x70000000, 0x80000000] +* (aka MMIO1). +* +* Indexing convention (this model): +* - Expose a single logical instance at index 0. +* - pcie[0] -> hardware RC_H (PCIe1) +* - phy[0] -> hardware PHY1 +* - mmio.0 -> guest address range MMIO1: 0x70000000-0x80000000 +* - RC_L / PCIe0 is not created and mapped. +*/ +static bool aspeed_soc_ast2600_pcie_realize (DeviceState *dev,Error **errp) +{ +Aspeed2600SoCState *a =ASPEED2600_SOC (dev); +AspeedSoCState *s =ASPEED_SOC (dev); +AspeedSoCClass *sc =ASPEED_SOC_GET_CLASS (s); + g_autofree char *name = NULL; +MemoryRegion *mmio_alias; +MemoryRegion *mmio_mr; +qemu_irq irq; + +if (!sysbus_realize (SYS_BUS_DEVICE (&s->pcie_phy[0 ]), errp)) { +return false; + } +aspeed_mmio_map (s,SYS_BUS_DEVICE (&s->pcie_phy[0 ]),0 , + sc->memmap[ASPEED_DEV_PCIE_PHY1 ]); + +object_property_set_int (OBJECT (&s->pcie[0 ]),"dram-base" , + sc->memmap[ASPEED_DEV_SDRAM ], + &error_abort); +object_property_set_link (OBJECT (&s->pcie[0 ]),"dram" ,OBJECT (s->dram_mr), + &error_abort); +if (!sysbus_realize (SYS_BUS_DEVICE (&s->pcie[0 ]), errp)) {
hw/arm/aspeed_ast2600.c static uint64_t aspeed_calc_affinity(int cpu) · line 347
Quoted 10 lines
hw/arm/aspeed_ast2600.c +10
-0+return false; + } +aspeed_mmio_map (s,SYS_BUS_DEVICE (&s->pcie[0 ]),0 , + sc->memmap[ASPEED_DEV_PCIE0 ]); + + irq =qdev_get_gpio_in (DEVICE (&a->a7mpcore), + sc->irqmap[ASPEED_DEV_PCIE0 ]); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->pcie[0 ].rc),0 , irq); + + name =g_strdup_printf ("aspeed.pcie-mmio.0" );
Please drop the name variable.
hw/arm/aspeed_ast2600.c static uint64_t aspeed_calc_affinity(int cpu) · line 349
Quoted 2 lines
hw/arm/aspeed_ast2600.c +2
-0+ + mmio_alias =g_new0 (MemoryRegion,1 );
Why not add the alias to AspeedSoCState and avoid the allocation ?
Thanks,
C.
Quoted 27 lines
hw/arm/aspeed_ast2600.c +17
-0+ mmio_mr =sysbus_mmio_get_region (SYS_BUS_DEVICE (&s->pcie[0 ].rc),1 ); + +memory_region_init_alias (mmio_alias,OBJECT (&s->pcie[0 ].rc), name, + mmio_mr, sc->memmap[ASPEED_DEV_PCIE_MMIO1 ], +0x10000000 ); +memory_region_add_subregion (s->memory, + sc->memmap[ASPEED_DEV_PCIE_MMIO1 ], + mmio_alias); + +return true; +} +static void aspeed_soc_ast2600_realize (DeviceState *dev,Error **errp) {int i;@@ -438,6 +512,11 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)sysbus_connect_irq (SYS_BUS_DEVICE (&s->peci),0 ,aspeed_soc_get_irq (s,ASPEED_DEV_PECI )); +/* PCIe Root Complex (RC) */ +if (!aspeed_soc_ast2600_pcie_realize (dev, errp)) { +return ; + } +/* FMC, The number of CS is set at the board level */ object_property_set_link (OBJECT (&s->fmc),"dram" ,OBJECT (s->dram_mr), &error_abort);
RE: [SPAM] [PATCH v3 08/14] hw/arm/aspeed_ast2600: Add PCIe RC support (RC_H only)
Hi Cédric
Quoted 123 lines
Subject: Re: [SPAM] [PATCH v3 08/14] hw/arm/aspeed_ast2600: Add PCIe RC support (
RC_Honly)Quoted 14 lines · Jamin Lin
Wire up the PCIe Root Complex in the AST2600 SoC model.
According to the AST2600 firmware driver, only the
RC_Hcontroller is supported.RC_Huses PCIe PHY1 at0x1e6ed200and the PCIe config (H2X) register block at0x1e770000. TheRC_HMMIO window is mapped at 0x70000000–0x80000000.RC_Lis not modeled. TheRC_Hinterrupt is wired to IRQ 168. OnlyRC_His realized and connected to the SoC interrupt controller.The SoC integration initializes PCIe PHY1, instantiates a single RC instance, wires its MMIO regions, and connects its interrupt. An alias region is added to map the RC MMIO space into the guest physical address space.
Quoted 7 lines
This provides enough functionality for firmware and guest drivers to discover and use the AST2600
RC_HRoot Complex while leavingRC_Lunimplemented.Signed-off-by Jamin Lin <[email protected]>--- hw/arm/aspeed_ast2600.c | 79+++++++++++++++++++++++++++++++++++++++++
hw/arm/aspeed_ast2600.c static const hwaddr aspeed_soc_ast2600_memmap[]
Quoted 7 lines
1 file changed, 79 insertions(+)hw/arm/aspeed_ast2600.c index renamed from hw/arm/aspeed_ast2600.c +0
-0
d12707f0ab..0779e3b8e2100644hw/arm/aspeed_ast2600.c +0
-0@@ -48,11 +48,13 @@ static const hwaddr aspeed_soc_ast2600_memmap[]= {
hw/arm/aspeed_ast2600.c static const hwaddr aspeed_soc_ast2600_memmap[] =
Quoted 14 lines
hw/arm/aspeed_ast2600.c +2
-0[ASPEED_DEV_XDMA] = 0x1E6E7000, [ASPEED_DEV_ADC] = 0x1E6E9000, [ASPEED_DEV_DP] = 0x1E6EB000, + [ASPEED_DEV_PCIE_PHY1] = 0x1E6ED200, [ASPEED_DEV_SBC] = 0x1E6F2000, [ASPEED_DEV_EMMC_BC] = 0x1E6f5000, [ASPEED_DEV_VIDEO] = 0x1E700000, [ASPEED_DEV_SDHCI] = 0x1E740000, [ASPEED_DEV_EMMC] = 0x1E750000, + [ASPEED_DEV_PCIE0] = 0x1E770000, [ASPEED_DEV_GPIO] = 0x1E780000, [ASPEED_DEV_GPIO_1_8V] = 0x1E780800, [ASPEED_DEV_RTC] = 0x1E781000,@@ -79,6 +81,7 @@ static const hwaddr aspeed_soc_ast2600_memmap[] ={
Quoted 16 lines
hw/arm/aspeed_ast2600.c +2
-0[ASPEED_DEV_FSI1] = 0x1E79B000, [ASPEED_DEV_FSI2] = 0x1E79B100, [ASPEED_DEV_I3C] = 0x1E7A0000, + [ASPEED_DEV_PCIE_MMIO1] = 0x70000000, [ASPEED_DEV_SDRAM] = 0x80000000, };@@ -127,6 +130,7 @@ static const int aspeed_soc_ast2600_irqmap[] = { [ASPEED_DEV_LPC] = 35, [ASPEED_DEV_IBT] = 143, [ASPEED_DEV_I2C] = 110, /* 110 -> 125 */ + [ASPEED_DEV_PCIE0] = 168, [ASPEED_DEV_PECI] = 38, [ASPEED_DEV_ETH1] = 2, [ASPEED_DEV_ETH2] = 3,hw/arm/aspeed_ast2600.c static void aspeed_soc_ast2600_init(Object *obj) · line 198
Quoted 4 lines
hw/arm/aspeed_ast2600.c +1
-0@@ -191,6 +195,10 @@ static void aspeed_soc_ast2600_init(Object *obj)snprintf (typename,sizeof (typename),"aspeed.i2c-%s" , socname);object_initialize_child (obj,"i2c" , &s->i2c, typename); + object_initialize_child(obj, "pcie-cfg", &s->pcie[0],
TYPE_ASPEED_PCIE_CFG);Quoted 11 lines
hw/arm/aspeed_ast2600.c +3
-0+object_initialize_child (obj,"pcie-phy[*]" , &s->pcie_phy[0 ], +TYPE_ASPEED_PCIE_PHY ); +object_initialize_child (obj,"peci" , &s->peci,TYPE_ASPEED_PECI );snprintf(typename, sizeof(typename), "aspeed.fmc-%s", socname);hw/arm/aspeed_ast2600.c +0
-0@@ -285,6 +293,72 @@ static uint64_t aspeed_calc_affinity(int cpu)return (0xf <<ARM_AFF1_SHIFT ) | cpu; }hw/arm/aspeed_ast2600.c static uint64_t aspeed_calc_affinity(int cpu) · line 305
Quoted 10 lines
hw/arm/aspeed_ast2600.c +10
-0+/* +* PCIe Root Complex (RC) +* +* H2X register space (single block 0x00-0xFF): +* 0x00-0x7F : shared by RC_L (PCIe0) and RC_H (PCIe1) +* 0x80-0xBF : RC_L only +* 0xC0-0xFF : RC_H only +* +* Model scope / limitations: +* - Firmware supports RC_H only; this QEMU model does not support
RC_L.Quoted 20 lines
hw/arm/aspeed_ast2600.c +20
-0+* - RC_H uses PHY1 and the MMIO window [0x70000000, 0x80000000] +* (aka MMIO1). +* +* Indexing convention (this model): +* - Expose a single logical instance at index 0. +* - pcie[0] -> hardware RC_H (PCIe1) +* - phy[0] -> hardware PHY1 +* - mmio.0 -> guest address range MMIO1: 0x70000000-0x80000000 +* - RC_L / PCIe0 is not created and mapped. +*/ +static bool aspeed_soc_ast2600_pcie_realize (DeviceState *dev,Error +**errp) { +Aspeed2600SoCState *a =ASPEED2600_SOC (dev); +AspeedSoCState *s =ASPEED_SOC (dev); +AspeedSoCClass *sc =ASPEED_SOC_GET_CLASS (s); + g_autofree char *name = NULL; +MemoryRegion *mmio_alias; +MemoryRegion *mmio_mr; +qemu_irq irq; +hw/arm/aspeed_ast2600.c static uint64_t aspeed_calc_affinity(int cpu)
Quoted 10 lines
hw/arm/aspeed_ast2600.c +10
-0+if (!sysbus_realize (SYS_BUS_DEVICE (&s->pcie_phy[0 ]), errp)) { +return false; + } +aspeed_mmio_map (s,SYS_BUS_DEVICE (&s->pcie_phy[0 ]),0 , + sc->memmap[ASPEED_DEV_PCIE_PHY1 ]); + +object_property_set_int (OBJECT (&s->pcie[0 ]),"dram-base" , + sc->memmap[ASPEED_DEV_SDRAM ], + &error_abort); + object_property_set_link(OBJECT(&s->pcie[0]), "dram",
OBJECT(s->dram_mr),
Quoted 15 lines
hw/arm/aspeed_ast2600.c static uint64_t aspeed_calc_affinity(int cpu) · line 347
Quoted 12 lines
hw/arm/aspeed_ast2600.c +12
-0+ &error_abort); +if (!sysbus_realize (SYS_BUS_DEVICE (&s->pcie[0 ]), errp)) { +return false; + } +aspeed_mmio_map (s,SYS_BUS_DEVICE (&s->pcie[0 ]),0 , + sc->memmap[ASPEED_DEV_PCIE0 ]); + + irq =qdev_get_gpio_in (DEVICE (&a->a7mpcore), + sc->irqmap[ASPEED_DEV_PCIE0 ]); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->pcie[0 ].rc),0 , irq); + + name =g_strdup_printf ("aspeed.pcie-mmio.0" );Please drop the name variable.
Thanks for the your review and suggestion.
Will do.
Quoted 4 lines
hw/arm/aspeed_ast2600.c static uint64_t aspeed_calc_affinity(int cpu) · line 349
Quoted 2 lines
hw/arm/aspeed_ast2600.c +2
-0+ + mmio_alias =g_new0 (MemoryRegion,1 );Why not add the alias to AspeedSoCState and avoid the allocation ?
Will do.
Jamin
Quoted 41 lines
Thanks,
C.
hw/arm/aspeed_ast2600.c static uint64_t aspeed_calc_affinity(int cpu) · line 350
Quoted 1 line
hw/arm/aspeed_ast2600.c +1
-0+ mmio_mr =sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->pcie[0].rc),
hw/arm/aspeed_ast2600.c static uint64_t aspeed_calc_affinity(int cpu)
Quoted 4 lines
hw/arm/aspeed_ast2600.c +4
-0+ 1); + + memory_region_init_alias(mmio_alias, OBJECT(&s->pcie[0].rc), name, + mmio_mr,sc->memmap[ASPEED_DEV_PCIE_MMIO1],
hw/arm/aspeed_ast2600.c static uint64_t aspeed_calc_affinity(int cpu) · line 358
Quoted 3 lines
hw/arm/aspeed_ast2600.c +3
-0+ 0x10000000); + memory_region_add_subregion(s->memory, +sc->memmap[ASPEED_DEV_PCIE_MMIO1],
hw/arm/aspeed_ast2600.c static void
Quoted 9 lines
hw/arm/aspeed_ast2600.c +5
-0+ mmio_alias); + +return true; +} +static void aspeed_soc_ast2600_realize (DeviceState *dev,Error **errp) {int i;@@ -438,6 +512,11 @@ static void
aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)hw/arm/aspeed_ast2600.c static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
Quoted 10 lines
hw/arm/aspeed_ast2600.c +5
-0sysbus_connect_irq (SYS_BUS_DEVICE (&s->peci),0 ,aspeed_soc_get_irq (s,ASPEED_DEV_PECI )); +/* PCIe Root Complex (RC) */ +if (!aspeed_soc_ast2600_pcie_realize (dev, errp)) { +return ; + } +/* FMC, The number of CS is set at the board level */ object_property_set_link(OBJECT(&s->fmc), "dram",
OBJECT(s->dram_mr),Quoted 1 line
hw/arm/aspeed_ast2600.c +0
-0&error_abort);
PATCH v3 9/14 hw/pci-host/aspeed: Add AST2700 PCIe PHY
In reply to Jamin Lin viaIntroduce a PCIe Host Controller PHY model for AST2700. This adds an AST2700 specific PHY type (TYPE_ASPEED_2700_PCIE_PHY) with a 0x800 byte register space and link-status bits compatible with the firmware’s expectations.
AST2700 provides three PCIe RCs; PCIe0 and PCIe1 are GEN4, PCIe2 is GEN2. The PHY exposes:PEHR_2700_LINK_GEN2 at 0x344, bit 18 indicates GEN2 link up PEHR_2700_LINK_GEN4 at 0x358, bit 8 indicates GEN4 link up
In real hardware these GEN2/GEN4 link bits are mutually exclusive. QEMU does not model GEN2 vs GEN4 signaling differences, so the reset handler sets both bits to 1. This keeps the model simple and lets firmware see the link as up; firmware will read the appropriate register per RC port to infer the intended mode.
The header gains TYPE_ASPEED_2700_PCIE_PHY; the new class derives from TYPE_ASPEED_PCIE_PHY, sets nr_regs to 0x800 >> 2, and installs an AST2700 reset routine that programs the class code (0x06040011) and the GEN2/GEN4 status bits.
--- include/hw/pci-host/aspeed_pcie.h | 1 + hw/pci-host/aspeed_pcie.c | 39 +++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+)
include/hw/pci-host/aspeed_pcie.h +1 -0
@@ -114,6 +114,7 @@ struct AspeedPCIECfgClass { };#define TYPE_ASPEED_PCIE_PHY "aspeed.pcie-phy" +#define TYPE_ASPEED_2700_PCIE_PHY TYPE_ASPEED_PCIE_PHY "-ast2700"OBJECT_DECLARE_TYPE (AspeedPCIEPhyState, AspeedPCIEPhyClass,ASPEED_PCIE_PHY );struct AspeedPCIEPhyState {
hw/pci-host/aspeed_pcie.c +39 -0
@@ -690,6 +690,12 @@ REG32(PEHR_PROTECT, 0x7C) REG32(PEHR_LINK, 0xC0)FIELD (PEHR_LINK ,STS ,5 ,1 ) +/* AST2700 */ +REG32(PEHR_2700_LINK_GEN2, 0x344) + FIELD(PEHR_2700_LINK_GEN2, STS, 18, 1) +REG32(PEHR_2700_LINK_GEN4, 0x358) + FIELD(PEHR_2700_LINK_GEN4, STS, 8, 1) +#define ASPEED_PCIE_PHY_UNLOCK 0xA8 static uint64_t aspeed_pcie_phy_read(void *opaque, hwaddr addr,
@@ -797,6 +803,38 @@ static const TypeInfo aspeed_pcie_phy_info = { .class_size = sizeof(AspeedPCIEPhyClass), }; +static void aspeed_2700_pcie_phy_reset (DeviceState *dev) +{ +AspeedPCIEPhyState *s =ASPEED_PCIE_PHY (dev); +AspeedPCIEPhyClass *apc =ASPEED_PCIE_PHY_GET_CLASS (s); + +memset (s->regs,0 , apc->nr_regs <<2 ); + + s->regs[R_PEHR_ID ] = + (0x1150 <<R_PEHR_ID_DEV_SHIFT ) |PCI_VENDOR_ID_ASPEED ; + s->regs[R_PEHR_CLASS_CODE ] =0x06040011 ; + s->regs[R_PEHR_2700_LINK_GEN2 ] =R_PEHR_2700_LINK_GEN2_STS_MASK ; + s->regs[R_PEHR_2700_LINK_GEN4 ] =R_PEHR_2700_LINK_GEN4_STS_MASK ; +} + +static void aspeed_2700_pcie_phy_class_init (ObjectClass *klass, +const void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); +AspeedPCIEPhyClass *apc =ASPEED_PCIE_PHY_CLASS (klass); + + dc->desc ="ASPEED AST2700 PCIe Phy" ; +device_class_set_legacy_reset (dc, aspeed_2700_pcie_phy_reset); + + apc->nr_regs =0x800 >>2 ; +} + +static const TypeInfo aspeed_2700_pcie_phy_info = { + .name =TYPE_ASPEED_2700_PCIE_PHY , + .parent =TYPE_ASPEED_PCIE_PHY , + .class_init = aspeed_2700_pcie_phy_class_init, +}; +static void aspeed_pcie_register_types (void ) {type_register_static (&aspeed_pcie_rc_info);
@@ -804,6 +842,7 @@ static void aspeed_pcie_register_types(void)type_register_static (&aspeed_pcie_root_port_info);type_register_static (&aspeed_pcie_cfg_info);type_register_static (&aspeed_pcie_phy_info); +type_register_static (&aspeed_2700_pcie_phy_info); }type_init (aspeed_pcie_register_types);
Signature · 1 line
2.43.0
PATCH v3 10/14 hw/pci-host/aspeed: Add AST2700 PCIe config with dedicated H2X blocks
In reply to Jamin Lin viaIntroduce PCIe config (H2X) support for the AST2700 SoC.
Unlike the AST2600, the AST2700 provides three independent Root Complexes, each with its own H2X (AHB to PCIe bridge) register block of size 0x100. All RCs use the same MSI address (0x000000F0). The H2X block includes two different access paths:
1. CFGI (internal bridge): used to access the host bridge itself, always with BDF=0. The AST2700 controller simplifies the design by exposing only one register (H2X_CFGI_TLP) with fields for ADDR[15:0], BEN[19:16], and WR[20]. This is not a full TLP descriptor as in the external case. For QEMU readability and code reuse, the model converts H2X_CFGI_TLP into a standard TLP TX descriptor with BDF forced to 0 and then calls the existing helpers aspeed_pcie_cfg_readwrite() and aspeed_pcie_cfg_translate_write().
2. CFGE (external EP access): used to access external endpoints. The AST2700 design provides H2X_CFGE_TLP1 and a small FIFO at H2X_CFGE_TLPN. For reads, TX DESC0 is stored in TLP1 and DESC1/DESC2 in TLPN FIFO slots. For writes, TX DESC0 is stored in TLP1, DESC1/DESC2 in TLPN FIFO[0..1], and TX write data in TLPN FIFO[2].
The implementation extends AspeedPCIECfgState with a small FIFO and index, wires up new register definitions for AST2700, and adds a specific ops table and class (TYPE_ASPEED_2700_PCIE_CFG). The reset handler clears the FIFO state. Interrupt and MSI status registers are also supported.
This provides enough modeling for firmware and drivers to use any of the three PCIe RCs on AST2700 with their own dedicated H2X config window, while reusing existing TLP decode helpers in QEMU.
--- include/hw/pci-host/aspeed_pcie.h | 3 + hw/pci-host/aspeed_pcie.c | 158 ++++++++++++++++++++++++++++++ 2 files changed, 161 insertions(+)
include/hw/pci-host/aspeed_pcie.h +3 -0
@@ -87,6 +87,7 @@ struct AspeedPCIERcState {/* Bridge between AHB bus and PCIe RC. */ #define TYPE_ASPEED_PCIE_CFG "aspeed.pcie-cfg" +#define TYPE_ASPEED_2700_PCIE_CFG TYPE_ASPEED_PCIE_CFG "-ast2700"OBJECT_DECLARE_TYPE (AspeedPCIECfgState, AspeedPCIECfgClass,ASPEED_PCIE_CFG );struct AspeedPCIECfgState {
@@ -98,6 +99,8 @@ struct AspeedPCIECfgState {const AspeedPCIERcRegs *rc_regs;AspeedPCIERcState rc; +uint32_t tlpn_fifo[3 ]; +uint32_t tlpn_idx; };struct AspeedPCIECfgClass {
hw/pci-host/aspeed_pcie.c +158 -0
194 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v3 11/14 hw/pci-host/aspeed: Disable Root Device and place Root Port at 00:00.0 to AST2700
In reply to Jamin Lin viaAST2700 does not implement a PCIe Root Device; each RC exposes a single PCIe Root Port at devfn 0:0.0.
--- hw/pci-host/aspeed_pcie.c | 2 ++ 1 file changed, 2 insertions(+)
hw/pci-host/aspeed_pcie.c +2 -0
@@ -823,6 +823,8 @@ static void aspeed_2700_pcie_cfg_class_init(ObjectClass *klass, apc->nr_regs =0x100 >>2 ; apc->rc_msi_addr =0x000000F0 ; apc->rc_bus_nr =0 ; + apc->rc_has_rd = false; + apc->rc_rp_addr =PCI_DEVFN (0 ,0 ); }static const TypeInfo aspeed_2700_pcie_cfg_info = {
Signature · 1 line
2.43.0
PATCH v3 12/14 hw/arm/aspeed_ast27x0: Introduce 3 PCIe RCs for AST2700
In reply to Jamin Lin viaAdd PCIe Root Complex support to the AST2700 SoC model.
The AST2700 A1 silicon revision provides three PCIe Root Complexes:
PCIe0 with its PHY at 0x12C15000, config (H2X) block at 0x120E0000, MMIO window at 0x60000000, and GIC IRQ 56.
PCIe1 with its PHY at 0x12C15800, config (H2X) block at 0x120F0000, MMIO window at 0x80000000, and GIC IRQ 57.
PCIe2 with its PHY at 0x14C1C000, config (H2X) block at 0x140D0000, MMIO window at 0xA0000000, and IRQ routed through INTC4 bit 31 mapped to GIC IRQ 196.
Each RC instantiates a PHY device, a PCIe config (H2X) bridge, and an MMIO alias region. The per-RC MMIO alias size is 0x20000000. The AST2700 A0 silicon revision does not support PCIe Root Complexes, so pcie_num is set to 0 in that variant.
--- include/hw/arm/aspeed_soc.h | 1 + hw/arm/aspeed_ast27x0.c | 76 +++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+)
include/hw/arm/aspeed_soc.h +1 -0
@@ -185,6 +185,7 @@ struct AspeedSoCClass {uint32_t silicon_rev;uint64_t sram_size;uint64_t secsram_size; +int pcie_num;int spis_num;int ehcis_num;int wdts_num;
hw/arm/aspeed_ast27x0.c +76 -0
154 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v3 13/14 tests/functional/arm/test_aspeed_ast2600: Add PCIe and network test
In reply to Jamin Lin viaExtend the AST2600 functional tests with PCIe and network checks.
This patch introduces a new helper "do_ast2600_pcie_test()" that runs "lspci" on the emulated system and verifies the presence of the expected PCIe devices:
- 80:00.0 Host bridge: ASPEED Technology, Inc. Device 2600
- 80:08.0 PCI bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge
- 81:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection
To exercise the PCIe network device, the test adds:
-device e1000e,netdev=net1,bus=pcie.0
-netdev user,id=net1
and assigns an IP address to the interface, verifying it with ip addr.
--- tests/functional/arm/test_aspeed_ast2600.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
tests/functional/arm/test_aspeed_ast2600.py +20 -0
@@ -101,6 +101,23 @@ def test_arm_ast2600_evb_buildroot_tpm(self): 'https://github.com/AspeedTech-BMC/openbmc/releases/download/v09.07/ast2600-default-obmc.tar.gz', 'cb6c08595bcbba1672ce716b068ba4e48eda1ed9abe78a07b30392ba2278feba') + def do_ast2600_pcie_test(self): + exec_command_and_wait_for_pattern(self, + 'lspci -s 80:00.0', + '80:00.0 Host bridge: ' + 'ASPEED Technology, Inc. Device 2600') + exec_command_and_wait_for_pattern(self, + 'lspci -s 80:08.0', + '80:08.0 PCI bridge: ' + 'ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge') + exec_command_and_wait_for_pattern(self, + 'lspci -s 81:00.0', + '81:00.0 Ethernet controller: ' + 'Intel Corporation 82574L Gigabit Network Connection') + exec_command_and_wait_for_pattern(self, + 'ip addr add 192.168.1.100/24 dev eth4 && ip addr', + 'inet 192.168.1.100/24 scope global eth4') + def test_arm_ast2600_evb_sdk(self): self.set_machine('ast2600-evb')
@@ -110,6 +127,8 @@ def test_arm_ast2600_evb_sdk(self): 'tmp105,bus=aspeed.i2c.bus.5,address=0x4d,id=tmp-test') self.vm.add_args('-device', 'ds1338,bus=aspeed.i2c.bus.5,address=0x32') + self.vm.add_args('-device', 'e1000e,netdev=net1,bus=pcie.0') + self.vm.add_args('-netdev', 'user,id=net1') self.do_test_arm_aspeed_sdk_start( self.scratch_file("ast2600-default", "image-bmc"))
@@ -135,6 +154,7 @@ def test_arm_ast2600_evb_sdk(self): year = time.strftime("%Y") exec_command_and_wait_for_pattern(self, '/sbin/hwclock -f /dev/rtc1', year) + self.do_ast2600_pcie_test() def test_arm_ast2600_otp_blockdev_device(self): self.vm.set_machine("ast2600-evb")
Signature · 1 line
2.43.0
Re: [SPAM] [PATCH v3 13/14] tests/functional/arm/test_aspeed_ast2600: Add PCIe and network test
+ Thomas
Quoted 35 lines · Jamin Lin
Extend the AST2600 functional tests with PCIe and network checks.
This patch introduces a new helper "
do_ast2600_pcie_test()" that runs "lspci" on the emulated system and verifies the presence of the expected PCIe devices:- 80:00.0 Host bridge: ASPEED Technology, Inc. Device 2600
- 80:08.0 PCI bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge
- 81:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network ConnectionTo exercise the PCIe network device, the test adds:
-device e1000e,netdev=net1,bus=pcie.0 -netdev user,id=net1and assigns an IP address to the interface, verifying it with
ip addr.Signed-off-by Jamin Lin <[email protected]>--- tests/functional/arm/test_aspeed_ast2600.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)tests/functional/arm/test_aspeed_ast2600.py +6
-0@@ -101,6 +101,23 @@ def test_arm_ast2600_evb_buildroot_tpm(self): 'https://github.com/AspeedTech-BMC/openbmc/releases/download/v09.07/ast2600-default-obmc.tar.gz', 'cb6c08595bcbba1672ce716b068ba4e48eda1ed9abe78a07b30392ba2278feba') + def do_ast2600_pcie_test(self): + exec_command_and_wait_for_pattern(self, + 'lspci -s 80:00.0', + '80:00.0 Host bridge: ' + 'ASPEED Technology, Inc. Device 2600') + exec_command_and_wait_for_pattern(self,
tests/functional/arm/test_aspeed_ast2600.py def test_arm_ast2600_evb_buildroot_tpm(self): · line 119
Quoted 10 lines
tests/functional/arm/test_aspeed_ast2600.py +10
-0+ 'lspci -s 80:08.0', + '80:08.0 PCI bridge: ' + 'ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge') + exec_command_and_wait_for_pattern(self, + 'lspci -s 81:00.0', + '81:00.0 Ethernet controller: ' + 'Intel Corporation 82574L Gigabit Network Connection') + exec_command_and_wait_for_pattern(self, + 'ip addr add 192.168.1.100/24 dev eth4 && ip addr', + 'inet 192.168.1.100/24 scope global eth4')
I think checking that the user netdev returned 'inet 10.0.2.15/24' should be enough. It would mean that DHCP has worked and that MSI were triggered. No need to assign a new IP address IMO.
tests/functional/arm/test_aspeed_ast2600.py def test_arm_ast2600_evb_sdk(self): · line 131
Quoted 10 lines
tests/functional/arm/test_aspeed_ast2600.py +3
-0+ def test_arm_ast2600_evb_sdk(self): self.set_machine('ast2600-evb')@@ -110,6 +127,8 @@ def test_arm_ast2600_evb_sdk(self): 'tmp105,bus=aspeed.i2c.bus.5,address=0x4d,id=tmp-test') self.vm.add_args('-device', 'ds1338,bus=aspeed.i2c.bus.5,address=0x32') + self.vm.add_args('-device', 'e1000e,netdev=net1,bus=pcie.0') + self.vm.add_args('-netdev', 'user,id=net1')
you need to add
self.require_netdev('user')
Thanks,
C.
Quoted 11 lines
tests/functional/arm/test_aspeed_ast2600.py +1
-0self.do_test_arm_aspeed_sdk_start( self.scratch_file("ast2600-default", "image-bmc"))@@ -135,6 +154,7 @@ def test_arm_ast2600_evb_sdk(self): year = time.strftime("%Y") exec_command_and_wait_for_pattern(self, '/sbin/hwclock -f /dev/rtc1', year) + self.do_ast2600_pcie_test() def test_arm_ast2600_otp_blockdev_device(self): self.vm.set_machine("ast2600-evb")
RE: [SPAM] [PATCH v3 13/14] tests/functional/arm/test_aspeed_ast2600: Add PCIe and network test
Hi Cédric
Quoted 61 lines
tests/functional/arm/test_aspeed_ast2600: Add PCIe and network test
+ Thomas
Quoted 4 lines · Jamin Lin
Extend the AST2600 functional tests with PCIe and network checks.
This patch introduces a new helper "
do_ast2600_pcie_test()" that runs "lspci" on the emulated system and verifies the presence of the expected PCIedevices:
Quoted 9 lines
- 80:00.0 Host bridge: ASPEED Technology, Inc. Device 2600
- 80:08.0 PCI bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge
- 81:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network ConnectionTo exercise the PCIe network device, the test adds:
Quoted 8 lines
-device e1000e,netdev=net1,bus=pcie.0 -netdev user,id=net1and assigns an IP address to the interface, verifying it with
ip addr.Signed-off-by Jamin Lin <[email protected]>--- tests/functional/arm/test_aspeed_ast2600.py | 20++++++++++++++++++++
tests/functional/arm/test_aspeed_ast2600.py def test_arm_ast2600_evb_buildroot_tpm(self): · line 101
Quoted 9 lines
1 file changed, 20 insertions(+)tests/functional/arm/test_aspeed_ast2600.py +0
-0@@ -101,6 +101,23 @@ def test_arm_ast2600_evb_buildroot_tpm(self):'https://github.com/AspeedTech-BMC/openbmc/releases/download/v09.07/ast 2600-default-obmc.tar.gz',
Quoted 2 lines
'
cb6c08595bcbba1672ce716b068ba4e48eda1ed9abe78a07b30392ba2278feba' )Quoted 7 lines
tests/functional/arm/test_aspeed_ast2600.py +6
-0+ def do_ast2600_pcie_test(self): + exec_command_and_wait_for_pattern(self, + 'lspci -s 80:00.0', + '80:00.0 Host bridge: ' + 'ASPEED Technology, Inc. Device 2600') + exec_command_and_wait_for_pattern(self,tests/functional/arm/test_aspeed_ast2600.py def test_arm_ast2600_evb_buildroot_tpm(self): · line 119
Quoted 10 lines
tests/functional/arm/test_aspeed_ast2600.py +10
-0+ 'lspci -s 80:08.0', + '80:08.0 PCI bridge: ' + 'ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge') + exec_command_and_wait_for_pattern(self, + 'lspci -s 81:00.0', + '81:00.0 Ethernet controller: ' + 'Intel Corporation 82574L Gigabit Network Connection') + exec_command_and_wait_for_pattern(self, + 'ip addr add 192.168.1.100/24 dev eth4 && ip addr', + 'inet 192.168.1.100/24 scope global eth4')
Quoted 4 lines
I think checking that the user netdev returned 'inet 10.0.2.15/24' should be enough. It would mean that DHCP has worked and that MSI were triggered. No need to assign a new IP address IMO.
Thanks for your review and suggestion.
Will fix it.
Quoted 13 lines
tests/functional/arm/test_aspeed_ast2600.py def test_arm_ast2600_evb_sdk(self): · line 131
Quoted 10 lines
tests/functional/arm/test_aspeed_ast2600.py +3
-0+ def test_arm_ast2600_evb_sdk(self): self.set_machine('ast2600-evb')@@ -110,6 +127,8 @@ def test_arm_ast2600_evb_sdk(self): 'tmp105,bus=aspeed.i2c.bus.5,address=0x4d,id=tmp-test') self.vm.add_args('-device', 'ds1338,bus=aspeed.i2c.bus.5,address=0x32') + self.vm.add_args('-device', 'e1000e,netdev=net1,bus=pcie.0') + self.vm.add_args('-netdev', 'user,id=net1')you need to add
Quoted 2 lines
self.require_netdev('user')
Will add.
Jamin
Quoted 19 lines
Thanks,
C.
Quoted 11 lines
tests/functional/arm/test_aspeed_ast2600.py +1
-0self.do_test_arm_aspeed_sdk_start( self.scratch_file("ast2600-default", "image-bmc"))@@ -135,6 +154,7 @@ def test_arm_ast2600_evb_sdk(self): year = time.strftime("%Y") exec_command_and_wait_for_pattern(self, '/sbin/hwclock -f /dev/rtc1', year) + self.do_ast2600_pcie_test() def test_arm_ast2600_otp_blockdev_device(self): self.vm.set_machine("ast2600-evb")
PATCH v3 14/14 tests/functional/aarch64/aspeed_ast2700: Add PCIe and network tests
In reply to Jamin Lin viaExtend the AST2700 and AST2700fc functional tests with PCIe and network checks.
This patch introduces a helper "do_ast2700_pcie_test()" that runs "lspci" on the emulated system and verifies the expected PCIe devices:
- 0002:00:00.0 PCI bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge
- 0002:01:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection
Additional changes:
- Add -device e1000e,netdev=net1,bus=pcie.2 -netdev user,id=net1 to the AST2700 and AST2700fc test machines.
- In the AST2700 vbootrom test, assign an IP address to the e1000e interface and verify it using ip addr.
--- .../functional/aarch64/test_aspeed_ast2700.py | 19 +++++++++++++++++++ .../aarch64/test_aspeed_ast2700fc.py | 13 +++++++++++++ 2 files changed, 32 insertions(+)
tests/functional/aarch64/test_aspeed_ast2700.py +19 -0
@@ -69,6 +69,16 @@ def do_ast2700_i2c_test(self): exec_command_and_wait_for_pattern(self, 'cat /sys/bus/i2c/devices/1-004d/hwmon/hwmon*/temp1_input', '18000') + def do_ast2700_pcie_test(self): + exec_command_and_wait_for_pattern(self, + 'lspci -s 0002:00:00.0', + '0002:00:00.0 PCI bridge: ' + 'ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge') + exec_command_and_wait_for_pattern(self, + 'lspci -s 0002:01:00.0', + '0002:01:00.0 Ethernet controller: ' + 'Intel Corporation 82574L Gigabit Network Connection') + def start_ast2700_test(self, name): num_cpu = 4 uboot_size = os.path.getsize(self.scratch_file(name,
@@ -127,18 +137,27 @@ def test_aarch64_ast2700a1_evb_sdk_v09_06(self): self.set_machine('ast2700a1-evb') self.archive_extract(self.ASSET_SDK_V906_AST2700A1) + self.vm.add_args('-device', 'e1000e,netdev=net1,bus=pcie.2') + self.vm.add_args('-netdev', 'user,id=net1') self.start_ast2700_test('ast2700-default') self.verify_openbmc_boot_and_login('ast2700-default') self.do_ast2700_i2c_test() + self.do_ast2700_pcie_test() def test_aarch64_ast2700a1_evb_sdk_vbootrom_v09_07(self): self.set_machine('ast2700a1-evb') self.archive_extract(self.ASSET_SDK_V907_AST2700A1_VBOOROM) + self.vm.add_args('-device', 'e1000e,netdev=net1,bus=pcie.2') + self.vm.add_args('-netdev', 'user,id=net1') self.start_ast2700_test_vbootrom('ast2700-default') self.verify_vbootrom_firmware_flow() self.verify_openbmc_boot_and_login('ast2700-default') self.do_ast2700_i2c_test() + self.do_ast2700_pcie_test() + exec_command_and_wait_for_pattern(self, + 'ip addr add 192.168.1.100/24 dev eth2 && ip addr', + 'inet 192.168.1.100/24 scope global eth2') if __name__ == '__main__': QemuSystemTest.main()
tests/functional/aarch64/test_aspeed_ast2700fc.py +13 -0
@@ -20,6 +20,8 @@ def do_test_aarch64_aspeed_sdk_start(self, image): self.vm.set_console() self.vm.add_args('-device', 'tmp105,bus=aspeed.i2c.bus.1,address=0x4d,id=tmp-test') + self.vm.add_args('-device', 'e1000e,netdev=net1,bus=pcie.2') + self.vm.add_args('-netdev', 'user,id=net1') self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw', '-net', 'nic', '-net', 'user', '-snapshot')
@@ -49,6 +51,16 @@ def do_ast2700_i2c_test(self): exec_command_and_wait_for_pattern(self, 'cat /sys/bus/i2c/devices/1-004d/hwmon/hwmon*/temp1_input', '18000') + def do_ast2700_pcie_test(self): + exec_command_and_wait_for_pattern(self, + 'lspci -s 0002:00:00.0', + '0002:00:00.0 PCI bridge: ' + 'ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge') + exec_command_and_wait_for_pattern(self, + 'lspci -s 0002:01:00.0', + '0002:01:00.0 Ethernet controller: ' + 'Intel Corporation 82574L Gigabit Network Connection') + def do_ast2700fc_ssp_test(self): self.vm.shutdown() self.vm.set_console(console_index=1)
@@ -128,6 +140,7 @@ def test_aarch64_ast2700fc_sdk_v09_06(self): self.start_ast2700fc_test('ast2700-default') self.verify_openbmc_boot_and_login('ast2700-default') self.do_ast2700_i2c_test() + self.do_ast2700_pcie_test() self.do_ast2700fc_ssp_test() self.do_ast2700fc_tsp_test()
Signature · 1 line
2.43.0
Hell Jamin,
Quoted 15 lines · Jamin Lin
v1:
1. Add PCIe PHY, CFG, and MMIO window support for AST2600.
Note: Only supportsRC_H.
2. Add PCIe PHY, CFG, and MMIO window support for AST2700.
Note: Supports 3 RCs.v2:
1. Introduce a new root port device.
2. For AST2600RC_H, add the root device at 80:00.0 and a root port at 80.08.0 to match the real hardware topology, allowing users to attach PCIe devices at the root port.
3. For AST2700, add a root port at 00.00.0 for each PCIe root complex to match the real hardware topology, allowing users to attach PCIe devices at the root port.
Quoted 6 lines
v3:
1. Fix review issues.
2. update functional test for the e1000e network card.
3. update license header
4. Adding "Based on previous work from Cedric Le Goater, with Jamin's summary implementation.
v3 looks good. I only had a few comments on memory allocation (g_autofree and MMIO alias regions) and on functional tests.
v4 should be the last.
Quoted 6 lines
Dependencies
QEMU version:
https://github.com/qemu/qemu/commit/f0007b7f03e2d7fc33e71c3a582f2364c51a226b
Quoted 7 lines
This patch series depends on the following patch series:
1. hw/arm/aspeed Move ast2700-evb alias to ast2700a1-evb
https://patchwork.kernel.org/project/qemu-devel/patch/[email protected]/
2. tests/functional/arm: Update test images for ASPEED chips
https://patchwork.kernel.org/project/qemu-devel/cover/[email protected]/
3. tests/functional/arm: Add OTP functional test
https://patchwork.kernel.org/project/qemu-devel/cover/[email protected]/
There changes are in aspeed-next. You could use it as a reference in the cover letter.
Thanks,
C.
Hi Cédric
Quoted 30 lines
Subject: Re: [SPAM] [PATCH v3 00/14] Support PCIe RC to AST2600 and AST2700
Hell Jamin,
Quoted 9 lines · Jamin Lin
v1:
1. Add PCIe PHY, CFG, and MMIO window support for AST2600.
Note: Only supportsRC_H.
2. Add PCIe PHY, CFG, and MMIO window support for AST2700.
Note: Supports 3 RCs.v2:
1. Introduce a new root port device.
2. For AST2600RC_H, add the root device at 80:00.0 and a root port at80.08.0
Quoted 1 line
to match the real hardware topology, allowing users to attach PCIe
devices
Quoted 2 lines
at the root port.
3. For AST2700, add a root port at 00.00.0 for each PCIe root complex tomatch
Quoted 1 line
the real hardware topology, allowing users to attach PCIe devices at
the
Quoted 7 lines
root port.
v3:
1. Fix review issues.
2. update functional test for the e1000e network card.
3. update license header
4. Adding "Based on previous work from Cedric Le Goater, with Jamin's
Quoted 8 lines
summary
Quoted 1 line
implementation.
v3 looks good. I only had a few comments on memory allocation (
g_autofreeand MMIO alias regions) and on functional tests.v4 should be the last.
Thanks for your review and kindly support.
Will resend v4 very soon.
Quoted 22 lines
Quoted 6 lines
Dependencies
QEMU version:
https://github.com/qemu/qemu/commit/f0007b7f03e2d7fc33e71c3a582f2364
c5Quoted 12 lines
1a226b
This patch series depends on the following patch series:
1. hw/arm/aspeed Move ast2700-evb alias to ast2700a1-evb
https://patchwork.kernel.org/project/qemu-devel/patch/20250902062550.3
[email protected]/
2. tests/functional/arm: Update test images for ASPEED chips
https://patchwork.kernel.org/project/qemu-devel/cover/20250904100556.1
[email protected]/
3. tests/functional/arm: Add OTP functional test
https://patchwork.kernel.org/project/qemu-devel/cover/20250917035917.4
[email protected]/
Quoted 3 lines
There changes are in aspeed-next. You could use it as a reference in the cover letter.
Will update it in v4 cover letter.
Jamin
Quoted 4 lines
Thanks,
C.
Quoted 35 lines · Jamin Lin
Hi Cédric
Quoted 33 lines
Subject: Re: [SPAM] [PATCH v3 00/14] Support PCIe RC to AST2600 and AST2700
Hell Jamin,
Quoted 9 lines · Jamin Lin
v1:
1. Add PCIe PHY, CFG, and MMIO window support for AST2600.
Note: Only supportsRC_H.
2. Add PCIe PHY, CFG, and MMIO window support for AST2700.
Note: Supports 3 RCs.v2:
1. Introduce a new root port device.
2. For AST2600RC_H, add the root device at 80:00.0 and a root port at80.08.0
Quoted 1 line
to match the real hardware topology, allowing users to attach PCIe
devices
Quoted 2 lines
at the root port.
3. For AST2700, add a root port at 00.00.0 for each PCIe root complex tomatch
Quoted 1 line
the real hardware topology, allowing users to attach PCIe devices at
the
Quoted 7 lines
root port.
v3:
1. Fix review issues.
2. update functional test for the e1000e network card.
3. update license header
4. Adding "Based on previous work from Cedric Le Goater, with Jamin'ssummary
Quoted 1 line
implementation.
Quoted 8 lines
Quoted 5 lines
v3 looks good. I only had a few comments on memory allocation (
g_autofreeand MMIO alias regions) and on functional tests.v4 should be the last.
Thanks for your review and kindly support.
Will resend v4 very soon.
One last thing, the list of PCI capabilities reported on real HW is a little different. See below. When you have time, it would be good to adjust the model if possible. It can come later.
Thanks,
C.
root@ast2600-default:~# lspci -vvv 80:00.0 Host bridge: ASPEED Technology, Inc. Device 2600 Subsystem: ASPEED Technology, Inc. Device 2600 Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx- Status: Cap- 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx- Latency: 0
80:08.0 PCI bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge (rev 06) (prog-if 00 [Normal decode])
Subsystem: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr+ Stepping- SERR+ FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Interrupt: pin A routed to IRQ 82
Bus: primary=80, secondary=81, subordinate=81, sec-latency=0
I/O behind bridge: 1000-1fff [size=4K] [16-bit]
Memory behind bridge: 70000000-700fffff [size=1M] [32-bit]
Prefetchable memory behind bridge: 00000000fff00000-00000000000fffff [disabled] [64-bit] Secondary status: 66MHz+ FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort+ <SERR- <PERR-
BridgeCtl: Parity+ SERR+ NoISA- VGA- VGA16- MAbort- >Reset- FastB2B-
PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
Capabilities: [50] MSI: Enable+ Count=1/1 Maskable- 64bit+
Address: 000000001e77005c Data: 0000
Capabilities: [78] Power Management version 3
Flags: PMEClk- DSI- D1+ D2+ AuxCurrent=375mA PME(D0+,D1+,D2+,D3hot+,D3cold+)
Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME-
Capabilities: [80] Express (v2) Root Port (Slot-), IntMsgNum 0
DevCap: MaxPayload 512 bytes, PhantFunc 0
ExtTag+ RBE+ TEE-IO-
DevCtl: CorrErr- NonFatalErr- FatalErr- UnsupReq-
RlxdOrd+ ExtTag+ PhantFunc- AuxPwr- NoSnoop+
MaxPayload 128 bytes, MaxReadReq 512 bytes
DevSta: CorrErr- NonFatalErr- FatalErr- UnsupReq- AuxPwr+ TransPend-
LnkCap: Port #0, Speed 5GT/s, Width x1, ASPM L0s L1, Exit Latency L0s <1us, L1 <64us
ClockPM- Surprise- LLActRep- BwNot+ ASPMOptComp+
LnkCtl: ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk-
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed 2.5GT/s, Width x1
TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
RootCap: CRSVisible-
RootCtl: ErrCorrectable- ErrNon-Fatal- ErrFatal- PMEIntEna+ CRSVisible-
RootSta: PME ReqID 0000, PMEStatus- PMEPending-
DevCap2: Completion Timeout: Range ABCD, TimeoutDis+ NROPrPrP- LTR-
10BitTagComp- 10BitTagReq- OBFF Not Supported, ExtFmt- EETLPPrefix- EmergencyPowerReduction Not Supported, EmergencyPowerReductionInit- FRS- LN System CLS Not Supported, TPHComp- ExtTPHComp- ARIFwd-
AtomicOpsCap: Routing- 32bit- 64bit- 128bitCAS-
DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis- ARIFwd-
AtomicOpsCtl: ReqEn- EgressBlck-
IDOReq- IDOCompl- LTR- EmergencyPowerReductionReq-
10BitTagReq- OBFF Disabled, EETLPPrefixBlk-
LnkCtl2: Target Link Speed: 5GT/s, EnterCompliance- SpeedDis-
Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS- Compliance Preset/De-emphasis: -6dB de-emphasis, 0dB preshoot
LnkSta2: Current De-emphasis Level: -3.5dB, EqualizationComplete- EqualizationPhase1-
EqualizationPhase2- EqualizationPhase3- LinkEqualizationRequest- Retimer- 2Retimers- CrosslinkRes: unsupported
Capabilities: [c0] Subsystem: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge
Capabilities: [100 v1] Virtual Channel
Caps: LPEVC=0 RefClk=100ns PATEntryBits=1
Arb: Fixed- WRR32- WRR64- WRR128-
Ctrl: ArbSelect=Fixed
Status: InProgress-
VC0: Caps: PATOffset=00 MaxTimeSlots=1 RejSnoopTrans-
Arb: Fixed- WRR32- WRR64- WRR128- TWRR128- WRR256-
Ctrl: Enable+ ID=0 ArbSelect=Fixed TC/VC=ff
Status: NegoPending- InProgress-
Capabilities: [800 v1] Advanced Error Reporting
UESta: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP-
ECRC- UnsupReq- ACSViol- UncorrIntErr- BlockedTLP- AtomicOpBlocked- TLPBlockedErr- PoisonTLPBlocked- DMWrReqBlocked- IDECheck- MisIDETLP- PCRC_CHECK- TLPXlatBlocked-
UEMsk: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP-
ECRC- UnsupReq- ACSViol- UncorrIntErr- BlockedTLP- AtomicOpBlocked- TLPBlockedErr- PoisonTLPBlocked- DMWrReqBlocked- IDECheck- MisIDETLP- PCRC_CHECK- TLPXlatBlocked-
UESvrt: DLP+ SDES+ TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+
ECRC- UnsupReq- ACSViol- UncorrIntErr- BlockedTLP- AtomicOpBlocked- TLPBlockedErr- PoisonTLPBlocked- DMWrReqBlocked- IDECheck- MisIDETLP- PCRC_CHECK- TLPXlatBlocked-
CESta: RxErr- BadTLP- BadDLLP- Rollover- Timeout- AdvNonFatalErr- CorrIntErr- HeaderOF-
CEMsk: RxErr- BadTLP- BadDLLP- Rollover- Timeout- AdvNonFatalErr+ CorrIntErr- HeaderOF-
AERCap: First Error Pointer: 00, ECRCGenCap- ECRCGenEn- ECRCChkCap- ECRCChkEn-
MultHdrRecCap- MultHdrRecEn- TLPPfxPres- HdrLogCap-
HeaderLog: 00000000 00000000 00000000 00000000
RootCmd: CERptEn- NFERptEn- FERptEn-
RootSta: CERcvd- MultCERcvd- UERcvd- MultUERcvd-
FirstFatal- NonFatalMsg- FatalMsg- IntMsgNum 0
ErrorSrc: ERR_COR: 0000 ERR_FATAL/NONFATAL: 0000
Kernel driver in use: pcieport
Hi Cédric
Quoted 50 lines
Subject: Re: [SPAM] [PATCH v3 00/14] Support PCIe RC to AST2600 and AST2700
Quoted 46 lines · Jamin Lin
Hi Cédric
Quoted 43 lines
Subject: Re: [SPAM] [PATCH v3 00/14] Support PCIe RC to AST2600 and AST2700
Hell Jamin,
Quoted 10 lines · Jamin Lin
v1:
1. Add PCIe PHY, CFG, and MMIO window support for AST2600.
Note: Only supportsRC_H.
2. Add PCIe PHY, CFG, and MMIO window support for AST2700.
Note: Supports 3 RCs.v2:
1. Introduce a new root port device.
2. For AST2600RC_H, add the root device at 80:00.0 and a root
port at80.08.0
Quoted 2 lines
to match the real hardware topology, allowing users to attach
PCIedevices
Quoted 3 lines
at the root port.
3. For AST2700, add a root port at 00.00.0 for each PCIe root
complex tomatch
Quoted 2 lines
the real hardware topology, allowing users to attach PCIe
devices atthe
Quoted 8 lines
root port.
v3:
1. Fix review issues.
2. update functional test for the e1000e network card.
3. update license header
4. Adding "Based on previous work from Cedric Le Goater, with
Jamin'ssummary
Quoted 1 line
implementation.
v3 looks good. I only had a few comments on memory allocation (
g_autofreeand MMIO alias regions) and on functional tests.v4 should be the last.
Quoted 7 lines
Quoted 2 lines
Thanks for your review and kindly support.
Will resend v4 very soon.One last thing, the list of PCI capabilities reported on real HW is a little different. See below. When you have time, it would be good to adjust the model if possible. It can come later.
Thanks for the suggestion and for reporting this issue. I’ll add it to my working queue. Here are the tasks currently in my queue:
1. Control coprocessor reset for AST2700
https://patchwork.kernel.org/project/qemu-devel/cover/[email protected]/
2. Analyze issue "func-arm-aspeed_ast2500 test occasionally times out"
https://gitlab.com/qemu-project/qemu/-/issues/3117
3. Adjust PCIe capabilities
3. Support AST2700 IPC model(may require refactoring the INTC model if needed)
4. Support AST2700 A2 (planned for end of this year or Q1 next year)
5. Support AST2700 boot from BootMCU(RISC-V) instead of vbootrom, if a single binary ready.
Thanks-Jamin
Quoted 127 lines
Thanks,
C.
root@ast2600-default:~# lspci -vvv 80:00.0 Host bridge: ASPEED Technology, Inc. Device 2600 Subsystem: ASPEED Technology, Inc. Device 2600 Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx- Status: Cap- 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx- Latency: 080:08.0 PCI bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge (rev 06) (prog-if 00 [Normal decode])
Subsystem: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop-
ParErr+ Stepping- SERR+ FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort-
<TAbort- <MAbort- >SERR- <PERR- INTx-Latency: 0, Cache Line Size: 64 bytes Interrupt: pin A routed to IRQ 82 Bus: primary=80, secondary=81, subordinate=81, sec-latency=0 I/O behind bridge: 1000-1fff [size=4K] [16-bit] Memory behind bridge: 70000000-700fffff [size=1M] [32-bit] Prefetchable memory behind bridge: 00000000fff00000-00000000000fffff[disabled] [64-bit]
Secondary status: 66MHz+ FastB2B- ParErr- DEVSEL=medium >TAbort-
<TAbort- <MAbort+ <SERR- <PERR-
BridgeCtl: Parity+ SERR+ NoISA- VGA- VGA16- MAbort- >Reset- FastB2B-
PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
Capabilities: [50] MSI: Enable+ Count=1/1 Maskable- 64bit+
Address:000000001e77005cData: 0000
Capabilities: [78] Power Management version 3
Flags: PMEClk- DSI- D1+ D2+ AuxCurrent=375mAPME(D0+,D1+,D2+,D3hot+,D3cold+)
Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME-
Capabilities: [80] Express (v2) Root Port (Slot-), IntMsgNum 0
DevCap: MaxPayload 512 bytes, PhantFunc 0
ExtTag+ RBE+ TEE-IO-
DevCtl: CorrErr- NonFatalErr- FatalErr- UnsupReq-
RlxdOrd+ ExtTag+ PhantFunc- AuxPwr- NoSnoop+ MaxPayload 128 bytes, MaxReadReq 512 bytes
DevSta: CorrErr- NonFatalErr- FatalErr- UnsupReq- AuxPwr+
TransPend-
LnkCap: Port #0, Speed 5GT/s, Width x1, ASPM L0s L1, Exit Latency
L0s <1us, L1 <64us
ClockPM- Surprise- LLActRep- BwNot+ ASPMOptComp+
LnkCtl: ASPM Disabled; RCB 64 bytes, LnkDisable- CommClk-
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed 2.5GT/s, Width x1
TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
RootCap: CRSVisible-
RootCtl: ErrCorrectable- ErrNon-Fatal- ErrFatal- PMEIntEna+
CRSVisible-
RootSta: PME ReqID 0000, PMEStatus- PMEPending-
DevCap2: Completion Timeout: Range ABCD, TimeoutDis+
NROPrPrP- LTR-
10BitTagComp- 10BitTagReq- OBFF Not Supported, ExtFmt-
EETLPPrefix-
EmergencyPowerReduction Not Supported,
EmergencyPowerReductionInit-
FRS- LN System CLS Not Supported, TPHComp- ExtTPHComp-
ARIFwd-
AtomicOpsCap: Routing- 32bit- 64bit- 128bitCAS-
DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis- ARIFwd-
AtomicOpsCtl: ReqEn- EgressBlck-
IDOReq- IDOCompl- LTR- EmergencyPowerReductionReq- 10BitTagReq- OBFF Disabled, EETLPPrefixBlk-
LnkCtl2: Target Link Speed: 5GT/s, EnterCompliance- SpeedDis-
Transmit Margin: Normal Operating Range,
EnterModifiedCompliance- ComplianceSOS-
Compliance Preset/De-emphasis: -6dB de-emphasis, 0dB
preshoot
LnkSta2: Current De-emphasis Level: -3.5dB, EqualizationComplete-
EqualizationPhase1-
EqualizationPhase2- EqualizationPhase3-
LinkEqualizationRequest-
Retimer- 2Retimers- CrosslinkRes: unsupported
Capabilities: [c0] Subsystem: ASPEED Technology, Inc. AST1150 PCI-to-PCI
Bridge
Capabilities: [100 v1] Virtual Channel
Caps: LPEVC=0 RefClk=100ns PATEntryBits=1
Arb: Fixed- WRR32- WRR64- WRR128-
Ctrl: ArbSelect=Fixed
Status: InProgress-
VC0: Caps: PATOffset=00 MaxTimeSlots=1 RejSnoopTrans-
Arb: Fixed- WRR32- WRR64- WRR128- TWRR128- WRR256-
Ctrl: Enable+ ID=0 ArbSelect=Fixed TC/VC=ff
Status: NegoPending- InProgress-
Capabilities: [800 v1] Advanced Error Reporting
UESta: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt-
RxOF- MalfTLP-
ECRC- UnsupReq- ACSViol- UncorrIntErr- BlockedTLP-
AtomicOpBlocked- TLPBlockedErr-
PoisonTLPBlocked- DMWrReqBlocked- IDECheck- MisIDETLP-
PCRC_CHECK- TLPXlatBlocked-
UEMsk: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt-
RxOF- MalfTLP-
ECRC- UnsupReq- ACSViol- UncorrIntErr- BlockedTLP-
AtomicOpBlocked- TLPBlockedErr-
PoisonTLPBlocked- DMWrReqBlocked- IDECheck- MisIDETLP-
PCRC_CHECK- TLPXlatBlocked-
UESvrt: DLP+ SDES+ TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt-
RxOF+ MalfTLP+
ECRC- UnsupReq- ACSViol- UncorrIntErr- BlockedTLP-
AtomicOpBlocked- TLPBlockedErr-
PoisonTLPBlocked- DMWrReqBlocked- IDECheck- MisIDETLP-
PCRC_CHECK- TLPXlatBlocked-
CESta: RxErr- BadTLP- BadDLLP- Rollover- Timeout-
AdvNonFatalErr- CorrIntErr- HeaderOF-
CEMsk: RxErr- BadTLP- BadDLLP- Rollover- Timeout-
AdvNonFatalErr+ CorrIntErr- HeaderOF-
AERCap: First Error Pointer: 00, ECRCGenCap- ECRCGenEn-
ECRCChkCap- ECRCChkEn-
MultHdrRecCap- MultHdrRecEn- TLPPfxPres- HdrLogCap-
HeaderLog: 00000000 00000000 00000000 00000000
RootCmd: CERptEn- NFERptEn- FERptEn-
RootSta: CERcvd- MultCERcvd- UERcvd- MultUERcvd-
FirstFatal- NonFatalMsg- FatalMsg- IntMsgNum 0
ErrorSrc:ERR_COR: 0000 ERR_FATAL/NONFATAL: 0000
Kernel driver in use: pcieport
Aspeed backlog (was Re: [SPAM] [PATCH v3 00/14] Support PCIe RC to AST2600 and AST2700)
Hello Jamin,
Quoted 10 lines
Quoted 4 lines
One last thing, the list of PCI capabilities reported on real HW is a little different. See below. When you have time, it would be good to adjust the model if possible. It can come later.
Thanks for the suggestion and for reporting this issue. I’ll add it to my working queue. Here are the tasks currently in my queue:
1. Control coprocessor reset for AST2700
https://patchwork.kernel.org/project/qemu-devel/cover/[email protected]/
This needs a rework of the co processor models. This should be QEMU 10.2 material IMO.
Quoted 6 lines
2. Analyze issue "func-arm-aspeed_ast2500 test occasionally times out"
https://gitlab.com/qemu-project/qemu/-/issues/3117
3. Adjust PCIe capabilities
3. Support AST2700 IPC model(may require refactoring the INTC model if needed)
4. Support AST2700 A2 (planned for end of this year or Q1 next year)
5. Support AST2700 boot from BootMCU(RISC-V) instead of vbootrom, if a single binary ready.
It would be great if Troy (?) could resend the models, it's good to have since single binary is making progress.
Also, these changes may be of interest, they need review :
- usb/uhci: Add UHCI sysbus support, and enable for AST (Guenter Roeck)
https://lore.kernel.org//qemu-devel/[email protected]
Looks really good. Needs reviewers and stakeholders.
- i3c: aspeed: Add I3C support (Joe Komlodi)
https://lore.kernel.org//qemu-devel/[email protected]
Looks good overall. Needs reviewers and stakeholders.
- Add Aspeed GPIO test and Support Nuvoton Serial GPIO (Coco Li)
https://lore.kernel.org//qemu-devel/[email protected] Needs reviewers
- hw/arm/aspeed: AST1700 IO expander support for (Kane-Chen-AS)
https://lore.kernel.org//qemu-devel/[email protected]
Needs rework. I will comment more when time permits
Thanks,
C.
RE: Aspeed backlog (was Re: [SPAM] [PATCH v3 00/14] Support PCIe RC to AST2600 and AST2700)
Hi Cédric
Quoted 12 lines
Subject: Aspeed backlog (was Re: [SPAM] [PATCH v3 00/14] Support PCIe RC to AST2600 and AST2700)
Hello Jamin,
Quoted 6 lines
Quoted 4 lines
One last thing, the list of PCI capabilities reported on real HW is a little different. See below. When you have time, it would be good to adjust the model if possible. It can come later.
Thanks for the suggestion and for reporting this issue. I’ll add it to my
working queue.
Quoted 8 lines
Quoted 5 lines
Here are the tasks currently in my queue:
1. Control coprocessor reset for AST2700
https://patchwork.kernel.org/project/qemu-devel/cover/20250717034054.1
[email protected]/This needs a rework of the co processor models. This should be QEMU 10.2 material IMO.
Yes, I am reworking it, and I will discuss with you within this patch series if I have any questions during the rework.
Quoted 7 lines
Quoted 7 lines
2. Analyze issue "func-arm-aspeed_ast2500 test occasionally times out"
https://gitlab.com/qemu-project/qemu/-/issues/3117
3. Adjust PCIe capabilities
3. Support AST2700 IPC model(may require refactoring the INTC model if needed) 4. Support AST2700 A2 (planned for end of this year or Q1 next year) 5. Support AST2700 boot from BootMCU(RISC-V) instead of vbootrom,
Quoted 5 lines
if a single binary ready.
It would be great if Troy (?) could resend the models, it's good to have since single binary is making progress.
I will organize and send out Troy’s patch for the AST2700 BootMCU. So far, we have only tested it up to running SPL with qemu-system-riscv32.
Thanks-Jamin
Quoted 36 lines
Also, these changes may be of interest, they need review :
- usb/uhci: Add UHCI sysbus support, and enable for AST (Guenter Roeck)
https://lore.kernel.org//qemu-devel/20241112170152.217664-1-linux@roeck-u
s.netLooks really good. Needs reviewers and stakeholders.
- i3c: aspeed: Add I3C support (Joe Komlodi)
https://lore.kernel.org//qemu-devel/20250613000411.1516521-1-komlodi@go
ogle.comLooks good overall. Needs reviewers and stakeholders.
- Add Aspeed GPIO test and Support Nuvoton Serial GPIO (Coco Li)
https://lore.kernel.org//qemu-devel/20250903213809.3779860-1-lixiaoyan@g
oogle.comNeeds reviewers
- hw/arm/aspeed: AST1700 IO expander support for (Kane-Chen-AS)
https://lore.kernel.org//qemu-devel/20250917013143.1600377-1-kane_chen@
aspeedtech.comNeeds rework. I will comment more when time permits
Thanks,
C.