[PATCH 0/2] hw/net/bcm2838_genet: TX index wrap and full RX ring

Lorand Marton posted 2 patches 2 weeks, 6 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/cover.1793613972.genet-ring-fixes-v1.git.lorandmarton.dev@gmail.com
Maintainers: Peter Maydell <peter.maydell@linaro.org>, "Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>, Jason Wang <jasowangio@gmail.com>, Fabiano Rosas <farosas@suse.de>, Laurent Vivier <lvivier@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>
hw/net/bcm2838_genet.c           |  42 ++++++-
tests/qtest/bcm2838-genet-test.c | 204 +++++++++++++++++++++++++++++++
tests/qtest/meson.build          |   2 +
3 files changed, 247 insertions(+), 1 deletion(-)
create mode 100644 tests/qtest/bcm2838-genet-test.c
[PATCH 0/2] hw/net/bcm2838_genet: TX index wrap and full RX ring
Posted by Lorand Marton 2 weeks, 6 days ago
Based-on: <20261027143036.44973-1-marcelomanzo@gmail.com>

Two fixes for the BCM2838 GENET model of "[PATCH v6 00/17]
hw/arm/raspi4b: working PCIe and GENET (real networking)", which is in
target-arm.next. They apply to target-arm.next; if that is simpler,
they can also be folded into patch 12/17 (implement GENET TX path) and
patch 13/17 (implement GENET RX path) of that series.

- The TX consumer index counted past 16 bits, so the first transmit
  across the wrap never ended: the device sent the ring's descriptors
  forever with the BQL held, and the guest and the monitor hung. A
  guest sending a sustained stream hung after about 65k descriptors.
- The RX path wrote frames past the consumer index of a full ring and
  overwrote frames the guest had not read. The fix keeps them queued
  in the net layer until the guest frees descriptors, as e1000 does;
  real GENET drops them and counts them in DISCARD_CNT.

Patch 1 adds tests/qtest/bcm2838-genet-test.c. Each test fails with
only its fix reverted (the TX test hangs).

I found these bugs while running Raspberry Pi OS images on a model of
the Compute Module 4: https://github.com/LorandMarton/boardtwin. Its
QEMU changes are on the boardtwin-develop branch of
https://github.com/LorandMarton/qemu. I intend to send the board model
(raspicm4) after the 11.2 release.

Checked: each patch builds and passes the test; the aarch64 qtests
pass (33, 3 skipped: the slow cdrom test and the two swtpm tests).

Lorand Marton (2):
  hw/net/bcm2838_genet: wrap the TX consumer index at 16 bits
  hw/net/bcm2838_genet: hold RX frames while the ring is full

 hw/net/bcm2838_genet.c           |  42 ++++++-
 tests/qtest/bcm2838-genet-test.c | 204 +++++++++++++++++++++++++++++++
 tests/qtest/meson.build          |   2 +
 3 files changed, 247 insertions(+), 1 deletion(-)
 create mode 100644 tests/qtest/bcm2838-genet-test.c


base-commit: eb5ac4b5bb4e221771cef0c53004f99499133f3e
-- 
2.56.0
Re: [PATCH 0/2] hw/net/bcm2838_genet: TX index wrap and full RX ring
Posted by Peter Maydell 2 weeks, 2 days ago
On Mon, 2 Nov 2026 at 10:42, Lorand Marton <lorandmarton.dev@gmail.com> wrote:
>
> Based-on: <20261027143036.44973-1-marcelomanzo@gmail.com>
>
> Two fixes for the BCM2838 GENET model of "[PATCH v6 00/17]
> hw/arm/raspi4b: working PCIe and GENET (real networking)", which is in
> target-arm.next. They apply to target-arm.next; if that is simpler,
> they can also be folded into patch 12/17 (implement GENET TX path) and
> patch 13/17 (implement GENET RX path) of that series.
>
> - The TX consumer index counted past 16 bits, so the first transmit
>   across the wrap never ended: the device sent the ring's descriptors
>   forever with the BQL held, and the guest and the monitor hung. A
>   guest sending a sustained stream hung after about 65k descriptors.
> - The RX path wrote frames past the consumer index of a full ring and
>   overwrote frames the guest had not read. The fix keeps them queued
>   in the net layer until the guest frees descriptors, as e1000 does;
>   real GENET drops them and counts them in DISCARD_CNT.
>
> Patch 1 adds tests/qtest/bcm2838-genet-test.c. Each test fails with
> only its fix reverted (the TX test hangs).
>
> I found these bugs while running Raspberry Pi OS images on a model of
> the Compute Module 4: https://github.com/LorandMarton/boardtwin. Its
> QEMU changes are on the boardtwin-develop branch of
> https://github.com/LorandMarton/qemu. I intend to send the board model
> (raspicm4) after the 11.2 release.
>
> Checked: each patch builds and passes the test; the aarch64 qtests
> pass (33, 3 skipped: the slow cdrom test and the two swtpm tests).
>
> Lorand Marton (2):
>   hw/net/bcm2838_genet: wrap the TX consumer index at 16 bits
>   hw/net/bcm2838_genet: hold RX frames while the ring is full



Applied to target-arm.next, thanks.

-- PMM
Re: [PATCH 0/2] hw/net/bcm2838_genet: TX index wrap and full RX ring
Posted by Peter Maydell 2 weeks, 6 days ago
On Mon, 2 Nov 2026 at 10:42, Lorand Marton <lorandmarton.dev@gmail.com> wrote:
>
> Based-on: <20261027143036.44973-1-marcelomanzo@gmail.com>
>
> Two fixes for the BCM2838 GENET model of "[PATCH v6 00/17]
> hw/arm/raspi4b: working PCIe and GENET (real networking)", which is in
> target-arm.next. They apply to target-arm.next; if that is simpler,
> they can also be folded into patch 12/17 (implement GENET TX path) and
> patch 13/17 (implement GENET RX path) of that series.
>
> - The TX consumer index counted past 16 bits, so the first transmit
>   across the wrap never ended: the device sent the ring's descriptors
>   forever with the BQL held, and the guest and the monitor hung. A
>   guest sending a sustained stream hung after about 65k descriptors.
> - The RX path wrote frames past the consumer index of a full ring and
>   overwrote frames the guest had not read. The fix keeps them queued
>   in the net layer until the guest frees descriptors, as e1000 does;
>   real GENET drops them and counts them in DISCARD_CNT.

I'm just about to send a pullreq with the GENET changes in it,
to hit the softfreeze deadline. I think what I'll do with these
bugfix patches is put them in for the next lot after that, so
we have some time for code review, rather than trying to apply
them in a hurry and maybe merge them with the existing tx and rx
patches.

thanks
-- PMM