Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: qemu emulated machine crashes due to disk timeouts



On Thu, May 07, 2020 at 05:11:54PM -0000, Michael van Elst wrote:
> stix%stix.id.au@localhost (Paul Ripke) writes:
> 
> >Would making ATA_DELAY configurable via options(4) be worth it?
> 
> That, and maybe even a sysctl.

How about this attached patch? Made it a per-device sysctl knob,
and renamed other miscellaneous usage of ATA_DELAY. Have had this
running under qemu amd64 with no hard errors,
hw.wd0.ata_timeout_ms=30000.
GENERIC & ALL build fine for amd64 & i386.

-- 
Paul Ripke
"Great minds discuss ideas, average minds discuss events, small minds
 discuss people."
-- Disputed: Often attributed to Eleanor Roosevelt. 1948.
diff --git a/sys/dev/ata/ata_wdc.c b/sys/dev/ata/ata_wdc.c
index 45bffcd29fcb..26c04a10f2c6 100644
--- a/sys/dev/ata/ata_wdc.c
+++ b/sys/dev/ata/ata_wdc.c
@@ -100,8 +100,6 @@ extern int wdcdebug_wd_mask; /* inited in wd.c */
 #define ATADEBUG_PRINT(args, level)
 #endif
 
-#define ATA_DELAY 10000 /* 10s for a drive I/O */
-
 static void	wdc_ata_bio(struct ata_drive_datas*, struct ata_xfer *);
 static int	wdc_ata_bio_start(struct ata_channel *,struct ata_xfer *);
 static int	_wdc_ata_bio_start(struct ata_channel *,struct ata_xfer *);
@@ -220,15 +218,15 @@ wdc_ata_bio_start(struct ata_channel *chp, struct ata_xfer *xfer)
 		    WDSD_IBM | (xfer->c_drive << 4));
 		DELAY(10);
 		errstring = "wait";
-		if (wdcwait(chp, WDCS_DRDY, WDCS_DRDY, ATA_DELAY, wait_flags,
-		    &tfd))
+		if (wdcwait(chp, WDCS_DRDY, WDCS_DRDY, xfer->c_ata_c.timeout,
+		    wait_flags, &tfd))
 			goto ctrltimeout;
 		wdccommandshort(chp, xfer->c_drive, WDCC_RECAL);
 		/* Wait for at last 400ns for status bit to be valid */
 		DELAY(1);
 		errstring = "recal";
-		if (wdcwait(chp, WDCS_DRDY, WDCS_DRDY, ATA_DELAY, wait_flags,
-		    &tfd))
+		if (wdcwait(chp, WDCS_DRDY, WDCS_DRDY, xfer->c_ata_c.timeout,
+		    wait_flags, &tfd))
 			goto ctrltimeout;
 		if (ATACH_ST(tfd) & (WDCS_ERR | WDCS_DWF))
 			goto ctrlerror;
@@ -241,8 +239,8 @@ wdc_ata_bio_start(struct ata_channel *chp, struct ata_xfer *xfer)
 		wdccommand(chp, drvp->drive, SET_FEATURES, 0, 0, 0,
 		    0x08 | drvp->PIO_mode, WDSF_SET_MODE);
 		errstring = "piomode";
-		if (wdcwait(chp, WDCS_DRDY, WDCS_DRDY, ATA_DELAY, wait_flags,
-		    &tfd))
+		if (wdcwait(chp, WDCS_DRDY, WDCS_DRDY, xfer->c_ata_c.timeout,
+		    wait_flags, &tfd))
 			goto ctrltimeout;
 		if (ATACH_ST(tfd) & (WDCS_ERR | WDCS_DWF))
 			goto ctrlerror;
@@ -260,8 +258,8 @@ wdc_ata_bio_start(struct ata_channel *chp, struct ata_xfer *xfer)
 			goto geometry;
 		}
 		errstring = "dmamode";
