# BCM2711: SD card writes hang when the Wi-Fi SDHCI controller interrupts

## What happens

On the BCM2711 the Arasan SDHCI controller (the Wi-Fi bus) and EMMC2 (the SD card) share the interrupt line `gic0,s126`. If the Arasan controller raises an interrupt while EMMC2 is in the middle of a DMA write, the handler consumes EMMC2's "buffer ready" status. The write never completes, the machine answers ping for 9 to 10 seconds and then reboots.

## Evidence

A standalone reproducer (`tools/sdhci-irq-repro/` in [freebsd-rpi-wifi](https://github.com/spagu/freebsd-rpi-wifi)) sends CMD52 reads to the Arasan slot at 400 kHz while a second process writes and `fsync`s to the SD card. It needs no Wi-Fi firmware and no `cywfm`. On a stock 15.0-RELEASE-p13 kernel, 5 runs out of 5 lost a write within the first second once the Arasan status was visible. With it hidden, 5 of 5 ran clean.

Side finding: `hw.bcm2835.sdhci.pio_mode=1`, the obvious workaround, stops the board from booting, and reads from the SD card return wrong data with it. That is a separate problem, not tracked down yet.

## Workaround

`cywfm` replaces the interrupt filter in the `sdhci_bcm` method table at runtime (`hw.cywfm.irq_fix=1`, on by default on the Pi 4).

## Status

The kernel patch (`patches/bcm2835_sdhci-shared-irq.diff`) applies to `releng/15.0` and `main` and builds with `-Werror`. Filing waits for 30 cycles on a patched kernel without the driver's workaround, plus an SD card regression test. Related existing reports: [PR 251033](https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=251033) shows the same "command interrupt with no active command" message, and a note was added there in 2023.
