Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3520901imu; Mon, 7 Jan 2019 05:02:12 -0800 (PST) X-Google-Smtp-Source: ALg8bN7uCnHa6k7EndrXip+BvH4QwAtAyOdCnmRmz3vhY8CAyEcq1g7/5FCkTXpfysN7PFB9Hrch X-Received: by 2002:a17:902:8b88:: with SMTP id ay8mr61931703plb.55.1546866132343; Mon, 07 Jan 2019 05:02:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546866132; cv=none; d=google.com; s=arc-20160816; b=EfxOzqjtZwOeKCvJ9BM6Ceyi0KozctKGoL9MhtNIanZ5f4tm5kIYm7NIezFgXsurlT Oh8zKGF9RrQBeTl50vBGHXKf8CSl8fNNijUA80deFHoeYtgFHAx08YFy+FJqV6XS+ZaT bXFOt/7kLKrdMmoTUbMcjTXVBPpWzC5QPqy1iI4wZCP3a6LEmO4nr4Z5EdFldjJAlIZE EaPub+Wa9VPtgTMEHLc/wctS8F5yd9DTE9iW3jIlPLDKp++aRoUTnChQqCOeP1THVvDJ 9cBQxXS7HFKBtFp9ghZXbcOIZ7PyK9jcH1krQDkjUmI53WxeLT4kRBK6vXIjKmztw8HZ dsNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ki0F1tFWTyVjjaMXC5utb0w6DRUpdEBda25wgQsctgM=; b=wHSwsCDctzj0tmHl+8ifjoKJuYnZki78OgCSCOMxI3ZYEkut8WLN75rToUqcUXCbNe sbO6/a3cFenqLEzzcYiTLwR3Gz2eskGUHOxu5YyJe+rPqgnA+Rld1+s1J7JAMKicakGQ HtVAMA45XT0QNuxRdUFO3C4nbxU/iC2ClPHYM1V7fygbWgm2m4ykCcELQNDbzDQ2SZup 4s2IeuNNnkY+ecd9VUjgUlLWhQ2S2nhvdhwMC+/bs3fDHLqed/e5lXrZAD9NoMrrCG7N 6duZiYbZ3QXAnTpq8MFP/ZS05w3CAW8WSmrjHNEq7OsS0nARiqNjwuAGpzhKW/egYVZb /0ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=X7oFaY3v; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c31si62478509pgc.465.2019.01.07.05.01.55; Mon, 07 Jan 2019 05:02:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=X7oFaY3v; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730371AbfAGNAB (ORCPT + 99 others); Mon, 7 Jan 2019 08:00:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:47508 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730361AbfAGM77 (ORCPT ); Mon, 7 Jan 2019 07:59:59 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DBDED21736; Mon, 7 Jan 2019 12:59:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546865998; bh=YfQlL0P6uuFcDsWoiE50D+RrF6eOqllvTwVP4TpBkOo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X7oFaY3vOJfMCy2YKa1fgQI+GDxKyZqGCgMXuf/9aOV73I/QVS/n2BU2UjcmgJJ3Z 3/qmiplYIYpkgHVfv+c/RnO1X1H8H3eZKcBJjvR9S8Q+/0SYY/hezokrHhXXUmVkum i3ajb7ckzib8cyOfXmUbQaoOiPpIcGGGtLnK0Ecg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Claudiu Beznea , Nicolas Ferre , "David S. Miller" Subject: [PATCH 4.14 013/101] net: macb: restart tx after tx used bit read Date: Mon, 7 Jan 2019 13:32:01 +0100 Message-Id: <20190107105331.885070977@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190107105330.372621917@linuxfoundation.org> References: <20190107105330.372621917@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Claudiu Beznea [ Upstream commit 4298388574dae6168fa8940b3edc7ba965e8a7ab ] On some platforms (currently detected only on SAMA5D4) TX might stuck even the pachets are still present in DMA memories and TX start was issued for them. This happens due to race condition between MACB driver updating next TX buffer descriptor to be used and IP reading the same descriptor. In such a case, the "TX USED BIT READ" interrupt is asserted. GEM/MACB user guide specifies that if a "TX USED BIT READ" interrupt is asserted TX must be restarted. Restart TX if used bit is read and packets are present in software TX queue. Packets are removed from software TX queue if TX was successful for them (see macb_tx_interrupt()). Signed-off-by: Claudiu Beznea Acked-by: Nicolas Ferre Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/cadence/macb_main.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -60,7 +60,8 @@ #define MACB_TX_ERR_FLAGS (MACB_BIT(ISR_TUND) \ | MACB_BIT(ISR_RLE) \ | MACB_BIT(TXERR)) -#define MACB_TX_INT_FLAGS (MACB_TX_ERR_FLAGS | MACB_BIT(TCOMP)) +#define MACB_TX_INT_FLAGS (MACB_TX_ERR_FLAGS | MACB_BIT(TCOMP) \ + | MACB_BIT(TXUBR)) /* Max length of transmit frame must be a multiple of 8 bytes */ #define MACB_TX_LEN_ALIGN 8 @@ -1243,6 +1244,21 @@ static int macb_poll(struct napi_struct return work_done; } +static void macb_tx_restart(struct macb_queue *queue) +{ + unsigned int head = queue->tx_head; + unsigned int tail = queue->tx_tail; + struct macb *bp = queue->bp; + + if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE) + queue_writel(queue, ISR, MACB_BIT(TXUBR)); + + if (head == tail) + return; + + macb_writel(bp, NCR, macb_readl(bp, NCR) | MACB_BIT(TSTART)); +} + static irqreturn_t macb_interrupt(int irq, void *dev_id) { struct macb_queue *queue = dev_id; @@ -1300,6 +1316,9 @@ static irqreturn_t macb_interrupt(int ir if (status & MACB_BIT(TCOMP)) macb_tx_interrupt(queue); + if (status & MACB_BIT(TXUBR)) + macb_tx_restart(queue); + /* Link change detection isn't possible with RMII, so we'll * add that if/when we get our hands on a full-blown MII PHY. */