-		if (wdcwait(chp, WDCS_DRDY, WDCS_DRDY, ATA_DELAY, wait_flags,
-		    &tfd))
+		if (wdcwait(chp, WDCS_DRDY, WDCS_DRDY, xfer->c_ata_c.timeout,
+		    wait_flags, &tfd))
 			goto ctrltimeout;
 		if (ATACH_ST(tfd) & (WDCS_ERR | WDCS_DWF))
 			goto ctrlerror;
@@ -275,8 +273,8 @@ geometry:
 		    (drvp->lp->d_type == DKTYPE_ST506) ?
 			drvp->lp->d_precompcyl / 4 : 0);
 		errstring = "geometry";
-		if (wdcwait(chp, WDCS_DRDY, WDCS_DRDY, ATA_DELAY, wait_flags,
-		    &tfd))
+		if (wdcwait(chp, WDCS_DRDY, WDCS_DRDY, xfer->c_ata_c.timeout,
+		    wait_flags, &tfd))
 			goto ctrltimeout;
 		if (ATACH_ST(tfd) & (WDCS_ERR | WDCS_DWF))
 			goto ctrlerror;
@@ -286,8 +284,8 @@ multimode:
 		wdccommand(chp, xfer->c_drive, WDCC_SETMULTI, 0, 0, 0,
 		    drvp->multi, 0);
 		errstring = "setmulti";
-		if (wdcwait(chp, WDCS_DRDY, WDCS_DRDY, ATA_DELAY, wait_flags,
-		    &tfd))
+		if (wdcwait(chp, WDCS_DRDY, WDCS_DRDY, xfer->c_ata_c.timeout,
+		    wait_flags, &tfd))
 			goto ctrltimeout;
 		if (ATACH_ST(tfd) & (WDCS_ERR | WDCS_DWF))
 			goto ctrlerror;
@@ -447,8 +445,8 @@ _wdc_ata_bio_start(struct ata_channel *chp, struct ata_xfer *xfer)
 				wdc->select(chp, xfer->c_drive);
 			bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_sdh],
 			    0, WDSD_IBM | (xfer->c_drive << 4));
-			switch(wdc_wait_for_ready(chp, ATA_DELAY, wait_flags,
-			    &tfd)) {
+			switch(wdc_wait_for_ready(chp, xfer->c_ata_c.timeout,
+			    wait_flags, &tfd)) {
 			case WDCWAIT_OK:
 				break;
 			case WDCWAIT_TOUT:
@@ -481,7 +479,8 @@ _wdc_ata_bio_start(struct ata_channel *chp, struct ata_xfer *xfer)
 			/* start timeout machinery */
 			if ((xfer->c_flags & C_POLL) == 0)
 				callout_reset(&chp->c_timo_callout,
-				    ATA_DELAY / 1000 * hz, wdctimeout, chp);
+				    xfer->c_ata_c.timeout / 1000 * hz,
+				    wdctimeout, chp);
 			/* wait for irq */
 			goto intr;
 		} /* else not DMA */
@@ -532,7 +531,8 @@ _wdc_ata_bio_start(struct ata_channel *chp, struct ata_xfer *xfer)
 			wdc->select(chp, xfer->c_drive);
 		bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_sdh], 0,
 		    WDSD_IBM | (xfer->c_drive << 4));
