From patchwork Sat May 21 16:09:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuyu Wei X-Patchwork-Id: 9130609 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 674A660762 for ; Sat, 21 May 2016 16:09:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5AAB42807E for ; Sat, 21 May 2016 16:09:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4D00128114; Sat, 21 May 2016 16:09:47 +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.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID 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 D48322807E for ; Sat, 21 May 2016 16:09:46 +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 1b49TC-0006AD-Fp; Sat, 21 May 2016 16:09:42 +0000 Received: from mail-qk0-x242.google.com ([2607:f8b0:400d:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1b49TA-00068k-Gl for linux-rockchip@lists.infradead.org; Sat, 21 May 2016 16:09:41 +0000 Received: by mail-qk0-x242.google.com with SMTP id n62so12435756qkc.2 for ; Sat, 21 May 2016 09:09:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=6FYdcj0a9Ts/SEZ60rgEMqR5T4nryh68N0bJ26qdTDY=; b=0X2HpOY9x+BJey2YwzJe9eHjOIYq6+u/O4WgYKpHFpSkCH2/vfNy3vP8rV0GWQd9er LYeqdf1lH4hpZ2S7+aKgHybAmU1aqK584rFDu9LbDyi4/aqDYzVIKj++QCy03pRYcKYN PYlDiGPddbOdM4SODrk5arkVBm7c/1ngIUCEzPUxPcXL1dLP60lcOL/HhmegfcrgexpE 2tywrykTHNq8QeBgtdqxry/DWwttIXUnSOTxcQ1EaYimOkXi8oMJ9fs5KgcBhZ4q3VGm 3MkE1rrFrnts+sUMCE56mclKmftU1pJGNrY2BsuOexaN2qh1ZdZ0cB0TqN43qyCfEKuv jekA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=6FYdcj0a9Ts/SEZ60rgEMqR5T4nryh68N0bJ26qdTDY=; b=murNLKUjLrvunoQl90sGxUshXq+d12rgXioRCqhf6UsQ9jWsJxA13YuVGfBIQwZHPt HQ0W0SMA7xrGGZZSzqEtL65rGt7hRprCUXQdxonj1GuVWK5yaupkccKLgh3m6CPzWwre prKN0HCXn8M74ajN4hE3qZ7Nx/Qigugkj3OI/imxpSUwqIhxaAKXKq3we9B9tDKhqa4X okRQeAbFRp66yWXL2ndfHM7rCo3nVY15fJNSTHrkezvM3J4+trX5FV9CqMsO2jtNVJp6 iwgF0mhN1rWYmLed9gih37EkxfSdFSiWuFYLk2cl7zKqJzEXVjL4mI7fI3R7CMmUlZ7T gyxQ== X-Gm-Message-State: AOPr4FXLQoVETy9GvpuQcQSnTvkTBmDiMouXs3HW7aGjXKGB8zfhisN3q6CBj8qjJxdNMQ== X-Received: by 10.200.55.47 with SMTP id o44mr4555577qtb.61.1463846958904; Sat, 21 May 2016 09:09:18 -0700 (PDT) Received: from debian-dorm ([159.203.126.36]) by smtp.gmail.com with ESMTPSA id x127sm10655333qhe.5.2016.05.21.09.09.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 21 May 2016 09:09:18 -0700 (PDT) Date: Sun, 22 May 2016 00:09:10 +0800 From: Shuyu Wei To: Francois Romieu Subject: Re: [PATCH v2] ethernet:arc: Fix racing of TX ring buffer Message-ID: <20160521160910.GA14945@debian-dorm> References: <20160517152520.GA2750@debian-dorm> <20160517.142456.2247845107325931733.davem@davemloft.net> <20160518000153.GA21757@electric-eye.fr.zoreil.com> <573CD09D.1060307@gmx.de> <20160518225529.GA18671@electric-eye.fr.zoreil.com> <573E2D0C.604@gmx.de> <20160520003145.GA22420@electric-eye.fr.zoreil.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160520003145.GA22420@electric-eye.fr.zoreil.com> User-Agent: Mutt/1.6.0 (2016-04-01) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160521_090940_627676_7CE2850C X-CRM114-Status: GOOD ( 12.55 ) 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: heiko@sntech.de, netdev@vger.kernel.org, linux-rockchip@lists.infradead.org, Lino Sanfilippo , David Miller , wxt@rock-chips.com Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Looks like I got it wrong in the first place. priv->tx_buff is not for the device, so there's no need to move it. The race has been fixed by commit c278c253f3d9, I forgot to check it out. That's my fault. I do find another problem. We need to use a barrier to make sure skb_tx_timestamp() is called before setting the FOR_EMAC flag. According to the comment(include/linux/skbuff.h): >/** > * skb_tx_timestamp() - Driver hook for transmit timestamping > * > * Ethernet MAC Drivers should call this function in their hard_xmit() > * function immediately before giving the sk_buff to the MAC hardware. > * > * Specifically, one should make absolutely sure that this function is > * called before TX completion of this packet can trigger. Otherwise > * the packet could potentially already be freed. > * > * @skb: A socket buffer. > */ diff --git a/drivers/net/ethernet/arc/emac_main.c b/drivers/net/ethernet/arc/emac_main.c index a3a9392..c2447b0 100644 --- a/drivers/net/ethernet/arc/emac_main.c +++ b/drivers/net/ethernet/arc/emac_main.c @@ -686,6 +686,9 @@ static int arc_emac_tx(struct sk_buff *skb, struct net_device *ndev) skb_tx_timestamp(skb); + /* Make sure timestamp is set */ + smp_wmb(); + *info = cpu_to_le32(FOR_EMAC | FIRST_OR_LAST_MASK | len); /* Make sure info word is set */