All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] fix compares of jiffies
@ 2001-12-28 21:23 Tim Schmielau
  0 siblings, 0 replies; 8+ messages in thread
From: Tim Schmielau @ 2001-12-28 21:23 UTC (permalink / raw)
  To: dmalek; +Cc: source, benh, linuxppc-dev, tim


Dear Linux kernel code maintainer,

some weeks ago in the course of a discussion on lkml
(see http://www.uwsg.indiana.edu/hypermail/linux/kernel/0110.3/1553.html
and follow-ups) linux kernels of the 2.4 series turned out to sometime
lock up after 497.1 days of uptime, when the "jiffies" variable wraps
back to zero.

Checking the kernel code, I found a number of places where jiffies
were compared in a way that seems to break when they wrap. For these,
I made up patches to use the macros "time_before()" or "time_after()"
that are supposed to handle wraparound correctly.

For a small part of the patches, I believe you to be the relevant kernel code
maintainer. Appended to this email you will find some lines explaining
why I decided to mail or cc: you on this (an extract of the copyright notice
or the MAINTAINERS file), followed by the patch itself. If I mailed you
in error, please drop me a short note.

I kindly ask you to approve the correctness of the patch, and pass it on to
the relevant people for inclusion into the mainline kernel.

Thanks,
Tim Schmielau (tim@physik3.uni-rostock.de)



/*
 * BK Id: SCCS/s.uart.c 1.19 10/26/01 09:59:32 trini
 */
/*
 *  UART driver for MPC860 CPM SCC or SMC
 *  Copyright (c) 1997 Dan Malek (dmalek@jlc.net)
 *

/*
 * BK Id: SCCS/s.uart.c 1.6 05/17/01 18:14:20 cort
 */
