Page MenuHomeFreeBSD

powerpc: Implement atomic_(f)cmpset_ for short and char
ClosedPublic

Authored by jhibbits on Sep 17 2019, 3:14 AM.

Details

Summary

This adds two implementations for each atomic_fcmpset_ and
atomic_cmpset_ short and char functions, selectable at compile time for
the target architecture. By default, it uses a shift-and-mask to
perform atomic updates to sub-components of 32-bit words. However, if
ISA_206_ATOMICS is defined it uses the ll/sc instructions for halfword and
bytes, introduced in PowerISA 2.06. These instructions are supported by
all IBM processors from POWER7 on, as well as the Freescale/NXP e6500
core. Although the e5500 and e500mc both implement PowerISA 2.06 they
do not implement these instructions.

As part of this, clean up the atomic_(f)cmpset_acq and _rel wrappers, by
using macros to reduce code duplication.

ISA_206_ATOMICS requires clang or newer binutils (2.20 or later).

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

jhibbits created this revision.Sep 17 2019, 3:14 AM
kevans added a subscriber: kevans.Thu, Oct 3, 6:06 PM

I have applied this patch on top of yours: https://people.freebsd.org/~kevans/ppc-nonisa206.diff -- to just have powerpc/ use the common sys/_atomic_subword.h version entirely if ISA_206_ATOMICS is not defined. That diff also includes atomic_fcmpset_{,acq_,rel_}{8,16} #defines, as those were missed here.

This revision was not accepted when it landed; it landed in state Needs Review.Tue, Oct 8, 1:36 AM
This revision was automatically updated to reflect the committed changes.