Subject: Re: No IDE-DMA after sup today ("no driver support")...
To: None <bouyer@antioche.lip6.fr>
From: Charles M. Hannum <root@ihack.net>
List: current-users
Date: 10/21/1998 06:54:16
While I'm looking at the DMA mode setup...

Why does the code first set PIO mode, and then DMA mode, on drives
that do DMA?  This is a waste.  It would make more sense to do:

Index: ata_wdc.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ata/ata_wdc.c,v
retrieving revision 1.6
diff -c -2 -r1.6 ata_wdc.c
*** ata_wdc.c	1998/10/13 15:18:46	1.6
--- ata_wdc.c	1998/10/21 10:54:13
***************
*** 583,587 ****
  	/* fall through */
  
! 	case PIOMODE:
  		/* Don't try to set modes if controller can't be adjusted */
  		if ((chp->wdc->cap & WDC_CAPABILITY_MODE) == 0)
--- 583,587 ----
  	/* fall through */
  
! 	case XFERMODE:
  		/* Don't try to set modes if controller can't be adjusted */
  		if ((chp->wdc->cap & WDC_CAPABILITY_MODE) == 0)
***************
*** 590,607 ****
  		if ((drvp->drive_flags & DRIVE_MODE) == 0)
  			goto geometry;
- 		wdccommand(chp, drvp->drive, SET_FEATURES, 0, 0, 0,
- 		    0x08 | drvp->PIO_mode, WDSF_SET_MODE);
- 		drvp->state = PIOMODE_WAIT;
- 		break;
- 
- 	case PIOMODE_WAIT:
- 		errstring = "piomode";
- 		if (wdcwait(chp, WDCS_DRDY, WDCS_DRDY, ATA_DELAY))
- 			goto timeout;
- 		if (chp->ch_status & (WDCS_ERR | WDCS_DWF))
- 			goto error;
- 	/* fall through */
- 
- 	case DMAMODE:
  		if (drvp->drive_flags & DRIVE_UDMA) {
  			wdccommand(chp, drvp->drive, SET_FEATURES, 0, 0, 0,
--- 590,593 ----
***************
*** 611,620 ****
  			    0x20 | drvp->DMA_mode, WDSF_SET_MODE);
  		} else {
! 			goto geometry;
  		}	
! 		drvp->state = DMAMODE_WAIT;
  		break;
! 	case DMAMODE_WAIT:
! 		errstring = "dmamode";
  		if (wdcwait(chp, WDCS_DRDY, WDCS_DRDY, ATA_DELAY))
  			goto timeout;
--- 597,608 ----
  			    0x20 | drvp->DMA_mode, WDSF_SET_MODE);
  		} else {
! 			wdccommand(chp, drvp->drive, SET_FEATURES, 0, 0, 0,
! 			    0x08 | drvp->PIO_mode, WDSF_SET_MODE);
  		}	
! 		drvp->state = XFERMODE_WAIT;
  		break;
! 
! 	case XFERMODE_WAIT:
! 		errstring = "xfermode";
  		if (wdcwait(chp, WDCS_DRDY, WDCS_DRDY, ATA_DELAY))
  			goto timeout;