if ((drvp->drive_flags & (DRIVE_DMA | DRIVE_UDMA)) &&
if (!(xfer->c_flags & C_POLL) && (drvp->drive_flags & (DRIVE_DMA | DRIVE_UDMA)) &&
wdc_atapi_start(chp, xfer)	struct channel_softc *chp;	struct wdc_xfer *xfer;{	struct scsi_xfer *sc_xfer = xfer->cmd;	struct ata_drive_datas *drvp = &chp->ch_drive[xfer->drive];	WDCDEBUG_PRINT(("wdc_atapi_start %s:%d:%d, scsi flags 0x%x\n",	    chp->wdc->sc_dev.dv_xname, chp->channel, drvp->drive,	    sc_xfer->flags), DEBUG_XFERS);	/* Adjust C_DMA, it may have changed if we are requesting sense */	if ((drvp->drive_flags & (DRIVE_DMA | DRIVE_UDMA)) &&	    (sc_xfer->datalen > 0 || (xfer->c_flags & C_SENSE)))		xfer->c_flags |= C_DMA;	else		xfer->c_flags &= ~C_DMA;	/* Do control operations specially. */	if (drvp->state < READY) {		if (drvp->state != IDENTIFY) {			printf("%s:%d:%d: bad state %d in wdc_atapi_start\n",			    chp->wdc->sc_dev.dv_xname, chp->channel,			    xfer->drive, drvp->state);			panic("wdc_atapi_start: bad state");		}		wdc_atapi_ctrl(chp, xfer, 0);		return;	}		if (wdc_select_drive(chp, xfer->drive, ATAPI_DELAY) < 0) {		printf("wdc_atapi_start: not ready, st = %02x\n",		    chp->ch_status);		sc_xfer->error = XS_TIMEOUT;		wdc_atapi_reset(chp, xfer);		return;	}	if (drvp->atapi_cap & ACAP_DSC) {		if (atapi_dsc_wait(drvp, sc_xfer->timeout)) {			sc_xfer->error = XS_TIMEOUT;			wdc_atapi_reset(chp, xfer);			return;		}		WDCDEBUG_PRINT(("wdc_atapi_start %s:%d:%d, DSC asserted\n",		    chp->wdc->sc_dev.dv_xname, chp->channel, drvp->drive),		    DEBUG_DSC);		drvp->drive_flags &= ~DRIVE_DSCWAIT;	}	/*	 * Even with WDCS_ERR, the device should accept a command packet	 * Limit length to what can be stuffed into the cylinder register	 * (16 bits).  Some CD-ROMs seem to interpret '0' as 65536,	 * but not all devices do that and it's not obvious from the	 * ATAPI spec that that behaviour should be expected.  If more	 * data is necessary, multiple data transfer phases will be done.	 */	wdccommand(chp, xfer->drive, ATAPI_PKT_CMD, 	    sc_xfer->datalen <= 0xffff ? sc_xfer->datalen : 0xffff,	    0, 0, 0, 	    (xfer->c_flags & C_DMA) ? ATAPI_PKT_CMD_FTRE_DMA : 0);	/*	 * If there is no interrupt for CMD input, busy-wait for it (done in 	 * the interrupt routine. If it is a polled command, call the interrupt	 * routine until command is done.	 */	if (((drvp->atapi_cap & ATAPI_CFG_DRQ_MASK) != ATAPI_CFG_IRQ_DRQ) ||	    (sc_xfer->flags & SCSI_POLL) || (drvp->atapi_cap & ACAP_DSC)) {		/* Wait for at last 400ns for status bit to be valid */		DELAY(1);		wdc_atapi_intr(chp, xfer, 0);	} else {		chp->ch_flags |= WDCF_IRQ_WAIT;		timeout(wdctimeout, chp, hz);		return;	}	if ((sc_xfer->flags & SCSI_POLL) || (drvp->atapi_cap & ACAP_DSC)) {		while ((sc_xfer->flags & ITSDONE) == 0) {			if (drvp->atapi_cap & ACAP_DSC) {				if (atapi_poll_wait(				    (drvp->drive_flags & DRIVE_DSCWAIT) ?				    atapi_dsc_ready : atapi_dsc_semiready,				    drvp, sc_xfer->timeout, PZERO + PCATCH,				    "atapist")) {					sc_xfer->error = XS_TIMEOUT;					wdc_atapi_reset(chp, xfer);					return;				}			} else				/* Wait for at last 400ns for status bit to				   be valid */				DELAY(1);			wdc_atapi_intr(chp, xfer, 0);		}	}}