qemu-e2k/hw/sd
Peter Maydell f3d9fe8f95 hw/sd/bcm2835_sdhost: Don't raise spurious interrupts
The Linux bcm2835_sdhost driver doesn't work on QEMU, because our
model raises spurious data interrupts.  Our function
bcm2835_sdhost_fifo_run() will flag an interrupt any time it is
called with s->datacnt == 0, even if the host hasn't actually issued
a data read or write command yet.  This means that the driver gets a
spurious data interrupt as soon as it enables IRQs and then does
something else that causes us to call the fifo_run routine, like
writing to SDHCFG, and before it does the write to SDCMD to issue the
read.  The driver's IRQ handler then spins forever complaining that
there's no data and the SD controller isn't in a state where there's
going to be any data:

[   41.040738] sdhost-bcm2835 3f202000.mmc: fsm 1, hsts 00000000
[   41.042059] sdhost-bcm2835 3f202000.mmc: fsm 1, hsts 00000000
(continues forever).

Move the interrupt flag setting to more plausible places:
 * for BUSY, raise this as soon as a BUSYWAIT command has executed
 * for DATA, raise this when the FIFO has any space free (for a write)
   or any data in it (for a read)
 * for BLOCK, raise this when the data count is 0 and we've
   actually done some reading or writing

This is pure guesswork since the documentation for this hardware is
not public, but it is sufficient to get the Linux bcm2835_sdhost
driver to work.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20180319161556.16446-3-peter.maydell@linaro.org
2018-04-10 13:02:25 +01:00
..
bcm2835_sdhost.c hw/sd/bcm2835_sdhost: Don't raise spurious interrupts 2018-04-10 13:02:25 +01:00
core.c hw: Do not include "sysemu/block-backend.h" if it is not necessary 2018-03-12 16:12:46 +01:00
Makefile.objs sdcard: Display command name when tracing CMD/ACMD 2018-03-09 17:09:44 +00:00
milkymist-memcard.c hw/sd/milkymist-memcard: expose a SDBus and connect the SDCard to it 2018-02-22 15:12:52 +00:00
omap_mmc.c hw/sd/omap_mmc: Reset SD card on controller reset 2018-01-16 13:28:13 +00:00
pl181.c hw/sd/pl181: Reset SD card on controller reset 2018-01-16 13:28:11 +00:00
pxa2xx_mmci.c hw/sd/pxa2xx_mmci: add read/write() trace events 2018-01-11 13:25:39 +00:00
sd.c sdcard: Add the Tuning Command (CMD19) 2018-03-09 17:09:44 +00:00
sdhci-internal.h sdhci: add Spec v4.2 register definitions 2018-02-13 16:15:09 +01:00
sdhci.c sdhci: fix incorrect use of Error * 2018-03-23 18:26:45 +00:00
sdmmc-internal.c sdcard: Display command name when tracing CMD/ACMD 2018-03-09 17:09:44 +00:00
sdmmc-internal.h sdcard: Display command name when tracing CMD/ACMD 2018-03-09 17:09:44 +00:00
ssi-sd.c hw/sd/ssi-sd: use the SDBus API, connect the SDCard to the bus 2018-02-22 15:12:52 +00:00
trace-events hw/sd/bcm2835_sdhost: Add tracepoints 2018-04-10 13:02:25 +01:00