From patchwork Fri May 18 10:32:09 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fernando Luis Vazquez Cao X-Patchwork-Id: 160145 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D5BE2B6FB9 for ; Sat, 19 May 2012 03:59:00 +1000 (EST) Received: from localhost ([::1]:40220 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SVRS6-0008PY-Bp for incoming@patchwork.ozlabs.org; Fri, 18 May 2012 13:58:58 -0400 Received: from eggs.gnu.org ([208.118.235.92]:52308) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SVKTp-0005tV-2i for qemu-devel@nongnu.org; Fri, 18 May 2012 06:32:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SVKTn-0005Bm-3Q for qemu-devel@nongnu.org; Fri, 18 May 2012 06:32:16 -0400 Received: from tama50.ecl.ntt.co.jp ([129.60.39.147]:59422) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SVKTm-0005At-K4 for qemu-devel@nongnu.org; Fri, 18 May 2012 06:32:15 -0400 Received: from mfs6.rdh.ecl.ntt.co.jp (mfs6.rdh.ecl.ntt.co.jp [129.60.39.149]) by tama50.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id q4IAW97r019185; Fri, 18 May 2012 19:32:09 +0900 Received: from mfs6.rdh.ecl.ntt.co.jp (localhost [127.0.0.1]) by mfs6.rdh.ecl.ntt.co.jp (Postfix) with ESMTP id 9FC5E6831; Fri, 18 May 2012 19:32:09 +0900 (JST) Received: from imail1.m.ecl.ntt.co.jp (imail1.m.ecl.ntt.co.jp [129.60.5.246]) by mfs6.rdh.ecl.ntt.co.jp (Postfix) with ESMTP id 95B756830; Fri, 18 May 2012 19:32:09 +0900 (JST) Received: from [129.60.241.51] (nexus.sic.ecl.ntt.co.jp [129.60.241.51]) by imail1.m.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id q4IAW928014971; Fri, 18 May 2012 19:32:09 +0900 Message-ID: <4FB62529.9030006@lab.ntt.co.jp> Date: Fri, 18 May 2012 19:32:09 +0900 From: Fernando Luis Vazquez Cao User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.4) Gecko/20120510 Icedove/10.0.4 MIME-Version: 1.0 To: aliguori@us.ibm.com, mst@redhat.com References: <20120517052542.17932.58011.stgit@dhcp-8-146.nay.redhat.com> In-Reply-To: <20120517052542.17932.58011.stgit@dhcp-8-146.nay.redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 129.60.39.147 X-Mailman-Approved-At: Fri, 18 May 2012 13:58:24 -0400 Cc: Jason Wang , qemu-devel@nongnu.org, avi@redhat.com Subject: Re: [Qemu-devel] [PATCH] rtl8139: validate rx ring before receiving packets 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 Hi Anthony, Michael, While at it, could you pick up the attached patch too? It has already been acked by Igor Kovalenko. Thanks, Fernando Subject: [PATCH] rtl8139: honor RxOverflow flag in can_receive method 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 --- diff -urNp qemu-orig/hw/rtl8139.c qemu/hw/rtl8139.c --- qemu-orig/hw/rtl8139.c 2012-05-18 19:17:06.090565651 +0900 +++ qemu/hw/rtl8139.c 2012-05-09 15:48:50.000000000 +0900 @@ -802,7 +802,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)); } }