Netdev List
 help / color / mirror / Atom feed
From: Ben Hutchings <bhutchings@solarflare.com>
To: <jiang.biao2@zte.com.cn>
Cc: David Miller <davem@davemloft.net>, <li.fengmao@zte.com.cn>,
	<manish.chopra@qlogic.com>, <netdev@vger.kernel.org>,
	<rajesh.borundia@qlogic.com>, <sony.chacko@qlogic.com>,
	<wang.liang82@zte.com.cn>, <cai.qu@zte.com.cn>,
	<long.chun@zte.com.cn>
Subject: Re: 答复: Re: [Patch] netxen_nic: Bugfix for wrong RUNNING status of NX3031 NICs with no link
Date: Mon, 6 Jan 2014 20:24:39 +0000	[thread overview]
Message-ID: <1389039879.9947.104.camel@bwh-desktop.uk.level5networks.com> (raw)
In-Reply-To: <OF9AC42061.4BF09F2E-ON48257C55.00253C5A-48257C55.0027274D@zte.com.cn>

On Fri, 2014-01-03 at 15:07 +0800, jiang.biao2@zte.com.cn wrote:
> >>> You cannot do this, because at the very exact moment you call
> >>> register_netdevice() the device can be brought up and once the
> >>> device is up the link can be brought up.
> 
> >>> Therefore if you invoke netif_carrier_off() right after
> >>> register_netdevice(), it can cancel out a legitimate
> >>> netif_carrier_on() call.
> 
> >> register_netdevice() should be call in probe(), at that time, is
> >> it impossible to bring up device because the driver loading has
> >> not finished?
> 
> > So far as the networking core is concerned, when register_netdevice() is
> > called the device is ready to use.  But you can do:
> 
> > rtnl_lock();
> > register_netdevice();
> > netif_carrier_off();
> > rtnl_unlock();
> 
> > However, as I said before, the current order in netxen_nic works and
> > only older kernel versions require you to call netif_carrier_off() after
> > registering the device.
> 
> >> Even that, the netif_carrier_off() will be called before
> >> netif_carrier_on(), and that will not be a problem.
> 
> >> Besides, the other net drivers(e.g igb, e1000, e1000e) I saw all
> >> call netif_carrier_off() after register_netdev(). There is no such
> >> problems in these drivers.
> 
> > It is not easy to hit the race condition but it is real.
> 
> But the problem I depicted really exists in the current netxen_nic driver,
> you can easily reproduce it following the reproduction steps.

'Current' as in Linux 3.12/3.13-rc7?

I don't know where I would find a Netxen card now.  So I can't test
netxen_nic myself, but I can assure you the sfc driver does things in
the same order and it works correctly.

> Can the following modification fix both the problem I faced and the race
> you worried?
> 
> netif_carrier_off();
> netdev->operstate=IF_OPER_DOWN;
> register_netdevice();

register_netdevice() calls linkwatch_init_dev() which sets the operstate
if necessary.  You should not set it directly.

Ben.

-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

  parent reply	other threads:[~2014-01-06 20:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-02  6:32 [Patch] netxen_nic: Bugfix for wrong RUNNING status of NX3031 NICs with no link jiang.biao2
2014-01-02  8:24 ` David Miller
2014-01-02  9:16   ` jiang.biao2
2014-01-02 18:00     ` Ben Hutchings
     [not found]       ` <OF9AC42061.4BF09F2E-ON48257C55.00253C5A-48257C55.0027274D@zte.com.cn>
2014-01-03  7:18         ` =?iso-2022-jp-3?B?GyRCRXobJChQJTsbKEI6?= " David Miller
2014-01-06 20:24         ` Ben Hutchings [this message]
     [not found]   ` <OFB91B6321.D74C0B57-ON48257C54.00308F8C-48257C54.0030D7E7@zte.com.cn>
2014-01-02 17:33     ` 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=1389039879.9947.104.camel@bwh-desktop.uk.level5networks.com \
    --to=bhutchings@solarflare.com \
    --cc=cai.qu@zte.com.cn \
    --cc=davem@davemloft.net \
    --cc=jiang.biao2@zte.com.cn \
    --cc=li.fengmao@zte.com.cn \
    --cc=long.chun@zte.com.cn \
    --cc=manish.chopra@qlogic.com \
    --cc=netdev@vger.kernel.org \
    --cc=rajesh.borundia@qlogic.com \
    --cc=sony.chacko@qlogic.com \
    --cc=wang.liang82@zte.com.cn \
    /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