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

From: Greg KH
Date: Sat Mar 05 2005 - 00:54:56 EST


ChangeSet 1.2085, 2005/03/02 16:59:41-08:00, johnpol@xxxxxxxxxxx

[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@xxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx>


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@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/