netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Michael Chan" <mchan@broadcom.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, "Michael Chan" <mchan@broadcom.com>
Subject: [PATCH net-next 1/6] bnx2: Prevent ethtool -s from crashing when device is down.
Date: Thu, 10 Jul 2008 18:29:10 -0700	[thread overview]
Message-ID: <1215739755-5495-1-git-send-email-mchan@broadcom.com> (raw)

The device may be in D3-hot state and may crash if we try to
configure the speed settings by accessing the registers.

Signed-off-by: Michael Chan <mchan@broadcom.com>
---
 drivers/net/bnx2.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index ad61cfd..e9cfb02 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -6215,6 +6215,12 @@ bnx2_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 	    !(bp->phy_flags & BNX2_PHY_FLAG_REMOTE_PHY_CAP))
 		goto err_out_unlock;
 
+	/* If device is down, we can store the settings only if the user
+	 * is setting the currently active port.
+	 */
+	if (!netif_running(dev) && cmd->port != bp->phy_port)
+		goto err_out_unlock;
+
 	if (cmd->autoneg == AUTONEG_ENABLE) {
 		autoneg |= AUTONEG_SPEED;
 
@@ -6272,7 +6278,12 @@ bnx2_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 	bp->req_line_speed = req_line_speed;
 	bp->req_duplex = req_duplex;
 
-	err = bnx2_setup_phy(bp, cmd->port);
+	err = 0;
+	/* If device is down, the new settings will be picked up when it is
+	 * brought up.
+	 */
+	if (netif_running(dev))
+		err = bnx2_setup_phy(bp, cmd->port);
 
 err_out_unlock:
 	spin_unlock_bh(&bp->phy_lock);
-- 
1.5.5.GIT



             reply	other threads:[~2008-07-11  1:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-11  1:29 Michael Chan [this message]
2008-07-11  1:29 ` [PATCH net-next 2/6] bnx2: Add PCI ID for 5716 Michael Chan
2008-07-15  5:37   ` David Miller
2008-07-11  1:29 ` [PATCH net-next 3/6] bnx2: Add ack parameter to bnx2_fw_sync() Michael Chan
2008-07-15  5:38   ` David Miller
2008-07-11  1:29 ` [PATCH net-next 4/6] bnx2: Allow flexible VLAN tag settings Michael Chan
2008-07-15  5:39   ` David Miller
2008-07-11  1:29 ` [PATCH net-next 5/6] bnx2: Support secondary MAC addresses Michael Chan
2008-07-15  5:39   ` David Miller
2008-07-11  1:29 ` [PATCH net-next 6/6] bnx2: Update version to 1.7.8 Michael Chan
2008-07-15  5:40   ` David Miller
2008-07-15  5:37 ` [PATCH net-next 1/6] bnx2: Prevent ethtool -s from crashing when device is down 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=1215739755-5495-1-git-send-email-mchan@broadcom.com \
    --to=mchan@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /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).