netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ingo Oeser <netdev@axxeo.de>
To: Olof Johansson <olof@lixom.net>
Cc: jgarzik@pobox.com, netdev@vger.kernel.org,
	Stephen Hemminger <shemminger@linux-foundation.org>,
	Francois Romieu <romieu@fr.zoreil.com>,
	Christoph Hellwig <hch@infradead.org>
Subject: Re: [PATCH] [v3] PA Semi PWRficient Ethernet driver
Date: Wed, 31 Jan 2007 13:44:31 +0100	[thread overview]
Message-ID: <200701311344.31692.netdev@axxeo.de> (raw)
In-Reply-To: <20070131054457.GA32043@lixom.net>

Hi,

Olof Johansson schrieb:
[...]
> +static int pasemi_mac_close(struct net_device *dev)
> +{
[..]
> +	do {
> +		pci_read_config_dword(mac->dma_pdev,
> +				      PAS_DMA_TXCHAN_TCMDSTA(mac->dma_txch),
> +				      &stat);
> +	} while (stat & PAS_DMA_TXCHAN_TCMDSTA_ACT);
> +
> +	do {
> +		pci_read_config_dword(mac->dma_pdev,
> +				      PAS_DMA_RXCHAN_CCMDSTA(mac->dma_rxch),
> +				      &stat);
> +	} while (stat & PAS_DMA_RXCHAN_CCMDSTA_ACT);
> +
> +	do {
> +		pci_read_config_dword(mac->dma_pdev,
> +				      PAS_DMA_RXINT_RCMDSTA(mac->dma_if),
> +				      &stat);
> +	} while (stat & PAS_DMA_RXINT_RCMDSTA_ACT);

You might want to write these loops like that:

#define MAX_READ_TRIES 10000
unsigned int tries;
unsigned int state;
for(tries=0; tries < MAX_READ_TRIES; tries++)
{
	read_stat(&stat);
	if ((stat & STATE_FLAG) == 0);
		break;
	cond_resched();
}
if (stat & STATE_FLAG) {
	dev_err(&mac->pdev->dev, "Failed to stop device, possible hardware error?\n");
        /* Panic, disable device, mark unusable, whatever is better than hanging here */
}

That way you:
- Let you give other processes a chance to run, 
  while you wait for your hardware state to change 
  (if your hardware can tolerate these latencies).
- can somehow handle hardware failure and at least give the user a clue
  what is happening.

Regards

Ingo Oeser

  parent reply	other threads:[~2007-01-31 12:44 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-29  6:08 [PATCH] PA Semi PWRficient Ethernet driver Olof Johansson
2007-01-29 18:22 ` Stephen Hemminger
2007-01-30  1:41   ` Olof Johansson
2007-01-30  2:34     ` Jeff Garzik
2007-01-30 20:53       ` Olof Johansson
2007-01-29 22:35 ` Francois Romieu
2007-01-30  1:41   ` Olof Johansson
2007-01-30 10:06     ` Christoph Hellwig
2007-01-30 15:34       ` Olof Johansson
2007-01-30 21:45     ` Francois Romieu
2007-01-31  4:52       ` Olof Johansson
2007-01-30  1:44 ` [PATCH] [v2]PA " Olof Johansson
2007-01-31  5:44   ` [PATCH] [v3] PA " Olof Johansson
2007-01-31 10:34     ` Jeff Garzik
2007-02-01  3:40       ` Olof Johansson
2007-01-31 12:44     ` Ingo Oeser [this message]
2007-01-31 15:16       ` Olof Johansson
2007-01-31 18:38     ` Stephen Hemminger
2007-02-01  3:20       ` Olof Johansson
2007-02-01  3:43     ` [PATCH] [v4] " Olof Johansson
2007-02-02 13:26       ` Jeff Garzik
2007-01-30 10:03 ` [PATCH] " Christoph Hellwig
2007-01-30 15:36   ` Olof Johansson

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=200701311344.31692.netdev@axxeo.de \
    --to=netdev@axxeo.de \
    --cc=hch@infradead.org \
    --cc=jgarzik@pobox.com \
    --cc=netdev@vger.kernel.org \
    --cc=olof@lixom.net \
    --cc=romieu@fr.zoreil.com \
    --cc=shemminger@linux-foundation.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).