This series finishes and fixes up Sergey Kambalin's "Raspberry Pi 4B
machine" series from 2024 (patchwork series 829638, [1]), giving
raspi4b a working PCIe Root Complex and GENET Ethernet controller.
Right now raspi4b has no working networking at all: it has no genet
and no PCIe, and while the guest's dwc_otg USB driver loads, it
never actually enumerates a device, so usb-net -- the path that
works on raspi3b -- doesn't work here either. raspi4b guests are
stuck without a network device out of the box.
Kambalin's series added the missing PCIe/GENET scaffolding (patches
13-15 and 19-29 of 41), but only the earlier base-SoC patches ever
landed; the PCIe/GENET/RNG/thermal patches were never merged and the
series went quiet after v6. This series carries forward just the
PCIe and GENET parts (RNG/thermal are out of scope here).
This series:
- Rebases patches 13-15 (PCIe Root Complex + host) and 19-29
(GENET stub through RX/TX/MDIO) against current master, adapting
them to API changes since 2024: header paths moved under
hw/core/, class_init()'s void *data became const void *data, the
Resettable phases API replaced the plain DeviceClass::reset hook,
and Property[] lost its DEFINE_PROP_END_OF_LIST() sentinel. This
adaptation is confined to the patches that needed it (the "add"/
"enable"/"stub"/"register ops" patches below) -- no functional
change, just API updates to make the existing logic build again.
- Fixes three real bugs found while getting an actual guest to
boot and get a DHCP lease end to end (patches 15-17):
1. A PHY autonegotiation-restart deadlock: the guest driver
requests a restart and polls forever for an acknowledgment
that a discarded FIELD_DP16() return value meant it would
never get. This alone was enough to make the link never come
up.
2. RX checksum reporting stored the wrong value in the wrong
byte order, making the guest reject valid inbound packets
("hw csum failure").
3. TX ring activation checked the wrong register field
(1-bit-wide GENET_DMA_CTRL.EN instead of the 17-bit-wide
per-ring GENET_DMA_RING_CFG.EN), so only ring 0 could ever be
seen as active; traffic hashed onto any other ring silently
dropped, eventually tripping the guest's TX watchdog.
- Updates docs/system/arm/raspi.rst (PCIe/GENET move from "missing"
to "implemented") and adds a functional test
(test_arm_raspi4_genet) that boots with the GENET NIC, confirms
the driver probes it, and confirms the link actually comes up --
which serves as a regression test for bug #1 above.
Testing: built and boot-tested repeatedly against both a vanilla
Raspberry Pi OS (Bullseye) image and a third-party product image
(SimRacingStudio's magicbox-os), and against the exact kernel/initrd
assets tests/functional/aarch64/test_raspi4.py already pins.
`scripts/checkpatch.pl` is clean (0 errors) across the whole series;
`tests/functional/aarch64/test_raspi3.py` and `test_raspi4.py`
(all three tests, including the new one) pass.
Sergey, I've CC'd you as the original author -- happy to fold in any
feedback you have on how the PCIe/GENET adaptation or the bug fixes
were done, and to give you a spot in this series' history however
you'd prefer if you'd like to be more actively involved in getting
it landed.
[1] https://patchwork.kernel.org/project/qemu-devel/cover/20240226000259.2752893-1-sergey.kambalin@auriga.com/
Marcelo Manzo (9):
hw/arm/bcm2838_pcie: add BCM2838 PCIe Root Complex
hw/arm/bcm2838: enable BCM2838 PCIe host bridge
hw/net/bcm2838_genet: add GENET stub device
hw/arm/bcm2838: enable BCM2838 GENET controller
hw/net/bcm2838_genet: fix PHY autonegotiation-restart deadlock
hw/net/bcm2838_genet: fix bogus RX checksum reporting
hw/net/bcm2838_genet: fix TX ring activation check
docs/system/arm/raspi: move PCIe/GENET from missing to implemented
tests/functional/aarch64: add raspi4b GENET networking test
Sergey Kambalin (10):
hw/arm/bcm2838_pcie: add BCM2838 PCIe host
hw/net/bcm2838_genet: add GENET register structs, part 1/4
hw/net/bcm2838_genet: add GENET register structs, part 2/4
hw/net/bcm2838_genet: add GENET register structs, part 3/4
hw/net/bcm2838_genet: add GENET register structs, part 4/4
hw/net/bcm2838_genet: add GENET register access macros
hw/net/bcm2838_genet: implement GENET register ops
hw/net/bcm2838_genet: implement GENET MDIO
hw/net/bcm2838_genet: implement GENET TX path
hw/net/bcm2838_genet: implement GENET RX path
docs/system/arm/raspi.rst | 4 +-
hw/arm/bcm2838.c | 15 +
hw/arm/bcm2838_pcie.c | 297 ++++++
hw/arm/bcm2838_peripherals.c | 34 +
hw/arm/meson.build | 4 +-
hw/arm/raspi4b.c | 2 -
hw/arm/trace-events | 4 +
hw/net/bcm2838_genet.c | 1101 +++++++++++++++++++++++
hw/net/meson.build | 2 +
hw/net/trace-events | 16 +
include/hw/arm/bcm2838_pcie.h | 75 ++
include/hw/arm/bcm2838_peripherals.h | 6 +
include/hw/net/bcm2838_genet.h | 426 +++++++++
tests/functional/aarch64/test_raspi4.py | 30 +
14 files changed, 2011 insertions(+), 5 deletions(-)
create mode 100644 hw/arm/bcm2838_pcie.c
create mode 100644 hw/net/bcm2838_genet.c
create mode 100644 include/hw/arm/bcm2838_pcie.h
create mode 100644 include/hw/net/bcm2838_genet.h
--
2.47.1