LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* ohci : strange looking use of round_jiffies_relative. possible bug ?
@ 2008-03-26 14:38 Richard Kennedy
2008-03-26 15:37 ` Alan Stern
0 siblings, 1 reply; 7+ messages in thread
From: Richard Kennedy @ 2008-03-26 14:38 UTC (permalink / raw)
To: dbrownell; +Cc: linux-usb, lkml
I was looking at the uses of round_jiffies and noticed that the ohci
unlink_watchdog_func() calls
mod_timer(&ohci->unlink_watchdog, round_jiffies_relative(HZ));
Which looks a bit strange as it will set the timer to 0 <= t < HZ.
Reading the comments I think that is really is expecting to setup timer
to (now + 1s)
mod_timer(&ohci->unlink_watchdog, round_jiffies(jiffies + HZ));
If this is not true then perhaps it needs a comment to explain what it
_is_ trying to do, because it's got me baffled ;)
Cheers
Richard
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: ohci : strange looking use of round_jiffies_relative. possible bug ?
2008-03-26 14:38 ohci : strange looking use of round_jiffies_relative. possible bug ? Richard Kennedy
@ 2008-03-26 15:37 ` Alan Stern
2008-03-26 15:46 ` Richard Kennedy
2008-03-26 16:32 ` [patch] usb ohci : fix 2 timers to fire at jiffies + 1s Richard Kennedy
0 siblings, 2 replies; 7+ messages in thread
From: Alan Stern @ 2008-03-26 15:37 UTC (permalink / raw)
To: Richard Kennedy; +Cc: dbrownell, linux-usb, lkml
On Wed, 26 Mar 2008, Richard Kennedy wrote:
> I was looking at the uses of round_jiffies and noticed that the ohci
> unlink_watchdog_func() calls
> mod_timer(&ohci->unlink_watchdog, round_jiffies_relative(HZ));
>
> Which looks a bit strange as it will set the timer to 0 <= t < HZ.
> Reading the comments I think that is really is expecting to setup timer
> to (now + 1s)
>
> mod_timer(&ohci->unlink_watchdog, round_jiffies(jiffies + HZ));
>
> If this is not true then perhaps it needs a comment to explain what it
> _is_ trying to do, because it's got me baffled ;)
I'd say it's a bug. Or rather a pair of bugs, since that mod_timer()
call appears in two places.
Alan Stern
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: ohci : strange looking use of round_jiffies_relative. possible bug ?
2008-03-26 15:37 ` Alan Stern
@ 2008-03-26 15:46 ` Richard Kennedy
2008-03-26 18:06 ` Mike Nuss
2008-03-26 16:32 ` [patch] usb ohci : fix 2 timers to fire at jiffies + 1s Richard Kennedy
1 sibling, 1 reply; 7+ messages in thread
From: Richard Kennedy @ 2008-03-26 15:46 UTC (permalink / raw)
To: Alan Stern; +Cc: dbrownell, linux-usb, lkml
On Wed, 2008-03-26 at 11:37 -0400, Alan Stern wrote:
> On Wed, 26 Mar 2008, Richard Kennedy wrote:
>
> > I was looking at the uses of round_jiffies and noticed that the ohci
> > unlink_watchdog_func() calls
> > mod_timer(&ohci->unlink_watchdog, round_jiffies_relative(HZ));
> >
> > Which looks a bit strange as it will set the timer to 0 <= t < HZ.
> > Reading the comments I think that is really is expecting to setup timer
> > to (now + 1s)
> >
> > mod_timer(&ohci->unlink_watchdog, round_jiffies(jiffies + HZ));
> >
> > If this is not true then perhaps it needs a comment to explain what it
> > _is_ trying to do, because it's got me baffled ;)
>
> I'd say it's a bug. Or rather a pair of bugs, since that mod_timer()
> call appears in two places.
>
> Alan Stern
>
Thanks. In that case I'll post a patch.
Richard
^ permalink raw reply [flat|nested] 7+ messages in thread
* [patch] usb ohci : fix 2 timers to fire at jiffies + 1s
2008-03-26 15:37 ` Alan Stern
2008-03-26 15:46 ` Richard Kennedy
@ 2008-03-26 16:32 ` Richard Kennedy
2008-03-27 18:53 ` David Brownell
1 sibling, 1 reply; 7+ messages in thread
From: Richard Kennedy @ 2008-03-26 16:32 UTC (permalink / raw)
To: linux-usb; +Cc: dbrownell, lkml, Alan Stern
Code inspection discovered in 2 places timers were being
incorrectly setup using round_jiffies_relative(HZ).
The timer would then fire at time (0 <= T < HZ).
Fix them to use round_jiffies(jiffies + HZ);
Signed-off-by: Richard Kennedy <richard@rsk.demon.co.uk>
---
compiled on latest v2.6.25-rc7-11 git head but not otherwise tested.
Richard
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index dd4798e..33f1c1c 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -467,7 +467,7 @@ static void unlink_watchdog_func(unsigned long _ohci)
out:
kfree(seen);
if (ohci->eds_scheduled)
- mod_timer(&ohci->unlink_watchdog, round_jiffies_relative(HZ));
+ mod_timer(&ohci->unlink_watchdog, round_jiffies(jiffies + HZ));
done:
spin_unlock_irqrestore(&ohci->lock, flags);
}
diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c
index 5181732..9c9f3b5 100644
--- a/drivers/usb/host/ohci-q.c
+++ b/drivers/usb/host/ohci-q.c
@@ -169,7 +169,7 @@ static int ed_schedule (struct ohci_hcd *ohci, struct ed *ed)
if (quirk_zfmicro(ohci)
&& (ed->type == PIPE_INTERRUPT)
&& !(ohci->eds_scheduled++))
- mod_timer(&ohci->unlink_watchdog, round_jiffies_relative(HZ));
+ mod_timer(&ohci->unlink_watchdog, round_jiffies(jiffies + HZ));
wmb ();
/* we care about rm_list when setting CLE/BLE in case the HC was at
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: ohci : strange looking use of round_jiffies_relative. possible bug ?
2008-03-26 15:46 ` Richard Kennedy
@ 2008-03-26 18:06 ` Mike Nuss
2008-03-27 18:55 ` David Brownell
0 siblings, 1 reply; 7+ messages in thread
From: Mike Nuss @ 2008-03-26 18:06 UTC (permalink / raw)
To: Richard Kennedy; +Cc: Alan Stern, dbrownell, linux-usb, lkml
On Wed, Mar 26, 2008 at 11:46 AM, Richard Kennedy
<richard@rsk.demon.co.uk> wrote:
>
> On Wed, 2008-03-26 at 11:37 -0400, Alan Stern wrote:
> > On Wed, 26 Mar 2008, Richard Kennedy wrote:
> >
> > > I was looking at the uses of round_jiffies and noticed that the ohci
> > > unlink_watchdog_func() calls
> > > mod_timer(&ohci->unlink_watchdog, round_jiffies_relative(HZ));
> > >
> > > Which looks a bit strange as it will set the timer to 0 <= t < HZ.
> > > Reading the comments I think that is really is expecting to setup timer
> > > to (now + 1s)
> > >
> > > mod_timer(&ohci->unlink_watchdog, round_jiffies(jiffies + HZ));
> > >
> > > If this is not true then perhaps it needs a comment to explain what it
> > > _is_ trying to do, because it's got me baffled ;)
Yes, my intent there was a roughly 1 second delay. You're correct, it's wrong.
> > I'd say it's a bug. Or rather a pair of bugs, since that mod_timer()
> > call appears in two places.
Yup.
Mike
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [patch] usb ohci : fix 2 timers to fire at jiffies + 1s
2008-03-26 16:32 ` [patch] usb ohci : fix 2 timers to fire at jiffies + 1s Richard Kennedy
@ 2008-03-27 18:53 ` David Brownell
0 siblings, 0 replies; 7+ messages in thread
From: David Brownell @ 2008-03-27 18:53 UTC (permalink / raw)
To: Richard Kennedy; +Cc: linux-usb, lkml, Alan Stern
On Wednesday 26 March 2008, Richard Kennedy wrote:
> Code inspection discovered in 2 places timers were being
> incorrectly setup using round_jiffies_relative(HZ).
> The timer would then fire at time (0 <= T < HZ).
>
> Fix them to use round_jiffies(jiffies + HZ);
>
> Signed-off-by: Richard Kennedy <richard@rsk.demon.co.uk>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
> ---
>
> compiled on latest v2.6.25-rc7-11 git head but not otherwise tested.
> Richard
>
> diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
> index dd4798e..33f1c1c 100644
> --- a/drivers/usb/host/ohci-hcd.c
> +++ b/drivers/usb/host/ohci-hcd.c
> @@ -467,7 +467,7 @@ static void unlink_watchdog_func(unsigned long _ohci)
> out:
> kfree(seen);
> if (ohci->eds_scheduled)
> - mod_timer(&ohci->unlink_watchdog, round_jiffies_relative(HZ));
> + mod_timer(&ohci->unlink_watchdog, round_jiffies(jiffies + HZ));
> done:
> spin_unlock_irqrestore(&ohci->lock, flags);
> }
> diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c
> index 5181732..9c9f3b5 100644
> --- a/drivers/usb/host/ohci-q.c
> +++ b/drivers/usb/host/ohci-q.c
> @@ -169,7 +169,7 @@ static int ed_schedule (struct ohci_hcd *ohci, struct ed *ed)
> if (quirk_zfmicro(ohci)
> && (ed->type == PIPE_INTERRUPT)
> && !(ohci->eds_scheduled++))
> - mod_timer(&ohci->unlink_watchdog, round_jiffies_relative(HZ));
> + mod_timer(&ohci->unlink_watchdog, round_jiffies(jiffies + HZ));
> wmb ();
>
> /* we care about rm_list when setting CLE/BLE in case the HC was at
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: ohci : strange looking use of round_jiffies_relative. possible bug ?
2008-03-26 18:06 ` Mike Nuss
@ 2008-03-27 18:55 ` David Brownell
0 siblings, 0 replies; 7+ messages in thread
From: David Brownell @ 2008-03-27 18:55 UTC (permalink / raw)
To: Mike Nuss, Richard Kennedy; +Cc: Alan Stern, linux-usb, lkml
On Wednesday 26 March 2008, Mike Nuss wrote:
> On Wed, Mar 26, 2008 at 11:46 AM, Richard Kennedy
> <richard@rsk.demon.co.uk> wrote:
>
> > > I'd say it's a bug. Or rather a pair of bugs, since that mod_timer()
> > > call appears in two places.
>
> Yup.
Although ... one specific to the Compaq ZF Micro chipset,
so it's a bug with rather limited impact. Do Not Panic.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-03-27 19:07 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-26 14:38 ohci : strange looking use of round_jiffies_relative. possible bug ? Richard Kennedy
2008-03-26 15:37 ` Alan Stern
2008-03-26 15:46 ` Richard Kennedy
2008-03-26 18:06 ` Mike Nuss
2008-03-27 18:55 ` David Brownell
2008-03-26 16:32 ` [patch] usb ohci : fix 2 timers to fire at jiffies + 1s Richard Kennedy
2008-03-27 18:53 ` David Brownell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).