From patchwork Fri Feb 5 21:52:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Troy Kisky X-Patchwork-Id: 8239941 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 65F249F37A for ; Fri, 5 Feb 2016 21:59:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8BD1D203B8 for ; Fri, 5 Feb 2016 21:59:28 +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 98BFA203B4 for ; Fri, 5 Feb 2016 21:59:27 +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 1aRoO4-0006ZR-F9; Fri, 05 Feb 2016 21:57:56 +0000 Received: from mail-pa0-x229.google.com ([2607:f8b0:400e:c03::229]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aRoLn-0004MH-Do for linux-arm-kernel@lists.infradead.org; Fri, 05 Feb 2016 21:55:38 +0000 Received: by mail-pa0-x229.google.com with SMTP id ho8so40383707pac.2 for ; Fri, 05 Feb 2016 13:55:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=boundarydevices-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0Qx3n+jK9/CmIs1a4qO1ukOinVQ1JnJsdM16xHC+w5E=; b=T78iOwOfHtH0yvHpRdhRghEBDgocrdwBCxDOblYILJcodfxm4YBffqwXDQx7VTgDaF NbjRmAUdLso/a1D0vcXBxEPH41rqxo+/9K2CkLlFsY2+thXCa6Dm74wVRJqnDId1fPJO 60eDs5LmB524WqaXXQB25cPKsj2/5z2+ffB4gKs1eeJsByolBftK+3Z92s0eZy3SqJlV AK+lP9EtvjNiIAX/DmJS72iSe16PZnW9B9FbtvBahn5px9mISS1faEvY+0gZuAJUQ2Fz q3k/eiMUxiO3Te1OWRJxg5NPmn42j15PM+7h/CSBjkK7ym4CALrDluM2CqgOVieGLaJ9 m8bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0Qx3n+jK9/CmIs1a4qO1ukOinVQ1JnJsdM16xHC+w5E=; b=izd8tG02WGVwLiqyTCjvn7t6IJq/fasq6g/DAayS0aFr03GP8IDh6fQ3n/6xRptLLd uuBUDR9Y9YULm0MaadAifj+ar2UgmPziVvDyALoDx9Fy1cdvYkOyWLXjnUZtr3FfCIx5 Wv8xvjt0pPuKRUJLNO29S8fGrM82kG0FCI/kBb9CmOv2BpKmKCzl85Y01IY76JVL0aDn SlP58bXC5DGJc3b8I4eOR6DroR51wyqlETtmA9wUCIcnJiYlH9U9NEUf4CWGRvHOGunX mGHvVuTNCfbz26h28MhY4Cf862nBLPCZxfwSytQt5jt0Wz1+LOAesi4AeJXKAoIpvOvp mvYA== X-Gm-Message-State: AG10YOSuCsfn21Fb4RNvQ/UTonGp4wvnupJY5pEcRp83r1qA1teCZWtp8nXvAWeZhxcXfQ== X-Received: by 10.66.187.145 with SMTP id fs17mr23205907pac.81.1454709316442; Fri, 05 Feb 2016 13:55:16 -0800 (PST) Received: from localhost.localdomain (wsip-70-184-93-199.ph.ph.cox.net. [70.184.93.199]) by smtp.googlemail.com with ESMTPSA id v75sm26628688pfa.39.2016.02.05.13.55.14 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 05 Feb 2016 13:55:15 -0800 (PST) From: Troy Kisky To: netdev@vger.kernel.org, davem@davemloft.net, B38611@freescale.com Subject: [PATCH net-next V2 7/8] net: fec: don't transfer ownership until descriptor write is complete Date: Fri, 5 Feb 2016 14:52:49 -0700 Message-Id: <1454709170-19527-8-git-send-email-troy.kisky@boundarydevices.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1454709170-19527-1-git-send-email-troy.kisky@boundarydevices.com> References: <1454709170-19527-1-git-send-email-troy.kisky@boundarydevices.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160205_135535_818102_E42A3FCF X-CRM114-Status: GOOD ( 11.90 ) X-Spam-Score: -1.9 (-) 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: fabio.estevam@freescale.com, andrew@lunn.ch, linux@arm.linux.org.uk, arnd@arndb.de, Troy Kisky , laci@boundarydevices.com, johannes@sipsolutions.net, l.stach@pengutronix.de, shawnguo@kernel.org, linux-arm-kernel@lists.infradead.org, tremyfr@gmail.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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 If you don't own it, you shouldn't write to it. Signed-off-by: Troy Kisky --- drivers/net/ethernet/freescale/fec_main.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index ca2708d..97ca72a 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -390,6 +390,10 @@ fec_enet_txq_submit_frag_skb(struct fec_enet_priv_tx_q *txq, bdp->cbd_bufaddr = cpu_to_fec32(addr); bdp->cbd_datlen = cpu_to_fec16(frag_len); + /* Make sure the updates to rest of the descriptor are + * performed before transferring ownership. + */ + wmb(); bdp->cbd_sc = cpu_to_fec16(status); } @@ -499,6 +503,10 @@ static int fec_enet_txq_submit_skb(struct fec_enet_priv_tx_q *txq, bdp->cbd_datlen = cpu_to_fec16(buflen); bdp->cbd_bufaddr = cpu_to_fec32(addr); + /* Make sure the updates to rest of the descriptor are performed before + * transferring ownership. + */ + wmb(); /* Send it on its way. Tell FEC it's ready, interrupt when done, * it's the last BD of the frame, and to put the CRC on the end. @@ -1475,7 +1483,6 @@ rx_processing_done: /* Mark the buffer empty */ status |= BD_ENET_RX_EMPTY; - bdp->cbd_sc = cpu_to_fec16(status); if (fep->bufdesc_ex) { struct bufdesc_ex *ebdp = (struct bufdesc_ex *)bdp; @@ -1484,6 +1491,11 @@ rx_processing_done: ebdp->cbd_prot = 0; ebdp->cbd_bdu = 0; } + /* Make sure the updates to rest of the descriptor are + * performed before transferring ownership. + */ + wmb(); + bdp->cbd_sc = cpu_to_fec16(status); /* Update BD pointer to next entry */ bdp = fec_enet_get_nextdesc(bdp, &rxq->bd);