qemu/hw
Andrey Smirnov b2b012afdd imx_fec: Change queue flushing heuristics
In current implementation, packet queue flushing logic seem to suffer
from a deadlock like scenario if a packet is received by the interface
before before Rx ring is initialized by Guest's driver. Consider the
following sequence of events:

	1. A QEMU instance is started against a TAP device on Linux
	   host, running Linux guest, e. g., something to the effect
	   of:

	   qemu-system-arm \
	      -net nic,model=imx.fec,netdev=lan0 \
	      netdev tap,id=lan0,ifname=tap0,script=no,downscript=no \
	      ... rest of the arguments ...

	2. Once QEMU starts, but before guest reaches the point where
	   FEC deriver is done initializing the HW, Guest, via TAP
	   interface, receives a number of multicast MDNS packets from
	   Host (not necessarily true for every OS, but it happens at
	   least on Fedora 25)

	3. Recieving a packet in such a state results in
	   imx_eth_can_receive() returning '0', which in turn causes
	   tap_send() to disable corresponding event (tap.c:203)

	4. Once Guest's driver reaches the point where it is ready to
	   recieve packets it prepares Rx ring descriptors and writes
	   ENET_RDAR_RDAR to ENET_RDAR register to indicate to HW that
	   more descriptors are ready. And at this points emulation
	   layer does this:

	   	 s->regs[index] = ENET_RDAR_RDAR;
                 imx_eth_enable_rx(s);

	   which, combined with:

	   	  if (!s->regs[ENET_RDAR]) {
		     qemu_flush_queued_packets(qemu_get_queue(s->nic));
		  }

	   results in Rx queue never being flushed and corresponding
	   I/O event beign disabled.

To prevent the problem, change the code to always flush packet queue
when ENET_RDAR transitions 0 -> ENET_RDAR_RDAR.

Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Philippe Mathieu-Daudé <f4bug@amsat.org>
Cc: qemu-devel@nongnu.org
Cc: qemu-arm@nongnu.org
Cc: yurovsky@gmail.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2018-01-11 13:25:35 +00:00
..
9pfs 9pfs: deprecate handle backend 2018-01-08 11:18:23 +01:00
acpi hw/acpi: ACPI_PM_* defines are not restricted to i386 arch 2017-12-18 17:07:02 +03:00
adc
alpha hw/timer/mc146818: rename rtc_init() -> mc146818_rtc_init() 2017-12-18 17:07:02 +03:00
arm imx_fec: Do not link to netdev 2018-01-11 13:25:34 +00:00
audio misc: remove old i386 dependency 2017-12-18 17:07:02 +03:00
block nvme: Add tracing 2017-12-22 15:03:41 +01:00
bt
char misc: drop old i386 dependency 2017-12-18 17:07:03 +03:00
core Pull request 2017-12-20 11:30:55 +00:00
cpu hw: use "qemu/osdep.h" as first #include in source files 2017-12-18 17:07:02 +03:00
cris
display hw/display/vga: extract public API from i386/pc to "hw/display/vga.h" 2017-12-18 17:07:02 +03:00
dma sun4m: remove include/hw/sparc/sun4m.h and all references to it 2018-01-09 21:48:20 +00:00
gpio
i2c hw/i2c: remove old i386 dependency 2017-12-18 17:07:02 +03:00
i386 acpi: Update TPM2 ACPI table to more recent specs 2017-12-22 11:03:21 -05:00
ide hw/block: Use errp directly rather than local_err 2017-12-19 10:25:03 +00:00
input Split adb.c into adb.c, adb-mouse.c and adb-kbd.c 2017-12-21 20:11:28 +01:00
intc sun4m: remove include/hw/sparc/sun4m.h and all references to it 2018-01-09 21:48:20 +00:00
ipack
ipmi hw/ipmi: remove old i386 dependency 2017-12-18 17:07:02 +03:00
isa hw/timer/mc146818: rename rtc_init() -> mc146818_rtc_init() 2017-12-18 17:07:02 +03:00
lm32
m68k
mem
microblaze
mips hw/mips/boston: Remove workaround for writes to ROM aborting 2017-12-21 09:30:32 +01:00
misc dump-guest-memory.py: fix "You can't do that without a process to debug" 2018-01-02 14:49:54 +01:00
moxie hw/moxie/moxiesim: Add support for loading a BIOS on moxiesim 2017-12-21 09:30:31 +01:00
net imx_fec: Change queue flushing heuristics 2018-01-11 13:25:35 +00:00
nios2 nios2: remove duplicated includes (in code commented out) 2017-12-18 17:07:02 +03:00
nvram
openrisc
pci
pci-bridge misc: remove old i386 dependency 2017-12-18 17:07:02 +03:00
pci-host sun4u: split IOMMU device out from apb.c to sun4u_iommu.c 2018-01-09 21:48:20 +00:00
pcmcia
ppc hw/net/ne2000: extract ne2k-isa code from i386/pc to ne2000-isa.c 2017-12-18 17:07:02 +03:00
s390x misc: remove duplicated includes 2017-12-18 17:07:02 +03:00
scsi scsi: provide general-purpose functions to manage sense data 2017-12-21 09:30:32 +01:00
sd
sh4
smbios hw: use "qemu/osdep.h" as first #include in source files 2017-12-18 17:07:02 +03:00
sparc sun4m: remove include/hw/sparc/sun4m.h and all references to it 2018-01-09 21:48:20 +00:00
sparc64 sun4u_iommu: add trace event for IOMMU translations 2018-01-09 21:48:20 +00:00
ssi hw/ssi/aspeed_smc: remove unused #include 2017-12-18 17:07:02 +03:00
timer sun4m: remove include/hw/sparc/sun4m.h and all references to it 2018-01-09 21:48:20 +00:00
tpm tpm: Implement tpm_sized_buffer_reset 2017-12-22 09:01:09 -05:00
tricore
unicore32 hw/unicore32: restrict hw addr defines to source file 2017-12-18 17:07:02 +03:00
usb dev-storage: Fix the unusual function name 2017-12-19 10:25:08 +00:00
vfio hw: use "qemu/osdep.h" as first #include in source files 2017-12-18 17:07:02 +03:00
virtio hw/virtio-balloon: remove old i386 dependency 2017-12-18 17:07:02 +03:00
watchdog misc: drop old i386 dependency 2017-12-18 17:07:03 +03:00
xen
xenpv
xtensa
Makefile.objs