From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:54023) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SiEJA-0007LA-CA for qemu-devel@nongnu.org; Fri, 22 Jun 2012 20:34:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SiEJ7-0007xf-Kn for qemu-devel@nongnu.org; Fri, 22 Jun 2012 20:34:35 -0400 Received: from mail-pz0-f45.google.com ([209.85.210.45]:50139) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SiEJ7-0007rl-BX for qemu-devel@nongnu.org; Fri, 22 Jun 2012 20:34:33 -0400 Received: by mail-pz0-f45.google.com with SMTP id n2so3053134dad.4 for ; Fri, 22 Jun 2012 17:34:32 -0700 (PDT) Sender: fluxion From: Michael Roth Date: Fri, 22 Jun 2012 19:33:21 -0500 Message-Id: <1340411610-22596-18-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1340411610-22596-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1340411610-22596-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH stable-1.1 17/26] rtl8139: honor RxOverflow flag in can_receive method List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com From: Fernando Luis Vazquez Cao Some drivers (Linux' 8139too among them) rely on the NIC injecting an interrupt in the event of a receive buffer overflow and, accordingly, set the RxOverflow bit in the interrupt mask. Unfortunately rtl8139's can_receive method ignores the RxOverflow flag, which may lead to a situation where rtl8139 stops receiving packets (can_receive returns 0) when the receive buffer becomes full. If the driver eventually read from the receive buffer or reset the card the emulator could recover from this situation. However some implementations only do this upon receiving an interrupt with either RxOK or RxOverflow set in the ISR; interrupt that will never come because QEMU's flow control mechanisms would prevent rtl8139 from receiving any packet. Letting packets go through when the overflow interrupt is enabled makes the QEMU emulator compliant to the spec and solves the problem. This patch should fix a relatively common (in our experience) network stall observed when running enterprise distros with rtl8139 as the NIC; in some cases the 8139too device driver gets loaded and when under heavy load the network eventually stops working. Reported-by: Hayato Kakuta Tested-by: Hayato Kakuta Acked-by: Igor Kovalenko Signed-off-by: Fernando Luis Vazquez Cao Signed-off-by: Michael S. Tsirkin --- hw/rtl8139.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/hw/rtl8139.c b/hw/rtl8139.c index eb22d04..f6f144b 100644 --- a/hw/rtl8139.c +++ b/hw/rtl8139.c @@ -802,7 +802,7 @@ static int rtl8139_can_receive(VLANClientState *nc) } else { avail = MOD2(s->RxBufferSize + s->RxBufPtr - s->RxBufAddr, s->RxBufferSize); - return (avail == 0 || avail >= 1514); + return (avail == 0 || avail >= 1514 || (s->IntrMask & RxOverflow)); } } -- 1.7.4.1