Commit d2b2fea3 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
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
parents 42cbaeec edcc8a38
Loading
Loading
Loading
Loading
+66 −32
Original line number Diff line number Diff line
@@ -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,10 +191,12 @@ static inline u8 readb(const volatile void __iomem *addr)
{
	u8 val;

	if (rwmmio_tracepoint_enabled(rwmmio_read))
		log_read_mmio(8, addr, _THIS_IP_, _RET_IP_);
	__io_br();
	val = __raw_readb(addr);
	__io_ar(val);
	if (rwmmio_tracepoint_enabled(rwmmio_post_read))
		log_post_read_mmio(val, 8, addr, _THIS_IP_, _RET_IP_);
	return val;
}
@@ -204,10 +208,12 @@ static inline u16 readw(const volatile void __iomem *addr)
{
	u16 val;

	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);
	if (rwmmio_tracepoint_enabled(rwmmio_post_read))
		log_post_read_mmio(val, 16, addr, _THIS_IP_, _RET_IP_);
	return val;
}
@@ -219,10 +225,12 @@ static inline u32 readl(const volatile void __iomem *addr)
{
	u32 val;

	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);
	if (rwmmio_tracepoint_enabled(rwmmio_post_read))
		log_post_read_mmio(val, 32, addr, _THIS_IP_, _RET_IP_);
	return val;
}
@@ -235,10 +243,12 @@ static inline u64 readq(const volatile void __iomem *addr)
{
	u64 val;

	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);
	if (rwmmio_tracepoint_enabled(rwmmio_post_read))
		log_post_read_mmio(val, 64, addr, _THIS_IP_, _RET_IP_);
	return val;
}
@@ -249,10 +259,12 @@ static inline u64 readq(const volatile void __iomem *addr)
#define writeb writeb
static inline void writeb(u8 value, volatile void __iomem *addr)
{
	if (rwmmio_tracepoint_enabled(rwmmio_write))
		log_write_mmio(value, 8, addr, _THIS_IP_, _RET_IP_);
	__io_bw();
	__raw_writeb(value, addr);
	__io_aw();
	if (rwmmio_tracepoint_enabled(rwmmio_post_write))
		log_post_write_mmio(value, 8, addr, _THIS_IP_, _RET_IP_);
}
#endif
@@ -261,10 +273,12 @@ static inline void writeb(u8 value, volatile void __iomem *addr)
#define writew writew
static inline void writew(u16 value, volatile void __iomem *addr)
{
	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();
	if (rwmmio_tracepoint_enabled(rwmmio_post_write))
		log_post_write_mmio(value, 16, addr, _THIS_IP_, _RET_IP_);
}
#endif
@@ -273,10 +287,12 @@ static inline void writew(u16 value, volatile void __iomem *addr)
#define writel writel
static inline void writel(u32 value, volatile void __iomem *addr)
{
	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();
	if (rwmmio_tracepoint_enabled(rwmmio_post_write))
		log_post_write_mmio(value, 32, addr, _THIS_IP_, _RET_IP_);
}
#endif
@@ -286,10 +302,12 @@ static inline void writel(u32 value, volatile void __iomem *addr)
#define writeq writeq
static inline void writeq(u64 value, volatile void __iomem *addr)
{
	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();
	if (rwmmio_tracepoint_enabled(rwmmio_post_write))
		log_post_write_mmio(value, 64, addr, _THIS_IP_, _RET_IP_);
}
#endif
@@ -306,8 +324,10 @@ static inline u8 readb_relaxed(const volatile void __iomem *addr)
{
	u8 val;

	if (rwmmio_tracepoint_enabled(rwmmio_read))
		log_read_mmio(8, addr, _THIS_IP_, _RET_IP_);
	val = __raw_readb(addr);
	if (rwmmio_tracepoint_enabled(rwmmio_post_read))
		log_post_read_mmio(val, 8, addr, _THIS_IP_, _RET_IP_);
	return val;
}
@@ -319,8 +339,10 @@ static inline u16 readw_relaxed(const volatile void __iomem *addr)
{
	u16 val;

	if (rwmmio_tracepoint_enabled(rwmmio_read))
		log_read_mmio(16, addr, _THIS_IP_, _RET_IP_);
	val = __le16_to_cpu((__le16 __force)__raw_readw(addr));
	if (rwmmio_tracepoint_enabled(rwmmio_post_read))
		log_post_read_mmio(val, 16, addr, _THIS_IP_, _RET_IP_);
	return val;
}
@@ -332,8 +354,10 @@ static inline u32 readl_relaxed(const volatile void __iomem *addr)
{
	u32 val;

	if (rwmmio_tracepoint_enabled(rwmmio_read))
		log_read_mmio(32, addr, _THIS_IP_, _RET_IP_);
	val = __le32_to_cpu((__le32 __force)__raw_readl(addr));
	if (rwmmio_tracepoint_enabled(rwmmio_post_read))
		log_post_read_mmio(val, 32, addr, _THIS_IP_, _RET_IP_);
	return val;
}
@@ -345,8 +369,10 @@ static inline u64 readq_relaxed(const volatile void __iomem *addr)
{
	u64 val;

	if (rwmmio_tracepoint_enabled(rwmmio_read))
		log_read_mmio(64, addr, _THIS_IP_, _RET_IP_);
	val = __le64_to_cpu((__le64 __force)__raw_readq(addr));
	if (rwmmio_tracepoint_enabled(rwmmio_post_read))
		log_post_read_mmio(val, 64, addr, _THIS_IP_, _RET_IP_);
	return val;
}
@@ -356,8 +382,10 @@ 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)
{
	if (rwmmio_tracepoint_enabled(rwmmio_write))
		log_write_mmio(value, 8, addr, _THIS_IP_, _RET_IP_);
	__raw_writeb(value, addr);
	if (rwmmio_tracepoint_enabled(rwmmio_post_write))
		log_post_write_mmio(value, 8, addr, _THIS_IP_, _RET_IP_);
}
#endif
@@ -366,8 +394,10 @@ 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)
{
	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);
	if (rwmmio_tracepoint_enabled(rwmmio_post_write))
		log_post_write_mmio(value, 16, addr, _THIS_IP_, _RET_IP_);
}
#endif
@@ -376,8 +406,10 @@ 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)
{
	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);
	if (rwmmio_tracepoint_enabled(rwmmio_post_write))
		log_post_write_mmio(value, 32, addr, _THIS_IP_, _RET_IP_);
}
#endif
@@ -386,8 +418,10 @@ 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)
{
	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);
	if (rwmmio_tracepoint_enabled(rwmmio_post_write))
		log_post_write_mmio(value, 64, addr, _THIS_IP_, _RET_IP_);
}
#endif
+1 −0
Original line number Diff line number Diff line
@@ -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 */				\
+2 −2
Original line number Diff line number Diff line
@@ -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);		\