lkml.org 
[lkml]   [2005]   [Mar]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH] w1: get rid of the potential problems with atomic operations.
Date
From
ChangeSet 1.2085, 2005/03/02 16:59:41-08:00, johnpol@2ka.mipt.ru

[PATCH] w1: get rid of the potential problems with atomic operations.

Get rid of the potential problems with atomic operations.

According to upcoming atomic_ops.txt by David Miller and Anton Blanchard
some archs may reoder atomic operations with nonatomic, since
the former are always visible but the latter are not, this can lead
to unpredicted behaviour.

Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


drivers/w1/w1_family.c | 2 ++
drivers/w1/w1_therm.c | 2 ++
2 files changed, 4 insertions(+)


diff -Nru a/drivers/w1/w1_family.c b/drivers/w1/w1_family.c
--- a/drivers/w1/w1_family.c 2005-03-04 12:37:51 -08:00
+++ b/drivers/w1/w1_family.c 2005-03-04 12:37:51 -08:00
@@ -138,7 +138,9 @@

void __w1_family_get(struct w1_family *f)
{
+ smp_mb__before_atomic_inc();
atomic_inc(&f->refcnt);
+ smp_mb__after_atomic_inc();
}

EXPORT_SYMBOL(w1_family_get);
diff -Nru a/drivers/w1/w1_therm.c b/drivers/w1/w1_therm.c
--- a/drivers/w1/w1_therm.c 2005-03-04 12:37:51 -08:00
+++ b/drivers/w1/w1_therm.c 2005-03-04 12:37:51 -08:00
@@ -104,6 +104,7 @@
int i, max_trying = 10;

atomic_inc(&sl->refcnt);
+ smp_mb__after_atomic_inc();
if (down_interruptible(&sl->master->mutex)) {
count = 0;
goto out_dec;
@@ -179,6 +180,7 @@
out:
up(&dev->mutex);
out_dec:
+ smp_mb__before_atomic_inc();
atomic_dec(&sl->refcnt);

return count;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:10    [W:0.081 / U:0.220 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site