Thread (22 messages) 22 messages, 5 authors, 2021-11-29

Re: [PATCHv4 2/2] arm64/io: Add a header for mmio access instrumentation

From: Arnd Bergmann <arnd@arndb.de>
Date: 2021-11-18 15:25:09
Also in: linux-arm-msm, lkml

On Mon, Nov 15, 2021 at 12:33 PM Sai Prakash Ranjan
[off-list ref] wrote:
 /*
  * Generic IO read/write.  These perform native-endian accesses.
  */
-#define __raw_writeb __raw_writeb
-static inline void __raw_writeb(u8 val, volatile void __iomem *addr)
+static inline void arch_raw_writeb(u8 val, volatile void __iomem *addr)
 {
        asm volatile("strb %w0, [%1]" : : "rZ" (val), "r" (addr));
 }
Woundn't removing the #define here will break the logic in
include/asm-generic/io.h,
making it fall back to the pointer-dereference version for the actual access?
+#if IS_ENABLED(CONFIG_TRACE_MMIO_ACCESS) && !(defined(__DISABLE_TRACE_MMIO__))
+DECLARE_TRACEPOINT(rwmmio_write);
+DECLARE_TRACEPOINT(rwmmio_read);
+
+void log_write_mmio(const char *width, volatile void __iomem *addr);
+void log_read_mmio(const char *width, const volatile void __iomem *addr);
+
+#define __raw_write(v, a, _l)  ({                              \
+       volatile void __iomem *_a = (a);                        \
+       if (tracepoint_enabled(rwmmio_write))                   \
+               log_write_mmio(__stringify(write##_l), _a);     \
+       arch_raw_write##_l((v), _a);                            \
+       })
This feels like it's getting too big to be inlined. Have you considered
integrating this with the lib/logic_iomem.c infrastructure instead?

That already provides a way to override MMIO areas, and it lets you do
the logging from a single place rather than having it duplicated in every
single caller. It also provides a way of filtering it based on the ioremap()
call.

        Arnd

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help