Revert to basing all timeout/timer values in ms rather than us. The switch
authorPeter Avalos <pavalos@dragonflybsd.org>
Fri, 6 Jul 2007 05:58:26 +0000 (05:58 +0000)
committerPeter Avalos <pavalos@dragonflybsd.org>
Fri, 6 Jul 2007 05:58:26 +0000 (05:58 +0000)
to us was to help out the Linux port, but really just invited overflow.
In fact, the request sense timer was overflowing prior to this change making
it much shorter than intended.

aic_osm_lib.h:
        Be more careful about overflow in all timer/timeout primitives.

Obtained-from: FreeBSD

sys/dev/disk/aic7xxx/aic79xx.c
sys/dev/disk/aic7xxx/aic79xx.h
sys/dev/disk/aic7xxx/aic7xxx.c
sys/dev/disk/aic7xxx/aic_osm_lib.h

index 9e62439..354fc9c 100644 (file)
@@ -39,8 +39,8 @@
  *
  * $Id: //depot/aic7xxx/aic7xxx/aic79xx.c#246 $
  *
- * $FreeBSD: src/sys/dev/aic7xxx/aic79xx.c,v 1.32 2004/08/18 16:35:52 gibbs Exp $
- * $DragonFly: src/sys/dev/disk/aic7xxx/aic79xx.c,v 1.23 2007/07/06 05:17:17 pavalos Exp $
+ * $FreeBSD: src/sys/dev/aic7xxx/aic79xx.c,v 1.33 2004/11/18 20:22:30 gibbs Exp $
+ * $DragonFly: src/sys/dev/disk/aic7xxx/aic79xx.c,v 1.24 2007/07/06 05:58:26 pavalos Exp $
  */
 
 #include "aic79xx_osm.h"
@@ -6448,7 +6448,7 @@ ahd_init(struct ahd_softc *ahd)
        }
 init_done:
        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);
        return (0);
 }
@@ -8016,7 +8016,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
 static void
 ahd_reset_poll(void *arg)
 {
@@ -8034,7 +8034,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();
@@ -8086,7 +8086,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();
 }
@@ -8308,7 +8308,7 @@ ahd_handle_scsi_status(struct ahd_softc *ahd, struct scb *scb)
                 */
                if (ahd->scb_data.recovery_scbs == 0
                 || (scb->flags & SCB_RECOVERY_SCB) != 0)
-                       aic_scb_timer_reset(scb, 5 * 1000000);
+                       aic_scb_timer_reset(scb, 5 * 1000);
                break;
        }
        case SCSI_STATUS_OK:
@@ -9352,7 +9352,7 @@ bus_reset:
                        ahd_outb(ahd, SCSISIGO, last_phase|ATNO);
                        ahd_print_path(ahd, active_scb);
                        kprintf("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) {
@@ -9444,7 +9444,7 @@ bus_reset:
                        ahd_set_scbptr(ahd, active_scbptr);
                        ahd_print_path(ahd, scb);
                        kprintf("Queuing a BDR SCB\n");
-                       aic_scb_timer_reset(scb, 2 * 1000000);
+                       aic_scb_timer_reset(scb, 2 * 1000);
                        break;
                }
        }
index 803ebe9..ecb9b5a 100644 (file)
@@ -39,8 +39,8 @@
  *
  * $Id: //depot/aic7xxx/aic7xxx/aic79xx.h#107 $
  *
- * $FreeBSD: src/sys/dev/aic7xxx/aic79xx.h,v 1.22 2004/08/18 16:33:14 gibbs Exp $
- * $DragonFly: src/sys/dev/disk/aic7xxx/aic79xx.h,v 1.11 2007/07/06 05:07:58 pavalos Exp $
+ * $FreeBSD: src/sys/dev/aic7xxx/aic79xx.h,v 1.23 2004/11/18 20:22:31 gibbs Exp $
+ * $DragonFly: src/sys/dev/disk/aic7xxx/aic79xx.h,v 1.12 2007/07/06 05:58:26 pavalos Exp $
  */
 
 #ifndef _AIC79XX_H_
@@ -1152,7 +1152,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];
index bca94b2..e91c813 100644 (file)
@@ -39,8 +39,8 @@
  *
  * $Id: //depot/aic7xxx/aic7xxx/aic7xxx.c#155 $
  *
