From patchwork Fri Jun 8 20:05:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 927026 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 412YSS0sRdz9rxs for ; Sat, 9 Jun 2018 06:10:48 +1000 (AEST) Received: from localhost ([::1]:37983 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRNif-00023h-Mu for incoming@patchwork.ozlabs.org; Fri, 08 Jun 2018 16:10:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47925) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRNez-0007fr-94 for qemu-devel@nongnu.org; Fri, 08 Jun 2018 16:07:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRNew-0006pZ-Rj for qemu-devel@nongnu.org; Fri, 08 Jun 2018 16:06:57 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:51051) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRNew-0006nu-HC; Fri, 08 Jun 2018 16:06:54 -0400 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue002 [212.227.15.167]) with ESMTPSA (Nemesis) id 0Mf66r-1fcbuj2baT-00OUcp; Fri, 08 Jun 2018 22:06:32 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Fri, 8 Jun 2018 22:05:58 +0200 Message-Id: <20180608200558.386-14-laurent@vivier.eu> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180608200558.386-1-laurent@vivier.eu> References: <20180608200558.386-1-laurent@vivier.eu> X-Provags-ID: V03:K1:wEvUxou2nbTVyLP1tPnudaQu8M89qNMmIxn2nVkH9wK7WabXPLR WVPaEJbWTp8SCJNj4wyNjSc+IlhHjzK/CISuH8gEhiVVBa2zXmv2Fa7OEfIWg0ptKbHcg/Q JR8YSiuYWCVoWtaXnTT02XcivVScPiq87KR7Lk8frE6bBvnq8/JvedM0aaClWUOfMJ2Yoz7 YH/ZLs1DjhU0cTYhytlAg== X-UI-Out-Filterresults: notjunk:1; V01:K0:0zmjVcHWmMA=:23ilJtj7yKn8slxHBIMnmq 7uG9v1BMTVpOltd/ZiuthchxhlcIPfRRU6WzkDPN+HooCFwJdUTfkfyeYEO90zKvwhVQTeiRL KU49Vv57G19b1NOXPb0sQ8klRRqrj12tJEw4EKqiBxvfvzzXMnm+dQ6OEgb9OO43b5na3xKzn oKgIqnZC1QgGDKhf6wubc1S9/5jfXnK3e2mVJ7LRGBIo60nnttIsZguhbf9f/XDNJl+lo6Lv1 YMjlSpYXz7I9VlYNxatKkAZktxf69sOKpUeh6ieetp/KNBra22dKNJ0uUgTAqPR0GyQrdqM1h d7N4sDxVFRxG/lJrJjEgNJKD8eNmP0iWjhbob980RZ2cKnHADksnwFSfl2mBTHvbQTmZn6r4E Bkx+nxvb13gaolVukat68qx0srY+ZS0Oadavvd5Cu1ES15roQu2TEQQYM1Ru+FkABmMFsI1Wv rjsavuymhb01X9z8IGUP5oXXdfB5wrvvC8AcItimt5PT025gOwtr9aQRiXe/Dv7zEfgghWcz/ G/9TIeDAK56YIOu/ZiozFZhQ8h0SzOFif5ZsQJ0mdn1HsrY6M+lH5fKo5dFbtI+UVIpPBGJgT 1/b2ajMVcw80GyMo2ny3k8eHSLZagG4DRBwg4bs33229h1SBv2nKW5wsFoopIPRN7vQ4WvJzo gLQVbL/fdMXlYzvnun59qc4K9hmdDGBM3efom+ZOeFzKRYuxq8tuEI4ETHBLouJOeJ5I= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.126.130 Subject: [Qemu-devel] [RFC 13/13] dp8393x: fix receiving buffer exhaustion X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Jason Wang , "Dr. David Alan Gilbert" , Max Reitz , =?utf-8?q?Herv=C3=A9_Poussineau?= , Gerd Hoffmann , Paolo Bonzini , Yongbok Kim , =?utf-8?q?Andreas_F=C3=A4rber?= , Aurelien Jarno , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The card is not able to exit from exhaustion state, because while the drive consumes the buffers, the RRP is incremented (when the driver clears the ISR RBE bit), so it stays equal to RWP, and while RRP == RWP, the card thinks it is always in exhaustion state. So the driver consumes all the buffers, but the card cannot receive new ones. This patch fixes the problem by not incrementing RRP when the driver clears the ISR RBE bit. Signed-off-by: Laurent Vivier Tested-by: Hervé Poussineau --- hw/net/dp8393x.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c index 40e5f8257b..fd0f6cf2a0 100644 --- a/hw/net/dp8393x.c +++ b/hw/net/dp8393x.c @@ -314,7 +314,7 @@ static void dp8393x_do_load_cam(dp8393xState *s) dp8393x_update_irq(s); } -static void dp8393x_do_read_rra(dp8393xState *s) +static void dp8393x_do_read_rra(dp8393xState *s, int next) { int width, size; @@ -333,19 +333,20 @@ static void dp8393x_do_read_rra(dp8393xState *s) s->regs[SONIC_CRBA0], s->regs[SONIC_CRBA1], s->regs[SONIC_RBWC0], s->regs[SONIC_RBWC1]); - /* Go to next entry */ - s->regs[SONIC_RRP] += size; + if (next) { + /* Go to next entry */ + s->regs[SONIC_RRP] += size; - /* Handle wrap */ - if (s->regs[SONIC_RRP] == s->regs[SONIC_REA]) { - s->regs[SONIC_RRP] = s->regs[SONIC_RSA]; - } + /* Handle wrap */ + if (s->regs[SONIC_RRP] == s->regs[SONIC_REA]) { + s->regs[SONIC_RRP] = s->regs[SONIC_RSA]; + } - /* Check resource exhaustion */ - if (s->regs[SONIC_RRP] == s->regs[SONIC_RWP]) - { - s->regs[SONIC_ISR] |= SONIC_ISR_RBE; - dp8393x_update_irq(s); + /* Check resource exhaustion */ + if (s->regs[SONIC_RRP] == s->regs[SONIC_RWP]) { + s->regs[SONIC_ISR] |= SONIC_ISR_RBE; + dp8393x_update_irq(s); + } } /* Done */ @@ -559,7 +560,7 @@ static void dp8393x_do_command(dp8393xState *s, uint16_t command) if (command & SONIC_CR_RST) dp8393x_do_software_reset(s); if (command & SONIC_CR_RRRA) - dp8393x_do_read_rra(s); + dp8393x_do_read_rra(s, 1); if (command & SONIC_CR_LCAM) dp8393x_do_load_cam(s); } @@ -650,7 +651,7 @@ static void dp8393x_write(void *opaque, hwaddr addr, uint64_t data, data &= s->regs[reg]; s->regs[reg] &= ~data; if (data & SONIC_ISR_RBE) { - dp8393x_do_read_rra(s); + dp8393x_do_read_rra(s, 0); } dp8393x_update_irq(s); if (dp8393x_can_receive(s->nic->ncs)) { @@ -852,7 +853,7 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf, if (s->regs[SONIC_RCR] & SONIC_RCR_LPKT) { /* Read next RRA */ - dp8393x_do_read_rra(s); + dp8393x_do_read_rra(s, 1); } }