From nobody Tue Feb 10 23:59:06 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528488718029810.307242547434; Fri, 8 Jun 2018 13:11:58 -0700 (PDT) Received: from localhost ([::1]:37991 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRNjp-0003E7-9c for importer@patchew.org; Fri, 08 Jun 2018 16:11:57 -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=20Poussineau?= , Gerd Hoffmann , Paolo Bonzini , Yongbok Kim , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Aurelien Jarno , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 =3D=3D 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=C3=A9 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); } =20 -static void dp8393x_do_read_rra(dp8393xState *s) +static void dp8393x_do_read_rra(dp8393xState *s, int next) { int width, size; =20 @@ -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]); =20 - /* Go to next entry */ - s->regs[SONIC_RRP] +=3D size; + if (next) { + /* Go to next entry */ + s->regs[SONIC_RRP] +=3D size; =20 - /* Handle wrap */ - if (s->regs[SONIC_RRP] =3D=3D s->regs[SONIC_REA]) { - s->regs[SONIC_RRP] =3D s->regs[SONIC_RSA]; - } + /* Handle wrap */ + if (s->regs[SONIC_RRP] =3D=3D s->regs[SONIC_REA]) { + s->regs[SONIC_RRP] =3D s->regs[SONIC_RSA]; + } =20 - /* Check resource exhaustion */ - if (s->regs[SONIC_RRP] =3D=3D s->regs[SONIC_RWP]) - { - s->regs[SONIC_ISR] |=3D SONIC_ISR_RBE; - dp8393x_update_irq(s); + /* Check resource exhaustion */ + if (s->regs[SONIC_RRP] =3D=3D s->regs[SONIC_RWP]) { + s->regs[SONIC_ISR] |=3D SONIC_ISR_RBE; + dp8393x_update_irq(s); + } } =20 /* 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, ui= nt64_t data, data &=3D s->regs[reg]; s->regs[reg] &=3D ~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, cons= t uint8_t * buf, =20 if (s->regs[SONIC_RCR] & SONIC_RCR_LPKT) { /* Read next RRA */ - dp8393x_do_read_rra(s); + dp8393x_do_read_rra(s, 1); } } =20 --=20 2.14.4