iommu.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. /*
  2. * iommu trace points
  3. *
  4. * Copyright (C) 2013 Shuah Khan <[email protected]>
  5. *
  6. */
  7. #undef TRACE_SYSTEM
  8. #define TRACE_SYSTEM iommu
  9. #if !defined(_TRACE_IOMMU_H) || defined(TRACE_HEADER_MULTI_READ)
  10. #define _TRACE_IOMMU_H
  11. #include <linux/tracepoint.h>
  12. #include <linux/pci.h>
  13. #include <linux/iommu.h>
  14. struct device;
  15. struct iommu_domain;
  16. DECLARE_EVENT_CLASS(iommu_group_event,
  17. TP_PROTO(int group_id, struct device *dev),
  18. TP_ARGS(group_id, dev),
  19. TP_STRUCT__entry(
  20. __field(int, gid)
  21. __string(device, dev_name(dev))
  22. ),
  23. TP_fast_assign(
  24. __entry->gid = group_id;
  25. __assign_str(device, dev_name(dev));
  26. ),
  27. TP_printk("IOMMU: groupID=%d device=%s",
  28. __entry->gid, __get_str(device)
  29. )
  30. );
  31. DEFINE_EVENT(iommu_group_event, add_device_to_group,
  32. TP_PROTO(int group_id, struct device *dev),
  33. TP_ARGS(group_id, dev)
  34. );
  35. DEFINE_EVENT(iommu_group_event, remove_device_from_group,
  36. TP_PROTO(int group_id, struct device *dev),
  37. TP_ARGS(group_id, dev)
  38. );
  39. DECLARE_EVENT_CLASS(iommu_device_event,
  40. TP_PROTO(struct device *dev),
  41. TP_ARGS(dev),
  42. TP_STRUCT__entry(
  43. __string(device, dev_name(dev))
  44. ),
  45. TP_fast_assign(
  46. __assign_str(device, dev_name(dev));
  47. ),
  48. TP_printk("IOMMU: device=%s", __get_str(device)
  49. )
  50. );
  51. DEFINE_EVENT(iommu_device_event, attach_device_to_domain,
  52. TP_PROTO(struct device *dev),
  53. TP_ARGS(dev)
  54. );
  55. DEFINE_EVENT(iommu_device_event, detach_device_from_domain,
  56. TP_PROTO(struct device *dev),
  57. TP_ARGS(dev)
  58. );
  59. TRACE_EVENT(map,
  60. TP_PROTO(struct iommu_domain *domain, unsigned long iova,
  61. phys_addr_t paddr, size_t size, int prot),
  62. TP_ARGS(domain, iova, paddr, size, prot),
  63. TP_STRUCT__entry(
  64. __string(name, domain->name)
  65. __field(u64, iova)
  66. __field(u64, paddr)
  67. __field(size_t, size)
  68. __field(int, prot)
  69. ),
  70. TP_fast_assign(
  71. __assign_str(name, domain->name);
  72. __entry->iova = iova;
  73. __entry->paddr = paddr;
  74. __entry->size = size;
  75. __entry->prot = prot;
  76. ),
  77. TP_printk("IOMMU:%s iova=0x%016llx paddr=0x%016llx size=0x%zx prot=0x%x",
  78. __get_str(name), __entry->iova, __entry->paddr,
  79. __entry->size, __entry->prot
  80. )
  81. );
  82. TRACE_EVENT(unmap,
  83. TP_PROTO(struct iommu_domain *domain, unsigned long iova, size_t size,
  84. size_t unmapped_size),
  85. TP_ARGS(domain, iova, size, unmapped_size),
  86. TP_STRUCT__entry(
  87. __string(name, domain->name)
  88. __field(u64, iova)
  89. __field(size_t, size)
  90. __field(size_t, unmapped_size)
  91. ),
  92. TP_fast_assign(
  93. __assign_str(name, domain->name);
  94. __entry->iova = iova;
  95. __entry->size = size;
  96. __entry->unmapped_size = unmapped_size;
  97. ),
  98. TP_printk("IOMMU:%s iova=0x%016llx size=0x%zx unmapped_size=0x%zx",
  99. __get_str(name), __entry->iova, __entry->size,
  100. __entry->unmapped_size
  101. )
  102. );
  103. TRACE_EVENT(map_sg,
  104. TP_PROTO(struct iommu_domain *domain, unsigned long iova, size_t size,
  105. int prot),
  106. TP_ARGS(domain, iova, size, prot),
  107. TP_STRUCT__entry(
  108. __string(name, domain->name)
  109. __field(u64, iova)
  110. __field(size_t, size)
  111. __field(int, prot)
  112. ),
  113. TP_fast_assign(
  114. __assign_str(name, domain->name);
  115. __entry->iova = iova;
  116. __entry->size = size;
  117. __entry->prot = prot;
  118. ),
  119. TP_printk("IOMMU:%s iova=0x%016llx size=0x%zx prot=0x%x",
  120. __get_str(name), __entry->iova, __entry->size,
  121. __entry->prot
  122. )
  123. );
  124. DECLARE_EVENT_CLASS(iommu_error,
  125. TP_PROTO(struct device *dev, unsigned long iova, int flags),
  126. TP_ARGS(dev, iova, flags),
  127. TP_STRUCT__entry(
  128. __string(device, dev_name(dev))
  129. __string(driver, dev_driver_string(dev))
  130. __field(u64, iova)
  131. __field(int, flags)
  132. ),
  133. TP_fast_assign(
  134. __assign_str(device, dev_name(dev));
  135. __assign_str(driver, dev_driver_string(dev));
  136. __entry->iova = iova;
  137. __entry->flags = flags;
  138. ),
  139. TP_printk("IOMMU:%s %s iova=0x%016llx flags=0x%04x",
  140. __get_str(driver), __get_str(device),
  141. __entry->iova, __entry->flags
  142. )
  143. );
  144. DEFINE_EVENT(iommu_error, io_page_fault,
  145. TP_PROTO(struct device *dev, unsigned long iova, int flags),
  146. TP_ARGS(dev, iova, flags)
  147. );
  148. DECLARE_EVENT_CLASS(iommu_tlbi,
  149. TP_PROTO(struct device *dev, u64 time),
  150. TP_ARGS(dev, time),
  151. TP_STRUCT__entry(
  152. __string(device, dev_name(dev))
  153. __field(u64, time)
  154. ),
  155. TP_fast_assign(
  156. __assign_str(device, dev_name(dev));
  157. __entry->time = time;
  158. ),
  159. TP_printk("IOMMU:%s %lld us",
  160. __get_str(device), __entry->time
  161. )
  162. );
  163. DEFINE_EVENT(iommu_tlbi, tlbi_start,
  164. TP_PROTO(struct device *dev, u64 time),
  165. TP_ARGS(dev, time)
  166. );
  167. DEFINE_EVENT(iommu_tlbi, tlbi_end,
  168. TP_PROTO(struct device *dev, u64 time),
  169. TP_ARGS(dev, time)
  170. );
  171. DEFINE_EVENT(iommu_tlbi, tlbi_throttle_start,
  172. TP_PROTO(struct device *dev, u64 time),
  173. TP_ARGS(dev, time)
  174. );
  175. DEFINE_EVENT(iommu_tlbi, tlbi_throttle_end,
  176. TP_PROTO(struct device *dev, u64 time),
  177. TP_ARGS(dev, time)
  178. );
  179. DEFINE_EVENT(iommu_tlbi, tlbsync_timeout,
  180. TP_PROTO(struct device *dev, u64 time),
  181. TP_ARGS(dev, time)
  182. );
  183. TRACE_EVENT(smmu_init,
  184. TP_PROTO(u64 time),
  185. TP_ARGS(time),
  186. TP_STRUCT__entry(
  187. __field(u64, time)
  188. ),
  189. TP_fast_assign(
  190. __entry->time = time;
  191. ),
  192. TP_printk("ARM SMMU init latency: %lld us", __entry->time)
  193. );
  194. #endif /* _TRACE_IOMMU_H */
  195. /* This part must be outside protection */
  196. #include <trace/define_trace.h>