Merge tag 'mfd-fixes-6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd
[platform/kernel/linux-rpi.git] / scripts / atomic / gen-atomic-instrumented.sh
index d9ffd74..8f8f8e3 100755 (executable)
@@ -68,12 +68,14 @@ gen_proto_order_variant()
        local args="$(gen_args "$@")"
        local retstmt="$(gen_ret_stmt "${meta}")"
 
+       gen_kerneldoc "" "${meta}" "${pfx}" "${name}" "${sfx}" "${order}" "${atomic}" "${int}" "$@"
+
 cat <<EOF
 static __always_inline ${ret}
 ${atomicname}(${params})
 {
 ${checks}
-       ${retstmt}arch_${atomicname}(${args});
+       ${retstmt}raw_${atomicname}(${args});
 }
 EOF
 
@@ -84,7 +86,6 @@ gen_xchg()
 {
        local xchg="$1"; shift
        local order="$1"; shift
-       local mult="$1"; shift
 
        kcsan_barrier=""
        if [ "${xchg%_local}" = "${xchg}" ]; then
@@ -104,9 +105,9 @@ cat <<EOF
 EOF
 [ -n "$kcsan_barrier" ] && printf "\t${kcsan_barrier}; \\\\\n"
 cat <<EOF
-       instrument_atomic_read_write(__ai_ptr, ${mult}sizeof(*__ai_ptr)); \\
-       instrument_read_write(__ai_oldp, ${mult}sizeof(*__ai_oldp)); \\
-       arch_${xchg}${order}(__ai_ptr, __ai_oldp, __VA_ARGS__); \\
+       instrument_atomic_read_write(__ai_ptr, sizeof(*__ai_ptr)); \\
+       instrument_read_write(__ai_oldp, sizeof(*__ai_oldp)); \\
+       raw_${xchg}${order}(__ai_ptr, __ai_oldp, __VA_ARGS__); \\
 })
 EOF
 
@@ -119,8 +120,8 @@ cat <<EOF
 EOF
 [ -n "$kcsan_barrier" ] && printf "\t${kcsan_barrier}; \\\\\n"
 cat <<EOF
-       instrument_atomic_read_write(__ai_ptr, ${mult}sizeof(*__ai_ptr)); \\
-       arch_${xchg}${order}(__ai_ptr, __VA_ARGS__); \\
+       instrument_atomic_read_write(__ai_ptr, sizeof(*__ai_ptr)); \\
+       raw_${xchg}${order}(__ai_ptr, __VA_ARGS__); \\
 })
 EOF
 
@@ -134,15 +135,10 @@ cat << EOF
 // DO NOT MODIFY THIS FILE DIRECTLY
 
 /*
- * This file provides wrappers with KASAN instrumentation for atomic operations.
- * To use this functionality an arch's atomic.h file needs to define all
- * atomic operations with arch_ prefix (e.g. arch_atomic_read()) and include
- * this file at the end. This file provides atomic_read() that forwards to
- * arch_atomic_read() for actual atomic operation.
- * Note: if an arch atomic operation is implemented by means of other atomic
- * operations (e.g. atomic_read()/atomic_cmpxchg() loop), then it needs to use
- * arch_ variants (i.e. arch_atomic_read()/arch_atomic_cmpxchg()) to avoid
- * double instrumentation.
+ * This file provoides atomic operations with explicit instrumentation (e.g.
+ * KASAN, KCSAN), which should be used unless it is necessary to avoid
+ * instrumentation. Where it is necessary to aovid instrumenation, the
+ * raw_atomic*() operations should be used.
  */
 #ifndef _LINUX_ATOMIC_INSTRUMENTED_H
 #define _LINUX_ATOMIC_INSTRUMENTED_H
@@ -166,24 +162,18 @@ grep '^[a-z]' "$1" | while read name meta args; do
 done
 
 
-for xchg in "xchg" "cmpxchg" "cmpxchg64" "try_cmpxchg" "try_cmpxchg64"; do
+for xchg in "xchg" "cmpxchg" "cmpxchg64" "cmpxchg128" "try_cmpxchg" "try_cmpxchg64" "try_cmpxchg128"; do
        for order in "" "_acquire" "_release" "_relaxed"; do
-               gen_xchg "${xchg}" "${order}" ""
+               gen_xchg "${xchg}" "${order}"
                printf "\n"
        done
 done
 
-for xchg in "cmpxchg_local" "cmpxchg64_local" "sync_cmpxchg" "try_cmpxchg_local" "try_cmpxchg64_local" ; do
-       gen_xchg "${xchg}" "" ""
+for xchg in "cmpxchg_local" "cmpxchg64_local" "cmpxchg128_local" "sync_cmpxchg" "try_cmpxchg_local" "try_cmpxchg64_local" "try_cmpxchg128_local"; do
+       gen_xchg "${xchg}" ""
        printf "\n"
 done
 
-gen_xchg "cmpxchg_double" "" "2 * "
-
-printf "\n\n"
-
-gen_xchg "cmpxchg_double_local" "" "2 * "
-
 cat <<EOF
 
 #endif /* _LINUX_ATOMIC_INSTRUMENTED_H */