Re: [PATCH] Fix for rtc.c non-atomic access to rtc_status

From: Tigran Aivazian (tigran@veritas.com)
Date: Sat Apr 22 2000 - 05:54:15 EST


On Thu, 20 Apr 2000, Cesar Eduardo Barros wrote:

> (not on the list, please CC: replies to me)
>
> Using atomic_* seems to cause a false sense of security in some people.
> atomic_set(...,atomic_read(...)) is not atomic, and rtc.c did it everywhere.
> Also, testing for a bit and later enabling it (like in rtc_open) causes races
> (two proccesses in SMP could open the rtc at the same time if they got the
> right timing). I patched it to use a spinlock instead.
>
> This is my first kernel patch, so I probably missed something (spinlocks are
> tricky). Also, I only tested compiling it.

the patch looks like it will work but why don't you instead of adding an
extra spinlock around normal arithmetic use bit manipulation routines from
<asm/bitops.h>? P6 microcode update driver uses those for a very similar
reason (only slightly simpler as it currently needs just one bit) as rtc
and needs no locking - take a look at arch/i386/kernel/microcode.c

Regards,
Tigran

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



This archive was generated by hypermail 2b29 : Sun Apr 23 2000 - 21:00:20 EST