Support PCIe RC to AST2600 and AST2700
Subsystems (2)
PATCH 1/11 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
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.
Testing PCIe RC model with e1000e PCIe device model
AST2600
The AST2600/ASPEED PCIe driver treats root bus 0x80 specially:
Only two device addresses are usable on the root bus:
addr 0: ASPEED host bridge
addr 8: usable for attaching a PCIe root port
To attach endpoints without driver changes, the test places a QEMU PCIe root port at 0x80:08.0 and attaches an e1000e NIC behind it.
The endpoint then enumerates on bus 0x81.
QEMU command line additions
-device pcie-root-port,id=root_port0,slot=1,addr=8,bus=pcie.0 -device e1000e,netdev=net0,bus=root_port0
-netdev user,id=net0
Verification with lspci:
0001:80:00.0 Host bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge 0001:80:08.0 PCI bridge: Red Hat, Inc. QEMU PCIe Root port 0001:81:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection
This is a temporary solution that allows attaching multiple PCIe devices while the ASPEED drivers does not support placing endpoints directly on bus numbers 0x80.
Test Image: ASPEED SDK v09.07. It okay to use ASPEED SDK v09.06.
https://github.com/AspeedTech-BMC/openbmc/releases/download/v09.07/ast2600-default-obmc.tar.gz
The e1000e driver is built into this image.
After booting, users should see the e1000e Ethernet interface. With this setup, RC_H on AST2600 can be tested using e1000e endpoints in QEMU.
Example system output:
root@ast2600-default:~# lspci
80:00.0 Host bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge
80:08.0 PCI bridge: Red Hat, Inc. QEMU PCIe Root port
81:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection
root@ast2600-default:~# ifconfig eth4
eth4 Link encap:Ethernet HWaddr 52:54:00:12:34:5A
inet addr:169.254.160.167 Bcast:169.254.255.255 Mask:255.255.0.0
inet6 addr: fe80::5054:ff:fe12:345a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:19 errors:0 dropped:0 overruns:0 frame:0
TX packets:54 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:4896 (4.7 KiB) TX bytes:8079 (7.8 KiB)
Interrupt:81 Memory:70040000-70060000root@ast2600-default:~# dmesg | grep "e1000e" [ 2.901955] e1000e: Intel(R) PRO/1000 Network Driver [ 2.902346] e1000e: Copyright(c) 1999 - 2015 Intel Corporation. [ 15.366727] e1000e 0000:81:00.0: Interrupt Throttling Rate (ints/sec) set to dynamic conservative mode [ 15.431884] e1000e 0000:81:00.0 0000:81:00.0 (uninitialized): registered PHC clock [ 15.508477] e1000e 0000:81:00.0 eth4: (PCI Express:2.5GT/s:Width x1) 52:54:00:12:34:5a [ 15.509301] e1000e 0000:81:00.0 eth4: Intel(R) PRO/1000 Network Connection [ 15.510768] e1000e 0000:81:00.0 eth4: MAC: 3, PHY: 8, PBA No: 000000-000 [ 49.781217] e1000e 0000:81:00.0 eth4: NIC Link is Up 1000 Mbps Full Duplex, Flow Control: Rx/Tx
AST2700:
The ASPEED PCIe driver only supports bus 0 with a single device at slot 0, which is reserved for the internal bridge. All endpoint devices must therefore reside on bus 1 to be discovered.
See the ASPEED PCIe driver implementation here:
https://github.com/AspeedTech-BMC/linux/blob/aspeed-master-v6.6/drivers/pci/controller/pcie-aspeed.c#L512
By default, the ASPEED SDK enables only PCIe RC2, so initial testing covers RC2 only.
To attach e1000e devices and test all three RCs, I created a new test image with driver modifications. This is a temporary solution. A better approach is still needed to allow placing e1000e directly under bus 1.
Test release: https://github.com/jamin-aspeed/openbmc/releases/tag/qemu-test-0907
Image download: https://github.com/jamin-aspeed/openbmc/releases/download/qemu-test-0907/ast2700-default-pcie-qemu.tar.xz
This image includes the following changes:
Kernel patch (AST2700 RC mode + PCIe driver updates):
https://github.com/jamin-aspeed/openbmc/releases/download/qemu-test-0907/0001-PCI-aspeed-Enable-AST2700-RC-mode-support-and-adjust.patch
OpenBMC patch (installs e1000e modules into rootfs for testing):
https://github.com/jamin-aspeed/openbmc/releases/download/qemu-test-0907/0001-packagegroup-aspeed-Add-Intel-e1000-e1000e-kernel-mo.patch
QEMU Test Command
Each PCIe RC bus adds a pcie-root-port with an e1000e NIC behind it:
-device pcie-root-port,id=root_port0,multifunction=on,slot=0,addr=1,bus=pcie.0 \
-device e1000e,netdev=net0,bus=root_port0 \
-netdev user,id=net0,hostfwd=:127.0.0.1:3222-:22,hostname=qemu0 \
-device pcie-root-port,id=root_port1,slot=1,addr=2,bus=pcie.1 \
-device e1000e,netdev=net1,bus=root_port1 \
-netdev user,id=net1,hostfwd=:127.0.0.1:4222-:22,hostname=qemu1 \
-device pcie-root-port,id=root_port2,slot=2,addr=3,bus=pcie.2 \
-device e1000e,netdev=net2,bus=root_port2 \
-netdev user,id=net2,hostfwd=:127.0.0.1:5222-:22,hostname=qemu2 \
Expected Results
With lspci, each RC should show the internal bridge, root port, and e1000e endpoint:
root@ast2700-default:~# lspci 0000:00:00.0 Host bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge 0000:00:01.0 PCI bridge: Red Hat, Inc. QEMU PCIe Root port 0000:01:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection 0001:00:00.0 Host bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge 0001:00:02.0 PCI bridge: Red Hat, Inc. QEMU PCIe Root port 0001:01:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection 0002:00:00.0 Host bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge 0002:00:03.0 PCI bridge: Red Hat, Inc. QEMU PCIe Root port 0002:01:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection
Load the e1000e driver:
Kernel logs confirm device initialization and link-up at 1 Gbps Full Duplex on eth2/eth3/eth4.
root@ast2700-default:~# modprobe e1000e [ 59.181623] e1000e: Intel(R) PRO/1000 Network Driver [ 59.181926] e1000e: Copyright(c) 1999 - 2015 Intel Corporation. [ 59.183508] e1000e 0000:01:00.0: enabling device (0000 -> 0002) [ 59.188808] e1000e 0000:01:00.0: Interrupt Throttling Rate (ints/sec) set to dynamic conservative mode [ 59.252590] e1000e 0000:01:00.0 0000:01:00.0 (uninitialized): registered PHC clock [ 59.330877] e1000e 0000:01:00.0 eth2: (PCI Express:2.5GT/s:Width x1) 52:54:00:12:34:56 [ 59.331990] e1000e 0000:01:00.0 eth2: Intel(R) PRO/1000 Network Connection [ 59.333211] e1000e 0000:01:00.0 eth2: MAC: 3, PHY: 8, PBA No: 000000-000 [ 59.334881] e1000e 0001:01:00.0: enabling device (0000 -> 0002) [ 59.341616] e1000e 0001:01:00.0: Interrupt Throttling Rate (ints/sec) set to dynamic conservative mode [ 59.394712] e1000e 0001:01:00.0 0001:01:00.0 (uninitialized): registered PHC clock [ 59.456674] e1000e 0001:01:00.0 eth3: (PCI Express:2.5GT/s:Width x1) 52:54:00:12:34:57 [ 59.457487] e1000e 0001:01:00.0 eth3: Intel(R) PRO/1000 Network Connection [ 59.458033] e1000e 0001:01:00.0 eth3: MAC: 3, PHY: 8, PBA No: 000000-000 [ 59.460037] e1000e 0002:01:00.0: enabling device (0000 -> 0002) [ 59.466403] e1000e 0002:01:00.0: Interrupt Throttling Rate (ints/sec) set to dynamic conservative mode [ 59.533361] e1000e 0002:01:00.0 0002:01:00.0 (uninitialized): registered PHC clock [ 59.654491] 8021q: adding VLAN 0 to HW filter on device eth2 [ 59.662100] e1000e 0002:01:00.0 eth4: (PCI Express:2.5GT/s:Width x1) 52:54:00:12:34:58 [ 59.662966] e1000e 0002:01:00.0 eth4: Intel(R) PRO/1000 Network Connection [ 59.663527] e1000e 0002:01:00.0 eth4: MAC: 3, PHY: 8, PBA No: 000000-000 root@ast2700-default:~# [ 59.814984] 8021q: adding VLAN 0 to HW filter on device eth3 [ 59.938859] 8021q: adding VLAN 0 to HW filter on device eth4 [ 59.954690] e1000e 0000:01:00.0 eth2: NIC Link is Up 1000 Mbps Full Duplex, Flow Control: Rx/Tx [ 60.116790] e1000e 0001:01:00.0 eth3: NIC Link is Up 1000 Mbps Full Duplex, Flow Control: Rx/Tx [ 60.237622] e1000e 0002:01:00.0 eth4: NIC Link is Up 1000 Mbps Full Duplex, Flow Control: Rx/Tx
After loading, users should see:
eth2: PCIe0
eth3: PCIe1
eth4: PCIe2
Example ifconfig output shows all interfaces (eth0-eth4) active, with eth2-eth4 bound to the e1000e NICs. With this setup, all three PCIe RCs on AST2700 can be tested using e1000e endpoints in QEMU.
root@ast2700-default:~# ifconfig
eth2 Link encap:Ethernet HWaddr 52:54:00:12:34:56
inet addr:169.254.120.135 Bcast:169.254.255.255 Mask:255.255.0.0
inet6 addr: fe80::5054:ff:fe12:3456/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:19 errors:0 dropped:0 overruns:0 frame:0
TX packets:51 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:5227 (5.1 KiB) TX bytes:8551 (8.3 KiB)
Interrupt:42 Memory:60040000-60060000eth3 Link encap:Ethernet HWaddr 52:54:00:12:34:57
inet addr:169.254.237.52 Bcast:169.254.255.255 Mask:255.255.0.0
inet6 addr: fe80::5054:ff:fe12:3457/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:16 errors:0 dropped:0 overruns:0 frame:0
TX packets:47 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:4786 (4.6 KiB) TX bytes:8175 (7.9 KiB)
Interrupt:45 Memory:80040000-80060000eth4 Link encap:Ethernet HWaddr 52:54:00:12:34:58
inet addr:169.254.84.173 Bcast:169.254.255.255 Mask:255.255.0.0
inet6 addr: fe80::5054:ff:fe12:3458/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:16 errors:0 dropped:0 overruns:0 frame:0
TX packets:47 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:4786 (4.6 KiB) TX bytes:8191 (7.9 KiB)
Interrupt:48 Memory:a0040000-a0060000Jamin Lin (11):
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 and host bridge 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) tests/functional/test_arm_aspeed_ast2600: Add PCIe test via root port
and e1000e
hw/pci-host/aspeed: Add AST2700 PCIe PHY hw/pci-host/aspeed: Add AST2700 PCIe config with dedicated H2X blocks hw/arm/aspeed_ast27x0: Introduce 3 PCIe RCs for AST2700 tests/functional: Add PCIe presence test for AST2700
include/hw/arm/aspeed_soc.h | 14 + include/hw/pci-host/aspeed_pcie.h | 125 +++ include/hw/pci/pci_ids.h | 2 + hw/arm/aspeed_ast2600.c | 69 +- hw/arm/aspeed_ast27x0.c | 61 ++ hw/pci-host/aspeed_pcie.c | 955 ++++++++++++++++++ hw/arm/Kconfig | 3 + hw/pci-host/Kconfig | 4 + hw/pci-host/meson.build | 1 + hw/pci-host/trace-events | 11 + .../functional/test_aarch64_aspeed_ast2700.py | 7 + .../test_aarch64_aspeed_ast2700fc.py | 6 + tests/functional/test_arm_aspeed_ast2600.py | 14 + 13 files changed, 1269 insertions(+), 3 deletions(-) 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 7/11 tests/functional/test_arm_aspeed_ast2600: Add PCIe test via root port and e1000e
Add a functional test that exercises the AST2600 PCIe RC_H by creating a root port and an e1000e endpoint behind it. The AST2600/ASPEED driver treats root bus 0x80 specially: only two device addresses are usable on the root bus, addr 0 (ASPEED host bridge) and addr 8. To attach endpoints without code changes, the test places a QEMU PCIe root port at 0x80:08.0 and hangs e1000e behind it so the endpoint enumerates on bus 0x81.
The test appends:
-device pcie-root-port,id=root_port0,slot=1,addr=8,bus=pcie.0 -device e1000e,netdev=net0,bus=root_port0
-netdev user,id=net0
It then verifies enumeration with lspci:
0001:80:00.0 Host bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge 0001:80:08.0 PCI bridge: Red Hat, Inc. QEMU PCIe Root port 0001:81:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection
This is a temporary solution that allows attaching multiple PCIe devices while the ASPEED drivers does not support placing endpoints directly on bus numbers 0x80.
--- tests/functional/test_arm_aspeed_ast2600.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
tests/functional/test_arm_aspeed_ast2600.py +14 -0
@@ -110,6 +110,10 @@ 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', + 'pcie-root-port,id=root_port0,slot=1,addr=8,bus=pcie.0') + self.vm.add_args('-device', 'e1000e,netdev=net0,bus=root_port0') + self.vm.add_args('-netdev', 'user,id=net0') self.do_test_arm_aspeed_sdk_start( self.scratch_file("ast2600-default", "image-bmc"))
@@ -136,5 +140,15 @@ def test_arm_ast2600_evb_sdk(self): exec_command_and_wait_for_pattern(self, '/sbin/hwclock -f /dev/rtc1', year) + exec_command_and_wait_for_pattern(self, + 'lspci -s 0001:80:00.0', + '0001:80:00.0 Host bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge') + exec_command_and_wait_for_pattern(self, + 'lspci -s 0001:80:08.0', + '0001:80:08.0 PCI bridge: Red Hat, Inc. QEMU PCIe Root port') + exec_command_and_wait_for_pattern(self, + 'lspci -s 0001:81:00.0', + '0001:81:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection') + if __name__ == '__main__': AspeedTest.main()
Signature · 1 line
2.43.0
PATCH 9/11 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
@@ -78,6 +78,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 {
@@ -88,6 +89,8 @@ struct AspeedPCIECfgState {uint32_t id;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 6/11 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 | 69 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 3 deletions(-)
hw/arm/aspeed_ast2600.c +66 -3
@@ -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);
@@ -292,7 +300,9 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)AspeedSoCState *s =ASPEED_SOC (dev);AspeedSoCClass *sc =ASPEED_SOC_GET_CLASS (s);qemu_irq irq; - g_autofree char *sram_name = NULL; + g_autofree char *name = NULL; +MemoryRegion *mmio_alias; +MemoryRegion *mmio_mr;/* Default boot region (SPI memory or ROMs) */ memory_region_init(&s->spi_boot_container, OBJECT(s),
@@ -362,8 +372,8 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) }/* SRAM */ - sram_name =g_strdup_printf ("aspeed.sram.%d" ,CPU (&a->cpu[0 ])->cpu_index); -if (!memory_region_init_ram (&s->sram,OBJECT (s), sram_name, sc->sram_size, + name =g_strdup_printf ("aspeed.sram.%d" ,CPU (&a->cpu[0 ])->cpu_index); +if (!memory_region_init_ram (&s->sram,OBJECT (s), name, sc->sram_size, errp)) {return ; }
@@ -438,6 +448,59 @@ 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) +* +* 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. +*/ +if (!sysbus_realize (SYS_BUS_DEVICE (&s->pcie_phy[0 ]), errp)) { +return ; + } +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 ; + } +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); +/* 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
PATCH 2/11 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.
--- include/hw/pci-host/aspeed_pcie.h | 44 +++++++++ hw/pci-host/aspeed_pcie.c | 159 ++++++++++++++++++++++++++++++ hw/arm/Kconfig | 3 + hw/pci-host/Kconfig | 4 + hw/pci-host/meson.build | 1 + hw/pci-host/trace-events | 4 + 6 files changed, 215 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 +44 -0
@@ -0,0 +1,44 @@ +/* +* ASPEED PCIe Host Controller +* +* Copyright (C) 2025 ASPEED Technology Inc. +* Copyright (c) 2022 Cédric Le Goater <[email protected]> +* +* Jamin Lin <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* This file is based on Cédric Le Goater's patch: +* "pci: Add Aspeed host bridge (WIP)" +* https://github.com/legoater/qemu/commit/d1b97b0c7844219d847122410dc189854f9d26df +* +* Modifications have been made to support 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 +159 -0
159 lines not on this page · raw message
hw/arm/Kconfig +3 -0
@@ -544,6 +544,7 @@ config ASPEED_SOC bool default y depends on TCG && ARM + imply PCI_DEVICES select DS1338 select FTGMAC100 select I2C
@@ -564,6 +565,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 10/11 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 | 61 +++++++++++++++++++++++++++++++++++++ 2 files changed, 62 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 +61 -0
139 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 11/11 tests/functional: Add PCIe presence test for AST2700
In reply to Jamin Lin viaAdd a basic functional test for the AST2700 PCIe Root Complex. The test runs "lspci" to verify that the internal host bridge is enumerated at BDF 0002:00:00.0.
Note: the ASPEED PCIe driver only supports bus 0 with a single device at slot 0, which is reserved for the internal bridge. All endpoint devices must reside on bus 1 to be discovered. As a result, this test only checks that the internal bridge is visible. Attaching pcie-root-port and e1000e devices is not possible without driver changes.
This is a temporary solution. See the ASPEED PCIe driver implementation for details:
https://github.com/AspeedTech-BMC/linux/blob/aspeed-master-v6.6/drivers/pci/controller/pcie-aspeed.c#L512
Additionally, the ASPEED SDK by default enables only PCIe RC2, so the test covers RC2 only.
--- tests/functional/test_aarch64_aspeed_ast2700.py | 7 +++++++ tests/functional/test_aarch64_aspeed_ast2700fc.py | 6 ++++++ 2 files changed, 13 insertions(+)
tests/functional/test_aarch64_aspeed_ast2700.py +7 -0
@@ -65,6 +65,11 @@ 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 Host bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge') + def start_ast2700_test(self, name): num_cpu = 4 uboot_size = os.path.getsize(self.scratch_file(name,
@@ -126,6 +131,7 @@ def test_aarch64_ast2700a1_evb_sdk_v09_06(self): 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_06(self): self.set_machine('ast2700a1-evb')
@@ -135,6 +141,7 @@ def test_aarch64_ast2700a1_evb_sdk_vbootrom_v09_06(self): self.verify_vbootrom_firmware_flow() self.verify_openbmc_boot_and_login('ast2700-default') self.do_ast2700_i2c_test() + self.do_ast2700_pcie_test() if __name__ == '__main__': QemuSystemTest.main()
tests/functional/test_aarch64_aspeed_ast2700fc.py +6 -0
@@ -49,6 +49,11 @@ 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 Host bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge') + def do_ast2700fc_ssp_test(self): self.vm.shutdown() self.vm.set_console(console_index=1)
@@ -128,6 +133,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
PATCH 3/11 hw/pci-host/aspeed: Add AST2600 PCIe config 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 port 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 device (TYPE_ASPEED_PCIE_ROOT).
- 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 | 67 +++++ hw/pci-host/aspeed_pcie.c | 467 ++++++++++++++++++++++++++++++ hw/pci-host/trace-events | 4 + 3 files changed, 538 insertions(+)
include/hw/pci-host/aspeed_pcie.h +67 -0
@@ -24,6 +24,73 @@#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_ROOT "aspeed.pcie-root" +OBJECT_DECLARE_SIMPLE_TYPE (AspeedPCIERootState,ASPEED_PCIE_ROOT ); + +struct AspeedPCIERootState { +PCIBridge parent_obj; +}; + +#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; + +AspeedPCIERootState root; +}; + +/* 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; + +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 +467 -0
479 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 5/11 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 8/11 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
@@ -102,6 +102,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
@@ -639,6 +639,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,
@@ -746,12 +752,45 @@ 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_root_info);type_register_static (&aspeed_pcie_rc_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 4/11 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
@@ -36,6 +36,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 {
@@ -55,11 +57,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 bus_nr;char name[16 ];qemu_irq irq;
@@ -87,6 +96,7 @@ struct AspeedPCIECfgClass {const AspeedPCIERegMap *reg_map;const MemoryRegionOps *reg_ops; +uint32_t rc_msi_addr;uint64_t rc_bus_nr;uint64_t nr_regs; };
hw/pci-host/aspeed_pcie.c +132 -0
192 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
Hello Jamin,
Quoted 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.Testing PCIe RC model with e1000e PCIe device model
AST2600
The AST2600/ASPEED PCIe driver treats root bus
0x80specially:
Only two device addresses are usable on the root bus:
addr 0: ASPEED host bridge
addr 8: usable for attaching a PCIe root portTo attach endpoints without driver changes, the test places a QEMU PCIe root port at 0x80:08.0 and attaches an e1000e NIC behind it.
The endpoint then enumerates on bus0x81.QEMU command line additions
(quoted diff) +0
-3-device pcie-root-port,id=root_port0,slot=1,addr=8,bus=pcie.0 -device e1000e,netdev=net0,bus=root_port0 -netdev user,id=net0Verification with lspci:
0001:80:00.0 Host bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge 0001:80:08.0 PCI bridge: Red Hat, Inc. QEMU PCIe Root port 0001:81:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection
Quoted 3 lines
This is a temporary solution that allows attaching multiple PCIe devices while the ASPEED drivers does not support placing endpoints directly on bus numbers
0x80.
Could we try to model the real HW topology ? On an ast2600a3 EVB with a PCI serial adapter plugged in the available slot :
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 (rev 06) 81:00.0 Serial controller: MosChip Semiconductor Technology Ltd. MCS9922 PCIe Multi-I/O Controller 81:00.1 Serial controller: MosChip Semiconductor Technology Ltd. MCS9922 PCIe Multi-I/O Controller
What is blocking us from modeling "Device 2600" ?
Thanks,
C.
Quoted 189 lines
Test Image: ASPEED SDK v09.07. It okay to use ASPEED SDK v09.06.
https://github.com/AspeedTech-BMC/openbmc/releases/download/v09.07/ast2600-default-obmc.tar.gzThe e1000e driver is built into this image.
After booting, users should see the e1000e Ethernet interface. With this setup,RC_Hon AST2600 can be tested using e1000e endpoints in QEMU.Example system output:
root@ast2600-default:~# lspci 80:00.0 Host bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge 80:08.0 PCI bridge: Red Hat, Inc. QEMU PCIe Root port 81:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection root@ast2600-default:~# ifconfig eth4 eth4 Link encap:Ethernet HWaddr 52:54:00:12:34:5A inet addr:169.254.160.167 Bcast:169.254.255.255 Mask:255.255.0.0 inet6 addr: fe80::5054:ff:fe12:345a/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:19 errors:0 dropped:0 overruns:0 frame:0 TX packets:54 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:4896 (4.7 KiB) TX bytes:8079 (7.8 KiB) Interrupt:81 Memory:70040000-70060000root@ast2600-default:~# dmesg | grep "e1000e" [ 2.901955] e1000e: Intel(R) PRO/1000 Network Driver [ 2.902346] e1000e: Copyright(c) 1999 - 2015 Intel Corporation. [ 15.366727] e1000e 0000:81:00.0: Interrupt Throttling Rate (ints/sec) set to dynamic conservative mode [ 15.431884] e1000e 0000:81:00.0 0000:81:00.0 (uninitialized): registered PHC clock [ 15.508477] e1000e 0000:81:00.0 eth4: (PCI Express:2.5GT/s:Width x1) 52:54:00:12:34:5a [ 15.509301] e1000e 0000:81:00.0 eth4: Intel(R) PRO/1000 Network Connection [ 15.510768] e1000e 0000:81:00.0 eth4: MAC: 3, PHY: 8, PBA No: 000000-000 [ 49.781217] e1000e 0000:81:00.0 eth4: NIC Link is Up 1000 Mbps Full Duplex, Flow Control: Rx/TxAST2700:
The ASPEED PCIe driver only supports bus 0 with a single device at slot 0, which is reserved for the internal bridge. All endpoint devices must therefore reside on bus 1 to be discovered.
See the ASPEED PCIe driver implementation here:
https://github.com/AspeedTech-BMC/linux/blob/aspeed-master-v6.6/drivers/pci/controller/pcie-aspeed.c#L512By default, the ASPEED SDK enables only PCIe RC2, so initial testing covers RC2 only.
To attach e1000e devices and test all three RCs, I created a new test image with driver modifications. This is a temporary solution. A better approach is still needed to allow placing e1000e directly under bus 1.
Test release: https://github.com/jamin-aspeed/openbmc/releases/tag/qemu-test-0907
Image download: https://github.com/jamin-aspeed/openbmc/releases/download/qemu-test-0907/ast2700-default-pcie-qemu.tar.xz
This image includes the following changes:
Kernel patch (AST2700 RC mode + PCIe driver updates):
https://github.com/jamin-aspeed/openbmc/releases/download/qemu-test-0907/0001-PCI-aspeed-Enable-AST2700-RC-mode-support-and-adjust.patchOpenBMC patch (installs e1000e modules into rootfs for testing):
https://github.com/jamin-aspeed/openbmc/releases/download/qemu-test-0907/0001-packagegroup-aspeed-Add-Intel-e1000-e1000e-kernel-mo.patchQEMU Test Command
Each PCIe RC bus adds a pcie-root-port with an e1000e NIC behind it:
-device pcie-root-port,id=root_port0,multifunction=on,slot=0,addr=1,bus=pcie.0 \ -device e1000e,netdev=net0,bus=root_port0 \ -netdev user,id=net0,hostfwd=:127.0.0.1:3222-:22,hostname=qemu0 \ -device pcie-root-port,id=root_port1,slot=1,addr=2,bus=pcie.1 \ -device e1000e,netdev=net1,bus=root_port1 \ -netdev user,id=net1,hostfwd=:127.0.0.1:4222-:22,hostname=qemu1 \ -device pcie-root-port,id=root_port2,slot=2,addr=3,bus=pcie.2 \ -device e1000e,netdev=net2,bus=root_port2 \ -netdev user,id=net2,hostfwd=:127.0.0.1:5222-:22,hostname=qemu2 \Expected Results
With lspci, each RC should show the internal bridge, root port, and e1000e endpoint:
root@ast2700-default:~# lspci 0000:00:00.0 Host bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge 0000:00:01.0 PCI bridge: Red Hat, Inc. QEMU PCIe Root port 0000:01:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection 0001:00:00.0 Host bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge 0001:00:02.0 PCI bridge: Red Hat, Inc. QEMU PCIe Root port 0001:01:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection 0002:00:00.0 Host bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge 0002:00:03.0 PCI bridge: Red Hat, Inc. QEMU PCIe Root port 0002:01:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network ConnectionLoad the e1000e driver:
Kernel logs confirm device initialization and link-up at 1 Gbps Full Duplex on eth2/eth3/eth4.root@ast2700-default:~# modprobe e1000e [ 59.181623] e1000e: Intel(R) PRO/1000 Network Driver [ 59.181926] e1000e: Copyright(c) 1999 - 2015 Intel Corporation. [ 59.183508] e1000e 0000:01:00.0: enabling device (0000 -> 0002) [ 59.188808] e1000e 0000:01:00.0: Interrupt Throttling Rate (ints/sec) set to dynamic conservative mode [ 59.252590] e1000e 0000:01:00.0 0000:01:00.0 (uninitialized): registered PHC clock [ 59.330877] e1000e 0000:01:00.0 eth2: (PCI Express:2.5GT/s:Width x1) 52:54:00:12:34:56 [ 59.331990] e1000e 0000:01:00.0 eth2: Intel(R) PRO/1000 Network Connection [ 59.333211] e1000e 0000:01:00.0 eth2: MAC: 3, PHY: 8, PBA No: 000000-000 [ 59.334881] e1000e 0001:01:00.0: enabling device (0000 -> 0002) [ 59.341616] e1000e 0001:01:00.0: Interrupt Throttling Rate (ints/sec) set to dynamic conservative mode [ 59.394712] e1000e 0001:01:00.0 0001:01:00.0 (uninitialized): registered PHC clock [ 59.456674] e1000e 0001:01:00.0 eth3: (PCI Express:2.5GT/s:Width x1) 52:54:00:12:34:57 [ 59.457487] e1000e 0001:01:00.0 eth3: Intel(R) PRO/1000 Network Connection [ 59.458033] e1000e 0001:01:00.0 eth3: MAC: 3, PHY: 8, PBA No: 000000-000 [ 59.460037] e1000e 0002:01:00.0: enabling device (0000 -> 0002) [ 59.466403] e1000e 0002:01:00.0: Interrupt Throttling Rate (ints/sec) set to dynamic conservative mode [ 59.533361] e1000e 0002:01:00.0 0002:01:00.0 (uninitialized): registered PHC clock [ 59.654491] 8021q: adding VLAN 0 to HW filter on device eth2 [ 59.662100] e1000e 0002:01:00.0 eth4: (PCI Express:2.5GT/s:Width x1) 52:54:00:12:34:58 [ 59.662966] e1000e 0002:01:00.0 eth4: Intel(R) PRO/1000 Network Connection [ 59.663527] e1000e 0002:01:00.0 eth4: MAC: 3, PHY: 8, PBA No: 000000-000 root@ast2700-default:~# [ 59.814984] 8021q: adding VLAN 0 to HW filter on device eth3 [ 59.938859] 8021q: adding VLAN 0 to HW filter on device eth4 [ 59.954690] e1000e 0000:01:00.0 eth2: NIC Link is Up 1000 Mbps Full Duplex, Flow Control: Rx/Tx [ 60.116790] e1000e 0001:01:00.0 eth3: NIC Link is Up 1000 Mbps Full Duplex, Flow Control: Rx/Tx [ 60.237622] e1000e 0002:01:00.0 eth4: NIC Link is Up 1000 Mbps Full Duplex, Flow Control: Rx/TxAfter loading, users should see:
eth2: PCIe0
eth3: PCIe1
eth4: PCIe2Example ifconfig output shows all interfaces (eth0-eth4) active, with eth2-eth4 bound to the e1000e NICs. With this setup, all three PCIe RCs on AST2700 can be tested using e1000e endpoints in QEMU.
root@ast2700-default:~# ifconfig eth2 Link encap:Ethernet HWaddr 52:54:00:12:34:56 inet addr:169.254.120.135 Bcast:169.254.255.255 Mask:255.255.0.0 inet6 addr: fe80::5054:ff:fe12:3456/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:19 errors:0 dropped:0 overruns:0 frame:0 TX packets:51 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:5227 (5.1 KiB) TX bytes:8551 (8.3 KiB) Interrupt:42 Memory:60040000-60060000eth3 Link encap:Ethernet HWaddr 52:54:00:12:34:57
inet addr:169.254.237.52 Bcast:169.254.255.255 Mask:255.255.0.0 inet6 addr: fe80::5054:ff:fe12:3457/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:16 errors:0 dropped:0 overruns:0 frame:0 TX packets:47 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:4786 (4.6 KiB) TX bytes:8175 (7.9 KiB) Interrupt:45 Memory:80040000-80060000eth4 Link encap:Ethernet HWaddr 52:54:00:12:34:58
inet addr:169.254.84.173 Bcast:169.254.255.255 Mask:255.255.0.0 inet6 addr: fe80::5054:ff:fe12:3458/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:16 errors:0 dropped:0 overruns:0 frame:0 TX packets:47 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:4786 (4.6 KiB) TX bytes:8191 (7.9 KiB) Interrupt:48 Memory:a0040000-a0060000Jamin Lin (11):
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 and host bridge 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_Honly) tests/functional/test_arm_aspeed_ast2600: Add PCIe test via root portand e1000ehw/pci-host/aspeed: Add AST2700 PCIe PHY hw/pci-host/aspeed: Add AST2700 PCIe config with dedicated H2X blocks hw/arm/aspeed_ast27x0: Introduce 3 PCIe RCs for AST2700 tests/functional: Add PCIe presence test for AST2700
include/hw/arm/aspeed_soc.h | 14 + include/hw/pci-host/aspeed_pcie.h | 125 +++ include/hw/pci/pci_ids.h | 2 + hw/arm/aspeed_ast2600.c | 69 +- hw/arm/aspeed_ast27x0.c | 61 ++ hw/pci-host/aspeed_pcie.c | 955 ++++++++++++++++++ hw/arm/Kconfig | 3 + hw/pci-host/Kconfig | 4 + hw/pci-host/meson.build | 1 + hw/pci-host/trace-events | 11 + .../functional/test_aarch64_aspeed_ast2700.py | 7 + .../test_aarch64_aspeed_ast2700fc.py | 6 + tests/functional/test_arm_aspeed_ast2600.py | 14 + 13 files changed, 1269 insertions(+), 3 deletions(-)create mode 100644
include/hw/pci-host/aspeed_pcie.hcreate mode 100644hw/pci-host/aspeed_pcie.c
Re: [SPAM] [PATCH v1 01/11] hw/pci/pci_ids Add PCI vendor ID for ASPEED
In reply to Jamin Lin viaQuoted 10 lines · Jamin Lin
Signed-off-by Jamin Lin <[email protected]>--- include/hw/pci/pci_ids.h | 2 ++ 1 file changed, 2 insertions(+)include/hw/pci/pci_ids.h +0
-0
include/hw/pci/pci_ids.h line 296
Quoted 6 lines
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
Thanks,
C.
Hi Cédric
Quoted 52 lines
Subject: Re: [SPAM] [PATCH v1 00/11] Support PCIe RC to AST2600 and AST2700
Hello Jamin,
Quoted 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.Testing PCIe RC model with e1000e PCIe device model
AST2600
The AST2600/ASPEED PCIe driver treats root bus
0x80specially:
Only two device addresses are usable on the root bus:
addr 0: ASPEED host bridge
addr 8: usable for attaching a PCIe root portTo attach endpoints without driver changes, the test places a QEMU PCIe root port at 0x80:08.0 and attaches an e1000e NIC behind it. The endpoint then enumerates on bus
0x81.QEMU command line additions
(quoted diff) +0
-2-device pcie-root-port,id=root_port0,slot=1,addr=8,bus=pcie.0 -device e1000e,netdev=net0,bus=root_port0 -netdev user,id=net0Verification with lspci:
0001:80:00.0 Host bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge
0001:80:08.0 PCI bridge: Red Hat, Inc. QEMU PCIe Root port 0001:81:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network ConnectionQuoted 3 lines
This is a temporary solution that allows attaching multiple PCIe devices while the ASPEED drivers does not support placing endpoints directly on bus numbers
0x80.Could we try to model the real HW topology ? On an ast2600a3 EVB with a PCI serial adapter plugged in the available slot :
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 (rev 06) 81:00.0 Serial controller: MosChip Semiconductor Technology Ltd. MCS9922 PCIe Multi-I/O Controller 81:00.1 Serial controller: MosChip Semiconductor Technology Ltd. MCS9922 PCIe Multi-I/O Controller
Quoted 2 lines
What is blocking us from modeling "Device 2600" ?
On real hardware, the AST2600 EVB shows two functions on bus 0x80:
0001:80:08.0 – AST1150 PCI-to-PCI Bridge
PCI bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge (rev 06)
Subsystem: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge
Flags: bus master, fast devsel, latency 0, IRQ 81
Bus: primary=80, secondary=81, subordinate=82
I/O behind bridge: 1000-1fff [size=4K] [16-bit]
Memory behind bridge: 70000000-75ffffff [size=96M] [32-bit] Prefetchable memory behind bridge: [disabled] [64-bit]
Capabilities: MSI, Power Management v3, Express Root Port, Virtual Channel, AER Kernel driver in use: pcieport
0001:80:00.0 – Host bridge (Device 2600)
Host bridge: ASPEED Technology, Inc. Device 2600
Subsystem: ASPEED Technology, Inc. Device 2600
Flags: bus master, fast devsel, latency 0
In contrast, on the AST2700 platform the enumeration starts directly at bus 0 with the AST1150 bridge, and no separate “Device 2700” host bridge is visible:
0002:00:00.0 – AST1150 PCI-to-PCI Bridge
PCI bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge (rev 10)
Flags: bus master, fast devsel, latency 0, IRQ 43
Bus: primary=00, secondary=01, subordinate=01
I/O behind bridge: [disabled]
Memory behind bridge: [disabled]
Prefetchable memory behind bridge: [disabled]
Capabilities: Express Root Port, MSI, Power Management v3,
Vendor Specific Information, L1 PM Substates, AER
Kernel driver in use: pcieport
What blocks me from modeling “Device 2600” today is mainly the "lack of a proper QEMU device model for the AST2600/AST2700 PCIe Host bridge". On AST2600, 80:00.0 is the host bridge and 80:08.0 is the downstream AST1150 bridge. To reproduce this topology in QEMU, we would need to:
1. Implement a new QEMU device for the AST2600/AST2700 host bridge, with its own PCI config space and initialization.
2. Integrate this model with the ASPEED PCIe driver, which currently only supports endpoints appearing behind a bridge on bus 0x81 for AST2600 and 0x01 for AST2700, and does not allow attaching devices directly under bus 0x80 for AST2600 and 0x00 for AST2700.
"Until such a host bridge model is introduced, the temporary workaround is to insert a generic QEMU pcie-root-port at 0x80:08.0." This allows endpoints to enumerate correctly, but it does not exactly match the EVB topology. Adding a dedicated AST2600 host bridge model is the next step if we want QEMU to reflect the hardware layout more faithfully, while keeping the AST2700 behavior (00:00.0 only) consistent.
Thanks-Jamin
Quoted 253 lines
Thanks,
C.
Quoted 6 lines
Reference:
https://github.com/AspeedTech-BMC/linux/blob/aspeed-master-v6.6/driver
s/pci/controller/pcie-aspeed.c#L309Test Image: ASPEED SDK v09.07. It okay to use ASPEED SDK v09.06.
https://github.com/AspeedTech-BMC/openbmc/releases/download/v09.07/ast
Quoted 5 lines
2600-default-obmc.tar.gz
The e1000e driver is built into this image.
After booting, users should see the e1000e Ethernet interface. With this setup,RC_Hon AST2600 can be tested using e1000e endpoints inQEMU.
Quoted 9 lines
Example system output:
root@ast2600-default:~# lspci 80:00.0 Host bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge 80:08.0 PCI bridge: Red Hat, Inc. QEMU PCIe Root port 81:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection root@ast2600-default:~# ifconfig eth4 eth4 Link encap:Ethernet HWaddr 52:54:00:12:34:5A inet addr:169.254.160.167 Bcast:169.254.255.255Mask:255.255.0.0
Quoted 8 lines
inet6 addr: fe80::5054:ff:fe12:345a/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:19 errors:0 dropped:0 overruns:0 frame:0 TX packets:54 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000
RX bytes:4896 (4.7 KiB) TX bytes:8079 (7.8 KiB) Interrupt:81 Memory:70040000-70060000Quoted 4 lines
root@ast2600-default:~# dmesg | grep "e1000e" [ 2.901955] e1000e: Intel(R) PRO/1000 Network Driver [ 2.902346] e1000e: Copyright(c) 1999 - 2015 Intel Corporation. [ 15.366727] e1000e 0000:81:00.0: Interrupt Throttling Rate (ints/sec) setto dynamic conservative mode
Quoted 1 line
[ 15.431884] e1000e 0000:81:00.0 0000:81:00.0 (uninitialized): registeredPHC clock
Quoted 1 line
[ 15.508477] e1000e 0000:81:00.0 eth4: (PCI Express:2.5GT/s:Width x1)52:54:00:12:34:5a
Quoted 1 line
[ 15.509301] e1000e 0000:81:00.0 eth4: Intel(R) PRO/1000 NetworkConnection
Quoted 1 line
[ 15.510768] e1000e 0000:81:00.0 eth4: MAC: 3, PHY: 8, PBA No:000000-000
Quoted 1 line
[ 49.781217] e1000e 0000:81:00.0 eth4: NIC Link is Up 1000 Mbps FullDuplex, Flow Control: Rx/Tx
Quoted 4 lines
AST2700:
Quoted 8 lines
The ASPEED PCIe driver only supports bus 0 with a single device at slot 0, which is reserved for the internal bridge. All endpoint devices must therefore reside on bus 1 to be discovered. See the ASPEED PCIe driver implementation here:
https://github.com/AspeedTech-BMC/linux/blob/aspeed-master-v6.6/driver
s/pci/controller/pcie-aspeed.c#L512By default, the ASPEED SDK enables only PCIe RC2, so initial testing covers
RC2 only.
Quoted 9 lines
To attach e1000e devices and test all three RCs, I created a new test image with driver modifications. This is a temporary solution. A better approach is still needed to allow placing e1000e directly under bus 1.
Test release:
https://github.com/jamin-aspeed/openbmc/releases/tag/qemu-test-0907
Image download:https://github.com/jamin-aspeed/openbmc/releases/download/qemu-test-09
Quoted 4 lines
07/ast2700-default-pcie-qemu.tar.xz
This image includes the following changes:
Kernel patch (AST2700 RC mode + PCIe driver updates):https://github.com/jamin-aspeed/openbmc/releases/download/qemu-test-09
Quoted 4 lines
07/0001-PCI-aspeed-Enable-AST2700-RC-mode-support-and-adjust.patchOpenBMC patch (installs e1000e modules into rootfs for testing):
https://github.com/jamin-aspeed/openbmc/releases/download/qemu-test-09
Quoted 7 lines
07/0001-packagegroup-aspeed-Add-Intel-e1000-e1000e-kernel-mo.patchQEMU Test Command
Each PCIe RC bus adds a pcie-root-port with an e1000e NIC behind it:
-device
pcie-root-port,id=root_port0,multifunction=on,slot=0,addr=1,bus=pcie.0 \
Quoted 9 lines
-device e1000e,netdev=net0,bus=root_port0 \ -netdev user,id=net0,hostfwd=:127.0.0.1:3222-:22,hostname=qemu0 \ -device pcie-root-port,id=root_port1,slot=1,addr=2,bus=pcie.1 \ -device e1000e,netdev=net1,bus=root_port1 \ -netdev user,id=net1,hostfwd=:127.0.0.1:4222-:22,hostname=qemu1 \ -device pcie-root-port,id=root_port2,slot=2,addr=3,bus=pcie.2 \ -device e1000e,netdev=net2,bus=root_port2 \ -netdev user,id=net2,hostfwd=:127.0.0.1:5222-:22,hostname=qemu2 \Quoted 3 lines
Expected Results
With lspci, each RC should show the internal bridge, root port, and e1000e
endpoint:
Quoted 18 lines
root@ast2700-default:~# lspci 0000:00:00.0 Host bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge 0000:00:01.0 PCI bridge: Red Hat, Inc. QEMU PCIe Root port 0000:01:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection 0001:00:00.0 Host bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge 0001:00:02.0 PCI bridge: Red Hat, Inc. QEMU PCIe Root port 0001:01:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection 0002:00:00.0 Host bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge 0002:00:03.0 PCI bridge: Red Hat, Inc. QEMU PCIe Root port 0002:01:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network ConnectionQuoted 2 lines
Load the e1000e driver:
Kernel logs confirm device initialization and link-up at 1 Gbps Full Duplex oneth2/eth3/eth4.
Quoted 5 lines
root@ast2700-default:~# modprobe e1000e [ 59.181623] e1000e: Intel(R) PRO/1000 Network Driver [ 59.181926] e1000e: Copyright(c) 1999 - 2015 Intel Corporation. [ 59.183508] e1000e 0000:01:00.0: enabling device (0000 -> 0002) [ 59.188808] e1000e 0000:01:00.0: Interrupt Throttling Rate (ints/sec) setto dynamic conservative mode
Quoted 1 line
[ 59.252590] e1000e 0000:01:00.0 0000:01:00.0 (uninitialized): registeredPHC clock
Quoted 1 line
[ 59.330877] e1000e 0000:01:00.0 eth2: (PCI Express:2.5GT/s:Width x1)52:54:00:12:34:56
Quoted 1 line
[ 59.331990] e1000e 0000:01:00.0 eth2: Intel(R) PRO/1000 NetworkConnection
Quoted 1 line
[ 59.333211] e1000e 0000:01:00.0 eth2: MAC: 3, PHY: 8, PBA No:000000-000
Quoted 2 lines
[ 59.334881] e1000e 0001:01:00.0: enabling device (0000 -> 0002) [ 59.341616] e1000e 0001:01:00.0: Interrupt Throttling Rate (ints/sec) setto dynamic conservative mode
Quoted 1 line
[ 59.394712] e1000e 0001:01:00.0 0001:01:00.0 (uninitialized): registeredPHC clock
Quoted 1 line
[ 59.456674] e1000e 0001:01:00.0 eth3: (PCI Express:2.5GT/s:Width x1)52:54:00:12:34:57
Quoted 1 line
[ 59.457487] e1000e 0001:01:00.0 eth3: Intel(R) PRO/1000 NetworkConnection
Quoted 1 line
[ 59.458033] e1000e 0001:01:00.0 eth3: MAC: 3, PHY: 8, PBA No:000000-000
Quoted 2 lines
[ 59.460037] e1000e 0002:01:00.0: enabling device (0000 -> 0002) [ 59.466403] e1000e 0002:01:00.0: Interrupt Throttling Rate (ints/sec) setto dynamic conservative mode
Quoted 1 line
[ 59.533361] e1000e 0002:01:00.0 0002:01:00.0 (uninitialized): registeredPHC clock
Quoted 2 lines
[ 59.654491] 8021q: adding VLAN 0 to HW filter on device eth2 [ 59.662100] e1000e 0002:01:00.0 eth4: (PCI Express:2.5GT/s:Width x1)52:54:00:12:34:58
Quoted 1 line
[ 59.662966] e1000e 0002:01:00.0 eth4: Intel(R) PRO/1000 NetworkConnection
Quoted 1 line
[ 59.663527] e1000e 0002:01:00.0 eth4: MAC: 3, PHY: 8, PBA No:000000-000
Quoted 1 line
root@ast2700-default:~# [ 59.814984] 8021q: adding VLAN 0 to HW filteron device eth3
Quoted 2 lines
[ 59.938859] 8021q: adding VLAN 0 to HW filter on device eth4 [ 59.954690] e1000e 0000:01:00.0 eth2: NIC Link is Up 1000 Mbps FullDuplex, Flow Control: Rx/Tx
Quoted 1 line
[ 60.116790] e1000e 0001:01:00.0 eth3: NIC Link is Up 1000 Mbps FullDuplex, Flow Control: Rx/Tx
Quoted 1 line
[ 60.237622] e1000e 0002:01:00.0 eth4: NIC Link is Up 1000 Mbps FullDuplex, Flow Control: Rx/Tx
Quoted 7 lines
After loading, users should see:
eth2: PCIe0
eth3: PCIe1
eth4: PCIe2Example ifconfig output shows all interfaces (eth0-eth4) active, with
eth2-eth4 bound to the e1000e NICs.
Quoted 1 line
With this setup, all three PCIe RCs on AST2700 can be tested using e1000e
endpoints in QEMU.
Quoted 4 lines
root@ast2700-default:~# ifconfig eth2 Link encap:Ethernet HWaddr 52:54:00:12:34:56 inet addr:169.254.120.135 Bcast:169.254.255.255Mask:255.255.0.0
Quoted 10 lines
inet6 addr: fe80::5054:ff:fe12:3456/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:19 errors:0 dropped:0 overruns:0 frame:0 TX packets:51 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000
RX bytes:5227 (5.1 KiB) TX bytes:8551 (8.3 KiB) Interrupt:42 Memory:60040000-60060000eth3 Link encap:Ethernet HWaddr 52:54:00:12:34:57
inet addr:169.254.237.52 Bcast:169.254.255.255Mask:255.255.0.0
Quoted 10 lines
inet6 addr: fe80::5054:ff:fe12:3457/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:16 errors:0 dropped:0 overruns:0 frame:0 TX packets:47 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000
RX bytes:4786 (4.6 KiB) TX bytes:8175 (7.9 KiB) Interrupt:45 Memory:80040000-80060000eth4 Link encap:Ethernet HWaddr 52:54:00:12:34:58
inet addr:169.254.84.173 Bcast:169.254.255.255Mask:255.255.0.0
Quoted 22 lines
inet6 addr: fe80::5054:ff:fe12:3458/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:16 errors:0 dropped:0 overruns:0 frame:0 TX packets:47 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000
RX bytes:4786 (4.6 KiB) TX bytes:8191 (7.9 KiB) Interrupt:48 Memory:a0040000-a0060000Jamin Lin (11):
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 and host bridge 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_Honly) tests/functional/test_arm_aspeed_ast2600: Add PCIe test via root portand e1000ehw/pci-host/aspeed: Add AST2700 PCIe PHY hw/pci-host/aspeed: Add AST2700 PCIe config with dedicated H2X blocks hw/arm/aspeed_ast27x0: Introduce 3 PCIe RCs for AST2700 tests/functional: Add PCIe presence test for AST2700
Quoted 6 lines
include/hw/arm/aspeed_soc.h | 14 + include/hw/pci-host/aspeed_pcie.h | 125 +++ include/hw/pci/pci_ids.h | 2 + hw/arm/aspeed_ast2600.c | 69 +- hw/arm/aspeed_ast27x0.c | 61 ++ hw/pci-host/aspeed_pcie.c | 955++++++++++++++++++
Quoted 11 lines
hw/arm/Kconfig | 3 + hw/pci-host/Kconfig | 4 + hw/pci-host/meson.build | 1 + hw/pci-host/trace-events | 11 + .../functional/test_aarch64_aspeed_ast2700.py | 7 + .../test_aarch64_aspeed_ast2700fc.py | 6 + tests/functional/test_arm_aspeed_ast2600.py | 14 + 13 files changed, 1269 insertions(+), 3 deletions(-)create mode 100644
include/hw/pci-host/aspeed_pcie.hcreate mode 100644hw/pci-host/aspeed_pcie.c
Hi Cédric
Quoted 105 lines
Cc: Troy Lee <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: RE: [SPAM] [PATCH v1 00/11] Support PCIe RC to AST2600 and AST2700Hi Cédric
Quoted 53 lines
Subject: Re: [SPAM] [PATCH v1 00/11] Support PCIe RC to AST2600 and AST2700
Hello Jamin,
Quoted 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.Testing PCIe RC model with e1000e PCIe device model
AST2600
The AST2600/ASPEED PCIe driver treats root bus
0x80specially:
Only two device addresses are usable on the root bus:
addr 0: ASPEED host bridge
addr 8: usable for attaching a PCIe root portTo attach endpoints without driver changes, the test places a QEMU PCIe root port at 0x80:08.0 and attaches an e1000e NIC behind it. The endpoint then enumerates on bus
0x81.QEMU command line additions
(quoted diff) +0
-2-device pcie-root-port,id=root_port0,slot=1,addr=8,bus=pcie.0 -device e1000e,netdev=net0,bus=root_port0 -netdev user,id=net0Verification with lspci:
0001:80:00.0 Host bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge
0001:80:08.0 PCI bridge: Red Hat, Inc. QEMU PCIe Root port 0001:81:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network ConnectionQuoted 3 lines
This is a temporary solution that allows attaching multiple PCIe devices while the ASPEED drivers does not support placing endpoints directly on bus numbers
0x80.Could we try to model the real HW topology ? On an ast2600a3 EVB with a PCI serial adapter plugged in the available slot :
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 (rev 06) 81:00.0 Serial controller: MosChip Semiconductor Technology Ltd. MCS9922 PCIe Multi-I/O Controller 81:00.1 Serial controller: MosChip Semiconductor Technology Ltd. MCS9922 PCIe Multi-I/O ControllerQuoted 2 lines
What is blocking us from modeling "Device 2600" ?
On real hardware, the AST2600 EVB shows two functions on bus
0x80:0001:80:08.0 – AST1150 PCI-to-PCI Bridge PCI bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge (rev 06)
Subsystem: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge
Flags: bus master, fast devsel, latency 0, IRQ 81
Bus: primary=80, secondary=81, subordinate=82 I/O behind bridge: 1000-1fff [size=4K] [16-bit] Memory behind bridge: 70000000-75ffffff [size=96M] [32-bit] Prefetchable memory behind bridge: [disabled] [64-bit]
Capabilities: MSI, Power Management v3, Express Root Port, Virtual Channel, AER Kernel driver in use: pcieport0001:80:00.0 – Host bridge (Device 2600) Host bridge: ASPEED Technology, Inc. Device 2600
Subsystem: ASPEED Technology, Inc. Device 2600
Flags: bus master, fast devsel, latency 0In contrast, on the AST2700 platform the enumeration starts directly at bus 0 with the AST1150 bridge, and no separate “Device 2700” host bridge is visible:
0002:00:00.0 – AST1150 PCI-to-PCI Bridge PCI bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge (rev 10)
Flags: bus master, fast devsel, latency 0, IRQ 43
Bus: primary=00, secondary=01, subordinate=01 I/O behind bridge: [disabled] Memory behind bridge: [disabled] Prefetchable memory behind bridge:
[disabled]
Capabilities: Express Root Port, MSI, Power Management v3,
Vendor Specific Information, L1 PM Substates, AER Kernel
driver in use: pcieportWhat blocks me from modeling “Device 2600” today is mainly the "lack of a proper QEMU device model for the AST2600/AST2700 PCIe Host bridge". On AST2600, 80:00.0 is the host bridge and 80:08.0 is the downstream AST1150 bridge. To reproduce this topology in QEMU, we would need to:
1. Implement a new QEMU device for the AST2600/AST2700 host bridge, with its own PCI config space and initialization.
2. Integrate this model with the ASPEED PCIe driver, which currently only supports endpoints appearing behind a bridge on bus0x81for AST2600 and0x01for AST2700, and does not allow attaching devices directly under bus0x80for AST2600 and0x00for AST2700.
Quoted 13 lines
"Until such a host bridge model is introduced, the temporary workaround is to insert a generic QEMU pcie-root-port at 0x80:08.0." This allows endpoints to enumerate correctly, but it does not exactly match the EVB topology. Adding a dedicated AST2600 host bridge model is the next step if we want QEMU to reflect the hardware layout more faithfully, while keeping the AST2700 behavior (00:00.0 only) consistent.
Thanks-Jamin
Quoted 5 lines
Thanks,
C.
I’ve updated the model to instantiate a PCIe Root Port at 80:08 and keep the original PCIe Host Bridge at 80:00. This now matches the real hardware topology. Thanks for the guidance—I’ll resend the patch. I’ll also review AST2700 to see whether the same approach can be applied.
Thanks-Jamin
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
root@ast2600-default:~# lspci -v
80:00.0 Host bridge: ASPEED Technology, Inc. Device 2600
Subsystem: Red Hat, Inc. Device 1100
Flags: bus master, fast devsel, latency 080:08.0 PCI bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge (prog-if 00 [Normal decode])
Subsystem: ASPEED Technology, Inc. Device 0000
Flags: bus master, fast devsel, latency 0, IRQ 81
Bus: primary=80, secondary=81, subordinate=81, sec-latency=0
I/O behind bridge: 1000-1fff [size=4K] [16-bit]
Memory behind bridge: 70000000-701fffff [size=2M] [32-bit]
Prefetchable memory behind bridge: 70200000-703fffff [size=2M] [32-bit]
Capabilities: [48] Express Root Port (Slot+), IntMsgNum 0
Capabilities: [40] Subsystem: ASPEED Technology, Inc. Device 0000
Capabilities: [100] Advanced Error Reporting
Kernel driver in use: pcieport
81:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection
Subsystem: Intel Corporation Device 0000
Flags: bus master, fast devsel, latency 0, IRQ 81
Memory at 70040000 (32-bit, non-prefetchable) [size=128K] Memory at 70060000 (32-bit, non-prefetchable) [size=128K] I/O ports at 1000 [size=32]
Memory at 70080000 (32-bit, non-prefetchable) [size=16K] Expansion ROM at 70000000 [disabled] [size=256K]
Capabilities: [c8] Power Management version 2
Capabilities: [d0] MSI: Enable- Count=1/1 Maskable- 64bit+
Capabilities: [e0] Express Endpoint, IntMsgNum 0
Capabilities: [a0] MSI-X: Enable+ Count=5 Masked-
Capabilities: [100] Advanced Error Reporting
Capabilities: [140] Device Serial Number 52-54-00-ff-ff-12-34-5a Kernel driver in use: e1000e
dev: aspeed.pcie-rc, id ""
gpio-out "sysbus-irq" 1
bus-nr = 128 (0x80)
msi-addr = 511115356 (0x1e77005c)
dram-base = 2147483648 (0x80000000)
x-config-reg-migration-enabled = true
bypass-iommu = false
mmio ffffffffffffffff/0000000010000000
mmio ffffffffffffffff/ffffffffffffffff
mmio ffffffffffffffff/0000000000010000
bus: pcie.0
type PCIE
dev: aspeed.pcie-rp, id ""
power_controller_present = true
disable-acs = false
chassis = 0 (0x0)
slot = 0 (0x0)
hotplug = true
x-do-not-expose-native-hotplug-cap = false
port = 0 (0x0)
aer_log_max = 8 (0x8)
x-pci-express-writeable-slt-bug = false
addr = 08.0
romfile = ""
romsize = 4294967295 (0xffffffff)
rombar = -1 (0xffffffffffffffff)
multifunction = false
x-pcie-lnksta-dllla = true
x-pcie-extcap-init = true
failover_pair_id = ""
acpi-index = 0 (0x0)
x-pcie-err-unc-mask = true
x-pcie-ari-nextfn-1 = false
x-max-bounce-buffer-size = 4096 (4 KiB)
sriov-pf = ""
x-pcie-ext-tag = true
busnr = 0 (0x0)
class PCI bridge, addr 00:08.0, pci id 1a03:1150 (sub 0000:0000)
bus: pcie.1
type PCIE
dev: e1000e, id ""
mac = "52:54:00:12:34:5a"
netdev = "net0"
disable_vnet_hdr = 0 (0x0)
subsys_ven = 32902 (0x8086)
subsys = 0 (0x0)
init-vet = true
migrate-timadj = true
addr = 00.0
romfile = "efi-e1000e.rom"
romsize = 262144 (0x40000)
rombar = -1 (0xffffffffffffffff)
multifunction = false
x-pcie-lnksta-dllla = true
x-pcie-extcap-init = true
failover_pair_id = ""
acpi-index = 0 (0x0)
x-pcie-err-unc-mask = true
x-pcie-ari-nextfn-1 = false
x-max-bounce-buffer-size = 4096 (4 KiB)
sriov-pf = ""
x-pcie-ext-tag = true
busnr = 129 (0x81)
class Ethernet controller, addr 81:00.0, pci id 8086:10d3 (sub 8086:0000)
bar 0: mem at 0x70040000 [0x7005ffff]
bar 1: mem at 0x70060000 [0x7007ffff]
bar 2: i/o at 0x19000 [0x1901f]
bar 3: mem at 0x70080000 [0x70083fff]
bar 6: mem at 0xffffffffffffffff [0x3fffe]
dev: aspeed.pcie-root, id ""
addr = 00.0
romfile = ""
romsize = 4294967295 (0xffffffff)
rombar = -1 (0xffffffffffffffff)
multifunction = false
x-pcie-lnksta-dllla = true
x-pcie-extcap-init = true
failover_pair_id = ""
acpi-index = 0 (0x0)
x-pcie-err-unc-mask = true
x-pcie-ari-nextfn-1 = false
x-max-bounce-buffer-size = 4096 (4 KiB)
sriov-pf = ""
x-pcie-ext-tag = true
busnr = 0 (0x0)
class Host bridge, addr 00:00.0, pci id 1a03:2600 (sub 1af4:1100)Command:
pcie.0: root bus
pcie.1: root port bus
-device e1000e,netdev=net0,bus=pcie.1
--- include/hw/pci-host/aspeed_pcie.h | 8 +++++++ hw/pci-host/aspeed_pcie.c | 35 ++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-)
include/hw/pci-host/aspeed_pcie.h +8 -0
@@ -44,6 +44,14 @@ typedef struct AspeedPCIERegMap {AspeedPCIERcRegs rc; } AspeedPCIERegMap; +#define TYPE_ASPEED_PCIE_RP "aspeed.pcie-rp" + +typedef struct AspeedPCIERPState { +PCIDevice parent_obj; +}AspeedPCIERPState ; + +OBJECT_DECLARE_SIMPLE_TYPE(AspeedPCIERPState, ASPEED_PCIE_RP) +#define TYPE_ASPEED_PCIE_ROOT "aspeed.pcie-root"OBJECT_DECLARE_SIMPLE_TYPE (AspeedPCIERootState,ASPEED_PCIE_ROOT );
hw/pci-host/aspeed_pcie.c +34 -1
@@ -23,10 +23,39 @@#include "hw/registerfields.h" #include "hw/irq.h" #include "hw/pci/pci_host.h" +#include "hw/pci/pcie_port.h" #include "hw/pci-host/aspeed_pcie.h" #include "hw/pci/msi.h" #include "trace.h" +/* +* PCIe Root Port +*/ + +static void aspeed_pcie_rp_class_init (ObjectClass *klass,const void *data) +{ +PCIDeviceClass *k =PCI_DEVICE_CLASS (klass); +DeviceClass *dc =DEVICE_CLASS (klass); +PCIERootPortClass *rpc =PCIE_ROOT_PORT_CLASS (klass); + + dc->desc ="ASPEED AST1150 PCIe Root Port" ; +set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); + + k->vendor_id =PCI_VENDOR_ID_ASPEED ; + k->device_id =0x1150 ; + dc->user_creatable = true; + + rpc->exp_offset =0x48 ; + rpc->aer_offset =0x100 ; +} + +static const TypeInfo aspeed_pcie_rp_info = { + .name =TYPE_ASPEED_PCIE_RP , + .parent =TYPE_PCIE_ROOT_PORT , + .class_init = aspeed_pcie_rp_class_init, + .interfaces = (InterfaceInfo []) { {INTERFACE_PCIE_DEVICE }, {0 } }, +}; +/* * PCIe Root */
@@ -39,7 +68,7 @@ static void aspeed_pcie_root_class_init(ObjectClass *klass, const void *data)set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); dc->desc ="ASPEED PCIe Host Bridge" ; k->vendor_id =PCI_VENDOR_ID_ASPEED ; - k->device_id =0x1150 ; + k->device_id =0x2600 ; k->class_id =PCI_CLASS_BRIDGE_HOST ; k->revision =0 ;
@@ -224,6 +253,9 @@ static void aspeed_pcie_rc_realize(DeviceState *dev, Error **errp)pci_setup_iommu (pci->bus, &aspeed_pcie_rc_iommu_ops, rc);qdev_realize (DEVICE (&rc->root),BUS (pci->bus), &error_fatal); + +PCIDevice *rp =pci_new (PCI_DEVFN (8 ,0 ),TYPE_ASPEED_PCIE_RP ); +pci_realize_and_unref (rp, pci->bus, errp); } static const char *aspeed_pcie_rc_root_bus_path(PCIHostState *host_bridge,
@@ -943,6 +975,7 @@ static const TypeInfo aspeed_2700_pcie_phy_info = {static void aspeed_pcie_register_types (void ) { +type_register_static (&aspeed_pcie_rp_info);type_register_static (&aspeed_pcie_root_info);type_register_static (&aspeed_pcie_rc_info);type_register_static (&aspeed_pcie_cfg_info);
Signature · 1 line
2.43.0
Quoted 278 lines
Quoted 4 lines
Quoted 8 lines
Quoted 7 lines
Reference:
https://github.com/AspeedTech-BMC/linux/blob/aspeed-master-v6.6/driv
er
s/pci/controller/pcie-aspeed.c#L309Test Image: ASPEED SDK v09.07. It okay to use ASPEED SDK v09.06.
https://github.com/AspeedTech-BMC/openbmc/releases/download/v09.07/ast
Quoted 17 lines
Quoted 6 lines
2600-default-obmc.tar.gz
The e1000e driver is built into this image.
After booting, users should see the e1000e Ethernet interface. With this setup,RC_Hon AST2600 can be tested using e1000e endpoints inQEMU.
Quoted 10 lines
Example system output:
root@ast2600-default:~# lspci 80:00.0 Host bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge 80:08.0 PCI bridge: Red Hat, Inc. QEMU PCIe Root port 81:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection root@ast2600-default:~# ifconfig eth4 eth4 Link encap:Ethernet HWaddr 52:54:00:12:34:5A inet addr:169.254.160.167 Bcast:169.254.255.255Quoted 3 lines
Mask:255.255.0.0
Quoted 2 lines
inet6 addr: fe80::5054:ff:fe12:345a/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500
Metric:1
Quoted 10 lines
Quoted 10 lines
RX packets:19 errors:0 dropped:0 overruns:0 frame:0 TX packets:54 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000
RX bytes:4896 (4.7 KiB) TX bytes:8079 (7.8 KiB) Interrupt:81 Memory:70040000-70060000root@ast2600-default:~# dmesg | grep "e1000e" [ 2.901955] e1000e: Intel(R) PRO/1000 Network Driver [ 2.902346] e1000e: Copyright(c) 1999 - 2015 Intel Corporation. [ 15.366727] e1000e 0000:81:00.0: Interrupt Throttling Rate (ints/sec)set
Quoted 2 lines
to dynamic conservative mode
Quoted 1 line
[ 15.431884] e1000e 0000:81:00.0 0000:81:00.0 (uninitialized):registered
Quoted 21 lines
PHC clock
Quoted 1 line
[ 15.508477] e1000e 0000:81:00.0 eth4: (PCI Express:2.5GT/s:Width x1)52:54:00:12:34:5a
Quoted 1 line
[ 15.509301] e1000e 0000:81:00.0 eth4: Intel(R) PRO/1000 NetworkConnection
Quoted 1 line
[ 15.510768] e1000e 0000:81:00.0 eth4: MAC: 3, PHY: 8, PBA No:000000-000
Quoted 1 line
[ 49.781217] e1000e 0000:81:00.0 eth4: NIC Link is Up 1000 Mbps FullDuplex, Flow Control: Rx/Tx
Quoted 12 lines
AST2700:
The ASPEED PCIe driver only supports bus 0 with a single device at slot 0, which is reserved for the internal bridge. All endpoint devices must therefore reside on bus 1 to be discovered. See the ASPEED PCIe driver implementation here:
https://github.com/AspeedTech-BMC/linux/blob/aspeed-master-v6.6/driv
er
s/pci/controller/pcie-aspeed.c#L512Quoted 7 lines
Quoted 2 lines
By default, the ASPEED SDK enables only PCIe RC2, so initial testing covers
RC2 only.
Quoted 4 lines
To attach e1000e devices and test all three RCs, I created a new test image with driver modifications. This is a temporary solution. A better approach is still needed to allow placing e1000e directly under bus
1.
Quoted 6 lines
Quoted 5 lines
Test release:
https://github.com/jamin-aspeed/openbmc/releases/tag/qemu-test-0907
Image download:https://github.com/jamin-aspeed/openbmc/releases/download/qemu-test-09
Quoted 5 lines
Quoted 4 lines
07/ast2700-default-pcie-qemu.tar.xz
This image includes the following changes:
Kernel patch (AST2700 RC mode + PCIe driver updates):https://github.com/jamin-aspeed/openbmc/releases/download/qemu-test-09
Quoted 5 lines
Quoted 4 lines
07/0001-PCI-aspeed-Enable-AST2700-RC-mode-support-and-adjust.patchOpenBMC patch (installs e1000e modules into rootfs for testing):
https://github.com/jamin-aspeed/openbmc/releases/download/qemu-test-09
Quoted 41 lines
Quoted 7 lines
07/0001-packagegroup-aspeed-Add-Intel-e1000-e1000e-kernel-mo.patchQEMU Test Command
Each PCIe RC bus adds a pcie-root-port with an e1000e NIC behind it:
-device
pcie-root-port,id=root_port0,multifunction=on,slot=0,addr=1,bus=pcie.0 \
Quoted 9 lines
-device e1000e,netdev=net0,bus=root_port0 \ -netdev user,id=net0,hostfwd=:127.0.0.1:3222-:22,hostname=qemu0 \ -device pcie-root-port,id=root_port1,slot=1,addr=2,bus=pcie.1 \ -device e1000e,netdev=net1,bus=root_port1 \ -netdev user,id=net1,hostfwd=:127.0.0.1:4222-:22,hostname=qemu1 \ -device pcie-root-port,id=root_port2,slot=2,addr=3,bus=pcie.2 \ -device e1000e,netdev=net2,bus=root_port2 \ -netdev user,id=net2,hostfwd=:127.0.0.1:5222-:22,hostname=qemu2 \Quoted 4 lines
Expected Results
With lspci, each RC should show the internal bridge, root port, and e1000e
endpoint:
Quoted 18 lines
root@ast2700-default:~# lspci 0000:00:00.0 Host bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge 0000:00:01.0 PCI bridge: Red Hat, Inc. QEMU PCIe Root port 0000:01:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection 0001:00:00.0 Host bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge 0001:00:02.0 PCI bridge: Red Hat, Inc. QEMU PCIe Root port 0001:01:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection 0002:00:00.0 Host bridge: ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge 0002:00:03.0 PCI bridge: Red Hat, Inc. QEMU PCIe Root port 0002:01:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network ConnectionQuoted 9 lines
Quoted 3 lines
Load the e1000e driver:
Kernel logs confirm device initialization and link-up at 1 Gbps Full Duplex oneth2/eth3/eth4.
Quoted 5 lines
root@ast2700-default:~# modprobe e1000e [ 59.181623] e1000e: Intel(R) PRO/1000 Network Driver [ 59.181926] e1000e: Copyright(c) 1999 - 2015 Intel Corporation. [ 59.183508] e1000e 0000:01:00.0: enabling device (0000 -> 0002) [ 59.188808] e1000e 0000:01:00.0: Interrupt Throttling Rate (ints/sec)set
Quoted 2 lines
to dynamic conservative mode
Quoted 1 line
[ 59.252590] e1000e 0000:01:00.0 0000:01:00.0 (uninitialized):registered
Quoted 9 lines
PHC clock
Quoted 1 line
[ 59.330877] e1000e 0000:01:00.0 eth2: (PCI Express:2.5GT/s:Width x1)52:54:00:12:34:56
Quoted 1 line
[ 59.331990] e1000e 0000:01:00.0 eth2: Intel(R) PRO/1000 NetworkConnection
Quoted 1 line
[ 59.333211] e1000e 0000:01:00.0 eth2: MAC: 3, PHY: 8, PBA No:000000-000
Quoted 2 lines
[ 59.334881] e1000e 0001:01:00.0: enabling device (0000 -> 0002) [ 59.341616] e1000e 0001:01:00.0: Interrupt Throttling Rate (ints/sec)set
Quoted 2 lines
to dynamic conservative mode
Quoted 1 line
[ 59.394712] e1000e 0001:01:00.0 0001:01:00.0 (uninitialized):registered
Quoted 9 lines
PHC clock
Quoted 1 line
[ 59.456674] e1000e 0001:01:00.0 eth3: (PCI Express:2.5GT/s:Width x1)52:54:00:12:34:57
Quoted 1 line
[ 59.457487] e1000e 0001:01:00.0 eth3: Intel(R) PRO/1000 NetworkConnection
Quoted 1 line
[ 59.458033] e1000e 0001:01:00.0 eth3: MAC: 3, PHY: 8, PBA No:000000-000
Quoted 2 lines
[ 59.460037] e1000e 0002:01:00.0: enabling device (0000 -> 0002) [ 59.466403] e1000e 0002:01:00.0: Interrupt Throttling Rate (ints/sec)set
Quoted 2 lines
to dynamic conservative mode
Quoted 1 line
[ 59.533361] e1000e 0002:01:00.0 0002:01:00.0 (uninitialized):registered
Quoted 9 lines
PHC clock
Quoted 2 lines
[ 59.654491] 8021q: adding VLAN 0 to HW filter on device eth2 [ 59.662100] e1000e 0002:01:00.0 eth4: (PCI Express:2.5GT/s:Width x1)52:54:00:12:34:58
Quoted 1 line
[ 59.662966] e1000e 0002:01:00.0 eth4: Intel(R) PRO/1000 NetworkConnection
Quoted 1 line
[ 59.663527] e1000e 0002:01:00.0 eth4: MAC: 3, PHY: 8, PBA No:000000-000
Quoted 1 line
root@ast2700-default:~# [ 59.814984] 8021q: adding VLAN 0 to HWfilter
Quoted 17 lines
on device eth3
Quoted 2 lines
[ 59.938859] 8021q: adding VLAN 0 to HW filter on device eth4 [ 59.954690] e1000e 0000:01:00.0 eth2: NIC Link is Up 1000 Mbps FullDuplex, Flow Control: Rx/Tx
Quoted 1 line
[ 60.116790] e1000e 0001:01:00.0 eth3: NIC Link is Up 1000 Mbps FullDuplex, Flow Control: Rx/Tx
Quoted 1 line
[ 60.237622] e1000e 0002:01:00.0 eth4: NIC Link is Up 1000 Mbps FullDuplex, Flow Control: Rx/Tx
Quoted 8 lines
After loading, users should see:
eth2: PCIe0
eth3: PCIe1
eth4: PCIe2Example ifconfig output shows all interfaces (eth0-eth4) active, with
eth2-eth4 bound to the e1000e NICs.
Quoted 10 lines
Quoted 2 lines
With this setup, all three PCIe RCs on AST2700 can be tested using e1000e
endpoints in QEMU.
Quoted 4 lines
root@ast2700-default:~# ifconfig eth2 Link encap:Ethernet HWaddr 52:54:00:12:34:56 inet addr:169.254.120.135 Bcast:169.254.255.255Mask:255.255.0.0
Quoted 2 lines
inet6 addr: fe80::5054:ff:fe12:3456/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500
Metric:1
Quoted 11 lines
Quoted 8 lines
RX packets:19 errors:0 dropped:0 overruns:0 frame:0 TX packets:51 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000
RX bytes:5227 (5.1 KiB) TX bytes:8551 (8.3 KiB) Interrupt:42 Memory:60040000-60060000eth3 Link encap:Ethernet HWaddr 52:54:00:12:34:57
inet addr:169.254.237.52 Bcast:169.254.255.255Mask:255.255.0.0
Quoted 2 lines
inet6 addr: fe80::5054:ff:fe12:3457/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500
Metric:1
Quoted 11 lines
Quoted 8 lines
RX packets:16 errors:0 dropped:0 overruns:0 frame:0 TX packets:47 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000
RX bytes:4786 (4.6 KiB) TX bytes:8175 (7.9 KiB) Interrupt:45 Memory:80040000-80060000eth4 Link encap:Ethernet HWaddr 52:54:00:12:34:58
inet addr:169.254.84.173 Bcast:169.254.255.255Mask:255.255.0.0
Quoted 2 lines
inet6 addr: fe80::5054:ff:fe12:3458/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500
Metric:1
Quoted 11 lines
Quoted 11 lines
RX packets:16 errors:0 dropped:0 overruns:0 frame:0 TX packets:47 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000
RX bytes:4786 (4.6 KiB) TX bytes:8191 (7.9 KiB) Interrupt:48 Memory:a0040000-a0060000Jamin Lin (11):
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 and host bridge hw/pci-host/aspeed: Add MSI support and per-RC IOMMU addressspace
Quoted 6 lines
Quoted 6 lines
hw/arm/aspeed: Wire up PCIe devices in SoC model hw/arm/aspeed_ast2600: Add PCIe RC support (
RC_Honly) tests/functional/test_arm_aspeed_ast2600: Add PCIe test via root portand e1000ehw/pci-host/aspeed: Add AST2700 PCIe PHY hw/pci-host/aspeed: Add AST2700 PCIe config with dedicated H2X
blocks
Quoted 21 lines
Quoted 9 lines
hw/arm/aspeed_ast27x0: Introduce 3 PCIe RCs for AST2700 tests/functional: Add PCIe presence test for AST2700
include/hw/arm/aspeed_soc.h | 14 + include/hw/pci-host/aspeed_pcie.h | 125 +++ include/hw/pci/pci_ids.h | 2 + hw/arm/aspeed_ast2600.c | 69 +- hw/arm/aspeed_ast27x0.c | 61 ++ hw/pci-host/aspeed_pcie.c | 955++++++++++++++++++
Quoted 11 lines
hw/arm/Kconfig | 3 + hw/pci-host/Kconfig | 4 + hw/pci-host/meson.build | 1 + hw/pci-host/trace-events | 11 + .../functional/test_aarch64_aspeed_ast2700.py | 7 + .../test_aarch64_aspeed_ast2700fc.py | 6 + tests/functional/test_arm_aspeed_ast2600.py | 14 + 13 files changed, 1269 insertions(+), 3 deletions(-)create mode 100644
include/hw/pci-host/aspeed_pcie.hcreate mode 100644hw/pci-host/aspeed_pcie.c