From patchwork Wed Apr 6 02:25:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Troy Kisky X-Patchwork-Id: 8757661 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 796CEC0553 for ; Wed, 6 Apr 2016 02:33:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8B84E202A1 for ; Wed, 6 Apr 2016 02:33:17 +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 91F9520295 for ; Wed, 6 Apr 2016 02:33:16 +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 1andFg-0002db-Py; Wed, 06 Apr 2016 02:31:28 +0000 Received: from mail-pf0-x229.google.com ([2607:f8b0:400e:c00::229]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1andD1-0007jQ-MJ for linux-arm-kernel@lists.infradead.org; Wed, 06 Apr 2016 02:28:45 +0000 Received: by mail-pf0-x229.google.com with SMTP id 184so23189503pff.0 for ; Tue, 05 Apr 2016 19:28:22 -0700 (PDT) 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=iP4Ylk9Ewpked6h+/UNpLf3CGynZmZFWeCfH7kmeyCY=; b=hYwXNuyiQ4+gXml5/2fPvu1y0T1KRT/vHpvfEhFVJdT+ol0HbTleKhIamfER32Rylh FwtJvxvKZbDoIIfH6oolSdEKDxF+Q+pcFhg1aE1Olre1UEtGx+YFjfrDVzjOYRTRYV6e 9fxoYKxMZQikuOLr48cwmIiuqXwCrWXNv9j24nUqKwe20dSdkAefN2veZqsXrMk+tdn7 /aci8xl4oYaHyXjt/dbQZ05E73JmejnbDjnLlhlSzxeVIGWrvUexU+34zEyX/SrL/M1z slVgYnFGZs38QuURPpatuT4GGzyb5SpHiMCbmyrCRPKRiL0NXUrYsF0gtB+zZRNTPMBL c/Ug== 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=iP4Ylk9Ewpked6h+/UNpLf3CGynZmZFWeCfH7kmeyCY=; b=lZ4jPULj6wi8RtDIPdO9sn5SLJjDn8dPtZG1ym7bVZZDm71Fp8vkSfMYt7z2y/2vOF 6arTAr9n8cK6S1FXjiV77TXWVpqj2vJQPoPti4wV7ojSpkYpp4M99tDGZQbL+QObHP5f /m4OCRu4Yb3ObxHtHwD4XUKcLDEXibYroKz6Z3ZbIhcRXblhDRKd7d0D1xgAit6fxMRM //aFbl0Cz5qZntGp6EAQ/aSyvMSIqUci2yVybUpTiz1lpemjDVZvuRG45QYoCpRBKdIW 5CjKra2C1GP91AncRbdMVKlg1Xq6zWcS8IaOoejK+FwHVV7qDeuTtA+YIVC2y7PW1Vo5 qwLA== X-Gm-Message-State: AD7BkJK+r2la9Ba9Dot43mJBCfv2Zq+6ZgVHkj3YH5O2SuRMONOspU9fBvEhznYprL+DWQ== X-Received: by 10.98.12.153 with SMTP id 25mr34390268pfm.27.1459909701985; Tue, 05 Apr 2016 19:28:21 -0700 (PDT) Received: from localhost.localdomain (wsip-70-184-93-199.ph.ph.cox.net. [70.184.93.199]) by smtp.googlemail.com with ESMTPSA id l14sm528682pfi.23.2016.04.05.19.28.20 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 05 Apr 2016 19:28:21 -0700 (PDT) From: Troy Kisky To: netdev@vger.kernel.org, davem@davemloft.net, fugang.duan@nxp.com, lznuaa@gmail.com Subject: [PATCH net-next V3 08/16] net: fec: set cbd_sc without relying on previous value Date: Tue, 5 Apr 2016 19:25:54 -0700 Message-Id: <1459909562-22865-9-git-send-email-troy.kisky@boundarydevices.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1459909562-22865-1-git-send-email-troy.kisky@boundarydevices.com> References: <1459909562-22865-1-git-send-email-troy.kisky@boundarydevices.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160405_192843_954416_DF6937B6 X-CRM114-Status: GOOD ( 15.06 ) 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: andrew@lunn.ch, stillcompiling@gmail.com, arnd@arndb.de, sergei.shtylyov@cogentembedded.com, Troy Kisky , gerg@uclinux.org, fabio.estevam@nxp.com, johannes@sipsolutions.net, l.stach@pengutronix.de, 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=-5.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 Relying on the wrap bit of cdb_sc to stay valid once initialized when the controller also writes to this byte seems undesirable since we can easily know what the value should be. Signed-off-by: Troy Kisky --- v3: change commit message --- drivers/net/ethernet/freescale/fec_main.c | 38 +++++++++---------------------- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 3cd0cdf..21d2cd0 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -340,9 +340,8 @@ fec_enet_txq_submit_frag_skb(struct fec_enet_priv_tx_q *txq, bdp = fec_enet_get_nextdesc(bdp, &txq->bd); ebdp = (struct bufdesc_ex *)bdp; - status = fec16_to_cpu(bdp->cbd_sc); - status &= ~BD_ENET_TX_STATS; - status |= (BD_ENET_TX_TC | BD_ENET_TX_READY); + status = BD_ENET_TX_TC | BD_ENET_TX_READY | + ((bdp == txq->bd.last) ? BD_SC_WRAP : 0); frag_len = skb_shinfo(skb)->frags[frag].size; /* Handle the last BD specially */ @@ -436,8 +435,6 @@ static int fec_enet_txq_submit_skb(struct fec_enet_priv_tx_q *txq, /* Fill in a Tx ring entry */ bdp = txq->bd.cur; last_bdp = bdp; - status = fec16_to_cpu(bdp->cbd_sc); - status &= ~BD_ENET_TX_STATS; /* Set buffer length and buffer pointer */ bufaddr = skb->data; @@ -462,6 +459,8 @@ static int fec_enet_txq_submit_skb(struct fec_enet_priv_tx_q *txq, return NETDEV_TX_OK; } + status = BD_ENET_TX_TC | BD_ENET_TX_READY | + ((bdp == txq->bd.last) ? BD_SC_WRAP : 0); if (nr_frags) { last_bdp = fec_enet_txq_submit_frag_skb(txq, skb, ndev); if (IS_ERR(last_bdp)) { @@ -512,7 +511,6 @@ static int fec_enet_txq_submit_skb(struct fec_enet_priv_tx_q *txq, /* 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. */ - status |= (BD_ENET_TX_READY | BD_ENET_TX_TC); bdp->cbd_sc = cpu_to_fec16(status); /* If this was the last BD in the ring, start at the beginning again. */ @@ -544,11 +542,6 @@ fec_enet_txq_put_data_tso(struct fec_enet_priv_tx_q *txq, struct sk_buff *skb, unsigned int estatus = 0; dma_addr_t addr; - status = fec16_to_cpu(bdp->cbd_sc); - status &= ~BD_ENET_TX_STATS; - - status |= (BD_ENET_TX_TC | BD_ENET_TX_READY); - if (((unsigned long) data) & fep->tx_align || fep->quirks & FEC_QUIRK_SWAP_FRAME) { memcpy(txq->tx_bounce[index], data, size); @@ -578,15 +571,16 @@ fec_enet_txq_put_data_tso(struct fec_enet_priv_tx_q *txq, struct sk_buff *skb, ebdp->cbd_esc = cpu_to_fec32(estatus); } + status = BD_ENET_TX_TC | BD_ENET_TX_READY | + ((bdp == txq->bd.last) ? BD_SC_WRAP : 0); /* Handle the last BD specially */ if (last_tcp) - status |= (BD_ENET_TX_LAST | BD_ENET_TX_TC); + status |= BD_ENET_TX_LAST; if (is_last) { status |= BD_ENET_TX_INTR; if (fep->bufdesc_ex) ebdp->cbd_esc |= cpu_to_fec32(BD_ENET_TX_INT); } - bdp->cbd_sc = cpu_to_fec16(status); return 0; @@ -602,13 +596,8 @@ fec_enet_txq_put_hdr_tso(struct fec_enet_priv_tx_q *txq, struct bufdesc_ex *ebdp = container_of(bdp, struct bufdesc_ex, desc); void *bufaddr; unsigned long dmabuf; - unsigned short status; unsigned int estatus = 0; - status = fec16_to_cpu(bdp->cbd_sc); - status &= ~BD_ENET_TX_STATS; - status |= (BD_ENET_TX_TC | BD_ENET_TX_READY); - bufaddr = txq->tso_hdrs + index * TSO_HEADER_SIZE; dmabuf = txq->tso_hdrs_dma + index * TSO_HEADER_SIZE; if (((unsigned long)bufaddr) & fep->tx_align || @@ -641,8 +630,8 @@ fec_enet_txq_put_hdr_tso(struct fec_enet_priv_tx_q *txq, ebdp->cbd_esc = cpu_to_fec32(estatus); } - bdp->cbd_sc = cpu_to_fec16(status); - + bdp->cbd_sc = cpu_to_fec16(BD_ENET_TX_TC | BD_ENET_TX_READY | + ((bdp == txq->bd.last) ? BD_SC_WRAP : 0)); return 0; } @@ -1454,12 +1443,6 @@ static int fec_rxq(struct net_device *ndev, struct fec_enet_priv_rx_q *rxq, } rx_processing_done: - /* Clear the status flags for this buffer */ - status &= ~BD_ENET_RX_STATS; - - /* Mark the buffer empty */ - status |= BD_ENET_RX_EMPTY; - if (fep->bufdesc_ex) { struct bufdesc_ex *ebdp = (struct bufdesc_ex *)bdp; @@ -1471,7 +1454,8 @@ rx_processing_done: * performed before transferring ownership. */ wmb(); - bdp->cbd_sc = cpu_to_fec16(status); + bdp->cbd_sc = cpu_to_fec16(BD_ENET_RX_EMPTY | + ((bdp == rxq->bd.last) ? BD_SC_WRAP : 0)); /* Update BD pointer to next entry */ bdp = fec_enet_get_nextdesc(bdp, &rxq->bd);