Module Name:    src
Committed By:   jdolecek
Date:           Tue Oct 10 21:37:49 UTC 2017

Modified Files:
        src/sys/dev/scsipi: atapi_wdc.c

Log Message:
revert the logic in wdc_atapi_intr() for wdc_wait_for_unbusy() to what it
was before NCQ merge; it got broken during the efford to remove ch_status
and ch_error on the branch

fixes atapi timeouts in vbox and with real harware reported separately
by Abhinav Upadhyay, Pault Goyette, Chavdar Ivanov, and Rares
Aioanei; with a bit of luck it could also fix PR kern/52605 and/or PR
kern/52606 by Martin Husemann


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.128 src/sys/dev/scsipi/atapi_wdc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/scsipi/atapi_wdc.c
diff -u src/sys/dev/scsipi/atapi_wdc.c:1.127 src/sys/dev/scsipi/atapi_wdc.c:1.128
--- src/sys/dev/scsipi/atapi_wdc.c:1.127	Sun Oct  8 21:33:38 2017
+++ src/sys/dev/scsipi/atapi_wdc.c	Tue Oct 10 21:37:49 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: atapi_wdc.c,v 1.127 2017/10/08 21:33:38 christos Exp $	*/
+/*	$NetBSD: atapi_wdc.c,v 1.128 2017/10/10 21:37:49 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: atapi_wdc.c,v 1.127 2017/10/08 21:33:38 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: atapi_wdc.c,v 1.128 2017/10/10 21:37:49 jdolecek Exp $");
 
 #ifndef ATADEBUG
 #define ATADEBUG
@@ -727,7 +727,7 @@ wdc_atapi_poll(struct ata_channel *chp, 
 }
 
 static int
-wdc_atapi_intr(struct ata_channel *chp, struct ata_xfer *xfer, int is)
+wdc_atapi_intr(struct ata_channel *chp, struct ata_xfer *xfer, int irq)
 {
 	struct atac_softc *atac = chp->ch_atac;
 	struct wdc_softc *wdc = CHAN_TO_WDC(chp);
@@ -736,7 +736,6 @@ wdc_atapi_intr(struct ata_channel *chp, 
 	struct ata_drive_datas *drvp = &chp->ch_drive[xfer->c_drive];
 	int len, phase, i, retries=0;
 	int ire, tfd;
-	int poll = ((xfer->c_flags & C_POLL) != 0);
 #if NATA_DMA
 	int error;
 #endif
@@ -792,8 +791,8 @@ wdc_atapi_intr(struct ata_channel *chp, 
 	bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_sdh], 0,
 	    WDSD_IBM | (xfer->c_drive << 4));
 	if (wdc_wait_for_unbusy(chp,
-	    poll ? sc_xfer->timeout : 0, AT_POLL, &tfd) == WDCWAIT_TOUT) {
-		if (!poll && (xfer->c_flags & C_TIMEOU) == 0) {
+	    (irq == 0) ? sc_xfer->timeout : 0, AT_POLL, &tfd) == WDCWAIT_TOUT) {
+		if (irq && (xfer->c_flags & C_TIMEOU) == 0) {
 			ata_channel_unlock(chp);
 			return 0; /* IRQ was not for us */
 		}

Reply via email to