Revert to basing all timeout/timer values in ms rather than us. The switch

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.
This commit is contained in:
Justin T. Gibbs 2004-11-18 20:22:31 +00:00
parent 949f900d46
commit ad32f91b6b
4 changed files with 26 additions and 16 deletions

View File

@ -6487,7 +6487,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);
}
@ -8055,7 +8055,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)
{
@ -8077,7 +8077,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);
@ -8135,7 +8135,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);
@ -8358,7 +8358,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:
@ -9406,7 +9406,7 @@ ahd_recover_commands(struct ahd_softc *ahd)
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) {
@ -9498,7 +9498,7 @@ ahd_recover_commands(struct ahd_softc *ahd)
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;
}
}

View File

@ -1151,7 +1151,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];

View File

@ -588,7 +588,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:
@ -7155,7 +7155,7 @@ ahc_recover_commands(struct ahc_softc *ahc)
ahc_print_path(ahc, active_scb);
printf("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) {
/*
@ -7257,7 +7257,7 @@ ahc_recover_commands(struct ahc_softc *ahc)
printf("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 */

View File

@ -199,24 +199,34 @@ 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)
{
uint64_t time;
time = msec;
time *= hz;
time /= 1000;
untimeout(aic_platform_timeout, (caddr_t)scb,
scb->io_ctx->ccb_h.timeout_ch);
scb->io_ctx->ccb_h.timeout_ch =
timeout(aic_platform_timeout, scb, (usec * hz)/1000000);
timeout(aic_platform_timeout, scb, time);
}
static __inline void