From patchwork Mon Nov 28 13:40:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyrille Pitchen X-Patchwork-Id: 9449547 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 05B97600CB for ; Mon, 28 Nov 2016 13:43:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFAF826E64 for ; Mon, 28 Nov 2016 13:43:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D493E27C05; Mon, 28 Nov 2016 13:43:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6BA3126E64 for ; Mon, 28 Nov 2016 13:43:13 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cBMBe-0008AO-Co; Mon, 28 Nov 2016 13:41:38 +0000 Received: from smtpout.microchip.com ([198.175.253.82] helo=email.microchip.com) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cBMBa-000861-Rb for linux-arm-kernel@lists.infradead.org; Mon, 28 Nov 2016 13:41:35 +0000 Received: from tenerife.corp.atmel.com (10.10.76.4) by chn-sv-exch05.mchp-main.com (10.10.76.106) with Microsoft SMTP Server id 14.3.181.6; Mon, 28 Nov 2016 06:41:12 -0700 From: Cyrille Pitchen To: , , , Subject: [PATCH net v2 1/1] net: macb: fix the RX queue reset in macb_rx() Date: Mon, 28 Nov 2016 14:40:55 +0100 Message-ID: <80ebb550eb6155e3b882cab1fb8d78a7385f8227.1480339901.git.cyrille.pitchen@atmel.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAC+NgFprPrMTGxcLF5cOi+9PYJsLg2ORjS1ktpk1/x2zx4H0ni8WBfn6Lr03GFvc+bWO06JiyismBLYAhijUzLym/IoE1Y9Ph0ILZAhWv185nbWDcwtvFyMUhJLCeUeLCs3/sXYycHGwChhJvHxxlBbFFBLIkXtx9zAZiMwvMZJTYvcMExBYW8JLYdOEPM4jNIqAqceYCRC+vQLzE8u6fjCC2hICcxM1zncwQcUGJkzOfsEDMkZA4+OIFWFxIQE1iYcsKZoj6QIlPGzaxQthOEjuXT2WBsO0kDk+/yA5hO0gs/T2HHaamfekbqHptie2v9kHZOhLbDvZD9dpK7JkxkQnCdpd48Gg5lO0rMethA1RNlMTbeadYJjCKzUJy6iwkpy5gZFrFKO3s4acbHKbrGuHsYWCql5ucUaCbm5iZp5ecn7uJERIjWTsYeyf5SzUwStXoTq+2cZwq8FV48Vpz3Rfrs5d9LJwSH51+8VQPi2lG6WZ5k96lBSG1R1g2nrilU7Pgtpj7p7dtHm47Ppl57NjHKJOT+HmD/+3JpYzKh4w+7bkyedef+8x9V2cyJL5J1vSST93D3yco/LDvUMQrrr5lqXeqQ3QP8c+rVEx9ZGAuuSphhuojJZbijERDLeai4kQAm8ZcmjICAAA= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161128_054135_010268_E0F7D74B X-CRM114-Status: UNSURE ( 9.87 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrei.Pistirica@microchip.com, Cyrille Pitchen , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On macb only (not gem), when a RX queue corruption was detected from macb_rx(), the RX queue was reset: during this process the RX ring buffer descriptor was initialized by macb_init_rx_ring() but we forgot to also set bp->rx_tail to 0. Indeed, when processing the received frames, bp->rx_tail provides the macb driver with the index in the RX ring buffer of the next buffer to process. So when the whole ring buffer is reset we must also reset bp->rx_tail so the driver is synchronized again with the hardware. Since macb_init_rx_ring() is called from many locations, currently from macb_rx() and macb_init_rings(), we'd rather add the "bp->rx_tail = 0;" line inside macb_init_rx_ring() than add the very same line after each call of this function. Without this fix, the rx queue is not reset properly to recover from queue corruption and connection drop may occur. Signed-off-by: Cyrille Pitchen Fixes: 9ba723b081a2 ("net: macb: remove BUG_ON() and reset the queue to handle RX errors") Acked-by: Nicolas Ferre --- ChangeLog: v1 -> v2: - rebase on net/master (v1 was based on net-next/master) - add "Acked-by:" tag from Nicolas Ferre. drivers/net/ethernet/cadence/macb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c index 533653bd7aec..3ede59c9cae0 100644 --- a/drivers/net/ethernet/cadence/macb.c +++ b/drivers/net/ethernet/cadence/macb.c @@ -975,6 +975,7 @@ static inline void macb_init_rx_ring(struct macb *bp) addr += bp->rx_buffer_size; } bp->rx_ring[RX_RING_SIZE - 1].addr |= MACB_BIT(RX_WRAP); + bp->rx_tail = 0; } static int macb_rx(struct macb *bp, int budget) @@ -1616,8 +1617,6 @@ static void macb_init_rings(struct macb *bp) bp->queues[0].tx_head = 0; bp->queues[0].tx_tail = 0; bp->queues[0].tx_ring[TX_RING_SIZE - 1].ctrl |= MACB_BIT(TX_WRAP); - - bp->rx_tail = 0; } static void macb_reset_hw(struct macb *bp)