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 [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html