1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Copyright (c) 2021, The Linux Foundation. All rights reserved.
4 */
5 #ifndef __LOG_MMIORW_H__
6 #define __LOG_MMIORW_H__
7
8 #include <linux/types.h>
9 #include <linux/atomic.h>
10 #include <linux/tracepoint-defs.h>
11
12 /*
13 * TODO - io.h is included in NVHE files and these tracepoints are getting
14 * enabled for NVHE too. To avoid these tracepoints enabling in NHVE below
15 * condition is introduced.
16 * !(defined(__DISABLE_TRACE_MMIO__))
17 */
18 #if IS_ENABLED(CONFIG_TRACE_MMIO_ACCESS) && !(defined(__DISABLE_TRACE_MMIO__))
19 DECLARE_TRACEPOINT(rwmmio_write);
20 DECLARE_TRACEPOINT(rwmmio_read);
21 DECLARE_TRACEPOINT(rwmmio_post_read);
22
23 void __log_write_mmio(u64 val, u8 width, volatile void __iomem *addr);
24 void __log_read_mmio(u8 width, const volatile void __iomem *addr);
25 void __log_post_read_mmio(u64 val, u8 width, const volatile void __iomem *addr);
26
27 #define log_write_mmio(val, width, addr) \
28 do { \
29 if (tracepoint_enabled(rwmmio_write)) \
30 __log_write_mmio(val, width, addr); \
31 } while (0)
32
33 #define log_read_mmio(width, addr) \
34 do { \
35 if (tracepoint_enabled(rwmmio_read)) \
36 __log_read_mmio(width, addr); \
37 } while (0)
38
39 #define log_post_read_mmio(val, width, addr) \
40 do { \
41 if (tracepoint_enabled(rwmmio_post_read)) \
42 __log_post_read_mmio(val, width, addr); \
43 } while (0)
44
45 #else
log_write_mmio(u64 val,u8 width,volatile void __iomem * addr)46 static inline void log_write_mmio(u64 val, u8 width, volatile void __iomem *addr)
47 { }
log_read_mmio(u8 width,const volatile void __iomem * addr)48 static inline void log_read_mmio(u8 width, const volatile void __iomem *addr)
49 { }
log_post_read_mmio(u64 val,u8 width,const volatile void __iomem * addr)50 static inline void log_post_read_mmio(u64 val, u8 width, const volatile void __iomem *addr)
51 { }
52 #endif /* CONFIG_TRACE_MMIO_ACCESS */
53
54 #endif /* __LOG_MMIORW_H__ */
55