Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1951309ybl; Sun, 19 Jan 2020 15:18:48 -0800 (PST) X-Google-Smtp-Source: APXvYqzgwwCT4JFat4e8emRhX60esp/kcRI86wf2eP3N7fveaRel3Cle+V9S3raFImtbhwrPtGF7 X-Received: by 2002:aca:c509:: with SMTP id v9mr10620069oif.151.1579475927869; Sun, 19 Jan 2020 15:18:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579475927; cv=none; d=google.com; s=arc-20160816; b=YUfD6jg0mdBtAJKoly5aq0Ah+mUne+R95r3S3zWvxaOBUhZksaO4nLg8o0+cOqWAP9 6YZASuxA8/dsmfAx9NPW1qlQizfjzJ0Ajvm5JXoLxye8sFf6qY8xjJ5bI+leRBHnBcSc ShZKXCKIOM6wivuNXtaGcKpwPMV1ULfgYiZvFSfSjCnaEjrcYoLkLWuv3DdXcPNRxlv6 E5L3nbOndxrArcSdyJp4TAD/nCcVSvnmD/jXBwBGLAvyNHC5I+ZoIz2zsAc9zfQY54lp 0mdtDWXyO2+hBnssyX3lk14B6tsDbGlkiCXQlox4uCMRUuxxMlUO23uGtBZERarADrMn GprQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:from:references:in-reply-to :message-id:cc:to; bh=RkAg1E5Ijxsk3aQnzKD2f57+k5yJEMgk6B8HsNLIZAw=; b=x3K5PeoYnrkYV+RQUCAXk3g1j31kHfuDdyxvxC8vok3/HNyxohuQatBuKIKC9UJb/T 7TEji3FiGO+FoHu6VXIbzlx403Sy6+Yu7FMFMxGUYx3xLvREqpqrnD93Q1KfhG6uri4X gyUvE9kThuIZcaY6+RDCRMPBkekbhU12FIiWx4FTUQ2oreoq6fsr5rx46HO+wJmPSAO0 1sg2eeGzQMssRN9Al18NdjpN0EeoFAmW6u2HI2NFwf4dfjdzqWu8QYbYoKdhcWdM4D7M 3EsjAp1ZKICdcyxJ1JG/3xNobppwKATy6RG7QHsUqoJknfIjphhElSGlxOTdLu+BkU8p j1Ew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j9si17429898oii.195.2020.01.19.15.18.36; Sun, 19 Jan 2020 15:18:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729370AbgASXRX (ORCPT + 99 others); Sun, 19 Jan 2020 18:17:23 -0500 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:49836 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729058AbgASXQd (ORCPT ); Sun, 19 Jan 2020 18:16:33 -0500 Received: by kvm5.telegraphics.com.au (Postfix, from userid 502) id 9464C299A6; Sun, 19 Jan 2020 18:16:31 -0500 (EST) To: "David S. Miller" Cc: Thomas Bogendoerfer , Chris Zankel , Laurent Vivier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Message-Id: <076fb31c15434eca5d73ed81bbee447e50646c18.1579474569.git.fthain@telegraphics.com.au> In-Reply-To: References: From: Finn Thain Subject: [PATCH net 17/19] net/sonic: Fix command register usage Date: Mon, 20 Jan 2020 09:56:09 +1100 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: Finn Thain --- 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 b70470ce9c9c..01055a53517d 100644 --- a/drivers/net/ethernet/natsemi/sonic.c +++ b/drivers/net/ethernet/natsemi/sonic.c @@ -691,7 +691,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; @@ -708,7 +707,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); /* @@ -738,14 +737,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 @@ -833,15 +825,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