From patchwork Mon Jan 30 02:17:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Fernando_Luis_V=C3=A1zquez_Cao?= X-Patchwork-Id: 138602 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BA30C1007D1 for ; Tue, 31 Jan 2012 01:49:46 +1100 (EST) Received: from localhost ([::1]:50823 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RrsYC-0006Or-LJ for incoming@patchwork.ozlabs.org; Mon, 30 Jan 2012 09:49:44 -0500 Received: from eggs.gnu.org ([140.186.70.92]:55433) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RrgoU-0002Fm-1R for qemu-devel@nongnu.org; Sun, 29 Jan 2012 21:17:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RrgoP-0001gr-Ps for qemu-devel@nongnu.org; Sun, 29 Jan 2012 21:17:46 -0500 Received: from serv2.oss.ntt.co.jp ([222.151.198.100]:37941) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RrgoP-0001gf-8y for qemu-devel@nongnu.org; Sun, 29 Jan 2012 21:17:41 -0500 Received: from serv2.oss.ntt.co.jp (localhost [127.0.0.1]) by serv2.oss.ntt.co.jp (Postfix) with ESMTP id DFFBA248311; Mon, 30 Jan 2012 11:17:36 +0900 (JST) Received: from serv1.oss.ntt.co.jp (serv1.oss.ntt.co.jp [172.19.0.2]) by serv2.oss.ntt.co.jp (Postfix) with ESMTP id C85F724830F; Mon, 30 Jan 2012 11:17:36 +0900 (JST) Received: from [172.17.1.84] (unknown [172.17.1.84]) by serv1.oss.ntt.co.jp (Postfix) with ESMTP id BA8CC260766; Mon, 30 Jan 2012 11:17:36 +0900 (JST) Message-ID: <1327889855.3455.2.camel@nexus.oss.ntt.co.jp> From: Fernando Luis =?ISO-8859-1?Q?V=E1zquez?= Cao To: qemu-devel@nongnu.org, Anthony Liguori , "Igor V. Kovalenko" Date: Mon, 30 Jan 2012 11:17:35 +0900 Organization: NTT Open Source Software Center X-Mailer: Evolution 3.2.2-1 Mime-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 222.151.198.100 X-Mailman-Approved-At: Mon, 30 Jan 2012 09:49:34 -0500 Cc: Mark McLoughlin , "Michael S. Tsirkin" Subject: [Qemu-devel] [PATCH] rtl8139: honor RxOverflow flag in can_receive method X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Signed-off-by: Fernando Luis Vazquez Cao Acked-by: Igor Kovalenko diff -urNp qemu-kvm-orig/hw/rtl8139.c qemu-kvm/hw/rtl8139.c --- qemu-kvm-orig/hw/rtl8139.c 2012-01-12 20:55:27.000000000 +0900 +++ qemu-kvm/hw/rtl8139.c 2012-01-18 17:20:12.000000000 +0900 @@ -824,7 +824,7 @@ static int rtl8139_can_receive(VLANClien } else { avail = MOD2(s->RxBufferSize + s->RxBufPtr - s->RxBufAddr, s->RxBufferSize); - return (avail == 0 || avail >= 1514); + return (avail == 0 || avail >= 1514 || (s->IntrMask & RxOverflow)); } }