/*
 *  UART driver for MPC8260 CPM SCC or SMC
 *  Copyright (c) 1999 Dan Malek (dmalek@jlc.net)
 *  Copyright (c) 2000 MontaVista Software, Inc. (source@mvista.com)
 *	2.3.99 updates
 *

LINUX FOR POWER MACINTOSH
P:	Benjamin Herrenschmidt
M:	benh@kernel.crashing.org
W:	http://www.linuxppc.org/
L:	linuxppc-dev@lists.linuxppc.org
S:	Maintained



--- linux-2.4.18-pre1/arch/ppc/8xx_io/uart.c	Sat Nov  3 02:43:54 2001
+++ linux-2.4.18-pre1-jiffies64/arch/ppc/8xx_io/uart.c	Fri Dec 28 15:07:17 2001
@@ -1802,7 +1802,7 @@
 		schedule_timeout(char_time);
 		if (signal_pending(current))
 			break;
-		if (timeout && ((orig_jiffies + timeout) < jiffies))
+		if (timeout && time_after(jiffies, orig_jiffies + timeout))
 			break;

 		/* The 'tx_cur' is really the next buffer to send.  We
--- linux-2.4.18-pre1/arch/ppc/8260_io/uart.c	Tue May 22 02:04:46 2001
+++ linux-2.4.18-pre1-jiffies64/arch/ppc/8260_io/uart.c	Fri Dec 28 15:11:16 2001
@@ -1736,7 +1736,7 @@
 		schedule_timeout(char_time);
 		if (signal_pending(current))
 			break;
-		if (timeout && ((orig_jiffies + timeout) < jiffies))
+		if (timeout && time_after(jiffies, orig_jiffies + timeout))
 			break;
 		bdp = info->tx_cur;
 	} while (bdp->cbd_sc & BD_SC_READY);

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [patch] fix compares of jiffies
@ 2001-12-28 21:23 Tim Schmielau
  0 siblings, 0 replies; 8+ messages in thread
From: Tim Schmielau @ 2001-12-28 21:23 UTC (permalink / raw)
  To: ralf; +Cc: linux-mips, tim

Dear Linux kernel code maintainer,

some weeks ago in the course of a discussion on lkml
(see http://www.uwsg.indiana.edu/hypermail/linux/kernel/0110.3/1553.html
and follow-ups) linux kernels of the 2.4 series turned out to sometime
lock up after 497.1 days of uptime, when the "jiffies" variable wraps
back to zero.

Checking the kernel code, I found a number of places where jiffies
were compared in a way that seems to break when they wrap. For these,
I made up patches to use the macros "time_before()" or "time_after()"
that are supposed to handle wraparound correctly.

For a small part of the patches, I believe you to be the relevant kernel code
maintainer. Appended to this email you will find some lines explaining
why I decided to mail or cc: you on this (an extract of the copyright notice
or the MAINTAINERS file), followed by the patch itself. If I mailed you
in error, please drop me a short note.

I kindly ask you to approve the correctness of the patch, and pass it on to
the relevant people for inclusion into the mainline kernel.

Thanks,
Tim Schmielau (tim@physik3.uni-rostock.de)



MIPS
P:	Ralf Baechle
M:	ralf@gnu.org
W:	http://oss.sgi.com/mips/mips-howto.html
L:	linux-mips@oss.sgi.com
S:	Maintained


--- linux-2.4.18-pre1/arch/mips/baget/vacserial.c	Sun Sep  9 19:43:01 2001
+++ linux-2.4.18-pre1-jiffies64/arch/mips/baget/vacserial.c	Fri Dec 28 14:57:14 2001
@@ -1785,7 +1785,7 @@
 		schedule_timeout(char_time);
 		if (signal_pending(current))
 			break;
-		if (timeout && ((orig_jiffies + timeout) < jiffies))
+		if (timeout && time_after(jiffies, orig_jiffies + timeout))
 			break;
 	}
 	current->state = TASK_RUNNING;

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [patch] fix compares of jiffies
@ 2002-09-22 11:45 Tim Schmielau
  0 siblings, 0 replies; 8+ messages in thread
From: Tim Schmielau @ 2002-09-22 11:45 UTC (permalink / raw)
  To: linux-sound

Dear Linux kernel code maintainer,

on rechecking the current stable kernel code, I found some places where jiffies
were compared in a way that seems to break when they wrap. For these,
I made up patches to use the macros "time_before()" or "time_after()"
that are supposed to handle wraparound correctly.

For a small part of the patches, I believe you to be the relevant kernel code
maintainer. Appended to this email you will find some lines explaining
why I decided to mail or cc: you on this (an extract of the copyright notice
or the MAINTAINERS file), followed by the patch itself. If I mailed you
in error, please drop me a short note.

I kindly ask you to approve the correctness of the patch, and pass it on to
the relevant people for inclusion into the mainline kernel.

Thanks,
Tim Schmielau (tim@physik3.uni-rostock.de)



 * 04-07-1999: Anthony Barbachan <barbcode@xmen.cis.fordham.edu>
 *          Added module parameter pss_firmware to allow the user to tell 
 *          the driver where the fireware file is located.  The default 
 *          setting is the previous hardcoded setting "/etc/sound/pss_synth".


--- linux-2.4.20-pre6/drivers/sound/pss.c	Wed Sep 11 13:36:53 2002
+++ linux-2.4.20-pre6-jfix/drivers/sound/pss.c	Wed Sep 11 12:58:44 2002
@@ -263,7 +263,7 @@
 	unsigned long   i, limit = jiffies + HZ/10;
 
 	outw(0x2000, REG(PSS_CONTROL));
-	for (i = 0; i < 32768 && (limit-jiffies >= 0); i++)
+	for (i = 0; i < 32768 && time_before_eq(jiffies, limit); i++)
 		inw(REG(PSS_CONTROL));
 	outw(0x0000, REG(PSS_CONTROL));
 	return 1;
@@ -362,11 +362,11 @@
 		outw(0, REG(PSS_DATA));
 
 		limit = jiffies + HZ/10;
-		for (i = 0; i < 32768 && (limit - jiffies >= 0); i++)
+		for (i = 0; i < 32768 && time_before_eq(jiffies, limit); i++)
 			val = inw(REG(PSS_STATUS));
 
 		limit = jiffies + HZ/10;
-		for (i = 0; i < 32768 && (limit-jiffies >= 0); i++)
+		for (i = 0; i < 32768 && time_before_eq(jiffies, limit); i++)
 		{
 			val = inw(REG(PSS_STATUS));
 			if (val & 0x4000)


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [patch] fix compares of jiffies
@ 2002-09-22 11:45 Tim Schmielau
  0 siblings, 0 replies; 8+ messages in thread
From: Tim Schmielau @ 2002-09-22 11:45 UTC (permalink / raw)
  To: lw_linux; +Cc: linux-scsi, tim

Dear Linux kernel code maintainer,

on rechecking the current stable kernel code, I found some places where jiffies
were compared in a way that seems to break when they wrap. For these,
I made up patches to use the macros "time_before()" or "time_after()"
that are supposed to handle wraparound correctly.

For a small part of the patches, I believe you to be the relevant kernel code
maintainer. Appended to this email you will find some lines explaining
why I decided to mail or cc: you on this (an extract of the copyright notice
or the MAINTAINERS file), followed by the patch itself. If I mailed you
in error, please drop me a short note.

I kindly ask you to approve the correctness of the patch, and pass it on to
the relevant people for inclusion into the mainline kernel.

Thanks,
Tim Schmielau (tim@physik3.uni-rostock.de)



/* 
 *  sym53c416.c
 *  Low-level SCSI driver for sym53c416 chip.
 *  Copyright (C) 1998 Lieven Willems (lw_linux@hotmail.com)


--- linux-2.4.20-pre6/drivers/scsi/sym53c416.c	Sun Sep 30 21:26:07 2001
+++ linux-2.4.20-pre6-jfix/drivers/scsi/sym53c416.c	Wed Sep 11 12:53:08 2002
@@ -277,7 +277,7 @@
 		{
 			i = jiffies + timeout;
 			restore_flags(flags);
-			while(jiffies < i && (inb(base + PIO_INT_REG) & EMPTY) && timeout)
+			while(time_before(jiffies, i) && (inb(base + PIO_INT_REG) & EMPTY) && timeout)
 				if(inb(base + PIO_INT_REG) & SCI)
 					timeout = 0;
 			save_flags(flags);
@@ -323,7 +323,7 @@
 		{
 			i = jiffies + timeout;
 			restore_flags(flags);
-			while(jiffies < i && (inb(base + PIO_INT_REG) & FULL) && timeout)
+			while(time_before(jiffies, i) && (inb(base + PIO_INT_REG) & FULL) && timeout)
 				;
 			save_flags(flags);
 			cli();
@@ -559,9 +559,9 @@
 	outb(0x00, base + DEST_BUS_ID);
 	/* Wait for interrupt to occur */
 	i = jiffies + 20;
