asm-generic: updates for 6.18

Two small patches for the asm-generic header files: Varad Gautam improves
 the MMIO tracing to be faster when the tracepoints are built into the
 kernel but disabled, while Qi Xi updates the DO_ONCE logic so that
 clearing the WARN_ONCE() flags does not change the other DO_ONCE users.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEo6/YBQwIrVS28WGKmmx57+YAGNkFAmjdrC0ACgkQmmx57+YA
 GNmOuQ//XvHAW5q/kBgoIxNaEAwEJn+6AnjGE/HWkyIPDEBJGOIAo02h/1BIXsIX
 PRGVYL/WOnhMMYAjPAGqFXF7kYjFmZx1/thFVsjVnPtkqR7AapEamLjSSmjXQTmp
 N0kUseD6Uv1X2IxVHcuTvFoZ/Z+fuz7RvmLtNhZ5DFnFJ4cHX2l8gEvOc1po5SX6
 +Q6fwtwMhMWa57N+E90UcWJFPetZ6UUN6dIidAdDYp+lBwP2HHsvm0tzr95Rw3a1
 ugAkcdSj67UyucNf3ECQ/JTtckPJBoxGSAOOpbT1f+SdO4zIHCY3TsOM7bt7Vvqp
 58GbyJ4f8sKN2LwjvBrvn8qNRRzuHfTYYK66D4ahy9zvPgYYWkTKJRLSI6HEkv1j
 cbSWUkV0C/e1CBbTQLoGzpjKEFPHefODU0n35sG60Tf8nG2fue2wCMCCjMnbyeEP
 eA+dEDxM7xvXPcNDdEKqKCLCV+zm2D+CqlfdIcwvrjF2x5dt/P+zFoLO0qIN8DE7
 GAMrKfjw5X5o4pe/9SD8E0hyVZnjWrZ0oc7IGT2zdAFNm/vlJ/xBuOlC8ZNNtnaJ
 DcAkADUKiudd5HYlC3bTThBVhEITfTacfF1qBy4T/jFzbk1l5yfQjwn+O9o71CkL
 j5blsdlrLOTkWfFaOq4Z2IBGWUif2K3cd/ata7J4+FX/MN2TLVM=
 =Vx5p
 -----END PGP SIGNATURE-----

Merge tag 'asm-generic-6.18' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic

Pull asm-generic updates from Arnd Bergmann:
 "Two small patches for the asm-generic header files: Varad Gautam
  improves the MMIO tracing to be faster when the tracepoints are built
  into the kernel but disabled, while Qi Xi updates the DO_ONCE logic so
  that clearing the WARN_ONCE() flags does not change the other DO_ONCE
  users"

* tag 'asm-generic-6.18' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic:
  once: fix race by moving DO_ONCE to separate section
  asm-generic/io.h: Skip trace helpers if rwmmio events are disabled
This commit is contained in:
Linus Torvalds 2025-10-01 17:47:16 -07:00
commit d2b2fea350
3 changed files with 69 additions and 34 deletions

View File

