]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commit
[ARM] 3978/1: macro to provide a 63-bit value from a 32-bit hardware counter
authorNicolas Pitre <nico@cam.org>
Mon, 4 Dec 2006 19:19:31 +0000 (20:19 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Thu, 7 Dec 2006 16:06:45 +0000 (16:06 +0000)
commit838ccbc35eae5b44d47724e5f694dbec4a26d269
tree374cd5d33b42cd5464bd45d62193307bc5f994ce
parentfa4adc614922c24601320e55bc5a1f837abad6e9
[ARM] 3978/1: macro to provide a 63-bit value from a 32-bit hardware counter

This is done in a completely lockless fashion. Bits 0 to 31 of the count
are provided by the hardware while bits 32 to 62 are stored in memory.
The top bit in memory is used to synchronize with the hardware count
half-period.  When the top bit of both counters (hardware and in memory)
differ then the memory is updated with a new value, incrementing it when
the hardware counter wraps around.  Because a word store in memory is
atomic then the incremented value will always be in synch with the top
bit indicating to any potential concurrent reader if the value in memory
is up to date or not wrt the needed increment.  And any race in updating
the value in memory is harmless as the same value would be stored more
than once.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
include/asm-arm/cnt32_to_63.h [new file with mode: 0644]