- * $FreeBSD: src/sys/dev/aic7xxx/aic7xxx.c,v 1.103 2004/10/19 20:48:05 gibbs Exp $
- * $DragonFly: src/sys/dev/disk/aic7xxx/aic7xxx.c,v 1.20 2007/07/06 05:45:52 pavalos Exp $
+ * $FreeBSD: src/sys/dev/aic7xxx/aic7xxx.c,v 1.104 2004/11/18 20:22:31 gibbs Exp $
+ * $DragonFly: src/sys/dev/disk/aic7xxx/aic7xxx.c,v 1.21 2007/07/06 05:58:26 pavalos Exp $
  */
 
 #include "aic7xxx_osm.h"
@@ -583,7 +583,7 @@ ahc_handle_seqint(struct ahc_softc *ahc, u_int intstat)
                         */
                        if (ahc->scb_data->recovery_scbs == 0
                         || (scb->flags & SCB_RECOVERY_SCB) != 0)
-                               aic_scb_timer_reset(scb, 5 * 1000000);
+                               aic_scb_timer_reset(scb, 5 * 1000);
                        break;
                }
                default:
@@ -7119,7 +7119,7 @@ bus_reset:
                        ahc_print_path(ahc, active_scb);
                        kprintf("BDR message in message buffer\n");
                        active_scb->flags |= SCB_DEVICE_RESET;
-                       aic_scb_timer_reset(scb, 2 * 1000000);
+                       aic_scb_timer_reset(scb, 2 * 1000);
                } else if (last_phase != P_BUSFREE
                        && (ahc_inb(ahc, SSTAT1) & REQINIT) == 0) {
                        /*
@@ -7221,7 +7221,7 @@ bus_reset:
                                kprintf("Queuing a BDR SCB\n");
                                ahc_qinfifo_requeue_tail(ahc, scb);
                                ahc_outb(ahc, SCBPTR, saved_scbptr);
-                               aic_scb_timer_reset(scb, 2 * 1000000);
+                               aic_scb_timer_reset(scb, 2 * 1000);
                        } else {
                                /* Go "immediatly" to the bus reset */
                                /* This shouldn't happen */
index 270ac47..e402ba1 100644 (file)
@@ -32,8 +32,8 @@
  *
  * $Id: //depot/aic7xxx/freebsd/dev/aic7xxx/aic_osm_lib.h#5 $
  *
- * $FreeBSD: src/sys/dev/aic7xxx/aic_osm_lib.h,v 1.3 2004/08/17 00:14:31 gibbs Exp $
- * $DragonFly: src/sys/dev/disk/aic7xxx/aic_osm_lib.h,v 1.3 2007/07/06 04:56:22 pavalos Exp $
+ * $FreeBSD: src/sys/dev/aic7xxx/aic_osm_lib.h,v 1.4 2004/11/18 20:22:31 gibbs Exp $
+ * $DragonFly: src/sys/dev/disk/aic7xxx/aic_osm_lib.h,v 1.4 2007/07/06 05:58:26 pavalos Exp $
  */
 
 /******************************** OS Includes *********************************/
@@ -199,21 +199,31 @@ static __inline u_int aic_get_timeout(struct scb *);
 static __inline void aic_scb_timer_reset(struct scb *, u_int);
 
 static __inline void
-aic_timer_reset(aic_timer_t *timer, u_int usec, aic_callback_t *func, void *arg)
+aic_timer_reset(aic_timer_t *timer, u_int msec, aic_callback_t *func, void *arg)
 {
-       callout_reset(timer, (usec * hz)/1000000, func, arg);
+       uint64_t time;
+
+       time = msec;
+       time *= hz;
+       time /= 1000;
+       callout_reset(timer, time, func, arg);
 }
 
 static __inline u_int
 aic_get_timeout(struct scb *scb)
 {
-       return (scb->io_ctx->ccb_h.timeout * 1000);
+       return (scb->io_ctx->ccb_h.timeout);
 }
 
 static __inline void
-aic_scb_timer_reset(struct scb *scb, u_int usec)
+aic_scb_timer_reset(struct scb *scb, u_int msec)
 {
-       callout_reset(&scb->io_ctx->ccb_h.timeout_ch, (usec * hz)/1000000,
+       uint64_t time;
+
+       time = msec;
+       time *= hz;
+       time /= 1000;
+       callout_reset(&scb->io_ctx->ccb_h.timeout_ch, time,
                aic_platform_timeout, scb);
 }