public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Prasanna Panchamukhi <ppanchamukhi@riverbed•com>
Cc: "e1000-devel@lists•sourceforge.net"
	<e1000-devel@lists•sourceforge.net>,
	"netdev@vger•kernel.org" <netdev@vger•kernel.org>,
	"bruce.w.allan@intel•com" <bruce.w.allan@intel•com>,
	"jesse.brandeburg@intel•com" <jesse.brandeburg@intel•com>
Subject: Re: [PATCH] e100: Fix race condition in e100_down() while testing
Date: Tue, 17 May 2011 20:07:21 -0700	[thread overview]
Message-ID: <4DD337E9.9080907@riverbed.com> (raw)
In-Reply-To: <1305670825-13603-1-git-send-email-prasanna.panchamukhi@riverbed.com>

Please ignore this, sending and updated one..

On 05/17/2011 03:20 PM, prasanna.panchamukhi@riverbed•com wrote:
> There is a race condition between e100_down() and e100_diag_test().
> During device testing e100_diag_test() ends up calling e100_up()/e100_down()
> even while the driver is already in e100_down().
> This patch fixes the above race condition by changing
> e100_up()/e100_down() to dev_open() and dev_close().
> Also fixes the race between e100_open() and e100_diag_test().
>
> Signed-off-by: Prasanna S. Panchamukh<prasanna.panchamukhi@riverbed•com>
> ---
>   drivers/net/e100.c |   21 +++++++++++++++++----
>   1 files changed, 17 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/e100.c b/drivers/net/e100.c
> index b0aa9e6..abbf229 100644
> --- a/drivers/net/e100.c
> +++ b/drivers/net/e100.c
> @@ -425,6 +425,10 @@ enum cb_command {
>   	cb_el     = 0x8000,
>   };
>
> +enum e100_state_t {
> +	__E100_TESTING
> +};
> +
>   struct rfd {
>   	__le16 status;
>   	__le16 command;
> @@ -623,6 +627,7 @@ struct nic {
>   	__le16 eeprom[256];
>   	spinlock_t mdio_lock;
>   	const struct firmware *fw;
> +	unsigned long state;
>   };
>
>   static inline void e100_write_flush(struct nic *nic)
> @@ -2570,8 +2575,10 @@ static void e100_diag_test(struct net_device *netdev,
>   {
>   	struct ethtool_cmd cmd;
>   	struct nic *nic = netdev_priv(netdev);
> +	int if_running = netif_running(netdev);
>   	int i, err;
>
> +	set_bit(__E100_TESTING,&nic->state);
>   	memset(data, 0, E100_TEST_LEN * sizeof(u64));
>   	data[0] = !mii_link_ok(&nic->mii);
>   	data[1] = e100_eeprom_load(nic);
> @@ -2580,8 +2587,9 @@ static void e100_diag_test(struct net_device *netdev,
>   		/* save speed, duplex&  autoneg settings */
>   		err = mii_ethtool_gset(&nic->mii,&cmd);
>
> -		if (netif_running(netdev))
> -			e100_down(nic);
> +		if (if_running)
> +			/* indicate we're in test mode */
> +			dev_open(netdev);
>   		data[2] = e100_self_test(nic);
>   		data[3] = e100_loopback_test(nic, lb_mac);
>   		data[4] = e100_loopback_test(nic, lb_phy);
> @@ -2589,12 +2597,13 @@ static void e100_diag_test(struct net_device *netdev,
>   		/* restore speed, duplex&  autoneg settings */
>   		err = mii_ethtool_sset(&nic->mii,&cmd);
>
> -		if (netif_running(netdev))
> -			e100_up(nic);
> +		if (if_running)
> +			dev_open(netdev);
>   	}
>   	for (i = 0; i<  E100_TEST_LEN; i++)
>   		test->flags |= data[i] ? ETH_TEST_FL_FAILED : 0;
>
> +	clear_bit(__E100_TESTING,&nic->state);
>   	msleep_interruptible(4 * 1000);
>   }
>
> @@ -2724,6 +2733,10 @@ static int e100_open(struct net_device *netdev)
>   	struct nic *nic = netdev_priv(netdev);
>   	int err = 0;
>
> +	/* disallow open during testing */
> +	if (test_bit(__E100_TESTING,&nic->state))
> +		return -EBUSY;
> +
>   	netif_carrier_off(netdev);
>   	if ((err = e100_up(nic)))
>   		netif_err(nic, ifup, nic->netdev, "Cannot open interface, aborting\n");


------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its 
next-generation tools to help Windows* and Linux* C/C++ and Fortran 
developers boost performance applications - including clusters. 
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
E1000-devel mailing list
E1000-devel@lists•sourceforge.net
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel&#174; Ethernet, visit http://communities.intel.com/community/wired

      reply	other threads:[~2011-05-18  3:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-17 22:20 [PATCH] e100: Fix race condition in e100_down() while testing prasanna.panchamukhi
2011-05-18  3:07 ` Prasanna Panchamukhi [this message]

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=4DD337E9.9080907@riverbed.com \
    --to=ppanchamukhi@riverbed$(echo .)com \
    --cc=bruce.w.allan@intel$(echo .)com \
    --cc=e1000-devel@lists$(echo .)sourceforge.net \
    --cc=jesse.brandeburg@intel$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=prasanna.panchamukhi@riverbed$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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