linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Finn Thain <fthain@telegraphics.com.au>
To: "David S. Miller" <davem@davemloft.net>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Chris Zankel <chris@zankel.net>,
	Laurent Vivier <laurent@vivier.eu>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Eric Dumazet <eric.dumazet@gmail.com>,
	Stephen Hemminger <stephen@networkplumber.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH net v3 10/12] net/sonic: Fix command register usage
Date: Thu, 23 Jan 2020 09:07:26 +1100	[thread overview]
Message-ID: <071a456ba88517a7d02b1eab29469efde6e55849.1579730846.git.fthain@telegraphics.com.au> (raw)
In-Reply-To: <cover.1579730846.git.fthain@telegraphics.com.au>

There are several issues relating to command register usage during
chip initialization.

Firstly, the SONIC sometimes comes out of software reset with the
Start Timer bit set. This gets logged as,

    macsonic macsonic eth0: sonic_init: status=24, i=101

Avoid this by giving the Stop Timer command earlier than later.

Secondly, the loop that waits for the Read RRA command to complete has
the break condition inverted. That's why the for loop iterates until
its termination condition. Call the helper for this instead.

Finally, give the Receiver Enable command after clearing interrupts,
not before, to avoid the possibility of losing an interrupt.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Tested-by: Stan Johnson <userm57@yahoo.com>
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
---
 drivers/net/ethernet/natsemi/sonic.c | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/natsemi/sonic.c b/drivers/net/ethernet/natsemi/sonic.c
index 42a6b87d8886..914cec2ccc28 100644
--- a/drivers/net/ethernet/natsemi/sonic.c
+++ b/drivers/net/ethernet/natsemi/sonic.c
@@ -664,7 +664,6 @@ static void sonic_multicast_list(struct net_device *dev)
  */
 static int sonic_init(struct net_device *dev)
 {
-	unsigned int cmd;
 	struct sonic_local *lp = netdev_priv(dev);
 	int i;
 
@@ -681,7 +680,7 @@ static int sonic_init(struct net_device *dev)
 	 * enable interrupts, then completely initialize the SONIC
 	 */
 	SONIC_WRITE(SONIC_CMD, 0);
-	SONIC_WRITE(SONIC_CMD, SONIC_CR_RXDIS);
+	SONIC_WRITE(SONIC_CMD, SONIC_CR_RXDIS | SONIC_CR_STP);
 	sonic_quiesce(dev, SONIC_CR_ALL);
 
 	/*
@@ -711,14 +710,7 @@ static int sonic_init(struct net_device *dev)
 	netif_dbg(lp, ifup, dev, "%s: issuing RRRA command\n", __func__);
 
 	SONIC_WRITE(SONIC_CMD, SONIC_CR_RRRA);
-	i = 0;
-	while (i++ < 100) {
-		if (SONIC_READ(SONIC_CMD) & SONIC_CR_RRRA)
-			break;
-	}
-
-	netif_dbg(lp, ifup, dev, "%s: status=%x, i=%d\n", __func__,
-		  SONIC_READ(SONIC_CMD), i);
+	sonic_quiesce(dev, SONIC_CR_RRRA);
 
 	/*
 	 * Initialize the receive descriptors so that they
@@ -806,15 +798,11 @@ static int sonic_init(struct net_device *dev)
 	 * enable receiver, disable loopback
 	 * and enable all interrupts
 	 */
-	SONIC_WRITE(SONIC_CMD, SONIC_CR_RXEN | SONIC_CR_STP);
 	SONIC_WRITE(SONIC_RCR, SONIC_RCR_DEFAULT);
 	SONIC_WRITE(SONIC_TCR, SONIC_TCR_DEFAULT);
 	SONIC_WRITE(SONIC_ISR, 0x7fff);
 	SONIC_WRITE(SONIC_IMR, SONIC_IMR_DEFAULT);
-
-	cmd = SONIC_READ(SONIC_CMD);
-	if ((cmd & SONIC_CR_RXEN) == 0 || (cmd & SONIC_CR_STP) == 0)
-		printk(KERN_ERR "sonic_init: failed, status=%x\n", cmd);
+	SONIC_WRITE(SONIC_CMD, SONIC_CR_RXEN);
 
 	netif_dbg(lp, ifup, dev, "%s: new status=%x\n", __func__,
 		  SONIC_READ(SONIC_CMD));
-- 
2.24.1


  reply	other threads:[~2020-01-22 22:24 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-22 22:07 [PATCH net v3 00/12] Fixes for SONIC ethernet driver Finn Thain
2020-01-22 22:07 ` Finn Thain [this message]
2020-01-22 22:07 ` [PATCH net v3 04/12] net/sonic: Fix interface error stats collection Finn Thain
2020-01-22 22:07 ` [PATCH net v3 08/12] net/sonic: Fix receive buffer replenishment Finn Thain
2020-01-22 22:07 ` [PATCH net v3 02/12] net/sonic: Clear interrupt flags immediately Finn Thain
2020-01-22 22:07 ` [PATCH net v3 06/12] net/sonic: Avoid needless receive descriptor EOL flag updates Finn Thain
2020-01-22 22:07 ` [PATCH net v3 03/12] net/sonic: Use MMIO accessors Finn Thain
2020-01-22 22:07 ` [PATCH net v3 11/12] net/sonic: Fix CAM initialization Finn Thain
2020-01-22 22:07 ` [PATCH net v3 12/12] net/sonic: Prevent tx watchdog timeout Finn Thain
2020-01-22 22:07 ` [PATCH net v3 09/12] net/sonic: Quiesce SONIC before re-initializing descriptor memory Finn Thain
2020-01-22 22:07 ` [PATCH net v3 07/12] net/sonic: Improve receive descriptor status flag check Finn Thain
2020-01-22 22:07 ` [PATCH net v3 01/12] net/sonic: Add mutual exclusion for accessing shared state Finn Thain
2020-01-22 22:07 ` [PATCH net v3 05/12] net/sonic: Fix receive buffer handling Finn Thain
2020-01-23 20:24 ` [PATCH net v3 00/12] Fixes for SONIC ethernet driver David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=071a456ba88517a7d02b1eab29469efde6e55849.1579730846.git.fthain@telegraphics.com.au \
    --to=fthain@telegraphics.com.au \
    --cc=chris@zankel.net \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=geert@linux-m68k.org \
    --cc=laurent@vivier.eu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    --cc=tsbogend@alpha.franken.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).