-		switch(wdc_wait_for_ready(chp, ATA_DELAY, wait_flags, &tfd)) {
+		switch(wdc_wait_for_ready(chp, xfer->c_ata_c.timeout,
+		    wait_flags, &tfd)) {
 		case WDCWAIT_OK:
 			break;
 		case WDCWAIT_TOUT:
@@ -552,7 +552,7 @@ _wdc_ata_bio_start(struct ata_channel *chp, struct ata_xfer *xfer)
 		/* start timeout machinery */
 		if ((xfer->c_flags & C_POLL) == 0)
 			callout_reset(&chp->c_timo_callout,
-			    ATA_DELAY / 1000 * hz, wdctimeout, chp);
+			    xfer->c_ata_c.timeout / 1000 * hz, wdctimeout, chp);
 	} else if (ata_bio->nblks > 1) {
 		/* The number of blocks in the last stretch may be smaller. */
 		nblks = xfer->c_bcount / drvp->lp->d_secsize;
@@ -567,7 +567,8 @@ _wdc_ata_bio_start(struct ata_channel *chp, struct ata_xfer *xfer)
 		 * we have to busy-wait here, we can't rely on running in
 		 * thread context.
 		 */
-		if (wdc_wait_for_drq(chp, ATA_DELAY, AT_POLL, &tfd) != 0) {
+		if (wdc_wait_for_drq(chp, xfer->c_ata_c.timeout, AT_POLL,
+		    &tfd) != 0) {
 			printf("%s:%d:%d: timeout waiting for DRQ, "
 			    "st=0x%02x, err=0x%02x\n",
 			    device_xname(atac->atac_dev), chp->ch_channel,
@@ -621,7 +622,7 @@ wdc_ata_bio_poll(struct ata_channel *chp, struct ata_xfer *xfer)
 	delay(1);
 #if NATA_DMA
 	if (chp->ch_flags & ATACH_DMA_WAIT) {
-		wdc_dmawait(chp, xfer, ATA_DELAY);
+		wdc_dmawait(chp, xfer, xfer->c_ata_c.timeout);
 		chp->ch_flags &= ~ATACH_DMA_WAIT;
 	}
 #endif
@@ -670,7 +671,7 @@ wdc_ata_bio_intr(struct ata_channel *chp, struct ata_xfer *xfer, int irq)
 
 	/* Ack interrupt done by wdc_wait_for_unbusy */
 	if (wdc_wait_for_unbusy(chp,
-	    (irq == 0) ? ATA_DELAY : 0, AT_POLL, &tfd) < 0) {
+	    (irq == 0) ? xfer->c_ata_c.timeout : 0, AT_POLL, &tfd) < 0) {
 		if (irq && (xfer->c_flags & C_TIMEOU) == 0) {
 			ata_channel_unlock(chp);
 			return 0; /* IRQ was not for us */
@@ -697,7 +698,8 @@ wdc_ata_bio_intr(struct ata_channel *chp, struct ata_xfer *xfer, int irq)
 			 * asserted for DMA transfers, so poll for DRDY.
 			 */
 			if (wdcwait(chp, WDCS_DRDY | WDCS_DRQ, WDCS_DRDY,
-			    ATA_DELAY, ATA_POLL, &tfd) == WDCWAIT_TOUT) {
+			    xfer->c_ata_c.timeout, ATA_POLL,
+			    &tfd) == WDCWAIT_TOUT) {
 				printf("%s:%d:%d: polled transfer timed out "
 				    "(st=0x%x)\n",
 				    device_xname(atac->atac_dev),
diff --git a/sys/dev/ata/wd.c b/sys/dev/ata/wd.c
index 67f79e7050f5..7d3e5d82fb0e 100644
--- a/sys/dev/ata/wd.c
+++ b/sys/dev/ata/wd.c
@@ -679,6 +679,7 @@ wdstart1(struct wd_softc *wd, struct buf *bp, struct ata_xfer *xfer)
 	xfer->c_bio.databuf = bp->b_data;
 	xfer->c_bio.blkdone = 0;
 	xfer->c_bio.bp = bp;
+	xfer->c_ata_c.timeout = wd->drv_ata_timeout_ms;
 
 #ifdef WD_CHAOS_MONKEY
 	/*
@@ -2224,6 +2225,20 @@ wd_sysctl_attach(struct wd_softc *wd)
 		return;
 	}
 
+	wd->drv_ata_timeout_ms = 10000;
+	if ((error = sysctl_createv(&wd->nodelog, 0, NULL, NULL,
+				CTLFLAG_READWRITE, CTLTYPE_INT, "ata_timeout_ms",
+				SYSCTL_DESCR("Timeout for ATA read/write "
+				"operations"),
+				NULL, 0, &wd->drv_ata_timeout_ms, 0,
+				CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL))
+				!= 0) {
+		aprint_error_dev(dksc->sc_dev,
+		    "could not create %s.%s.ata_timeout_ms sysctl - error %d\n",
+		    "hw", dksc->sc_xname, error);
+		return;
+	}
+
 #ifdef WD_CHAOS_MONKEY
 	wd->drv_chaos_freq = 0;
 	if ((error = sysctl_createv(&wd->nodelog, 0, NULL, NULL,
diff --git a/sys/dev/ata/wdvar.h b/sys/dev/ata/wdvar.h
index 07152ac80d5f..13ceb742db2e 100644
--- a/sys/dev/ata/wdvar.h
+++ b/sys/dev/ata/wdvar.h
@@ -84,6 +84,7 @@ struct wd_softc {
 	bool drv_ncq_prio;
 #define WD_USE_NCQ_PRIO(wd) \
 	((wd)->drv_ncq_prio && ((wd)->drvp->drive_flags & ATA_DRIVE_NCQ_PRIO))
+	int drv_ata_timeout_ms;
 #ifdef WD_CHAOS_MONKEY
 	int drv_chaos_freq;		/* frequency of simulated bio errors */
 	int drv_chaos_cnt;		/* count of processed bio read xfers */
diff --git a/sys/dev/ic/ahcisata_core.c b/sys/dev/ic/ahcisata_core.c
index fbe7869a3b27..f199376778e2 100644
--- a/sys/dev/ic/ahcisata_core.c
+++ b/sys/dev/ic/ahcisata_core.c
@@ -108,7 +108,6 @@ static const struct scsipi_bustype ahci_atapi_bustype = {
 };
 #endif /* NATAPIBUS */
 
-#define ATA_DELAY 10000 /* 10s for a drive I/O */
 #define ATA_RESET_DELAY 31000 /* 31s for a drive reset */
 #define AHCI_RST_WAIT (ATA_RESET_DELAY / 10)
 
@@ -1422,8 +1421,8 @@ ahci_bio_start(struct ata_channel *chp, struct ata_xfer *xfer)
 	AHCI_WRITE(sc, AHCI_P_CI(chp->ch_channel), 1U << xfer->c_slot);
 
 	if ((xfer->c_flags & C_POLL) == 0) {
-		callout_reset(&chp->c_timo_callout, mstohz(ATA_DELAY),
-		    ata_timeout, chp);
+		callout_reset(&chp->c_timo_callout,
+		    mstohz(xfer->c_ata_c.timeout), ata_timeout, chp);
 		return ATASTART_STARTED;
 	} else
 		return ATASTART_POLL;
@@ -1438,7 +1437,7 @@ ahci_bio_poll(struct ata_channel *chp, struct ata_xfer *xfer)
 	/*
 	 * Polled command. 
 	 */
-	for (int i = 0; i < ATA_DELAY * 10; i++) {
+	for (int i = 0; i < xfer->c_ata_c.timeout * 10; i++) {
 		if (xfer->c_bio.flags & ATA_ITSDONE)
 			break;
 		ahci_intr_port(achp);
@@ -1935,7 +1934,7 @@ ahci_atapi_poll(struct ata_channel *chp, struct ata_xfer *xfer)
 	/*
 	 * Polled command. 
 	 */
-	for (int i = 0; i < ATA_DELAY / 10; i++) {
+	for (int i = 0; i < xfer->c_ata_c.timeout / 10; i++) {
 		if (xfer->c_scsipi->xs_status & XS_STS_DONE)
 			break;
 		ahci_intr_port(achp);
diff --git a/sys/dev/ic/mvsata.c b/sys/dev/ic/mvsata.c
index 7673ba9f439c..d6e49d889062 100644
--- a/sys/dev/ic/mvsata.c
+++ b/sys/dev/ic/mvsata.c
@@ -108,7 +108,8 @@ int	mvsata_debug = 0;
 #define DPRINTF(n,x)
 #endif
 
-#define ATA_DELAY		10000	/* 10s for a drive I/O */
+#define MVSATA_DELAY		10000	/* 10s for a drive I/O */
+
 #define ATAPI_DELAY		10	/* 10 ms, this is used only before
 					   sending a cmd */
 #define ATAPI_MODE_DELAY	1000	/* 1s, timeout for SET_FEATURE cmds */
@@ -1111,7 +1112,8 @@ mvsata_bio_start(struct ata_channel *chp, struct ata_xfer *xfer)
 			/* start timeout machinery */
 			if ((xfer->c_flags & C_POLL) == 0)
 				callout_reset(&chp->c_timo_callout,
-				    mstohz(ATA_DELAY), ata_timeout, chp);
+				    mstohz(xfer->c_ata_c.timeout), ata_timeout,
+				    chp);
 			/* wait for irq */
 			goto intr;
 		} /* else not DMA */
@@ -1176,7 +1178,8 @@ do_pio:
 
 		/* Initiate command! */
 		MVSATA_WDC_WRITE_1(mvport, SRB_H, WDSD_IBM);
-		switch(wdc_wait_for_ready(chp, ATA_DELAY, wait_flags, &tfd)) {
+		switch(wdc_wait_for_ready(chp, xfer->c_ata_c.timeout,
+		    wait_flags, &tfd)) {
 		case WDCWAIT_OK:
 			break;
 		case WDCWAIT_TOUT:
@@ -1196,7 +1199,7 @@ do_pio:
 		/* start timeout machinery */
 		if ((xfer->c_flags & C_POLL) == 0)
 			callout_reset(&chp->c_timo_callout,
-			    mstohz(ATA_DELAY), wdctimeout, chp);
+			    mstohz(xfer->c_ata_c.timeout), wdctimeout, chp);
 	} else if (ata_bio->nblks > 1) {
 		/* The number of blocks in the last stretch may be smaller. */
 		nblks = xfer->c_bcount / drvp->lp->d_secsize;
@@ -1211,7 +1214,8 @@ do_pio:
 		 * we have to busy-wait here, we can't rely on running in
 		 * thread context.
 		 */
-		if (wdc_wait_for_drq(chp, ATA_DELAY, AT_POLL, &tfd) != 0) {
+		if (wdc_wait_for_drq(chp, xfer->c_ata_c.timeout, AT_POLL,
+		    &tfd) != 0) {
 			aprint_error_dev(atac->atac_dev,
 			    "channel %d: drive %d timeout waiting for DRQ,"
 			    " st=0x%02x, err=0x%02x\n",
@@ -1260,7 +1264,7 @@ mvsata_bio_poll(struct ata_channel *chp, struct ata_xfer *xfer)
 	/* Wait for at last 400ns for status bit to be valid */
 	delay(1);
 	if (chp->ch_flags & ATACH_DMA_WAIT) {
-		mvsata_edma_wait(mvport, xfer, ATA_DELAY);
+		mvsata_edma_wait(mvport, xfer, xfer->c_ata_c.timeout);
 		sc->sc_enable_intr(mvport, 1 /*on*/);
 		chp->ch_flags &= ~ATACH_DMA_WAIT;
 	}
@@ -1329,7 +1333,8 @@ mvsata_bio_intr(struct ata_channel *chp, struct ata_xfer *xfer, int intr_arg)
 
 	/* Ack interrupt done by wdc_wait_for_unbusy */
 	if (!(xfer->c_flags & C_DMA) &&
-	    (wdc_wait_for_unbusy(chp, (irq == 0) ? ATA_DELAY : 0, AT_POLL, &tfd)
+	    (wdc_wait_for_unbusy(chp, (irq == 0) ? xfer->c_ata_c.timeout : 0,
+	    AT_POLL, &tfd)
 							== WDCWAIT_TOUT)) {
 		if (irq && (xfer->c_flags & C_TIMEOU) == 0) {
 			ata_channel_unlock(chp);
@@ -1504,13 +1509,13 @@ mvsata_bio_ready(struct mvsata_port *mvport, struct ata_bio *ata_bio, int drive,
 	MVSATA_WDC_WRITE_1(mvport, SRB_H, WDSD_IBM);
 	DELAY(10);
 	errstring = "wait";
-	if (wdcwait(chp, WDCS_DRDY, WDCS_DRDY, ATA_DELAY, flags, &tfd))
+	if (wdcwait(chp, WDCS_DRDY, WDCS_DRDY, MVSATA_DELAY, flags, &tfd))
 		goto ctrltimeout;
 	wdccommandshort(chp, 0, WDCC_RECAL);
 	/* Wait for at least 400ns for status bit to be valid */
 	DELAY(1);
 	errstring = "recal";
-	if (wdcwait(chp, WDCS_DRDY, WDCS_DRDY, ATA_DELAY, flags, &tfd))
+	if (wdcwait(chp, WDCS_DRDY, WDCS_DRDY, MVSATA_DELAY, flags, &tfd))
 		goto ctrltimeout;
 	if (ATACH_ST(tfd) & (WDCS_ERR | WDCS_DWF))
 		goto ctrlerror;
@@ -1523,7 +1528,7 @@ mvsata_bio_ready(struct mvsata_port *mvport, struct ata_bio *ata_bio, int drive,
 	wdccommand(chp, 0, SET_FEATURES, 0, 0, 0,
 	    0x08 | drvp->PIO_mode, WDSF_SET_MODE);
 	errstring = "piomode-bio";
-	if (wdcwait(chp, WDCS_DRDY, WDCS_DRDY, ATA_DELAY, flags, &tfd))
+	if (wdcwait(chp, WDCS_DRDY, WDCS_DRDY, MVSATA_DELAY, flags, &tfd))
 		goto ctrltimeout;
 	if (ATACH_ST(tfd) & (WDCS_ERR | WDCS_DWF))
 		goto ctrlerror;
@@ -1536,7 +1541,7 @@ mvsata_bio_ready(struct mvsata_port *mvport, struct ata_bio *ata_bio, int drive,
 	else
 		goto geometry;
 	errstring = "dmamode-bio";
-	if (wdcwait(chp, WDCS_DRDY, WDCS_DRDY, ATA_DELAY, flags, &tfd))
+	if (wdcwait(chp, WDCS_DRDY, WDCS_DRDY, MVSATA_DELAY, flags, &tfd))
 		goto ctrltimeout;
 	if (ATACH_ST(tfd) & (WDCS_ERR | WDCS_DWF))
 		goto ctrlerror;
@@ -1548,7 +1553,7 @@ geometry:
 	    (drvp->lp->d_type == DKTYPE_ST506) ?
 	    drvp->lp->d_precompcyl / 4 : 0);
 	errstring = "geometry";
-	if (wdcwait(chp, WDCS_DRDY, WDCS_DRDY, ATA_DELAY, flags, &tfd))
+	if (wdcwait(chp, WDCS_DRDY, WDCS_DRDY, MVSATA_DELAY, flags, &tfd))
 		goto ctrltimeout;
 	if (ATACH_ST(tfd) & (WDCS_ERR | WDCS_DWF))
 		goto ctrlerror;
@@ -1557,7 +1562,7 @@ multimode:
 		goto ready;
 	wdccommand(chp, 0, WDCC_SETMULTI, 0, 0, 0, drvp->multi, 0);
 	errstring = "setmulti";
-	if (wdcwait(chp, WDCS_DRDY, WDCS_DRDY, ATA_DELAY, flags, &tfd))
+	if (wdcwait(chp, WDCS_DRDY, WDCS_DRDY, MVSATA_DELAY, flags, &tfd))
 		goto ctrltimeout;
 	if (ATACH_ST(tfd) & (WDCS_ERR | WDCS_DWF))
 		goto ctrlerror;
diff --git a/sys/dev/ic/siisata.c b/sys/dev/ic/siisata.c
index c8e1372339cd..5fa711418407 100644
--- a/sys/dev/ic/siisata.c
+++ b/sys/dev/ic/siisata.c
@@ -108,7 +108,7 @@ __KERNEL_RCSID(0, "$NetBSD: siisata.c,v 1.42 2020/04/13 10:49:34 jdolecek Exp $"
 int siisata_debug_mask = 0;
 #endif
 
-#define ATA_DELAY 10000		/* 10s for a drive I/O */
+#define SIISATA_DELAY 10000	/* 10s for a drive I/O */
 #define WDC_RESET_WAIT 31000	/* 31s for drive reset */
 
 #ifndef __BUS_SPACE_HAS_STREAM_METHODS
@@ -831,7 +831,7 @@ siisata_probe_drive(struct ata_channel *chp)
 
 		/* wait for ready */
 		timed_out = 1;
-		for (i = 0; i < ATA_DELAY / 10; i++) {
+		for (i = 0; i < SIISATA_DELAY / 10; i++) {
 			if (PRREAD(sc, PRX(chp->ch_channel, PRO_PS)) &
 			    PR_PS_PORT_READY) {
 				timed_out = 0;
@@ -1227,8 +1227,8 @@ siisata_bio_start(struct ata_channel *chp, struct ata_xfer *xfer)
 	siisata_activate_prb(schp, xfer->c_slot);
 
 	if ((ata_bio->flags & ATA_POLL) == 0) {
-		callout_reset(&chp->c_timo_callout, mstohz(ATA_DELAY),
-		    ata_timeout, chp);
+		callout_reset(&chp->c_timo_callout,
+		    mstohz(xfer->c_ata_c.timeout), ata_timeout, chp);
 		return ATASTART_STARTED;
 	} else
 		return ATASTART_POLL;
@@ -1242,7 +1242,7 @@ siisata_bio_poll(struct ata_channel *chp, struct ata_xfer *xfer)
 	/*
 	 * polled command
 	 */
-	for (int i = 0; i < ATA_DELAY * 10; i++) {
+	for (int i = 0; i < xfer->c_ata_c.timeout * 10; i++) {
 		if (xfer->c_bio.flags & ATA_ITSDONE)
 			break;
 		siisata_intr_port(schp);
@@ -1465,7 +1465,7 @@ siisata_reinit_port(struct ata_channel *chp, int drive)
 	}
 
 	PRWRITE(sc, PRX(chp->ch_channel, PRO_PCS), PR_PC_PORT_INITIALIZE);
-	for (int i = 0; i < ATA_DELAY * 100; i++) {
+	for (int i = 0; i < SIISATA_DELAY * 100; i++) {
 		ps = PRREAD(sc, PRX(chp->ch_channel, PRO_PS));
 		if ((ps & PR_PS_PORT_READY) != 0)
 			break;
@@ -1498,7 +1498,7 @@ siisata_device_reset(struct ata_channel *chp)
 
 	PRWRITE(sc, PRX(chp->ch_channel, PRO_PCS), PR_PC_DEVICE_RESET);
 
-	for (int i = 0; i < ATA_DELAY * 100; i++) {
+	for (int i = 0; i < SIISATA_DELAY * 100; i++) {
 		ps = PRREAD(sc, PRX(chp->ch_channel, PRO_PS));
 		if ((ps & PR_PS_PORT_READY) != 0)
 			break;
@@ -1844,7 +1844,7 @@ siisata_atapi_poll(struct ata_channel *chp, struct ata_xfer *xfer)
 	/*
 	 * polled command
 	 */
-	for (int i = 0; i < ATA_DELAY * 10; i++) {
+	for (int i = 0; i < xfer->c_ata_c.timeout * 10; i++) {
 		if (xfer->c_scsipi->xs_status & XS_STS_DONE)
 			break;
 		siisata_intr_port(schp);


Home | Main Index | Thread Index | Old Index