-	while(i > jiffies && !(inb(base + STATUS_REG) & SCI))
+	while(time_before(jiffies, i) && !(inb(base + STATUS_REG) & SCI))
 		barrier();
-	if(i <= jiffies) /* timed out */
+	if(time_after_eq(jiffies, i)) /* timed out */
 		return 0;
 	/* Get occurred irq */
 	irq = probe_irq_off(irqs);


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [patch] fix compares of jiffies
@ 2002-09-22 11:45 Tim Schmielau
  0 siblings, 0 replies; 8+ messages in thread
From: Tim Schmielau @ 2002-09-22 11:45 UTC (permalink / raw)
  To: linux-scsi; +Cc: tim

Dear Linux kernel code maintainer,

on rechecking the current stable kernel code, I found some places where jiffies
were compared in a way that seems to break when they wrap. For these,
I made up patches to use the macros "time_before()" or "time_after()"
that are supposed to handle wraparound correctly.

For a small part of the patches, I believe you to be the relevant kernel code
maintainer. Appended to this email you will find some lines explaining
why I decided to mail or cc: you on this (an extract of the copyright notice
or the MAINTAINERS file), followed by the patch itself. If I mailed you
in error, please drop me a short note.

I kindly ask you to approve the correctness of the patch, and pass it on to
the relevant people for inclusion into the mainline kernel.

