lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 31 Jan 2007 13:44:31 +0100
From:	Ingo Oeser <netdev@...eo.de>
To:	Olof Johansson <olof@...om.net>
Cc:	jgarzik@...ox.com, netdev@...r.kernel.org,
	Stephen Hemminger <shemminger@...ux-foundation.org>,
	Francois Romieu <romieu@...zoreil.com>,
	Christoph Hellwig <hch@...radead.org>
Subject: Re: [PATCH] [v3] PA Semi PWRficient Ethernet driver

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
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists