From patchwork Sun May 15 18:07:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Francois Romieu X-Patchwork-Id: 9096751 Return-Path: X-Original-To: patchwork-linux-rockchip@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 46F0EBF29F for ; Sun, 15 May 2016 18:08:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3784820220 for ; Sun, 15 May 2016 18:08:07 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id DB0B720218 for ; Sun, 15 May 2016 18:08:05 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1b20SR-0003Yo-1k; Sun, 15 May 2016 18:08:03 +0000 Received: from violet.fr.zoreil.com ([2001:4b98:dc0:41:216:3eff:fe56:8398]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1b20SO-0003XB-UM for linux-rockchip@lists.infradead.org; Sun, 15 May 2016 18:08:01 +0000 Received: from violet.fr.zoreil.com (localhost [127.0.0.1]) by violet.fr.zoreil.com (8.14.9/8.14.5) with ESMTP id u4FI7YHb023272; Sun, 15 May 2016 20:07:34 +0200 Received: (from romieu@localhost) by violet.fr.zoreil.com (8.14.9/8.14.5/Submit) id u4FI7Ys0023271; Sun, 15 May 2016 20:07:34 +0200 Date: Sun, 15 May 2016 20:07:34 +0200 From: Francois Romieu To: Shuyu Wei Subject: Re: [PATCH] ethernet:arc: Fix racing of TX ring buffer Message-ID: <20160515180734.GA23253@electric-eye.fr.zoreil.com> References: <20160514161602.GA3347@debian-dorm> <20160514200356.GA14105@electric-eye.fr.zoreil.com> <20160514231044.GA2968@debian-dorm> <20160515091953.GA19983@electric-eye.fr.zoreil.com> <20160515123829.GA2831@debian-dorm> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160515123829.GA2831@debian-dorm> X-Organisation: Land of Sunshine Inc. User-Agent: Mutt/1.5.23 (2014-03-12) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160515_110801_285094_034E2A34 X-CRM114-Status: UNSURE ( 9.00 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -3.3 (---) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-rockchip@lists.infradead.org, netdev@vger.kernel.org, heiko@sntech.de, davem@davemloft.net, wxt@rock-chips.com Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Shuyu Wei : [...] > I still have a question, is it possible that tx_clean() run > between priv->tx_buff[*txbd_curr].skb = skb and dma_wmb()? A (previous) run can take place after priv->tx_buff[*txbd_curr].skb and before *info = cpu_to_le32(FOR_EMAC | FIRST_OR_LAST_MASK | len). So, yes, the driver must check in arc_emac_tx_clean() that 1) either txbd_dirty != txbd_curr or 2) "info" is not consistent with a still-not-used status word. Please be patient with me and get rid of the useless "i" diff --git a/drivers/net/ethernet/arc/emac_main.c b/drivers/net/ethernet/arc/emac_main.c index a3a9392..337ea3b 100644 --- a/drivers/net/ethernet/arc/emac_main.c +++ b/drivers/net/ethernet/arc/emac_main.c @@ -153,9 +153,8 @@ static void arc_emac_tx_clean(struct net_device *ndev) { struct arc_emac_priv *priv = netdev_priv(ndev); struct net_device_stats *stats = &ndev->stats; - unsigned int i; - for (i = 0; i < TX_BD_NUM; i++) { + while (priv->txbd_dirty != priv->txbd_curr) { unsigned int *txbd_dirty = &priv->txbd_dirty; struct arc_emac_bd *txbd = &priv->txbd[*txbd_dirty]; struct buffer_state *tx_buff = &priv->tx_buff[*txbd_dirty];