summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2004-12-13 04:07:27 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2004-12-13 04:07:27 +0000
commit6414649aab02efd6444fb6d332d828658cfe9ef2 (patch)
tree6e4708984b23d77ce63cdf92c1ae1717ed4e4a4c /sys
parent4aeffaa1a581000c23d516d4d226c5f2a436a3fa (diff)
Use millisends rather than microseconds in parameters to timer
functions, and ultra-conservative calculations, to avoid possible overflow issues. Also consistant with values passed in scsi requests. Whitespace and comment tweaks. Update FreeBSD tags now that we are sync'd to the latest version. From FreeBSD aic79xx.c r1.33, aic79xx.h r1.23, aic_osm_lib.h r1.4.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/ic/aic79xx.c30
-rw-r--r--sys/dev/ic/aic79xx.h8
-rw-r--r--sys/dev/ic/aic79xx_openbsd.c27
-rw-r--r--sys/dev/ic/aic79xx_openbsd.h4
4 files changed, 40 insertions, 29 deletions
diff --git a/sys/dev/ic/aic79xx.c b/sys/dev/ic/aic79xx.c
index f8c586a60e2..9e161354e4f 100644
--- a/sys/dev/ic/aic79xx.c
+++ b/sys/dev/ic/aic79xx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aic79xx.c,v 1.20 2004/12/11 00:26:40 krw Exp $ */
+/* $OpenBSD: aic79xx.c,v 1.21 2004/12/13 04:07:25 krw Exp $ */
/*
* Copyright (c) 2004 Milos Urbanek, Kenneth R. Westerback & Marco Peereboom
@@ -66,6 +66,9 @@
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
+ * Id: //depot/aic7xxx/aic7xxx/aic79xx.c#246
+ *
+ * FreeBSD: src/sys/dev/aic7xxx/aic79xx.c,v 1.33 2004/11/18 20:22:30 gibbs Exp
*/
#include <sys/cdefs.h>
@@ -6315,7 +6318,7 @@ ahd_init(struct ahd_softc *ahd)
init_done:
ahd_reset_current_bus(ahd);
ahd_restart(ahd);
- aic_timer_reset(&ahd->stat_timer, AHD_STAT_UPDATE_US,
+ aic_timer_reset(&ahd->stat_timer, AHD_STAT_UPDATE_MS,
ahd_stat_timer, ahd);
/* We have to wait until after any system dumps... */
@@ -7888,7 +7891,7 @@ ahd_reset_channel(struct ahd_softc *ahd, char channel, int initiate_reset)
}
-#define AHD_RESET_POLL_US 1000
+#define AHD_RESET_POLL_MS 1
void
ahd_reset_poll(void *arg)
{
@@ -7910,7 +7913,7 @@ ahd_reset_poll(void *arg)
ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
ahd_outb(ahd, CLRSINT1, CLRSCSIRSTI);
if ((ahd_inb(ahd, SSTAT1) & SCSIRSTI) != 0) {
- aic_timer_reset(&ahd->reset_timer, AHD_RESET_POLL_US,
+ aic_timer_reset(&ahd->reset_timer, AHD_RESET_POLL_MS,
ahd_reset_poll, ahd);
ahd_unpause(ahd);
ahd_unlock(ahd, &s);
@@ -7968,7 +7971,7 @@ ahd_stat_timer(void *arg)
ahd->cmdcmplt_bucket = (ahd->cmdcmplt_bucket+1) & (AHD_STAT_BUCKETS-1);
ahd->cmdcmplt_total -= ahd->cmdcmplt_counts[ahd->cmdcmplt_bucket];
ahd->cmdcmplt_counts[ahd->cmdcmplt_bucket] = 0;
- aic_timer_reset(&ahd->stat_timer, AHD_STAT_UPDATE_US,
+ aic_timer_reset(&ahd->stat_timer, AHD_STAT_UPDATE_MS,
ahd_stat_timer, ahd);
ahd_unlock(ahd, &s);
ahd_list_unlock(&l);
@@ -8188,7 +8191,7 @@ ahd_handle_scsi_status(struct ahd_softc *ahd, struct scb *scb)
* Ensure we have enough time to actually
* retrieve the sense.
*/
- aic_scb_timer_reset(scb, 5 * 1000000);
+ aic_scb_timer_reset(scb, 5 * 1000);
break;
}
case SCSI_STATUS_OK:
@@ -9207,7 +9210,7 @@ bus_reset:
* untimed-out command is outstanding.
*/
if (ahd_other_scb_timeout(ahd, scb,
- active_scb) == 0)
+ active_scb) == 0)
goto bus_reset;
continue;
}
@@ -9222,7 +9225,7 @@ bus_reset:
ahd_outb(ahd, SCSISIGO, last_phase|ATNO);
ahd_print_path(ahd, active_scb);
printf("BDR message in message buffer\n");
- aic_scb_timer_reset(scb, 2 * 1000000);
+ aic_scb_timer_reset(scb, 2 * 1000);
break;
} else if (last_phase != P_BUSFREE
&& ahd_inb(ahd, SCSIPHASE) == 0) {
@@ -9262,15 +9265,6 @@ bus_reset:
* In either case (selection or reselection),
* we will now issue a target reset to the
* timed-out device.
- *
- * Set the MK_MESSAGE control bit indicating
- * that we desire to send a message. We
- * also set the disconnected flag since
- * in the paging case there is no guarantee
- * that our SCB control byte matches the
- * version on the card. We don't want the
- * sequencer to abort the command thinking
- * an unsolicited reselection occurred.
*/
scb->flags |= SCB_DEVICE_RESET;
scb->hscb->cdb_len = 0;
@@ -9323,7 +9317,7 @@ bus_reset:
ahd_set_scbptr(ahd, active_scbptr);
ahd_print_path(ahd, scb);
printf("Queuing a BDR SCB\n");
- aic_scb_timer_reset(scb, 2 * 1000000);
+ aic_scb_timer_reset(scb, 2 * 1000);
break;
}
}
diff --git a/sys/dev/ic/aic79xx.h b/sys/dev/ic/aic79xx.h
index e761d6ea684..072acb24db7 100644
--- a/sys/dev/ic/aic79xx.h
+++ b/sys/dev/ic/aic79xx.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: aic79xx.h,v 1.15 2004/12/10 17:00:36 krw Exp $ */
+/* $OpenBSD: aic79xx.h,v 1.16 2004/12/13 04:07:26 krw Exp $ */
/*
* Copyright (c) 2004 Milos Urbanek, Kenneth R. Westerback & Marco Peereboom
@@ -66,7 +66,9 @@
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
- * $FreeBSD: src/sys/dev/aic7xxx/aic79xx.h,v 1.18 2004/02/04 16:38:38 gibbs Exp $
+ * Id: //depot/aic7xxx/aic7xxx/aic79xx.h#107
+ *
+ * FreeBSD: src/sys/dev/aic7xxx/aic79xx.h,v 1.23 2004/11/18 20:22:31 gibbs Exp
*/
#ifndef _AIC79XX_H_
@@ -1171,7 +1173,7 @@ struct ahd_softc {
/*
* Statistics.
*/
-#define AHD_STAT_UPDATE_US 250000 /* 250ms */
+#define AHD_STAT_UPDATE_MS 250
#define AHD_STAT_BUCKETS 4
u_int cmdcmplt_bucket;
uint32_t cmdcmplt_counts[AHD_STAT_BUCKETS];
diff --git a/sys/dev/ic/aic79xx_openbsd.c b/sys/dev/ic/aic79xx_openbsd.c
index d43b19cf41a..8da21ece3b6 100644
--- a/sys/dev/ic/aic79xx_openbsd.c
+++ b/sys/dev/ic/aic79xx_openbsd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aic79xx_openbsd.c,v 1.12 2004/11/23 05:15:35 krw Exp $ */
+/* $OpenBSD: aic79xx_openbsd.c,v 1.13 2004/12/13 04:07:26 krw Exp $ */
/*
* Copyright (c) 2004 Milos Urbanek, Kenneth R. Westerback & Marco Peereboom
@@ -780,12 +780,27 @@ ahd_adapter_req_set_xfer_mode(struct ahd_softc *ahd, struct scb *scb)
}
void
-aic_scb_timer_reset(struct scb *scb, u_int usec)
+aic_timer_reset(aic_timer_t *timer, u_int msec, ahd_callback_t *func,
+ void *arg)
{
- if (!(scb->xs->xs_control & XS_CTL_POLL)) {
- callout_reset(&scb->xs->xs_callout,
- (usec * hz)/1000000, ahd_timeout, scb);
- }
+ uint64_t ticks;
+
+ ticks = msec;
+ ticks *= hz;
+ ticks /= 1000;
+ callout_reset(timer, ticks, func, arg);
+}
+
+void
+aic_scb_timer_reset(struct scb *scb, u_int msec)
+{
+ uint64_t ticks;
+
+ ticks = msec;
+ ticks *= hz;
+ ticks /= 1000;
+ if (!(scb->xs->xs_control & XS_CTL_POLL))
+ callout_reset(&scb->xs->xs_callout, ticks, ahd_timeout, scb);
}
void
diff --git a/sys/dev/ic/aic79xx_openbsd.h b/sys/dev/ic/aic79xx_openbsd.h
index 5371d68ad59..7c4fe4fca97 100644
--- a/sys/dev/ic/aic79xx_openbsd.h
+++ b/sys/dev/ic/aic79xx_openbsd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: aic79xx_openbsd.h,v 1.9 2004/11/23 05:15:35 krw Exp $ */
+/* $OpenBSD: aic79xx_openbsd.h,v 1.10 2004/12/13 04:07:26 krw Exp $ */
/*
* Copyright (c) 2004 Milos Urbanek, Kenneth R. Westerback & Marco Peereboom
@@ -158,10 +158,10 @@ typedef struct timeout aic_timer_t;
/***************************** Timer Facilities *******************************/
void ahd_timeout(void*);
+void aic_timer_reset(aic_timer_t *, u_int, ahd_callback_t *, void *);
void aic_scb_timer_reset(struct scb *, u_int);
#define aic_timer_stop timeout_del
-#define aic_timer_reset callout_reset
/*************************** Device Access ************************************/
#define ahd_inb(ahd, port) \