* [patch 2/4] cdrom/aztcd: remove sleep_on() usage
@ 2005-06-20 21:51 domen
2005-06-20 23:14 ` Jesper Juhl
2005-06-21 9:58 ` Johannes Stezenbach
0 siblings, 2 replies; 5+ messages in thread
From: domen @ 2005-06-20 21:51 UTC (permalink / raw)
To: emoenke; +Cc: linux-kernel, Nishanth Aravamudan, domen
[-- Attachment #1: sleep_on-drivers_cdrom_aztcd.patch --]
[-- Type: text/plain, Size: 1125 bytes --]
From: Nishanth Aravamudan <nacc@us.ibm.com>
Directly use wait-queues instead of the deprecated sleep_on().
This required adding a local waitqueue. Patch is compile-tested.
Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
Signed-off-by: Domen Puncer <domen@coderock.org>
---
aztcd.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletion(-)
Index: quilt/drivers/cdrom/aztcd.c
===================================================================
--- quilt.orig/drivers/cdrom/aztcd.c
+++ quilt/drivers/cdrom/aztcd.c
@@ -179,6 +179,7 @@
#include <linux/ioport.h>
#include <linux/string.h>
#include <linux/major.h>
+#include <linux/wait.h>
#include <linux/init.h>
@@ -429,9 +430,12 @@ static void dten_low(void)
#define STEN_LOW_WAIT statusAzt()
static void statusAzt(void)
{
+ DEFINE_WAIT(wait);
AztTimeout = AZT_STATUS_DELAY;
SET_TIMER(aztStatTimer, HZ / 100);
- sleep_on(&azt_waitq);
+ prepare_to_wait(&azt_waitq, &wait, TASK_UNINTERRUPTIBLE);
+ schedule();
+ finish_wait(&azt_waitq, &wait);
if (AztTimeout <= 0)
printk("aztcd: Error Wait STEN_LOW_WAIT command:%x\n",
aztCmd);
--
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch 2/4] cdrom/aztcd: remove sleep_on() usage
2005-06-20 21:51 [patch 2/4] cdrom/aztcd: remove sleep_on() usage domen
@ 2005-06-20 23:14 ` Jesper Juhl
2005-06-20 23:24 ` Nishanth Aravamudan
2005-06-21 9:58 ` Johannes Stezenbach
1 sibling, 1 reply; 5+ messages in thread
From: Jesper Juhl @ 2005-06-20 23:14 UTC (permalink / raw)
To: domen@coderock.org; +Cc: emoenke, linux-kernel, Nishanth Aravamudan
On 6/20/05, domen@coderock.org <domen@coderock.org> wrote:
> From: Nishanth Aravamudan <nacc@us.ibm.com>
>
>
>
> Directly use wait-queues instead of the deprecated sleep_on().
> This required adding a local waitqueue. Patch is compile-tested.
>
> Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
> Signed-off-by: Domen Puncer <domen@coderock.org>
> ---
> aztcd.c | 6 +++++-
> 1 files changed, 5 insertions(+), 1 deletion(-)
>
> Index: quilt/drivers/cdrom/aztcd.c
> ===================================================================
> --- quilt.orig/drivers/cdrom/aztcd.c
> +++ quilt/drivers/cdrom/aztcd.c
> @@ -179,6 +179,7 @@
> #include <linux/ioport.h>
> #include <linux/string.h>
> #include <linux/major.h>
> +#include <linux/wait.h>
>
> #include <linux/init.h>
>
> @@ -429,9 +430,12 @@ static void dten_low(void)
> #define STEN_LOW_WAIT statusAzt()
> static void statusAzt(void)
> {
> + DEFINE_WAIT(wait);
> AztTimeout = AZT_STATUS_DELAY;
> SET_TIMER(aztStatTimer, HZ / 100);
> - sleep_on(&azt_waitq);
> + prepare_to_wait(&azt_waitq, &wait, TASK_UNINTERRUPTIBLE);
> + schedule();
> + finish_wait(&azt_waitq, &wait);
> if (AztTimeout <= 0)
> printk("aztcd: Error Wait STEN_LOW_WAIT command:%x\n",
> aztCmd);
>
Hmm, now that noone's sleeping on azt_waitq the two
wake_up(&azt_waitq); calls in aztStatTimer() don't seem to make much
sense any more... Can they just go away or? If they can go away then
axt_waitq itself would seem to be a goner as well... It might just
be me missing something, but this patch looks incomplete and not
completely thought through to me.
--
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch 2/4] cdrom/aztcd: remove sleep_on() usage
2005-06-20 23:14 ` Jesper Juhl
@ 2005-06-20 23:24 ` Nishanth Aravamudan
2005-06-20 23:34 ` Jesper Juhl
0 siblings, 1 reply; 5+ messages in thread
From: Nishanth Aravamudan @ 2005-06-20 23:24 UTC (permalink / raw)
To: Jesper Juhl; +Cc: domen@coderock.org, emoenke, linux-kernel
On 21.06.2005 [01:14:11 +0200], Jesper Juhl wrote:
> On 6/20/05, domen@coderock.org <domen@coderock.org> wrote:
> > From: Nishanth Aravamudan <nacc@us.ibm.com>
> >
> >
> >
> > Directly use wait-queues instead of the deprecated sleep_on().
> > This required adding a local waitqueue. Patch is compile-tested.
> >
> > Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
> > Signed-off-by: Domen Puncer <domen@coderock.org>
> > ---
> > aztcd.c | 6 +++++-
> > 1 files changed, 5 insertions(+), 1 deletion(-)
> >
> > Index: quilt/drivers/cdrom/aztcd.c
> > ===================================================================
> > --- quilt.orig/drivers/cdrom/aztcd.c
> > +++ quilt/drivers/cdrom/aztcd.c
> > @@ -179,6 +179,7 @@
> > #include <linux/ioport.h>
> > #include <linux/string.h>
> > #include <linux/major.h>
> > +#include <linux/wait.h>
> >
> > #include <linux/init.h>
> >
> > @@ -429,9 +430,12 @@ static void dten_low(void)
> > #define STEN_LOW_WAIT statusAzt()
> > static void statusAzt(void)
> > {
> > + DEFINE_WAIT(wait);
> > AztTimeout = AZT_STATUS_DELAY;
> > SET_TIMER(aztStatTimer, HZ / 100);
> > - sleep_on(&azt_waitq);
> > + prepare_to_wait(&azt_waitq, &wait, TASK_UNINTERRUPTIBLE);
> > + schedule();
> > + finish_wait(&azt_waitq, &wait);
> > if (AztTimeout <= 0)
> > printk("aztcd: Error Wait STEN_LOW_WAIT command:%x\n",
> > aztCmd);
> >
>
> Hmm, now that noone's sleeping on azt_waitq the two
> wake_up(&azt_waitq); calls in aztStatTimer() don't seem to make much
> sense any more... Can they just go away or? If they can go away then
> axt_waitq itself would seem to be a goner as well... It might just
> be me missing something, but this patch looks incomplete and not
> completely thought through to me.
Huh? prepare_to_wait() means the 'wait' here is sleeping on azt_waitq...
Thanks,
Nish
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch 2/4] cdrom/aztcd: remove sleep_on() usage
2005-06-20 23:24 ` Nishanth Aravamudan
@ 2005-06-20 23:34 ` Jesper Juhl
0 siblings, 0 replies; 5+ messages in thread
From: Jesper Juhl @ 2005-06-20 23:34 UTC (permalink / raw)
To: Nishanth Aravamudan; +Cc: domen@coderock.org, emoenke, linux-kernel
On 6/21/05, Nishanth Aravamudan <nacc@us.ibm.com> wrote:
> On 21.06.2005 [01:14:11 +0200], Jesper Juhl wrote:
> > On 6/20/05, domen@coderock.org <domen@coderock.org> wrote:
> > > From: Nishanth Aravamudan <nacc@us.ibm.com>
> > >
> > >
> > >
> > > Directly use wait-queues instead of the deprecated sleep_on().
> > > This required adding a local waitqueue. Patch is compile-tested.
> > >
> > > Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
> > > Signed-off-by: Domen Puncer <domen@coderock.org>
> > > ---
> > > aztcd.c | 6 +++++-
> > > 1 files changed, 5 insertions(+), 1 deletion(-)
> > >
> > > Index: quilt/drivers/cdrom/aztcd.c
> > > ===================================================================
> > > --- quilt.orig/drivers/cdrom/aztcd.c
> > > +++ quilt/drivers/cdrom/aztcd.c
> > > @@ -179,6 +179,7 @@
> > > #include <linux/ioport.h>
> > > #include <linux/string.h>
> > > #include <linux/major.h>
> > > +#include <linux/wait.h>
> > >
> > > #include <linux/init.h>
> > >
> > > @@ -429,9 +430,12 @@ static void dten_low(void)
> > > #define STEN_LOW_WAIT statusAzt()
> > > static void statusAzt(void)
> > > {
> > > + DEFINE_WAIT(wait);
> > > AztTimeout = AZT_STATUS_DELAY;
> > > SET_TIMER(aztStatTimer, HZ / 100);
> > > - sleep_on(&azt_waitq);
> > > + prepare_to_wait(&azt_waitq, &wait, TASK_UNINTERRUPTIBLE);
> > > + schedule();
> > > + finish_wait(&azt_waitq, &wait);
> > > if (AztTimeout <= 0)
> > > printk("aztcd: Error Wait STEN_LOW_WAIT command:%x\n",
> > > aztCmd);
> > >
> >
> > Hmm, now that noone's sleeping on azt_waitq the two
> > wake_up(&azt_waitq); calls in aztStatTimer() don't seem to make much
> > sense any more... Can they just go away or? If they can go away then
> > axt_waitq itself would seem to be a goner as well... It might just
> > be me missing something, but this patch looks incomplete and not
> > completely thought through to me.
>
> Huh? prepare_to_wait() means the 'wait' here is sleeping on azt_waitq...
>
Ahh damn, sorry. Somehow I misread the first argument of
prepare_to_wait() and completely missed the fact that it was sleeping
on azt_waitq. It must be past my bedtime...
My bad - it looks good.
--
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch 2/4] cdrom/aztcd: remove sleep_on() usage
2005-06-20 21:51 [patch 2/4] cdrom/aztcd: remove sleep_on() usage domen
2005-06-20 23:14 ` Jesper Juhl
@ 2005-06-21 9:58 ` Johannes Stezenbach
1 sibling, 0 replies; 5+ messages in thread
From: Johannes Stezenbach @ 2005-06-21 9:58 UTC (permalink / raw)
To: domen; +Cc: emoenke, linux-kernel, Nishanth Aravamudan
domen@coderock.org wrote:
> From: Nishanth Aravamudan <nacc@us.ibm.com>
>
>
>
> Directly use wait-queues instead of the deprecated sleep_on().
> This required adding a local waitqueue. Patch is compile-tested.
IMHO this patch doesn't improve anything, it just makes the
code harder to read. sleep_on() is deprecated because there's
an inherent race between sleep_on() and wake_up(). To address
this you need to add a condition variable (e.g. AztStenLow) and
convert the code to use wait_event().
The timer trick used here makes it pretty hard to hit the
race, but with a preemptible kernel one could be preempted
between the SET_TIMER() and the sleep_on().
Johannes
> Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
> Signed-off-by: Domen Puncer <domen@coderock.org>
> ---
> aztcd.c | 6 +++++-
> 1 files changed, 5 insertions(+), 1 deletion(-)
>
> Index: quilt/drivers/cdrom/aztcd.c
> ===================================================================
> --- quilt.orig/drivers/cdrom/aztcd.c
> +++ quilt/drivers/cdrom/aztcd.c
> @@ -179,6 +179,7 @@
> #include <linux/ioport.h>
> #include <linux/string.h>
> #include <linux/major.h>
> +#include <linux/wait.h>
>
> #include <linux/init.h>
>
> @@ -429,9 +430,12 @@ static void dten_low(void)
> #define STEN_LOW_WAIT statusAzt()
> static void statusAzt(void)
> {
> + DEFINE_WAIT(wait);
> AztTimeout = AZT_STATUS_DELAY;
> SET_TIMER(aztStatTimer, HZ / 100);
> - sleep_on(&azt_waitq);
> + prepare_to_wait(&azt_waitq, &wait, TASK_UNINTERRUPTIBLE);
> + schedule();
> + finish_wait(&azt_waitq, &wait);
> if (AztTimeout <= 0)
> printk("aztcd: Error Wait STEN_LOW_WAIT command:%x\n",
> aztCmd);
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-06-21 9:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-20 21:51 [patch 2/4] cdrom/aztcd: remove sleep_on() usage domen
2005-06-20 23:14 ` Jesper Juhl
2005-06-20 23:24 ` Nishanth Aravamudan
2005-06-20 23:34 ` Jesper Juhl
2005-06-21 9:58 ` Johannes Stezenbach
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.