Support PCIe RC to AST2600 and AST2700
Subsystems (2)
v5 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.
v4:
1. Initialize pointers to NULL when declaring them.
2. Use distinct variable names to resolve memory leak issues.
3. Update functional tests to verify assigned IP addresses from Intel NIC Ethernet interfaces.
4. Introduce pcie_mmio_alias in AspeedSoCState instead of dynamically allocating memory.
v5:
1. fix memory leak issue. Replace g_autofree with array.
Dependencies
Based on https://github.com/legoater/qemu at the aspeed-next branch.
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 | 15 + include/hw/pci-host/aspeed_pcie.h | 137 +++ include/hw/pci/pci_ids.h | 2 + hw/arm/aspeed_ast2600.c | 74 ++ hw/arm/aspeed_ast27x0.c | 74 ++ hw/pci-host/aspeed_pcie.c | 1015 +++++++++++++++++ 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 | 21 + .../aarch64/test_aspeed_ast2700fc.py | 13 + tests/functional/arm/test_aspeed_ast2600.py | 21 + 13 files changed, 1391 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 v5 3/14 hw/pci-host/aspeed: Add AST2600 PCIe config space and host bridge
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 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 | 421 ++++++++++++++++++++++++++++++ hw/pci-host/trace-events | 4 + 3 files changed, 484 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 +421 -0
433 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
PATCH v5 1/14 hw/pci/pci_ids: Add PCI vendor ID for ASPEED
In reply to Jamin Lin via--- 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 v5 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 v5 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 v5 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 | 132 ++++++++++++++++++++++++++++++ hw/pci-host/trace-events | 3 + 3 files changed, 145 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 +132 -0
198 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 v5 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 | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
tests/functional/arm/test_aspeed_ast2600.py +21 -0
@@ -101,8 +101,26 @@ 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 show dev eth4', + 'inet 10.0.2.15/24') + def test_arm_ast2600_evb_sdk(self): self.set_machine('ast2600-evb') + self.require_netdev('user') self.archive_extract(self.ASSET_SDK_V907_AST2600)
@@ -110,6 +128,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 +155,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
PATCH v5 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
PATCH v5 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 | 74 +++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+)
include/hw/arm/aspeed_soc.h +1 -0
@@ -186,6 +186,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 +74 -0
152 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v5 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.
--- include/hw/arm/aspeed_soc.h | 1 + hw/arm/aspeed_ast2600.c | 74 +++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+)
include/hw/arm/aspeed_soc.h +1 -0
@@ -62,6 +62,7 @@ struct AspeedSoCState {MemoryRegion spi_boot_container;MemoryRegion spi_boot;MemoryRegion vbootrom; +MemoryRegion pcie_mmio_alias[ASPEED_PCIE_NUM ];AddressSpace dram_as;AspeedRtcState rtc;AspeedTimerCtrlState timerctrl;
hw/arm/aspeed_ast2600.c +74 -0
115 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v5 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 v5 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
@@ -696,6 +696,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,
@@ -803,6 +809,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);
@@ -810,6 +848,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 v5 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
@@ -829,6 +829,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 v5 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 v5 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 | 21 +++++++++++++++++++ .../aarch64/test_aspeed_ast2700fc.py | 13 ++++++++++++ 2 files changed, 34 insertions(+)
tests/functional/aarch64/test_aspeed_ast2700.py +21 -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,
@@ -125,20 +135,31 @@ def test_aarch64_ast2700a0_evb_sdk_v09_06(self): def test_aarch64_ast2700a1_evb_sdk_v09_06(self): self.set_machine('ast2700a1-evb') + self.require_netdev('user') 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.require_netdev('user') 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 show dev eth2', + 'inet 10.0.2.15/24') 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
Re: [SPAM] [PATCH v5 12/14] hw/arm/aspeed_ast27x0: Introduce 3 PCIe RCs for AST2700
In reply to Jamin Lin viaQuoted 14 lines · Jamin Lin
Add 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 at0x120E0000, MMIO window at0x60000000, and GIC IRQ 56.PCIe1 with its PHY at
0x12C15800, config (H2X) block at0x120F0000, MMIO window at0x80000000, and GIC IRQ 57.PCIe2 with its PHY at
0x14C1C000, config (H2X) block at0x140D0000, MMIO window at0xA0000000, and IRQ routed through INTC4 bit 31 mapped to GIC IRQ 196.
Quoted 6 lines
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, sopcie_numis set to 0 in that variant.Signed-off-by Jamin Lin <[email protected]>
Thanks,
C.
Quoted 186 lines
--- include/hw/arm/aspeed_soc.h | 1 + hw/arm/aspeed_ast27x0.c | 74 +++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+)include/hw/arm/aspeed_soc.h +1
-0@@ -186,6 +186,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 +74
-0@@ -38,6 +38,8 @@ static const hwaddr aspeed_soc_ast2700_memmap[] = { [ASPEED_DEV_EHCI2] = 0x12063000, [ASPEED_DEV_HACE] = 0x12070000, [ASPEED_DEV_EMMC] = 0x12090000, + [ASPEED_DEV_PCIE0] = 0x120E0000, + [ASPEED_DEV_PCIE1] = 0x120F0000, [ASPEED_DEV_INTC] = 0x12100000, [ASPEED_GIC_DIST] = 0x12200000, [ASPEED_GIC_REDIST] = 0x12280000,@@ -45,6 +47,8 @@ static const hwaddr aspeed_soc_ast2700_memmap[] = { [ASPEED_DEV_SCU] = 0x12C02000, [ASPEED_DEV_RTC] = 0x12C0F000, [ASPEED_DEV_TIMER1] = 0x12C10000, + [ASPEED_DEV_PCIE_PHY0] = 0x12C15000, + [ASPEED_DEV_PCIE_PHY1] = 0x12C15800, [ASPEED_DEV_SLI] = 0x12C17000, [ASPEED_DEV_UART4] = 0x12C1A000, [ASPEED_DEV_IOMEM1] = 0x14000000,@@ -59,6 +63,7 @@ static const hwaddr aspeed_soc_ast2700_memmap[] = { [ASPEED_DEV_ETH2] = 0x14060000, [ASPEED_DEV_ETH3] = 0x14070000, [ASPEED_DEV_SDHCI] = 0x14080000, + [ASPEED_DEV_PCIE2] = 0x140D0000, [ASPEED_DEV_EHCI3] = 0x14121000, [ASPEED_DEV_EHCI4] = 0x14123000, [ASPEED_DEV_ADC] = 0x14C00000,@@ -66,6 +71,7 @@ static const hwaddr aspeed_soc_ast2700_memmap[] = { [ASPEED_DEV_GPIO] = 0x14C0B000, [ASPEED_DEV_I2C] = 0x14C0F000, [ASPEED_DEV_INTCIO] = 0x14C18000, + [ASPEED_DEV_PCIE_PHY2] = 0x14C1C000, [ASPEED_DEV_SLIIO] = 0x14C1E000, [ASPEED_DEV_VUART] = 0x14C30000, [ASPEED_DEV_UART0] = 0x14C33000,@@ -81,6 +87,9 @@ static const hwaddr aspeed_soc_ast2700_memmap[] = { [ASPEED_DEV_UART11] = 0x14C33A00, [ASPEED_DEV_UART12] = 0x14C33B00, [ASPEED_DEV_WDT] = 0x14C37000, + [ASPEED_DEV_PCIE_MMIO0] = 0x60000000, + [ASPEED_DEV_PCIE_MMIO1] = 0x80000000, + [ASPEED_DEV_PCIE_MMIO2] = 0xA0000000, [ASPEED_DEV_SPI_BOOT] = 0x100000000, [ASPEED_DEV_LTPI] = 0x300000000, [ASPEED_DEV_SDRAM] = 0x400000000,@@ -156,6 +165,8 @@ static const int aspeed_soc_ast2700a1_irqmap[] = { [ASPEED_DEV_DP] = 28, [ASPEED_DEV_EHCI1] = 33, [ASPEED_DEV_EHCI2] = 37, + [ASPEED_DEV_PCIE0] = 56, + [ASPEED_DEV_PCIE1] = 57, [ASPEED_DEV_LPC] = 192, [ASPEED_DEV_IBT] = 192, [ASPEED_DEV_KCS] = 192,@@ -166,6 +177,7 @@ static const int aspeed_soc_ast2700a1_irqmap[] = { [ASPEED_DEV_WDT] = 195, [ASPEED_DEV_PWM] = 195, [ASPEED_DEV_I3C] = 195, + [ASPEED_DEV_PCIE2] = 196, [ASPEED_DEV_UART0] = 196, [ASPEED_DEV_UART1] = 196, [ASPEED_DEV_UART2] = 196,@@ -233,6 +245,7 @@ static const int ast2700_gic132_gic196_intcmap[] = { [ASPEED_DEV_UART12] = 18, [ASPEED_DEV_EHCI3] = 28, [ASPEED_DEV_EHCI4] = 29, + [ASPEED_DEV_PCIE2] = 31, };/* GICINT 133 */ @@ -519,6 +532,17 @@ static void aspeed_soc_ast2700_init(Object *obj)snprintf (typename,sizeof (typename),"aspeed.hace-%s" , socname);object_initialize_child (obj,"hace" , &s->hace, typename); + +for (i =0 ; i < sc->pcie_num; i++) { +snprintf (typename,sizeof (typename),"aspeed.pcie-phy-%s" , socname); +object_initialize_child (obj,"pcie-phy[*]" , &s->pcie_phy[i], typename); +object_property_set_int (OBJECT (&s->pcie_phy[i]),"id" , i, &error_abort); + +snprintf (typename,sizeof (typename),"aspeed.pcie-cfg-%s" , socname); +object_initialize_child (obj,"pcie-cfg[*]" , &s->pcie[i], typename); +object_property_set_int (OBJECT (&s->pcie[i]),"id" , i, &error_abort); + } +object_initialize_child (obj,"dpmcu" , &s->dpmcu,TYPE_UNIMPLEMENTED_DEVICE ); object_initialize_child(obj, "ltpi", &s->ltpi,@@ -610,6 +634,49 @@ static bool aspeed_soc_ast2700_gic_realize(DeviceState *dev, Error **errp)return true; } +static bool aspeed_soc_ast2700_pcie_realize (DeviceState *dev,Error **errp) +{ +AspeedSoCState *s =ASPEED_SOC (dev); +AspeedSoCClass *sc =ASPEED_SOC_GET_CLASS (s); +MemoryRegion *mmio_mr =NULL ; +char name[64 ]; +qemu_irq irq; +int i; + +for (i =0 ; i < sc->pcie_num; i++) { +if (!sysbus_realize (SYS_BUS_DEVICE (&s->pcie_phy[i]), errp)) { +return false; + } +aspeed_mmio_map (s,SYS_BUS_DEVICE (&s->pcie_phy[i]),0 , + sc->memmap[ASPEED_DEV_PCIE_PHY0 + i]); + +object_property_set_int (OBJECT (&s->pcie[i]),"dram-base" , + sc->memmap[ASPEED_DEV_SDRAM ], + &error_abort); +object_property_set_link (OBJECT (&s->pcie[i]),"dram" , +OBJECT (s->dram_mr), &error_abort); +if (!sysbus_realize (SYS_BUS_DEVICE (&s->pcie[i]), errp)) { +return false; + } +aspeed_mmio_map (s,SYS_BUS_DEVICE (&s->pcie[i]),0 , + sc->memmap[ASPEED_DEV_PCIE0 + i]); + irq =aspeed_soc_get_irq (s,ASPEED_DEV_PCIE0 + i); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->pcie[i].rc),0 , irq); + + mmio_mr =sysbus_mmio_get_region (SYS_BUS_DEVICE (&s->pcie[i].rc),1 ); +snprintf (name,sizeof (name),"aspeed.pcie-mmio.%d" , i); +memory_region_init_alias (&s->pcie_mmio_alias[i],OBJECT (&s->pcie[i].rc), + name, mmio_mr, + sc->memmap[ASPEED_DEV_PCIE_MMIO0 + i], +0x20000000 ); +memory_region_add_subregion (s->memory, + sc->memmap[ASPEED_DEV_PCIE_MMIO0 + i], + &s->pcie_mmio_alias[i]); + } + +return true; +} +static void aspeed_soc_ast2700_realize (DeviceState *dev,Error **errp) {int i;@@ -936,6 +1003,11 @@ static void aspeed_soc_ast2700_realize(DeviceState *dev, Error **errp)sysbus_connect_irq (SYS_BUS_DEVICE (&s->hace),0 ,aspeed_soc_get_irq (s,ASPEED_DEV_HACE )); +/* PCIe Root Complex (RC) */ +if (!aspeed_soc_ast2700_pcie_realize (dev, errp)) { +return ; + } + aspeed_mmio_map_unimplemented(s, SYS_BUS_DEVICE(&s->dpmcu), "aspeed.dpmcu", sc->memmap[ASPEED_DEV_DPMCU],@@ -974,6 +1046,7 @@ static void aspeed_soc_ast2700a0_class_init(ObjectClass *oc, const void *data) sc->valid_cpu_types = valid_cpu_types; sc->silicon_rev =AST2700_A0_SILICON_REV ; sc->sram_size =0x20000 ; + sc->pcie_num =0 ; sc->spis_num =3 ; sc->ehcis_num =2 ; sc->wdts_num =8 ;@@ -1002,6 +1075,7 @@ static void aspeed_soc_ast2700a1_class_init(ObjectClass *oc, const void *data) sc->valid_cpu_types = valid_cpu_types; sc->silicon_rev =AST2700_A1_SILICON_REV ; sc->sram_size =0x20000 ; + sc->pcie_num =3 ; sc->spis_num =3 ; sc->ehcis_num =4 ; sc->wdts_num =8 ;
Cédric Le Goater
AppliedQuoted 30 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.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.v4:
1. Initialize pointers to NULL when declaring them.
2. Use distinct variable names to resolve memory leak issues.
3. Update functional tests to verify assigned IP addresses from Intel NIC Ethernet interfaces.
4. Introducepcie_mmio_aliasin AspeedSoCState instead of dynamically allocating memory.
Quoted 3 lines
v5:
1. fix memory leak issue. Replaceg_autofreewith array.
Applied to aspeed-next.
Thanks,
C.
Hi Cédric
Quoted 39 lines
Subject: Re: [SPAM] [PATCH v5 00/14] Support PCIe RC to AST2600 and AST2700
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 10 lines
implementation.
v4:
1. Initialize pointers to NULL when declaring them.
2. Use distinct variable names to resolve memory leak issues.
3. Update functional tests to verify assigned IP addresses from Intel NIC Ethernet interfaces.
4. Introducepcie_mmio_aliasin AspeedSoCState instead of dynamically allocating memory.
Quoted 5 lines
Quoted 3 lines
v5:
1. fix memory leak issue. Replaceg_autofreewith array.Applied to aspeed-next.
I saw that this patch series has been merged into master, but it looks like this particular patch was missed:
https://patchwork.kernel.org/project/qemu-devel/patch/[email protected]/
[v5,14/14] tests/functional/aarch64/aspeed_ast2700: Add PCIe and network tests
Could you please help check on this?
Thanks,
Jamin
Quoted 4 lines
Thanks,
C.
Quoted 44 lines · Jamin Lin
Hi Cédric
Quoted 42 lines
Subject: Re: [SPAM] [PATCH v5 00/14] Support PCIe RC to AST2600 and AST2700
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 13 lines
implementation.
v4:
1. Initialize pointers to NULL when declaring them.
2. Use distinct variable names to resolve memory leak issues.
3. Update functional tests to verify assigned IP addresses from Intel NIC Ethernet interfaces.
4. Introducepcie_mmio_aliasin AspeedSoCState instead of dynamically allocating memory.v5:
1. fix memory leak issue. Replaceg_autofreewith array.
Quoted 8 lines
Quoted 2 lines
Applied to aspeed-next.
I saw that this patch series has been merged into master, but it looks like this particular patch was missed:
https://patchwork.kernel.org/project/qemu-devel/patch/[email protected]/
[v5,14/14] tests/functional/aarch64/aspeed_ast2700: Add PCIe and network testsCould you please help check on this?
my fault. I'll include it in the next PR. Sorry about that.
C.
Cédric Le Goater
AppliedRe: [SPAM] [PATCH v5 14/14] tests/functional/aarch64/aspeed_ast2700: Add PCIe and network tests
In reply to Jamin Lin viaQuoted 15 lines · Jamin Lin
Extend 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 ConnectionAdditional changes:
- Add-device e1000e,netdev=net1,bus=pcie.2 -netdev user,id=net1to the AST2700 and AST2700fc test machines.
- In the AST2700 vbootrom test, assign an IP address to the e1000e interface and verify it usingip addr.
Quoted 6 lines
Signed-off-by Jamin Lin <[email protected]>Reviewed-by Cédric Le Goater <[email protected]>--- .../functional/aarch64/test_aspeed_ast2700.py | 21 +++++++++++++++++++ .../aarch64/test_aspeed_ast2700fc.py | 13 ++++++++++++ 2 files changed, 34 insertions(+)
Applied to aspeed-next (since I forgot this patch in the previous PR)
Thanks,
C.