log_mmiorw.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. #include <linux/types.h>
  8. #include <linux/atomic.h>
  9. #include <linux/tracepoint-defs.h>
  10. /*
  11. * TODO - io.h is included in NVHE files and these tracepoints are getting
  12. * enabled for NVHE too. To avoid these tracepoints enabling in NHVE below
  13. * condition is introduced.
  14. * !(defined(__DISABLE_TRACE_MMIO__))
  15. */
  16. #if IS_ENABLED(CONFIG_TRACE_MMIO_ACCESS) && !(defined(__DISABLE_TRACE_MMIO__))
  17. DECLARE_TRACEPOINT(rwmmio_write);
  18. DECLARE_TRACEPOINT(rwmmio_read);
  19. DECLARE_TRACEPOINT(rwmmio_post_read);
  20. void __log_write_mmio(u64 val, u8 width, volatile void __iomem *addr);
  21. void __log_read_mmio(u8 width, const volatile void __iomem *addr);
  22. void __log_post_read_mmio(u64 val, u8 width, const volatile void __iomem *addr);
  23. #define log_write_mmio(val, width, addr) \
  24. do { \
  25. if (tracepoint_enabled(rwmmio_write)) \
  26. __log_write_mmio(val, width, addr); \
  27. } while (0)
  28. #define log_read_mmio(width, addr) \
  29. do { \
  30. if (tracepoint_enabled(rwmmio_read)) \
  31. __log_read_mmio(width, addr); \
  32. } while (0)
  33. #define log_post_read_mmio(val, width, addr) \
  34. do { \
  35. if (tracepoint_enabled(rwmmio_post_read)) \
  36. __log_post_read_mmio(val, width, addr); \
  37. } while (0)
  38. #else
  39. static inline void log_write_mmio(u64 val, u8 width, volatile void __iomem *addr)
  40. { }
  41. static inline void log_read_mmio(u8 width, const volatile void __iomem *addr)
  42. { }
  43. static inline void log_post_read_mmio(u64 val, u8 width, const volatile void __iomem *addr)
  44. { }
  45. #endif /* CONFIG_TRACE_MMIO_ACCESS */
  46. #endif /* __LOG_MMIORW_H__ */