mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Roger Larsson <roger.larsson@skelleftea.mail.telia.com>
To: lkml <linux-kernel@vger.kernel.org>
Cc: Tim Schmielau <tim@physik3.uni-rostock.de>
Subject: Re: [patch] jiffies wrap fixes for 2.5.60
Date: Tue, 11 Feb 2003 22:31:40 +0100	[thread overview]
Message-ID: <200302112231.41592.roger.larsson@skelleftea.mail.telia.com> (raw)
In-Reply-To: <Pine.LNX.4.33.0302112145290.15563-100000@gans.physik3.uni-rostock.de>

On Tuesday 11 February 2003 21:50, Tim Schmielau wrote:
> On Tue, 4 Feb 2003, Denis Vlasenko wrote:
> 
> > However, this is a bit cosmetic. There is a much more serious problem:
> >
> > 		Jiffy Wrap Bugs
> >
> > There were reports of machines hanging on jiffy wrap.
> > This is typically a result of incorrect jiffy use in some driver.
> > Ask Tim - he is hunting those problems regularly, but he is outnumbered
> > by buggy driver authors. :(
> 
> Speaking of which - here are my fixes for 2.5.60.
> Will take some sleep (and maybe even try to compile them) before feeding
> the patch monkey.
> 
> Tim
> 
> 
> --- linux-2.5.60/arch/cris/drivers/usb-host.c	Fri Jan 17 03:21:51 2003
> +++ linux-2.5.60-jfix/arch/cris/drivers/usb-host.c	Mon Feb 10 23:07:11 2003
> @@ -459,7 +459,7 @@
>  	*R_DMA_CH8_SUB2_CMD = IO_STATE(R_DMA_CH8_SUB2_CMD, cmd, stop);
>  	/* Somehow wait for the DMA to finish current activities */
>  	i = jiffies + 100;
> -	while (jiffies < i);
> +	while (time_before(jiffies, i));

Busy wait? For several jiffies! Please...
I hope that interrupts are not disabled.


> --- linux-2.5.60/drivers/char/moxa.c	Fri Jan 17 03:22:44 2003
> +++ linux-2.5.60-jfix/drivers/char/moxa.c	Mon Feb 10 23:01:59 2003
> @@ -2832,7 +2832,7 @@
> 
>  	st = jiffies;
>  	et = st + tick;
> -	while (jiffies < et);
> +	while (time_before(jiffies, et));
>  }

This is the function before the patch:

/*
 * moxadelay - delays a specified number ticks
 */
static void moxadelay(int tick)
{
	unsigned long st, et;

	st = jiffies;
	et = st + tick;
	while (jiffies < et);
}

And this is how it is used. In several places...

	moxadelay(1);		/* delay 10 ms */
Either the parameter or the comment are wrong - probably both... :-)
Since this does not guarantee anything! Jiffies might tick on the first
check...

But even worse useage is:

void MoxaPortSendBreak(int port, int ms100)
{
	unsigned long ofsAddr;

	ofsAddr = moxaTableAddr[port];
	if (ms100) {
		moxafunc(ofsAddr, FC_SendBreak, Magic_code);
		moxadelay(ms100 * (HZ / 10));
	} else {
		moxafunc(ofsAddr, FC_SendBreak, Magic_code);
		moxadelay(HZ / 4);	/* 250 ms */
	}
	moxafunc(ofsAddr, FC_StopBreak, Magic_code);
}

And this is not enough - the parameter comes from user space...
(it is said to be in units between 250 ... 500 ms, the code above uses
 100 ms...)

And there are more uses like this...

/RogerL

-- 
Roger Larsson
Skellefteå
Sweden


  reply	other threads:[~2003-02-11 21:26 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-02 22:55 [PATCH *] use 64 bit jiffies Tim Schmielau
2003-02-03  6:42 ` Denis Vlasenko
2003-02-03  8:28   ` Matti Aarnio
2003-02-03  8:47     ` Tim Schmielau
2003-02-03  8:55       ` Matti Aarnio
2003-02-04 13:00         ` Tim Schmielau
2003-02-04  6:41     ` Denis Vlasenko
2003-02-04  8:27       ` Robert de Bath
2003-02-04  8:41         ` Denis Vlasenko
2003-02-04  9:29       ` Jörn Engel
2003-02-04 13:04         ` Tim Schmielau
2003-02-17 13:55           ` Jörn Engel
2003-02-17 14:02             ` Tim Schmielau
2003-02-17 14:15             ` Matti Aarnio
2003-02-17 14:23               ` Tim Schmielau
2003-02-04 17:37       ` Randy.Dunlap
2003-02-16  1:37         ` [PATCH] make jiffies wrap 5 min after boot Tim Schmielau
2003-02-16  2:08           ` Anton Blanchard
2003-02-16  2:43             ` William Lee Irwin III
2003-02-16  2:50               ` Michael Vergoz
2003-02-16  6:37               ` Robert Love
2003-02-16  7:16                 ` Muli Ben-Yehuda
2003-02-16 11:50                   ` Falk Hueffner
2003-02-16 12:04                     ` William Lee Irwin III
2003-02-11 20:50       ` [patch] jiffies wrap fixes for 2.5.60 Tim Schmielau
2003-02-11 21:31         ` Roger Larsson [this message]
2003-02-12 12:09           ` Tim Schmielau
2003-02-05 11:42 ` use 64 bit jiffies broke HZ=100 case (and fix) Oleg Drokin
2003-02-05 12:22   ` Tim Schmielau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200302112231.41592.roger.larsson@skelleftea.mail.telia.com \
    --to=roger.larsson@skelleftea.mail.telia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tim@physik3.uni-rostock.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®