* [RESEND] [PATCH] RTC: assure proper memory ordering with respect to RTC_DEV_BUSY flag (was Re: RTC: convert mutex to bitfield)
[not found] ` <Pine.LNX.4.64.0711300944020.12807@jikos.suse.cz>
@ 2007-12-02 22:00 ` Jiri Kosina
2007-12-02 22:13 ` Alessandro Zummo
0 siblings, 1 reply; 2+ messages in thread
From: Jiri Kosina @ 2007-12-02 22:00 UTC (permalink / raw)
To: Andrew Morton
Cc: Alessandro Zummo, David Brownell, Nickk Piggin, linux-kernel
[ nobody seems to have picked this up, resending. This is a fix for
commit 8853c202b4 in Linus' tree ]
From: Jiri Kosina <jkosina@suse.cz>
RTC: assure proper memory ordering with respect to RTC_DEV_BUSY flag
We must make sure that the RTC_DEV_BUSY flag has proper lock semantics,
i.e. that the RTC_DEV_BUSY stores clearing the flag don't get reordered
before the preceeding stores and loads and vice versa.
Spotted by Nick Piggin.
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index a4f56e9..f1e00ff 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -293,7 +293,7 @@ int rtc_irq_register(struct rtc_device *rtc, struct rtc_task *task)
return -EINVAL;
/* Cannot register while the char dev is in use */
- if (test_and_set_bit(RTC_DEV_BUSY, &rtc->flags))
+ if (test_and_set_bit_lock(RTC_DEV_BUSY, &rtc->flags))
return -EBUSY;
spin_lock_irq(&rtc->irq_task_lock);
@@ -303,7 +303,7 @@ int rtc_irq_register(struct rtc_device *rtc, struct rtc_task *task)
}
spin_unlock_irq(&rtc->irq_task_lock);
- clear_bit(RTC_DEV_BUSY, &rtc->flags);
+ clear_bit_unlock(RTC_DEV_BUSY, &rtc->flags);
return retval;
}
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
index ae1bf17..025c60a 100644
--- a/drivers/rtc/rtc-dev.c
+++ b/drivers/rtc/rtc-dev.c
@@ -26,7 +26,7 @@ static int rtc_dev_open(struct inode *inode, struct file *file)
struct rtc_device, char_dev);
const struct rtc_class_ops *ops = rtc->ops;
- if (test_and_set_bit(RTC_DEV_BUSY, &rtc->flags))
+ if (test_and_set_bit_lock(RTC_DEV_BUSY, &rtc->flags))
return -EBUSY;
file->private_data = rtc;
@@ -41,7 +41,7 @@ static int rtc_dev_open(struct inode *inode, struct file *file)
}
/* something has gone wrong */
- clear_bit(RTC_DEV_BUSY, &rtc->flags);
+ clear_bit_unlock(RTC_DEV_BUSY, &rtc->flags);
return err;
}
@@ -402,7 +402,7 @@ static int rtc_dev_release(struct inode *inode, struct file *file)
if (rtc->ops->release)
rtc->ops->release(rtc->dev.parent);
- clear_bit(RTC_DEV_BUSY, &rtc->flags);
+ clear_bit_unlock(RTC_DEV_BUSY, &rtc->flags);
return 0;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [RESEND] [PATCH] RTC: assure proper memory ordering with respect to RTC_DEV_BUSY flag (was Re: RTC: convert mutex to bitfield)
2007-12-02 22:00 ` [RESEND] [PATCH] RTC: assure proper memory ordering with respect to RTC_DEV_BUSY flag (was Re: RTC: convert mutex to bitfield) Jiri Kosina
@ 2007-12-02 22:13 ` Alessandro Zummo
0 siblings, 0 replies; 2+ messages in thread
From: Alessandro Zummo @ 2007-12-02 22:13 UTC (permalink / raw)
To: Jiri Kosina
Cc: Andrew Morton, Alessandro Zummo, David Brownell, Nickk Piggin,
linux-kernel
On Sun, 2 Dec 2007 23:00:04 +0100 (CET)
Jiri Kosina <jkosina@suse.cz> wrote:
> [ nobody seems to have picked this up, resending. This is a fix for
> commit 8853c202b4 in Linus' tree ]
>
> From: Jiri Kosina <jkosina@suse.cz>
>
> RTC: assure proper memory ordering with respect to RTC_DEV_BUSY flag
>
> We must make sure that the RTC_DEV_BUSY flag has proper lock semantics,
> i.e. that the RTC_DEV_BUSY stores clearing the flag don't get reordered
> before the preceeding stores and loads and vice versa.
>
> Spotted by Nick Piggin.
>
> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
missed it, sorry.
Acked-by: Alessandro Zummo <a.zummo@towertech.it>
--
Best regards,
Alessandro Zummo,
Tower Technologies - Torino, Italy
http://www.towertech.it
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-12-02 22:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <200711301355.03139.nickpiggin@yahoo.com.au>
[not found] ` <Pine.LNX.4.64.0711300944020.12807@jikos.suse.cz>
2007-12-02 22:00 ` [RESEND] [PATCH] RTC: assure proper memory ordering with respect to RTC_DEV_BUSY flag (was Re: RTC: convert mutex to bitfield) Jiri Kosina
2007-12-02 22:13 ` Alessandro Zummo
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®