Thanks,
Tim Schmielau (tim@physik3.uni-rostock.de)



--- linux-2.4.20-pre6/drivers/scsi/scsi_obsolete.c	Sat Aug  3 02:39:44 2002
+++ linux-2.4.20-pre6-jfix/drivers/scsi/scsi_obsolete.c	Wed Sep 11 12:47:46 2002
@@ -967,7 +967,7 @@
 				   that the delay in internal_cmnd will guarantee at least a
 				   MIN_RESET_DELAY bus settle time.
 				 */
-				if (host->last_reset - jiffies > 20UL * HZ)
+				if (time_before(jiffies, host->last_reset - 20UL * HZ))
 					host->last_reset = jiffies;
 			} else {
 				host->host_busy++;


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [patch] fix compares of jiffies
@ 2002-09-22 11:45 Tim Schmielau
  0 siblings, 0 replies; 8+ messages in thread
From: Tim Schmielau @ 2002-09-22 11:45 UTC (permalink / raw)
  To: linux-serial; +Cc: tim

Dear Linux kernel code maintainer,

on rechecking the current stable kernel code, I found some places where jiffies
were compared in a way that seems to break when they wrap. For these,
I made up patches to use the macros "time_before()" or "time_after()"
that are supposed to handle wraparound correctly.

For a small part of the patches, I believe you to be the relevant kernel code
maintainer. Appended to this email you will find some lines explaining
why I decided to mail or cc: you on this (an extract of the copyright notice
or the MAINTAINERS file), followed by the patch itself. If I mailed you
in error, please drop me a short note.

I kindly ask you to approve the correctness of the patch, and pass it on to
the relevant people for inclusion into the mainline kernel.

Thanks,
Tim Schmielau (tim@physik3.uni-rostock.de)



--- linux-2.4.20-pre6/drivers/char/sb1250_duart.c	Sat Aug  3 02:39:43 2002
+++ linux-2.4.20-pre6-jfix/drivers/char/sb1250_duart.c	Wed Sep 11 12:31:18 2002
@@ -543,7 +543,7 @@
 	target_time = jiffies + timeout;
 	line = get_line(tty);
 	us = &uart_states[line];
-	while (!(get_status_reg(line) & M_DUART_TX_EMT) && (jiffies < target_time)) {
+	while (!(get_status_reg(line) & M_DUART_TX_EMT) && time_before(jiffies, target_time)) {
 	 	schedule_timeout(1);
 	}
 #ifdef DUART_SPEW


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [patch] fix compares of jiffies
@ 2002-09-22 11:45 Tim Schmielau
  0 siblings, 0 replies; 8+ messages in thread
From: Tim Schmielau @ 2002-09-22 11:45 UTC (permalink / raw)
  To: mike; +Cc: linux-eata, linux-scsi, tim

Dear Linux kernel code maintainer,

on rechecking the current stable kernel code, I found some places where jiffies
were compared in a way that seems to break when they wrap. For these,
I made up patches to use the macros "time_before()" or "time_after()"
that are supposed to handle wraparound correctly.

For a small part of the patches, I believe you to be the relevant kernel code
maintainer. Appended to this email you will find some lines explaining
why I decided to mail or cc: you on this (an extract of the copyright notice
or the MAINTAINERS file), followed by the patch itself. If I mailed you
in error, please drop me a short note.

I kindly ask you to approve the correctness of the patch, and pass it on to
the relevant people for inclusion into the mainline kernel.

Thanks,
Tim Schmielau (tim@physik3.uni-rostock.de)



EATA-DMA SCSI DRIVER
P:	Michael Neuffer
M:	mike@i-Connect.Net
L:	linux-eata@i-connect.net, linux-scsi@vger.kernel.org
S:	Maintained


--- linux-2.4.20-pre6/drivers/scsi/eata_generic.h	Wed Aug 15 10:22:16 2001
+++ linux-2.4.20-pre6-jfix/drivers/scsi/eata_generic.h	Wed Sep 11 12:48:52 2002
@@ -97,7 +97,7 @@
 #define DELAY(x) { ulong flags, i;                \
                    save_flags(flags); sti();      \
                    i = jiffies + (x * HZ);        \
-                   while (jiffies < i);           \
+                   while (time_before(jiffies, i));           \
                    restore_flags(flags); }
 
 /***********************************************


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [patch] fix compares of jiffies
@ 2002-09-22 11:45 Tim Schmielau
  0 siblings, 0 replies; 8+ messages in thread
From: Tim Schmielau @ 2002-09-22 11:45 UTC (permalink / raw)
  To: support; +Cc: linux-serial, tim

Dear Linux kernel code maintainer,

on rechecking the current stable kernel code, I found some places where jiffies
were compared in a way that seems to break when they wrap. For these,
I made up patches to use the macros "time_before()" or "time_after()"
that are supposed to handle wraparound correctly.

For a small part of the patches, I believe you to be the relevant kernel code
maintainer. Appended to this email you will find some lines explaining
why I decided to mail or cc: you on this (an extract of the copyright notice
or the MAINTAINERS file), followed by the patch itself. If I mailed you
in error, please drop me a short note.

I kindly ask you to approve the correctness of the patch, and pass it on to
the relevant people for inclusion into the mainline kernel.

Thanks,
Tim Schmielau (tim@physik3.uni-rostock.de)



/*****************************************************************************/
/*
 *           moxa.c  -- MOXA Intellio family multiport serial driver.
 *
 *      Copyright (C) 1999-2000  Moxa Technologies (support@moxa.com.tw).


 *    Fixes for C104H/PCI by Tim Hockin <thockin@sun.com>


--- linux-2.4.20-pre6/drivers/char/moxa.c	Thu Oct 25 22:53:47 2001
+++ linux-2.4.20-pre6-jfix/drivers/char/moxa.c	Wed Sep 11 12:38:26 2002
@@ -2836,7 +2836,7 @@
 
 	st = jiffies;
 	et = st + tick;
-	while (jiffies < et);
+	while (time_before(jiffies, et));
 }
 
 static void moxafunc(unsigned long ofsAddr, int cmd, ushort arg)

--- linux-2.4.20-pre6/drivers/char/mxser.c	Wed Sep 11 13:36:44 2002
+++ linux-2.4.20-pre6-jfix/drivers/char/mxser.c	Wed Sep 11 12:32:13 2002
@@ -883,7 +883,7 @@
 		while (!(inb(info->base + UART_LSR) & UART_LSR_TEMT)) {
 			set_current_state(TASK_INTERRUPTIBLE);
 			schedule_timeout(5);
-			if (jiffies > timeout)
+			if (time_after(jiffies, timeout))
 				break;
 		}
 	}


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2002-09-22 11:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-09-22 11:45 [patch] fix compares of jiffies Tim Schmielau
  -- strict thread matches above, loose matches on Subject: below --
2002-09-22 11:45 Tim Schmielau
2002-09-22 11:45 Tim Schmielau
2002-09-22 11:45 Tim Schmielau
2002-09-22 11:45 Tim Schmielau
2002-09-22 11:45 Tim Schmielau
2001-12-28 21:23 Tim Schmielau
2001-12-28 21:23 Tim Schmielau

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.