@ -75,6 +75,7 @@
#if IS_ENABLED(CONFIG_TRACE_MMIO_ACCESS) && !(defined(__DISABLE_TRACE_MMIO__))
#include <linux/tracepoint-defs.h>
#define rwmmio_tracepoint_enabled(tracepoint) tracepoint_enabled(tracepoint)
DECLARE_TRACEPOINT(rwmmio_write);
DECLARE_TRACEPOINT(rwmmio_post_write);
DECLARE_TRACEPOINT(rwmmio_read);
@ -91,6 +92,7 @@ void log_post_read_mmio(u64 val, u8 width, const volatile void __iomem *addr,
#else
#define rwmmio_tracepoint_enabled(tracepoint) false
static inline void log_write_mmio(u64 val, u8 width, volatile void __iomem *addr,
unsigned long caller_addr, unsigned long caller_addr0) {}
static inline void log_post_write_mmio(u64 val, u8 width, volatile void __iomem *addr,
@ -189,11 +191,13 @@ static inline u8 readb(const volatile void __iomem *addr)
{
u8 val;
log_read_mmio(8, addr, _THIS_IP_, _RET_IP_);
if (rwmmio_tracepoint_enabled(rwmmio_read))
log_read_mmio(8, addr, _THIS_IP_, _RET_IP_);
__io_br();
val = __raw_readb(addr);
__io_ar(val);
log_post_read_mmio(val, 8, addr, _THIS_IP_, _RET_IP_);
if (rwmmio_tracepoint_enabled(rwmmio_post_read))
log_post_read_mmio(val, 8, addr, _THIS_IP_, _RET_IP_);
return val;
}
#endif
@ -204,11 +208,13 @@ static inline u16 readw(const volatile void __iomem *addr)
{
u16 val;
log_read_mmio(16, addr, _THIS_IP_, _RET_IP_);
if (rwmmio_tracepoint_enabled(rwmmio_read))
log_read_mmio(16, addr, _THIS_IP_, _RET_IP_);
__io_br();
val = __le16_to_cpu((__le16 __force)__raw_readw(addr));
__io_ar(val);
log_post_read_mmio(val, 16, addr, _THIS_IP_, _RET_IP_);
if (rwmmio_tracepoint_enabled(rwmmio_post_read))
log_post_read_mmio(val, 16, addr, _THIS_IP_, _RET_IP_);
return val;
}
#endif
@ -219,11 +225,13 @@ static inline u32 readl(const volatile void __iomem *addr)
{
u32 val;
log_read_mmio(32, addr, _THIS_IP_, _RET_IP_);
if (rwmmio_tracepoint_enabled(rwmmio_read))
log_read_mmio(32, addr, _THIS_IP_, _RET_IP_);
__io_br();
val = __le32_to_cpu((__le32 __force)__raw_readl(addr));
__io_ar(val);
log_post_read_mmio(val, 32, addr, _THIS_IP_, _RET_IP_);
if (rwmmio_tracepoint_enabled(rwmmio_post_read))
log_post_read_mmio(val, 32, addr, _THIS_IP_, _RET_IP_);
return val;
}
#endif
@ -235,11 +243,13 @@ static inline u64 readq(const volatile void __iomem *addr)
{
u64 val;
log_read_mmio(64, addr, _THIS_IP_, _RET_IP_);
if (rwmmio_tracepoint_enabled(rwmmio_read))
log_read_mmio(64, addr, _THIS_IP_, _RET_IP_);
__io_br();
val = __le64_to_cpu((__le64 __force)__raw_readq(addr));
__io_ar(val);
log_post_read_mmio(val, 64, addr, _THIS_IP_, _RET_IP_);
if (rwmmio_tracepoint_enabled(rwmmio_post_read))
log_post_read_mmio(val, 64, addr, _THIS_IP_, _RET_IP_);
return val;
}
#endif
@ -249,11 +259,13 @@ static inline u64 readq(const volatile void __iomem *addr)
#define writeb writeb
static inline void writeb(u8 value, volatile void __iomem *addr)
{
log_write_mmio(value, 8, addr, _THIS_IP_, _RET_IP_);
if (rwmmio_tracepoint_enabled(rwmmio_write))
log_write_mmio(value, 8, addr, _THIS_IP_, _RET_IP_);
__io_bw();
__raw_writeb(value, addr);
__io_aw();
log_post_write_mmio(value, 8, addr, _THIS_IP_, _RET_IP_);
if (rwmmio_tracepoint_enabled(rwmmio_post_write))
log_post_write_mmio(value, 8, addr, _THIS_IP_, _RET_IP_);
}
#endif
@ -261,11 +273,13 @@ static inline void writeb(u8 value, volatile void __iomem *addr)
#define writew writew
static inline void writew(u16 value, volatile void __iomem *addr)
{
log_write_mmio(value, 16, addr, _THIS_IP_, _RET_IP_);
if (rwmmio_tracepoint_enabled(rwmmio_write))
log_write_mmio(value, 16, addr, _THIS_IP_, _RET_IP_);
__io_bw();
__raw_writew((u16 __force)cpu_to_le16(value), addr);
__io_aw();
log_post_write_mmio(value, 16, addr, _THIS_IP_, _RET_IP_);
if (rwmmio_tracepoint_enabled(rwmmio_post_write))
log_post_write_mmio(value, 16, addr, _THIS_IP_, _RET_IP_);
}
#endif
@ -273,11 +287,13 @@ static inline void writew(u16 value, volatile void __iomem *addr)
#define writel writel
static inline void writel(u32 value, volatile void __iomem *addr)
{
log_write_mmio(value, 32, addr, _THIS_IP_, _RET_IP_);
if (rwmmio_tracepoint_enabled(rwmmio_write))
log_write_mmio(value, 32, addr, _THIS_IP_, _RET_IP_);
__io_bw();
__raw_writel((u32 __force)__cpu_to_le32(value), addr);
__io_aw();
log_post_write_mmio(value, 32, addr, _THIS_IP_, _RET_IP_);
if (rwmmio_tracepoint_enabled(rwmmio_post_write))
log_post_write_mmio(value, 32, addr, _THIS_IP_, _RET_IP_);
}
#endif
@ -286,11 +302,13 @@ static inline void writel(u32 value, volatile void __iomem *addr)
#define writeq writeq
static inline void writeq(u64 value, volatile void __iomem *addr)
{
log_write_mmio(value, 64, addr, _THIS_IP_, _RET_IP_);
if (rwmmio_tracepoint_enabled(rwmmio_write))
log_write_mmio(value, 64, addr, _THIS_IP_, _RET_IP_);
__io_bw();
__raw_writeq((u64 __force)__cpu_to_le64(value), addr);
__io_aw();
log_post_write_mmio(value, 64, addr, _THIS_IP_, _RET_IP_);
if (rwmmio_tracepoint_enabled(rwmmio_post_write))
log_post_write_mmio(value, 64, addr, _THIS_IP_, _RET_IP_);
}
#endif
#endif /* CONFIG_64BIT */
@ -306,9 +324,11 @@ static inline u8 readb_relaxed(const volatile void __iomem *addr)
{
u8 val;
log_read_mmio(8, addr, _THIS_IP_, _RET_IP_);
if (rwmmio_tracepoint_enabled(rwmmio_read))
log_read_mmio(8, addr, _THIS_IP_, _RET_IP_);
val = __raw_readb(addr);
log_post_read_mmio(val, 8, addr, _THIS_IP_, _RET_IP_);
if (rwmmio_tracepoint_enabled(rwmmio_post_read))
log_post_read_mmio(val, 8, addr, _THIS_IP_, _RET_IP_);
return val;
}
#endif
@ -319,9 +339,11 @@ static inline u16 readw_relaxed(const volatile void __iomem *addr)
{
u16 val;
log_read_mmio(16, addr, _THIS_IP_, _RET_IP_);
if (rwmmio_tracepoint_enabled(rwmmio_read))
log_read_mmio(16, addr, _THIS_IP_, _RET_IP_);
val = __le16_to_cpu((__le16 __force)__raw_readw(addr));
log_post_read_mmio(val, 16, addr, _THIS_IP_, _RET_IP_);
if (rwmmio_tracepoint_enabled(rwmmio_post_read))
log_post_read_mmio(val, 16, addr, _THIS_IP_, _RET_IP_);
return val;
}
#endif
@ -332,9 +354,11 @@ static inline u32 readl_relaxed(const volatile void __iomem *addr)
{
u32 val;
log_read_mmio(32, addr, _THIS_IP_, _RET_IP_);
if (rwmmio_tracepoint_enabled(rwmmio_read))
log_read_mmio(32, addr, _THIS_IP_, _RET_IP_);
val = __le32_to_cpu((__le32 __force)__raw_readl(addr));
log_post_read_mmio(val, 32, addr, _THIS_IP_, _RET_IP_);
if (rwmmio_tracepoint_enabled(rwmmio_post_read))
log_post_read_mmio(val, 32, addr, _THIS_IP_, _RET_IP_);
return val;
}
#endif
@ -345,9 +369,11 @@ static inline u64 readq_relaxed(const volatile void __iomem *addr)
{
u64 val;
log_read_mmio(64, addr, _THIS_IP_, _RET_IP_);
if (rwmmio_tracepoint_enabled(rwmmio_read))
log_read_mmio(64, addr, _THIS_IP_, _RET_IP_);
val = __le64_to_cpu((__le64 __force)__raw_readq(addr));
log_post_read_mmio(val, 64, addr, _THIS_IP_, _RET_IP_);
if (rwmmio_tracepoint_enabled(rwmmio_post_read))
log_post_read_mmio(val, 64, addr, _THIS_IP_, _RET_IP_);
return val;
}
#endif
@ -356,9 +382,11 @@ static inline u64 readq_relaxed(const volatile void __iomem *addr)
#define writeb_relaxed writeb_relaxed
static inline void writeb_relaxed(u8 value, volatile void __iomem *addr)
{
log_write_mmio(value, 8, addr, _THIS_IP_, _RET_IP_);
if (rwmmio_tracepoint_enabled(rwmmio_write))
log_write_mmio(value, 8, addr, _THIS_IP_, _RET_IP_);
__raw_writeb(value, addr);
log_post_write_mmio(value, 8, addr, _THIS_IP_, _RET_IP_);
if (rwmmio_tracepoint_enabled(rwmmio_post_write))
log_post_write_mmio(value, 8, addr, _THIS_IP_, _RET_IP_);
}
#endif
@ -366,9 +394,11 @@ static inline void writeb_relaxed(u8 value, volatile void __iomem *addr)
#define writew_relaxed writew_relaxed
static inline void writew_relaxed(u16 value, volatile void __iomem *addr)
{
log_write_mmio(value, 16, addr, _THIS_IP_, _RET_IP_);
if (rwmmio_tracepoint_enabled(rwmmio_write))
log_write_mmio(value, 16, addr, _THIS_IP_, _RET_IP_);
__raw_writew((u16 __force)cpu_to_le16(value), addr);
log_post_write_mmio(value, 16, addr, _THIS_IP_, _RET_IP_);
if (rwmmio_tracepoint_enabled(rwmmio_post_write))
log_post_write_mmio(value, 16, addr, _THIS_IP_, _RET_IP_);
}
#endif
@ -376,9 +406,11 @@ static inline void writew_relaxed(u16 value, volatile void __iomem *addr)
#define writel_relaxed writel_relaxed
static inline void writel_relaxed(u32 value, volatile void __iomem *addr)
{
log_write_mmio(value, 32, addr, _THIS_IP_, _RET_IP_);
if (rwmmio_tracepoint_enabled(rwmmio_write))
log_write_mmio(value, 32, addr, _THIS_IP_, _RET_IP_);
__raw_writel((u32 __force)__cpu_to_le32(value), addr);
log_post_write_mmio(value, 32, addr, _THIS_IP_, _RET_IP_);
if (rwmmio_tracepoint_enabled(rwmmio_post_write))
log_post_write_mmio(value, 32, addr, _THIS_IP_, _RET_IP_);
}
#endif
@ -386,9 +418,11 @@ static inline void writel_relaxed(u32 value, volatile void __iomem *addr)
#define writeq_relaxed writeq_relaxed
static inline void writeq_relaxed(u64 value, volatile void __iomem *addr)
{
log_write_mmio(value, 64, addr, _THIS_IP_, _RET_IP_);
if (rwmmio_tracepoint_enabled(rwmmio_write))
log_write_mmio(value, 64, addr, _THIS_IP_, _RET_IP_);
__raw_writeq((u64 __force)__cpu_to_le64(value), addr);
log_post_write_mmio(value, 64, addr, _THIS_IP_, _RET_IP_);
if (rwmmio_tracepoint_enabled(rwmmio_post_write))
log_post_write_mmio(value, 64, addr, _THIS_IP_, _RET_IP_);
}
#endif

View File

@ -361,6 +361,7 @@ defined(CONFIG_AUTOFDO_CLANG) || defined(CONFIG_PROPELLER_CLANG)
__start_once = .; \
*(.data..once) \
__end_once = .; \
*(.data..do_once) \
STRUCT_ALIGN(); \
*(__tracepoints) \
/* implement dynamic printk debug */ \

View File

@ -46,7 +46,7 @@ void __do_once_sleepable_done(bool *done, struct static_key_true *once_key,
#define DO_ONCE(func, ...) \
({ \
bool ___ret = false; \
static bool __section(".data..once") ___done = false; \
static bool __section(".data..do_once") ___done = false; \
static DEFINE_STATIC_KEY_TRUE(___once_key); \
if (static_branch_unlikely(&___once_key)) { \
unsigned long ___flags; \
@ -64,7 +64,7 @@ void __do_once_sleepable_done(bool *done, struct static_key_true *once_key,
#define DO_ONCE_SLEEPABLE(func, ...) \
({ \
bool ___ret = false; \
static bool __section(".data..once") ___done = false; \
static bool __section(".data..do_once") ___done = false; \
static DEFINE_STATIC_KEY_TRUE(___once_key); \
if (static_branch_unlikely(&___once_key)) { \
___ret = __do_once_sleepable_start(&___done); \