From patchwork Thu Jan 28 21:25:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Troy Kisky X-Patchwork-Id: 8154511 Return-Path: X-Original-To: patchwork-linux-arm@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 284ECBEEE5 for ; Thu, 28 Jan 2016 21:56:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 599C52021B for ; Thu, 28 Jan 2016 21:56:52 +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 7474020218 for ; Thu, 28 Jan 2016 21:56:51 +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 1aOuXG-0000R3-4y; Thu, 28 Jan 2016 21:55:26 +0000 Received: from mail-pf0-x22c.google.com ([2607:f8b0:400e:c00::22c]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aOu81-00066E-Gt for linux-arm-kernel@lists.infradead.org; Thu, 28 Jan 2016 21:29:22 +0000 Received: by mail-pf0-x22c.google.com with SMTP id x125so29979413pfb.0 for ; Thu, 28 Jan 2016 13:29:01 -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=dvZ6Gi6Koa/rfE+48nH2U2lTmGoHzB7nUrhsJqfCRHM=; b=DBjiW75Q2i/k6ObSF180p3OMQR5TPHrQCytjwLkuZyino6XhjA53XDlSxts+5d37PK +KpP80TAzQ5Uso2sD+KmaGwW5jEOi9HpzVqKaSytoa3kpGPWniY3HpUzgHdpKAFY3n6R zysgvCriL0jCZTwx/f27pf85vstymNGA0cuhQam6WD3nojS9oiQVmW+CVvD0TR7W+6tm ydBvHourQibEyRjDmw7btfjXWJXP54dW//BMTxdu7XMkkgBOk0NMoLR4nSZ3VrU3LbSq tbkIV+fE78WW/uPqbk1qKh3T6gb/nmHrnPRn0Oz1YzxKKt5ouRO/yEmox39jGYq+jZ+A 0Uvw== 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=dvZ6Gi6Koa/rfE+48nH2U2lTmGoHzB7nUrhsJqfCRHM=; b=iPup9At3YFSxfFQWKBrnZpi9IJ02fSz6CP7WIb6T0JND7Md0hGvkRuPhvyFkxWZfZE tnmo38Hb2DAyizA+JiEnNwvEF+ON8kyHkKxx+OIz0X0h0Pvabo08gH84Jxg4qpQF8nWD lD7t1cI7PDPKCBEYmjMtSeLzCAKqOipJv3jhMS9kJljio5WUc43SNPEhzzM2EuNqpscR wZ5v0RkdC7kikFC+CPqVJ01COCmH5nbzIMZ6xfYl4LKYMCAtCN1fIK3WHFm6UG5SDSc+ uomy+pzFUs7F1oKJO55TQGIvr9qpyGmm9EEz1094H8k1/qML31oNqsVwsl4XkGqxMGnf VClA== X-Gm-Message-State: AG10YOSreHGUsF7ORkEu/iSYwQqupMXfWKEwHC9rJkxoPNNuOYcaxKfNu0eu5WxYR2aFzw== X-Received: by 10.98.42.10 with SMTP id q10mr7987221pfq.73.1454016540762; Thu, 28 Jan 2016 13:29:00 -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 c90sm18583190pfd.31.2016.01.28.13.28.59 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 28 Jan 2016 13:29:00 -0800 (PST) From: Troy Kisky To: netdev@vger.kernel.org, davem@davemloft.net, B38611@freescale.com Subject: [PATCH net-next 31/40] net: fec: don't transfer ownership until entire tso is queued Date: Thu, 28 Jan 2016 14:25:55 -0700 Message-Id: <1454016364-30985-32-git-send-email-troy.kisky@boundarydevices.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1454016364-30985-1-git-send-email-troy.kisky@boundarydevices.com> References: <1454016364-30985-1-git-send-email-troy.kisky@boundarydevices.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160128_132921_668098_7F402D44 X-CRM114-Status: GOOD ( 12.45 ) X-Spam-Score: -2.6 (--) 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, Troy Kisky , laci@boundarydevices.com, 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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,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 Otherwise, we cannot undo our work if an error condition arises later. Signed-off-by: Troy Kisky --- drivers/net/ethernet/freescale/fec_main.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index b829c29..ee6cd69 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -590,7 +590,8 @@ fec_enet_txq_put_data_tso(struct fec_enet_priv_tx_q *txq, struct sk_buff *skb, static int fec_enet_txq_put_hdr_tso(struct fec_enet_priv_tx_q *txq, struct sk_buff *skb, struct net_device *ndev, - struct bufdesc *bdp, int index) + struct bufdesc *bdp, int index, + unsigned short *pstatus) { struct fec_enet_private *fep = netdev_priv(ndev); int hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb); @@ -632,9 +633,7 @@ fec_enet_txq_put_hdr_tso(struct fec_enet_priv_tx_q *txq, ebdp->cbd_bdu = 0; ebdp->cbd_esc = estatus; } - - bdp->cbd_sc = status; - + *pstatus = status; return 0; } @@ -646,7 +645,10 @@ static int fec_enet_txq_submit_tso(struct fec_enet_priv_tx_q *txq, int hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb); int total_len, data_left; struct bufdesc *bdp = txq->bd.cur; + struct bufdesc *first_bdp = bdp; struct tso_t tso; + unsigned short status = 0; + unsigned short *pstatus = &status; unsigned int index = 0; int ret; @@ -676,7 +678,8 @@ static int fec_enet_txq_submit_tso(struct fec_enet_priv_tx_q *txq, /* prepare packet headers: MAC + IP + TCP */ hdr = txq->tso_hdrs + index * TSO_HEADER_SIZE; tso_build_hdr(skb, hdr, &tso, data_left, total_len == 0); - ret = fec_enet_txq_put_hdr_tso(txq, skb, ndev, bdp, index); + ret = fec_enet_txq_put_hdr_tso(txq, skb, ndev, bdp, index, + pstatus); if (ret) goto err_release; @@ -700,12 +703,23 @@ static int fec_enet_txq_submit_tso(struct fec_enet_priv_tx_q *txq, } bdp = fec_enet_get_nextdesc(bdp, &txq->bd); + pstatus = &bdp->cbd_sc; } /* Save skb pointer */ txq->tx_skbuff[index] = skb; - skb_tx_timestamp(skb); + /* 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, + */ + first_bdp->cbd_sc = status; + /* Make sure ownership is transferred before the + * update to txq->bd.cur. + */ + wmb(); txq->bd.cur = bdp; /* Trigger transmission start */