[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241203003856.GJ1253388@nvidia.com>
Date: Mon, 2 Dec 2024 20:38:56 -0400
From: Jason Gunthorpe <jgg@...dia.com>
To: Mark Rutland <mark.rutland@....com>, Uros Bizjak <ubizjak@...il.com>
Cc: Alejandro Jimenez <alejandro.j.jimenez@...cle.com>,
linux-kernel@...r.kernel.org
Subject: Help with atomic fallback
Hi Mark/Uros,
I hope one of you can help me unravel this, I'm trying to use
try_cmpxchg64_release() from driver code and 0-day is saying arc
compiles explode:
In file included from include/linux/atomic.h:80,
from drivers/iommu/generic_pt/fmt/../pt_defs.h:17,
from drivers/iommu/generic_pt/fmt/iommu_template.h:35,
from drivers/iommu/generic_pt/fmt/iommu_armv8_4k.c:13:
drivers/iommu/generic_pt/fmt/../pt_defs.h: In function 'pt_table_install64':
>> include/linux/atomic/atomic-arch-fallback.h:295:14: error: void value not ignored as it ought to be
295 | ___r = raw_cmpxchg64_release((_ptr), ___o, (_new)); \
| ^
include/linux/atomic/atomic-instrumented.h:4937:9: note: in expansion of macro 'raw_try_cmpxchg64_release'
4937 | raw_try_cmpxchg64_release(__ai_ptr, __ai_oldp, __VA_ARGS__); \
| ^~~~~~~~~~~~~~~~~~~~~~~~~
drivers/iommu/generic_pt/fmt/../pt_defs.h:144:16: note: in expansion of macro 'try_cmpxchg64_release'
144 | return try_cmpxchg64_release(entryp, &old_entry, table_entry);
Which is immediately because of a typo in atomic-arch-fallback.h code gen:
#if defined(arch_cmpxchg64_release)
#define raw_cmpxchg64_release arch_cmpxchg64_release
#elif defined(arch_cmpxchg64_relaxed)
#define raw_cmpxchg64_release(...) \
__atomic_op_release(arch_cmpxchg64, __VA_ARGS__)
#elif defined(arch_cmpxchg64)
#define raw_cmpxchg64_release arch_cmpxchg64
#else
extern void raw_cmpxchg64_release_not_implemented(void);
^^^^^^^^^^^^^^^^^^^^^
That should return int to make the compiler happy, but then it will
fail to link (I think, my cross compiler ICEs before it gets there)
However, arc defines:
static inline s64
arch_atomic64_cmpxchg(atomic64_t *ptr, s64 expected, s64 new)
{
And I see a:
static __always_inline s64
raw_atomic64_cmpxchg_release(atomic64_t *v, s64 old, s64 new)
{
#if defined(arch_atomic64_cmpxchg_release)
return arch_atomic64_cmpxchg_release(v, old, new);
#elif defined(arch_atomic64_cmpxchg_relaxed)
__atomic_release_fence();
return arch_atomic64_cmpxchg_relaxed(v, old, new);
#elif defined(arch_atomic64_cmpxchg)
return arch_atomic64_cmpxchg(v, old, new);
Which seems to strongly imply that arc can do the cmpxchg64_release
primitive.
But I haven't been able to figure out what is expected here for
arch_atomic64 vs try_cmpxchg64 to guess what is missing part here :\
Any advice?
Thanks,
Jason
Powered by blists - more mailing lists