Re: 2.1.125 Show stopper list: Draft

Andrea Arcangeli (andrea@e-mind.com)
Tue, 13 Oct 1998 18:31:55 +0200 (CEST)


On Tue, 13 Oct 1998, Alan Cox wrote:

>> > Jiffy Handling
>> > Many drivers still do not handle jiffy overflows nicely
>>
>> Alan, should we consider this really a bug? I think that to only _clean_
>> way to fix this problem would be to use a long long C type for jiffies
>> (decreasing performance). But decreasing performance is needed also to
>> catch the overflow...
>
>It is a bug. The only drivers that should have a problem are those that
>need to execute 250 day delay loops. Now I grant an NCR5380 is slow but
>its not that slow...
>
>There are also macros in the kernel tree now for time comparison with wrap
>around protection. Basically it uses a tcp like scheme so that the low 32bits
>are used for a 31bit relative range.
>
>So instead of
>
> x=jiffes+HZ/5
> while(jiffies<x)

If I understand well all cases like:

now = jiffies;
while (jiffies - now < HZ);

are just fine.

Here a fix for the drivers/scsi and drivers/char and include/linux
directories. The patch is against 2.1.125 + my parport update that I
sent to Linus some days ago.

Index: linux/drivers/char/cyclades.c
diff -u linux/drivers/char/cyclades.c:1.1.1.1 linux/drivers/char/cyclades.c:1.1.1.1.12.1
--- linux/drivers/char/cyclades.c:1.1.1.1 Fri Oct 2 19:23:13 1998
+++ linux/drivers/char/cyclades.c Tue Oct 13 17:28:27 1998
@@ -1000,13 +1000,13 @@
* occur during the bootup sequence
*/
timeout = jiffies+(HZ/10);
- while (timeout >= jiffies)
+ while (time_after_eq(timeout, jiffies))
;

cy_triggered = 0; /* Reset after letting things settle */

timeout = jiffies+(HZ/10);
- while (timeout >= jiffies)
+ while (time_after_eq(timeout, jiffies))
;

