From patchwork Wed Jun 12 21:41:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 250910 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 96ACA2C0095 for ; Thu, 13 Jun 2013 08:39:33 +1000 (EST) Received: from localhost ([::1]:41838 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UmstC-0007wW-Cm for incoming@patchwork.ozlabs.org; Wed, 12 Jun 2013 17:47:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39818) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Umsqx-0005he-UO for qemu-devel@nongnu.org; Wed, 12 Jun 2013 17:45:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Umsqw-0000xD-9p for qemu-devel@nongnu.org; Wed, 12 Jun 2013 17:45:15 -0400 Received: from mail-ie0-x22f.google.com ([2607:f8b0:4001:c03::22f]:40234) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Umsqw-0000x0-4P; Wed, 12 Jun 2013 17:45:14 -0400 Received: by mail-ie0-f175.google.com with SMTP id a13so11494993iee.20 for ; Wed, 12 Jun 2013 14:45:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=uNJt7TnOEGdEHwXlGIOq6/Wdvjcpu2uDx6iK827N7kk=; b=wDlClADhW0ULcFJ0fvcE19+wfPi+b2aORoEf4PBo5onlxTWY3+yvuJRbISA4J0ChOO Z1VG9bLE6t1XpZ23flEdT/JcUaVUe+c5dLxuyHZCkpAS1MbdnTi/mWy85UP4x8e6E7qd r/jshyFDlazj8X6grt2c8z6TTfOcALE6QED5w7mktkUQ4SCkB+c3Ofna815tIU82oaUh nyeVsXf3LoLzJM+O3Pq+HY8EtKI9cNiXZYuI2bT5z7XMdXt8+uYp1TI+nNFjN3414ZkK ui6vHGKqfdaNv2vG/HpAnK2GaL3qgtpGnQvKbtZOrwGQqwkjETr2q5pCUcbzrm6d9Cay 9QhQ== X-Received: by 10.50.92.70 with SMTP id ck6mr4387059igb.76.1371073513505; Wed, 12 Jun 2013 14:45:13 -0700 (PDT) Received: from localhost ([32.97.110.51]) by mx.google.com with ESMTPSA id ri10sm4288363igc.1.2013.06.12.14.45.12 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 12 Jun 2013 14:45:12 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Wed, 12 Jun 2013 16:41:15 -0500 Message-Id: <1371073298-14519-4-git-send-email-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1371073298-14519-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1371073298-14519-1-git-send-email-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4001:c03::22f Cc: qemu-stable@nongnu.org Subject: [Qemu-devel] [PATCH 03/26] rtl8139: flush queued packets when RxBufPtr is written 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 From: Stefan Hajnoczi Net queues support efficient "receive disable". For example, tap's file descriptor will not be polled while its peer has receive disabled. This saves CPU cycles for needlessly copying and then dropping packets which the peer cannot receive. rtl8139 is missing the qemu_flush_queued_packets() call that wakes the queue up when receive becomes possible again. As a result, the Windows 7 guest driver reaches a state where the rtl8139 cannot receive packets. The driver has actually refilled the receive buffer but we never resume reception. The bug can be reproduced by running a large FTP 'get' inside a Windows 7 guest: $ qemu -netdev tap,id=tap0,... -device rtl8139,netdev=tap0 The Linux guest driver does not trigger the bug, probably due to a different buffer management strategy. Reported-by: Oliver Francke Signed-off-by: Stefan Hajnoczi (cherry picked from commit 00b7ade807b5ce6779ddd86ce29c5521ec5c529a) Signed-off-by: Michael Roth --- hw/net/rtl8139.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c index 9369507..7993f9f 100644 --- a/hw/net/rtl8139.c +++ b/hw/net/rtl8139.c @@ -2575,6 +2575,9 @@ static void rtl8139_RxBufPtr_write(RTL8139State *s, uint32_t val) /* this value is off by 16 */ s->RxBufPtr = MOD2(val + 0x10, s->RxBufferSize); + /* more buffer space may be available so try to receive */ + qemu_flush_queued_packets(qemu_get_queue(s->nic)); + DPRINTF(" CAPR write: rx buffer length %d head 0x%04x read 0x%04x\n", s->RxBufferSize, s->RxBufAddr, s->RxBufPtr); }