for (i = 0, mask = 1; i < 16; i++, mask <<= 1) {
@@ -1050,7 +1050,7 @@
restore_flags(flags);

timeout = jiffies+(HZ/50);
- while (timeout >= jiffies) {
+ while (time_after_eq(timeout, jiffies)) {
if (cy_irq_triggered)
break;
}
@@ -2594,7 +2594,7 @@
schedule();
if (signal_pending(current))
break;
- if (timeout && ((orig_jiffies + timeout) < jiffies))
+ if (timeout && time_before(orig_jiffies + timeout, jiffies))
break;
}
current->state = TASK_RUNNING;
Index: linux/drivers/char/esp.c
diff -u linux/drivers/char/esp.c:1.1.1.1 linux/drivers/char/esp.c:1.1.1.1.12.1
--- linux/drivers/char/esp.c:1.1.1.1 Fri Oct 2 19:23:14 1998
+++ linux/drivers/char/esp.c Tue Oct 13 17:28:28 1998
@@ -2161,7 +2161,7 @@
if (signal_pending(current))
break;

- if (timeout && ((orig_jiffies + timeout) < jiffies))
+ if (timeout && time_before(orig_jiffies + timeout, jiffies))
break;

serial_out(info, UART_ESI_CMD1, ESI_NO_COMMAND);
Index: linux/drivers/char/istallion.c
diff -u linux/drivers/char/istallion.c:1.1.1.1 linux/drivers/char/istallion.c:1.1.1.1.12.1
--- linux/drivers/char/istallion.c:1.1.1.1 Fri Oct 2 19:23:14 1998
+++ linux/drivers/char/istallion.c Tue Oct 13 17:28:28 1998
@@ -2303,7 +2303,7 @@
if (signal_pending(current))
break;
stli_delay(2);
- if (jiffies >= tend)
+ if (time_after_eq(jiffies, tend))
break;
}
}
Index: linux/drivers/char/joystick.c
diff -u linux/drivers/char/joystick.c:1.1.1.1 linux/drivers/char/joystick.c:1.1.1.1.12.1
--- linux/drivers/char/joystick.c:1.1.1.1 Fri Oct 2 19:23:15 1998
+++ linux/drivers/char/joystick.c Tue Oct 13 17:28:28 1998
@@ -222,7 +222,7 @@
}
}
else
- if ((jiffies > js_bh_time + JS_BH_MAX_PERIOD) && !js_mark_time) {
+ if (time_after(jiffies, js_bh_time + JS_BH_MAX_PERIOD) && !js_mark_time) {
js_mark_time = jiffies;
mark_bh(JS_BH);
}
@@ -285,7 +285,7 @@
int i, j, k;
unsigned int t;

- if (jiffies > js_bh_time + JS_BH_MIN_PERIOD) {
+ if (time_after(jiffies, js_bh_time + JS_BH_MIN_PERIOD)) {

unsigned int old_axis[4];
unsigned int t_low, t_high;
Index: linux/drivers/char/n_tty.c
diff -u linux/drivers/char/n_tty.c:1.1.1.1 linux/drivers/char/n_tty.c:1.1.1.1.12.1
--- linux/drivers/char/n_tty.c:1.1.1.1 Fri Oct 2 19:23:13 1998
+++ linux/drivers/char/n_tty.c Tue Oct 13 17:28:28 1998
@@ -419,7 +419,7 @@
char buf[64];

tty->num_overrun++;
- if (tty->overrun_time < (jiffies - HZ)) {
+ if (time_before(tty->overrun_time, jiffies - HZ) {
printk("%s: %d input overrun(s)\n", tty_name(tty, buf),
tty->num_overrun);
tty->overrun_time = jiffies;
Index: linux/drivers/char/riscom8.c
diff -u linux/drivers/char/riscom8.c:1.1.1.1 linux/drivers/char/riscom8.c:1.1.1.1.12.1
--- linux/drivers/char/riscom8.c:1.1.1.1 Fri Oct 2 19:23:15 1998
+++ linux/drivers/char/riscom8.c Tue Oct 13 17:28:28 1998
@@ -228,7 +228,7 @@
{
unsigned long i;

- for (i = jiffies + delay; i > jiffies; ) ;
+ for (i = jiffies + delay; time_after(i,jiffies); ) ;
}

/* Reset and setup CD180 chip */
@@ -1174,7 +1174,7 @@
current->state = TASK_INTERRUPTIBLE;
current->timeout = jiffies + port->timeout;
schedule();
- if (jiffies > timeout)
+ if (time_after(jiffies, timeout))
break;
}
}
Index: linux/drivers/char/specialix.c
diff -u linux/drivers/char/specialix.c:1.1.1.1 linux/drivers/char/specialix.c:1.1.1.1.12.1
--- linux/drivers/char/specialix.c:1.1.1.1 Fri Oct 2 19:23:16 1998
+++ linux/drivers/char/specialix.c Tue Oct 13 17:28:28 1998
@@ -346,7 +346,7 @@
{
unsigned long i;

- for (i = jiffies + delay; i > jiffies; ) ;
+ for (i = jiffies + delay; time_after(i, jiffies); ) ;
}


@@ -1040,7 +1040,7 @@
/* Set baud rate for port */
tmp = (((SX_OSCFREQ + baud_table[baud]/2) / baud_table[baud] +
CD186x_TPC/2) / CD186x_TPC);
- if ((tmp < 0x10) && (again < jiffies)) {
+ if ((tmp < 0x10) && time_before(again, jiffies)) {
again = jiffies + HZ * 60;
/* Page 48 of version 2.0 of the CL-CD1865 databook */
if (tmp >= 12) {
@@ -1518,7 +1518,7 @@
current->state = TASK_INTERRUPTIBLE;
current->timeout = jiffies + port->timeout;
schedule();
- if (jiffies > timeout) {
+ if (time_after(jiffies, timeout)) {
printk (KERN_INFO "Timeout waiting for close\n");
break;
}
Index: linux/drivers/char/stallion.c
diff -u linux/drivers/char/stallion.c:1.1.1.1 linux/drivers/char/stallion.c:1.1.1.1.12.1
--- linux/drivers/char/stallion.c:1.1.1.1 Fri Oct 2 19:23:14 1998
+++ linux/drivers/char/stallion.c Tue Oct 13 17:28:28 1998
@@ -1694,7 +1694,7 @@
if (signal_pending(current))
break;
stl_delay(2);
- if (jiffies >= tend)
+ if (time_after_eq(jiffies, tend))
break;
}
}
Index: linux/drivers/scsi/53c7,8xx.c
diff -u linux/drivers/scsi/53c7,8xx.c:1.1.1.1 linux/drivers/scsi/53c7,8xx.c:1.1.1.1.12.1
--- linux/drivers/scsi/53c7,8xx.c:1.1.1.1 Fri Oct 2 19:23:19 1998
+++ linux/drivers/scsi/53c7,8xx.c Tue Oct 13 17:00:28 1998
@@ -1901,7 +1901,8 @@
*/

timeout = jiffies + 5 * HZ / 10;
- while ((hostdata->test_completed == -1) && jiffies < timeout)
+ while ((hostdata->test_completed == -1) &&
+ time_before(jiffies,timeout))
barrier();

failed = 1;
@@ -1986,7 +1987,8 @@
restore_flags(flags);

timeout = jiffies + 5 * HZ; /* arbitrary */
- while ((hostdata->test_completed == -1) && jiffies < timeout)
+ while ((hostdata->test_completed == -1) &&
+ time_before(jiffies, timeout))
barrier();
NCR53c7x0_write32 (DSA_REG, 0);

Index: linux/drivers/scsi/53c7xx.c
diff -u linux/drivers/scsi/53c7xx.c:1.1.1.1.2.1 linux/drivers/scsi/53c7xx.c:1.1.1.1.2.1.2.1
--- linux/drivers/scsi/53c7xx.c:1.1.1.1.2.1 Fri Oct 9 19:22:37 1998
+++ linux/drivers/scsi/53c7xx.c Tue Oct 13 17:00:28 1998
@@ -1612,7 +1612,8 @@
*/

timeout = jiffies + 5 * HZ / 10;
- while ((hostdata->test_completed == -1) && jiffies < timeout)
+ while ((hostdata->test_completed == -1) &&
+ time_before(jiffies, timeout))
barrier();

failed = 1;
@@ -1698,7 +1699,8 @@
restore_flags(flags);

timeout = jiffies + 5 * HZ; /* arbitrary */
- while ((hostdata->test_completed == -1) && jiffies < timeout)
+ while ((hostdata->test_completed == -1) &&
+ time_before(jiffies, timeout))
barrier();

NCR53c7x0_write32 (DSA_REG, 0);
Index: linux/drivers/scsi/NCR5380.c
diff -u linux/drivers/scsi/NCR5380.c:1.1.1.1 linux/drivers/scsi/NCR5380.c:1.1.1.1.12.1
--- linux/drivers/scsi/NCR5380.c:1.1.1.1 Fri Oct 2 19:23:19 1998
+++ linux/drivers/scsi/NCR5380.c Tue Oct 13 17:00:29 1998
@@ -686,7 +686,7 @@
save_flags(flags);
cli();
for (; expires_first &&
- ((struct NCR5380_hostdata *)expires_first->hostdata)->time_expires <= jiffies; )
+ time_before_eq(((struct NCR5380_hostdata *)expires_first->hostdata)->time_expires, jiffies); )
{
instance = ((struct NCR5380_hostdata *) expires_first->hostdata)->next_timer;
((struct NCR5380_hostdata *) expires_first->hostdata)->next_timer = NULL;
@@ -776,7 +776,7 @@
NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_DATA |
ICR_ASSERT_SEL);

- while (probe_irq == IRQ_NONE && jiffies < timeout)
+ while (probe_irq == IRQ_NONE && time_before(jiffies,timeout))
barrier();

NCR5380_write(SELECT_ENABLE_REG, 0);
@@ -1123,7 +1123,7 @@
printk("scsi%d: SCSI bus busy, waiting up to five seconds\n",
instance->host_no);
timeout = jiffies + 5 * HZ;
- while (jiffies < timeout && (NCR5380_read(STATUS_REG) & SR_BSY));
+ while (time_before(jiffies,timeout) && (NCR5380_read(STATUS_REG) & SR_BSY));
break;
case 2:
printk("scsi%d: bus busy, attempting abort\n",
@@ -1417,7 +1417,7 @@
&& !hostdata->dmalen
#endif
#ifdef USLEEP
- && (!hostdata->time_expires || hostdata->time_expires <= jiffies)
+ && (!hostdata->time_expires || time_before_eq(hostdata->time_expires, jiffies))
#endif
) {
restore_flags(flags);
@@ -1532,10 +1532,10 @@

spin_unlock_irq(&io_request_lock);
while (NCR5380_read(BUS_AND_STATUS_REG) & BASR_ACK
- && jiffies < timeout);
+ && time_before(jiffies, timeout));
spin_lock_irq(&io_request_lock);

- if (jiffies >= timeout)
+ if (time_after_eq(jiffies, timeout) )
printk("scsi%d: timeout at NCR5380.c:%d\n",
host->host_no, __LINE__);
}
@@ -1681,11 +1681,11 @@
spin_unlock_irq(&io_request_lock);

while (!(NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_PROGRESS)
- && jiffies < timeout);
+ && time_before(jiffies,timeout));

spin_lock_irq(&io_request_lock);

- if (jiffies >= timeout) {
+ if (time_after_eq(jiffies,timeout)) {
printk("scsi: arbitration timeout at %d\n", __LINE__);
NCR5380_write(MODE_REG, MR_BASE);
NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
@@ -1844,7 +1844,7 @@
waiting period */
#else
spin_unlock_irq(&io_request_lock);
- while ((jiffies < timeout) && !(NCR5380_read(STATUS_REG) &
+ while (time_before(jiffies, timeout) && !(NCR5380_read(STATUS_REG) &
(SR_BSY | SR_IO)));
spin_lock_irq(&io_request_lock);
#endif
@@ -1915,10 +1915,10 @@
unsigned long timeout = jiffies + NCR_TIMEOUT;

spin_unlock_irq(&io_request_lock);
- while (!(NCR5380_read(STATUS_REG) & SR_REQ) && jiffies < timeout);
+ while (!(NCR5380_read(STATUS_REG) & SR_REQ) && time_before(jiffies, timeout));
spin_lock_irq(&io_request_lock);

- if (jiffies >= timeout) {
+ if (time_after_eq(jiffies, timeout)) {
printk("scsi%d: timeout at NCR5380.c:%d\n", __LINE__);
NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
return -1;
@@ -3082,7 +3082,7 @@
{
/* RvC: go to sleep if polling time expired
*/
- if (!cmd->device->disconnect && jiffies >= poll_time)
+ if (!cmd->device->disconnect && time_after_eq(jiffies, poll_time))
{
hostdata->time_expires = jiffies + USLEEP_SLEEP;
#if (NDEBUG & NDEBUG_USLEEP)
Index: linux/drivers/scsi/NCR53c406a.c
diff -u linux/drivers/scsi/NCR53c406a.c:1.1.1.1 linux/drivers/scsi/NCR53c406a.c:1.1.1.1.12.1
--- linux/drivers/scsi/NCR53c406a.c:1.1.1.1 Fri Oct 2 19:23:20 1998
+++ linux/drivers/scsi/NCR53c406a.c Tue Oct 13 17:00:29 1998
@@ -657,10 +657,10 @@
static void wait_intr() {
int i = jiffies + WATCHDOG;

- while(i>jiffies && !(inb(STAT_REG)&0xe0)) /* wait for a pseudo-interrupt */
+ while(time_after(i,jiffies) && !(inb(STAT_REG)&0xe0)) /* wait for a pseudo-interrupt */
barrier();

- if (i <= jiffies) { /* Timed out */
+ if (time_before_eq(i,jiffies)) { /* Timed out */
rtrc(0);
current_SC->result = DID_TIME_OUT << 16;
current_SC->SCp.phase = idle;
@@ -984,9 +984,9 @@

/* Wait for the interrupt to occur */
i = jiffies + WATCHDOG;
- while(i > jiffies && !(inb(STAT_REG) & 0x80))
+ while(time_after(i, jiffies) && !(inb(STAT_REG) & 0x80))
barrier();
- if (i <= jiffies) { /* Timed out, must be hardware trouble */
+ if (time_before_eq(i, jiffies)) { /* Timed out, must be hardware trouble */
probe_irq_off(irqs);
return -1;
}
Index: linux/drivers/scsi/aha152x.c
diff -u linux/drivers/scsi/aha152x.c:1.1.1.1 linux/drivers/scsi/aha152x.c:1.1.1.1.12.1
--- linux/drivers/scsi/aha152x.c:1.1.1.1 Fri Oct 2 19:23:19 1998
+++ linux/drivers/scsi/aha152x.c Tue Oct 13 17:00:29 1998
@@ -574,7 +574,7 @@
{
unsigned long the_time = jiffies + amount; /* 0.01 seconds per jiffy */

- while (jiffies < the_time)
+ while (time_before(jiffies, the_time))
barrier();
}

@@ -1034,7 +1034,7 @@
SETBITS(DMACNTRL0, SWINT);

the_time=jiffies+100;
- while(!HOSTDATA(shpnt)->swint && jiffies<the_time)
+ while(!HOSTDATA(shpnt)->swint && time_before(jiffies, the_time))
barrier();

free_irq(shpnt->irq,0);
Index: linux/drivers/scsi/aic7xxx.c
diff -u linux/drivers/scsi/aic7xxx.c:1.1.1.1.2.1 linux/drivers/scsi/aic7xxx.c:1.1.1.1.2.1.2.2
--- linux/drivers/scsi/aic7xxx.c:1.1.1.1.2.1 Fri Oct 9 19:22:39 1998
+++ linux/drivers/scsi/aic7xxx.c Tue Oct 13 17:48:50 1998
@@ -4008,7 +4008,7 @@
}
if ( (p->dev_active_cmds[tindex] >=
p->dev_temp_queue_depth[tindex]) ||
- (p->dev_last_reset[tindex] >= (jiffies - (4 * HZ))) )
+ time_after_eq(p->dev_last_reset[tindex], jiffies - 4 * HZ) )
{
#ifdef AIC7XXX_VERBOSE_DEBUGGING
if (aic7xxx_verbose > 0xffff)
@@ -4156,7 +4156,7 @@
for(i=0; i<MAX_TARGETS; i++)
{
if ( (p->dev_timer[i].expires) &&
- (p->dev_timer[i].expires <= jiffies) )
+ time_before_eq(p->dev_timer[i].expires, jiffies) )
{
p->dev_timer[i].expires = 0;
if ( (p->dev_timer[i].prev != NULL) ||
Index: linux/drivers/scsi/atari_NCR5380.c
diff -u linux/drivers/scsi/atari_NCR5380.c:1.1.1.1 linux/drivers/scsi/atari_NCR5380.c:1.1.1.1.12.1
--- linux/drivers/scsi/atari_NCR5380.c:1.1.1.1 Fri Oct 2 19:23:21 1998
+++ linux/drivers/scsi/atari_NCR5380.c Tue Oct 13 17:00:30 1998
@@ -1459,9 +1459,9 @@
unsigned long timeout = jiffies + 2*NCR_TIMEOUT;

while (!(NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_PROGRESS)
- && jiffies < timeout && !hostdata->connected)
+ && time_before(jiffies, timeout) && !hostdata->connected)
;
- if (jiffies >= timeout)
+ if (time_after_eq(jiffies, timeout))
{
printk("scsi : arbitration timeout at %d\n", __LINE__);
NCR5380_write(MODE_REG, MR_BASE);
@@ -1616,7 +1616,7 @@
* only wait for BSY... (Famous german words: Der Klügere gibt nach :-)
*/

- while ((jiffies < timeout) && !(NCR5380_read(STATUS_REG) &
+ while (time_before(jiffies, timeout) && !(NCR5380_read(STATUS_REG) &
(SR_BSY | SR_IO)));

if ((NCR5380_read(STATUS_REG) & (SR_SEL | SR_IO)) ==
@@ -1629,7 +1629,7 @@
return -1;
}
#else
- while ((jiffies < timeout) && !(NCR5380_read(STATUS_REG) & SR_BSY));
+ while (time_before(jiffies, timeout) && !(NCR5380_read(STATUS_REG) & SR_BSY));
#endif

/*
Index: linux/drivers/scsi/atari_scsi.c
diff -u linux/drivers/scsi/atari_scsi.c:1.1.1.1 linux/drivers/scsi/atari_scsi.c:1.1.1.1.12.1
--- linux/drivers/scsi/atari_scsi.c:1.1.1.1 Fri Oct 2 19:23:20 1998
+++ linux/drivers/scsi/atari_scsi.c Tue Oct 13 17:00:30 1998
@@ -892,7 +892,7 @@
NCR5380_write( INITIATOR_COMMAND_REG, ICR_BASE );
NCR5380_read( RESET_PARITY_INTERRUPT_REG );

- for( end = jiffies + AFTER_RESET_DELAY; jiffies < end; )
+ for( end = jiffies + AFTER_RESET_DELAY; time_before(jiffies,end); )
barrier();

printk( " done\n" );
Index: linux/drivers/scsi/eata_dma.c
diff -u linux/drivers/scsi/eata_dma.c:1.1.1.1 linux/drivers/scsi/eata_dma.c:1.1.1.1.12.1
--- linux/drivers/scsi/eata_dma.c:1.1.1.1 Fri Oct 2 19:23:20 1998
+++ linux/drivers/scsi/eata_dma.c Tue Oct 13 17:00:30 1998
@@ -962,7 +962,7 @@
eata_send_command((u32) cp, (u32) base, EATA_CMD_DMA_SEND_CP);

i = jiffies + (3 * HZ);
- while (fake_int_happened == FALSE && jiffies <= i)
+ while (fake_int_happened == FALSE && time_before_eq(jiffies, i))
barrier();

DBG(DBG_INTR3, printk(KERN_DEBUG "fake_int_result: %#x hbastat %#x "
@@ -973,7 +973,7 @@
scsi_init_free((void *)cp, sizeof(struct eata_ccb));
scsi_init_free((void *)sp, sizeof(struct eata_sp));

- if ((fake_int_result & HA_SERROR) || jiffies > i){
+ if ((fake_int_result & HA_SERROR) || time_after(jiffies, i)){
printk(KERN_WARNING "eata_dma: trying to reset HBA at %x to clear "
"possible blink state\n", base);
/* hard reset the HBA */
Index: linux/drivers/scsi/eata_pio.c
diff -u linux/drivers/scsi/eata_pio.c:1.1.1.1 linux/drivers/scsi/eata_pio.c:1.1.1.1.12.1
--- linux/drivers/scsi/eata_pio.c:1.1.1.1 Fri Oct 2 19:23:20 1998
+++ linux/drivers/scsi/eata_pio.c Tue Oct 13 17:00:30 1998
@@ -500,7 +500,7 @@
HD(cmd)->state = RESET;

time = jiffies;
- while (jiffies < (time + (3 * HZ)) && limit++ < 10000000);
+ while (time_before(jiffies, time + 3 * HZ) && limit++ < 10000000);

DBG(DBG_ABNORM, printk(KERN_WARNING "eata_pio_reset: interrupts disabled, "
"loops %d.\n", limit));
Index: linux/drivers/scsi/imm.c
diff -u linux/drivers/scsi/imm.c:1.1.1.1.2.1 linux/drivers/scsi/imm.c:1.1.1.1.2.1.2.2
--- linux/drivers/scsi/imm.c:1.1.1.1.2.1 Fri Oct 2 19:39:32 1998
+++ linux/drivers/scsi/imm.c Tue Oct 13 17:48:53 1998
@@ -186,7 +186,7 @@
while (imm_hosts[i].p_busy)
{
schedule(); /* We are safe to schedule here */
- if (jiffies > now + 3*HZ)
+ if (time_after(jiffies,now + 3*HZ))
{
printk(KERN_ERR "imm%d: failed to claim parport because a "
"pardevice is owning the port for too longtime!\n",
@@ -831,7 +831,7 @@
* If we have been running for more than a full timer tick
* then take a rest.
*/
- if (jiffies > start_jiffies + 1)
+ if (time_after(jiffies,start_jiffies + 1))
return 0;

/*
Index: linux/drivers/scsi/mac_NCR5380.c
diff -u linux/drivers/scsi/mac_NCR5380.c:1.1.1.1 linux/drivers/scsi/mac_NCR5380.c:1.1.1.1.12.1
--- linux/drivers/scsi/mac_NCR5380.c:1.1.1.1 Fri Oct 2 19:23:23 1998
+++ linux/drivers/scsi/mac_NCR5380.c Tue Oct 13 17:00:31 1998
@@ -1458,9 +1458,9 @@
unsigned long timeout = jiffies + 2*NCR_TIMEOUT;

while (!(NCR5380_read(INITIATOR_COMMAND_REG) & ICR_ARBITRATION_PROGRESS)
- && jiffies < timeout && !hostdata->connected)
+ && time_before(jiffies, timeout) && !hostdata->connected)
;
- if (jiffies >= timeout)
+ if (time_after_eq(jiffies, timeout))
{
printk("scsi : arbitration timeout at %d\n", __LINE__);
NCR5380_write(MODE_REG, MR_BASE);
@@ -1615,7 +1615,7 @@
* only wait for BSY... (Famous german words: Der Klügere gibt nach :-)
*/

- while ((jiffies < timeout) && !(NCR5380_read(STATUS_REG) &
+ while (time_before(jiffies, timeout) && !(NCR5380_read(STATUS_REG) &
(SR_BSY | SR_IO)));

if ((NCR5380_read(STATUS_REG) & (SR_SEL | SR_IO)) ==
@@ -1628,7 +1628,7 @@
return -1;
}
#else
- while ((jiffies < timeout) && !(NCR5380_read(STATUS_REG) & SR_BSY));
+ while (time_before(jiffies, timeout) && !(NCR5380_read(STATUS_REG) & SR_BSY));
#endif

/*
Index: linux/drivers/scsi/mac_scsi.c
diff -u linux/drivers/scsi/mac_scsi.c:1.1.1.1 linux/drivers/scsi/mac_scsi.c:1.1.1.1.12.1
--- linux/drivers/scsi/mac_scsi.c:1.1.1.1 Fri Oct 2 19:23:23 1998
+++ linux/drivers/scsi/mac_scsi.c Tue Oct 13 17:00:31 1998
@@ -662,7 +662,7 @@
NCR5380_write( INITIATOR_COMMAND_REG, ICR_BASE );
NCR5380_read( RESET_PARITY_INTERRUPT_REG );

- for( end = jiffies + AFTER_RESET_DELAY; jiffies < end; )
+ for( end = jiffies + AFTER_RESET_DELAY; time_before(jiffies, end); )
barrier();

/* switch on SCSI IRQ again */
Index: linux/drivers/scsi/ncr53c8xx.c
diff -u linux/drivers/scsi/ncr53c8xx.c:1.1.1.1.2.1 linux/drivers/scsi/ncr53c8xx.c:1.1.1.1.2.1.2.2
--- linux/drivers/scsi/ncr53c8xx.c:1.1.1.1.2.1 Fri Oct 9 19:22:43 1998
+++ linux/drivers/scsi/ncr53c8xx.c Tue Oct 13 17:48:53 1998
@@ -5036,7 +5036,7 @@
** Force ordered tag if necessary to avoid timeouts
** and to preserve interactivity.
*/
- if (lp && lp->tags_stime + (3*HZ) <= jiffies) {
+ if (lp && time_before_eq(lp->tags_stime + 3*HZ, jiffies)) {
if (lp->tags_smap) {
order = M_ORDERED_TAG;
if ((DEBUG_FLAGS & DEBUG_TAGS)||bootverbose>2){
Index: linux/drivers/scsi/pci2000.c
diff -u linux/drivers/scsi/pci2000.c:1.1.1.1 linux/drivers/scsi/pci2000.c:1.1.1.1.12.1
--- linux/drivers/scsi/pci2000.c:1.1.1.1 Fri Oct 2 19:23:21 1998
+++ linux/drivers/scsi/pci2000.c Tue Oct 13 17:00:31 1998
@@ -108,7 +108,7 @@
do {
if ( !inb_p (padapter->cmd) )
return FALSE;
- } while ( timer > jiffies ); // test for timeout
+ } while ( time_after(timer, jiffies) ); // test for timeout
return TRUE;
}
/****************************************************************
Index: linux/drivers/scsi/pci2220i.c
diff -u linux/drivers/scsi/pci2220i.c:1.1.1.1 linux/drivers/scsi/pci2220i.c:1.1.1.1.12.1
--- linux/drivers/scsi/pci2220i.c:1.1.1.1 Fri Oct 2 19:23:22 1998
+++ linux/drivers/scsi/pci2220i.c Tue Oct 13 17:00:31 1998
@@ -152,7 +152,7 @@
outb_p (0x03, padapter->regDmaCmdStat); // kick the DMA engine in gear
return 0;
}
- } while ( timer > jiffies ); // test for timeout
+ } while ( time_after(timer, jiffies) ); // test for timeout

padapter->ide.ide.ides.cmd = 0; // null out the command byte
return 1;
@@ -192,7 +192,7 @@
return (WriteData (padapter));
return 0;
}
- } while ( timer > jiffies ); // test for timeout
+ } while ( time_after(timer, jiffies) ); // test for timeout

padapter->ide.ide.ides.cmd = 0; // null out the command byte
return status;
Index: linux/drivers/scsi/ppa.c
diff -u linux/drivers/scsi/ppa.c:1.1.1.1.2.1 linux/drivers/scsi/ppa.c:1.1.1.1.2.1.2.2
--- linux/drivers/scsi/ppa.c:1.1.1.1.2.1 Fri Oct 2 19:39:32 1998
+++ linux/drivers/scsi/ppa.c Tue Oct 13 17:48:53 1998
@@ -147,7 +147,7 @@
while (ppa_hosts[i].p_busy)
{
schedule(); /* We are safe to schedule here */
- if (jiffies > now + 3*HZ)
+ if (time_after(jiffies,now + 3*HZ))
{
printk(KERN_ERR "ppa%d: failed to claim parport because a "
"pardevice is owning the port for too longtime!\n",
@@ -867,7 +867,7 @@
* If we have been running for more than a full timer tick
* then take a rest.
*/
- if (jiffies > start_jiffies + 1)
+ if (time_after(jiffies,start_jiffies + 1))
return 0;

if (((r & 0xc0) != 0xc0) || (cmd->SCp.this_residual <= 0)) {
Index: linux/drivers/scsi/psi240i.c
diff -u linux/drivers/scsi/psi240i.c:1.1.1.1 linux/drivers/scsi/psi240i.c:1.1.1.1.12.1
--- linux/drivers/scsi/psi240i.c:1.1.1.1 Fri Oct 2 19:23:22 1998
+++ linux/drivers/scsi/psi240i.c Tue Oct 13 17:00:31 1998
@@ -129,7 +129,7 @@
outsw (pports[PORT_DATA], padapter->buffer, (USHORT)padapter->ide.ide.ide[2] * 256);
return 0;
}
- } while ( timer > jiffies ); // test for timeout
+ } while ( time_after(timer, jiffies) ); // test for timeout

padapter->ide.ide.ides.cmd = 0; // null out the command byte
return 1;
@@ -169,7 +169,7 @@

return 0;
}
- } while ( timer > jiffies ); // test for timeout
+ } while ( time_after(timer, jiffies) ); // test for timeout

padapter->ide.ide.ides.cmd = 0; // null out the command byte
return status;
Index: linux/drivers/scsi/qlogicfas.c
diff -u linux/drivers/scsi/qlogicfas.c:1.1.1.1 linux/drivers/scsi/qlogicfas.c:1.1.1.1.12.1
--- linux/drivers/scsi/qlogicfas.c:1.1.1.1 Fri Oct 2 19:23:21 1998
+++ linux/drivers/scsi/qlogicfas.c Tue Oct 13 17:00:31 1998
@@ -276,9 +276,9 @@
int i,k;
k = 0;
i = jiffies + WATCHDOG;
- while ( i > jiffies && !qabort && !((k = inb(qbase + 4)) & 0xe0))
+ while ( time_after(i, jiffies) && !qabort && !((k = inb(qbase + 4)) & 0xe0))
barrier();
- if (i <= jiffies)
+ if (time_before_eq(i, jiffies))
return (DID_TIME_OUT);
if (qabort)
return (qabort == 1 ? DID_ABORT : DID_RESET);
@@ -408,8 +408,8 @@
}
/*** Enter Status (and Message In) Phase ***/
k = jiffies + WATCHDOG;
- while ( k > jiffies && !qabort && !(inb(qbase + 4) & 6)); /* wait for status phase */
- if ( k <= jiffies ) {
+ while ( time_after(k, jiffies) && !qabort && !(inb(qbase + 4) & 6)); /* wait for status phase */
+ if ( time_before_eq(k, jiffies) ) {
ql_zap();
return (DID_TIME_OUT << 16);
}
Index: linux/drivers/scsi/scsi.c
diff -u linux/drivers/scsi/scsi.c:1.1.1.1.2.1 linux/drivers/scsi/scsi.c:1.1.1.1.2.1.2.1
--- linux/drivers/scsi/scsi.c:1.1.1.1.2.1 Fri Oct 9 19:22:44 1998
+++ linux/drivers/scsi/scsi.c Tue Oct 13 17:00:32 1998
@@ -1296,7 +1296,7 @@
*/
timeout = host->last_reset + MIN_RESET_DELAY;

- if (jiffies < timeout) {
+ if (time_before(jiffies, timeout)) {
int ticks_remaining = timeout - jiffies;
/*
* NOTE: This may be executed from within an interrupt
@@ -1366,7 +1366,7 @@
#ifdef DEBUG_DELAY
clock = jiffies + 4 * HZ;
spin_unlock_irq(&io_request_lock);
- while (jiffies < clock) barrier();
+ while (time_before(jiffies, clock)) barrier();
spin_lock_irq(&io_request_lock);
printk("done(host = %d, result = %04x) : routine at %p\n",
host->host_no, temp, host->hostt->command);
Index: linux/drivers/scsi/scsi_obsolete.c
diff -u linux/drivers/scsi/scsi_obsolete.c:1.1.1.1.2.1 linux/drivers/scsi/scsi_obsolete.c:1.1.1.1.2.1.2.2
--- linux/drivers/scsi/scsi_obsolete.c:1.1.1.1.2.1 Fri Oct 9 19:22:44 1998
+++ linux/drivers/scsi/scsi_obsolete.c Tue Oct 13 17:48:54 1998
@@ -608,7 +608,8 @@
{
if ((SCpnt->retries >= (SCpnt->allowed >> 1))
&& !(SCpnt->host->last_reset > 0 &&
- jiffies < SCpnt->host->last_reset + MIN_RESET_PERIOD)
+ time_before(jiffies, SCpnt->host->last_reset
+ + MIN_RESET_PERIOD))
&& !(SCpnt->flags & WAS_RESET))
{
printk("scsi%d channel %d : resetting for second half of retries.\n",
Index: linux/drivers/scsi/sd.c
diff -u linux/drivers/scsi/sd.c:1.1.1.1.2.1 linux/drivers/scsi/sd.c:1.1.1.1.2.1.2.1
--- linux/drivers/scsi/sd.c:1.1.1.1.2.1 Mon Oct 5 18:21:26 1998
+++ linux/drivers/scsi/sd.c Tue Oct 13 17:00:32 1998
@@ -1110,8 +1110,8 @@
unsigned char cmd[10];
char nbuff[6];
unsigned char *buffer;
- unsigned long spintime;
- int the_result, retries;
+ unsigned long spintime_value;
+ int the_result, retries, spintime;
Scsi_Cmnd * SCpnt;

/*
@@ -1206,16 +1206,18 @@
SCpnt->request.sem = NULL;
}

- spintime = jiffies;
+ spintime = 1;
+ spintime_value = jiffies
}

time1 = jiffies + HZ;
spin_unlock_irq(&io_request_lock);
- while(jiffies < time1); /* Wait 1 second for next try */
+ while(time_before(jiffies, time1)); /* Wait 1 second for next try */
printk( "." );
spin_lock_irq(&io_request_lock);
}
- } while(the_result && spintime && spintime+100*HZ > jiffies);
+ } while(the_result && spintime &&
+ time_after(spintime_value+100*HZ, jiffies));
if (spintime) {
if (the_result)
printk( "not responding...\n" );
Index: linux/drivers/scsi/seagate.c
diff -u linux/drivers/scsi/seagate.c:1.1.1.1 linux/drivers/scsi/seagate.c:1.1.1.1.12.1
--- linux/drivers/scsi/seagate.c:1.1.1.1 Fri Oct 2 19:23:19 1998
+++ linux/drivers/scsi/seagate.c Tue Oct 13 17:00:32 1998
@@ -379,8 +379,8 @@
{
register int count = 0, start = jiffies + 1, stop = start + 25;

- while (jiffies < start) ;
- for (; jiffies < stop; ++count) ;
+ while (time_before(jiffies, start)) ;
+ for (; time_before(jiffies, stop); ++count) ;

/*
* Ok, we now have a count for .25 seconds. Convert to a
@@ -903,9 +903,9 @@

while (((STATUS | STATUS | STATUS) &
(STAT_BSY | STAT_SEL)) &&
- (!st0x_aborted) && (jiffies < clock));
+ (!st0x_aborted) && time_before(jiffies, clock));

- if (jiffies > clock)
+ if (time_after(jiffies, clock))
return retcode (DID_BUS_BUSY);
else if (st0x_aborted)
return retcode (st0x_aborted);
Index: linux/drivers/scsi/wd7000.c
diff -u linux/drivers/scsi/wd7000.c:1.1.1.1 linux/drivers/scsi/wd7000.c:1.1.1.1.12.1
--- linux/drivers/scsi/wd7000.c:1.1.1.1 Fri Oct 2 19:23:19 1998
+++ linux/drivers/scsi/wd7000.c Tue Oct 13 17:00:32 1998
@@ -786,7 +786,7 @@
register unsigned WAITbits;
register unsigned long WAITtimeout = jiffies + WAITnexttimeout;

- while (jiffies <= WAITtimeout) {
+ while (time_before_eq(jiffies, WAITtimeout)) {
WAITbits = inb (port) & mask;

if (((WAITbits & allof) == allof) && ((WAITbits & noneof) == 0))
@@ -801,7 +801,7 @@
{
register unsigned long time = jiffies + how_long;

- while (jiffies < time);
+ while (time_before(jiffies, time));
}


@@ -863,7 +863,7 @@
spin_unlock_irq(&io_request_lock);
for (now = jiffies; now == jiffies; ); /* wait a jiffy */
spin_lock_irq(&io_request_lock);
- } while (freescbs < needed && jiffies <= timeout);
+ } while (freescbs < needed && time_before_eq(jiffies, timeout));
/*
* If we get here with enough free Scbs, we can take them.
* Otherwise, we timed out and didn't get enough.
@@ -1242,7 +1242,7 @@
*/
mail_out (host, (struct scb *) &icb);
timeout = jiffies + WAITnexttimeout; /* wait up to 2 seconds */
- while (icb.phase && jiffies < timeout)
+ while (icb.phase && time_before(jiffies, timeout))
barrier (); /* wait for completion */

if (icb.phase) {
Index: linux/include/linux/arcdevice.h
diff -u linux/include/linux/arcdevice.h:1.1.1.1 linux/include/linux/arcdevice.h:1.1.1.1.12.1
--- linux/include/linux/arcdevice.h:1.1.1.1 Fri Oct 2 19:22:40 1998
+++ linux/include/linux/arcdevice.h Tue Oct 13 17:28:38 1998
@@ -192,7 +192,7 @@



-#define JIFFER(time) for (delayval=jiffies+time; jiffies<delayval;) ;
+#define JIFFER(time) for (delayval=jiffies+time; time_before(jiffies,delayval);) ;

/* a complete ARCnet packet */
union ArcPacket
Index: linux/include/linux/timer.h
diff -u linux/include/linux/timer.h:1.1.1.1 linux/include/linux/timer.h:1.1.1.1.12.2
--- linux/include/linux/timer.h:1.1.1.1 Fri Oct 2 19:22:40 1998
+++ linux/include/linux/timer.h Tue Oct 13 18:01:05 1998
@@ -84,9 +84,19 @@
return((long)((a) - (b)) < 0L);
}

+extern inline int time_before_eq(unsigned long a, unsigned long b)
+{
+ return((long)((a) - (b)) <= 0L);
+}
+
extern inline int time_after(unsigned long a, unsigned long b)
{
return((long)((a) - (b)) > 0L);
+}
+
+extern inline int time_after_eq(unsigned long a, unsigned long b)
+{
+ return((long)((a) - (b)) >= 0L);
}

#endif

Andrea Arcangeli

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/