i915_oa_hsw.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752
  1. /*
  2. * Autogenerated file, DO NOT EDIT manually!
  3. *
  4. * Copyright (c) 2015 Intel Corporation
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a
  7. * copy of this software and associated documentation files (the "Software"),
  8. * to deal in the Software without restriction, including without limitation
  9. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10. * and/or sell copies of the Software, and to permit persons to whom the
  11. * Software is furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice (including the next
  14. * paragraph) shall be included in all copies or substantial portions of the
  15. * Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  20. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  22. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  23. * IN THE SOFTWARE.
  24. *
  25. */
  26. #include <linux/sysfs.h>
  27. #include "i915_drv.h"
  28. #include "i915_oa_hsw.h"
  29. enum metric_set_id {
  30. METRIC_SET_ID_RENDER_BASIC = 1,
  31. METRIC_SET_ID_COMPUTE_BASIC,
  32. METRIC_SET_ID_COMPUTE_EXTENDED,
  33. METRIC_SET_ID_MEMORY_READS,
  34. METRIC_SET_ID_MEMORY_WRITES,
  35. METRIC_SET_ID_SAMPLER_BALANCE,
  36. };
  37. int i915_oa_n_builtin_metric_sets_hsw = 6;
  38. static const struct i915_oa_reg b_counter_config_render_basic[] = {
  39. { _MMIO(0x2724), 0x00800000 },
  40. { _MMIO(0x2720), 0x00000000 },
  41. { _MMIO(0x2714), 0x00800000 },
  42. { _MMIO(0x2710), 0x00000000 },
  43. };
  44. static const struct i915_oa_reg mux_config_render_basic[] = {
  45. { _MMIO(0x253a4), 0x01600000 },
  46. { _MMIO(0x25440), 0x00100000 },
  47. { _MMIO(0x25128), 0x00000000 },
  48. { _MMIO(0x2691c), 0x00000800 },
  49. { _MMIO(0x26aa0), 0x01500000 },
  50. { _MMIO(0x26b9c), 0x00006000 },
  51. { _MMIO(0x2791c), 0x00000800 },
  52. { _MMIO(0x27aa0), 0x01500000 },
  53. { _MMIO(0x27b9c), 0x00006000 },
  54. { _MMIO(0x2641c), 0x00000400 },
  55. { _MMIO(0x25380), 0x00000010 },
  56. { _MMIO(0x2538c), 0x00000000 },
  57. { _MMIO(0x25384), 0x0800aaaa },
  58. { _MMIO(0x25400), 0x00000004 },
  59. { _MMIO(0x2540c), 0x06029000 },
  60. { _MMIO(0x25410), 0x00000002 },
  61. { _MMIO(0x25404), 0x5c30ffff },
  62. { _MMIO(0x25100), 0x00000016 },
  63. { _MMIO(0x25110), 0x00000400 },
  64. { _MMIO(0x25104), 0x00000000 },
  65. { _MMIO(0x26804), 0x00001211 },
  66. { _MMIO(0x26884), 0x00000100 },
  67. { _MMIO(0x26900), 0x00000002 },
  68. { _MMIO(0x26908), 0x00700000 },
  69. { _MMIO(0x26904), 0x00000000 },
  70. { _MMIO(0x26984), 0x00001022 },
  71. { _MMIO(0x26a04), 0x00000011 },
  72. { _MMIO(0x26a80), 0x00000006 },
  73. { _MMIO(0x26a88), 0x00000c02 },
  74. { _MMIO(0x26a84), 0x00000000 },
  75. { _MMIO(0x26b04), 0x00001000 },
  76. { _MMIO(0x26b80), 0x00000002 },
  77. { _MMIO(0x26b8c), 0x00000007 },
  78. { _MMIO(0x26b84), 0x00000000 },
  79. { _MMIO(0x27804), 0x00004844 },
  80. { _MMIO(0x27884), 0x00000400 },
  81. { _MMIO(0x27900), 0x00000002 },
  82. { _MMIO(0x27908), 0x0e000000 },
  83. { _MMIO(0x27904), 0x00000000 },
  84. { _MMIO(0x27984), 0x00004088 },
  85. { _MMIO(0x27a04), 0x00000044 },
  86. { _MMIO(0x27a80), 0x00000006 },
  87. { _MMIO(0x27a88), 0x00018040 },
  88. { _MMIO(0x27a84), 0x00000000 },
  89. { _MMIO(0x27b04), 0x00004000 },
  90. { _MMIO(0x27b80), 0x00000002 },
  91. { _MMIO(0x27b8c), 0x000000e0 },
  92. { _MMIO(0x27b84), 0x00000000 },
  93. { _MMIO(0x26104), 0x00002222 },
  94. { _MMIO(0x26184), 0x0c006666 },
  95. { _MMIO(0x26284), 0x04000000 },
  96. { _MMIO(0x26304), 0x04000000 },
  97. { _MMIO(0x26400), 0x00000002 },
  98. { _MMIO(0x26410), 0x000000a0 },
  99. { _MMIO(0x26404), 0x00000000 },
  100. { _MMIO(0x25420), 0x04108020 },
  101. { _MMIO(0x25424), 0x1284a420 },
  102. { _MMIO(0x2541c), 0x00000000 },
  103. { _MMIO(0x25428), 0x00042049 },
  104. };
  105. static const struct i915_oa_reg *
  106. get_render_basic_mux_config(struct drm_i915_private *dev_priv,
  107. int *len)
  108. {
  109. *len = ARRAY_SIZE(mux_config_render_basic);
  110. return mux_config_render_basic;
  111. }
  112. static const struct i915_oa_reg b_counter_config_compute_basic[] = {
  113. { _MMIO(0x2710), 0x00000000 },
  114. { _MMIO(0x2714), 0x00800000 },
  115. { _MMIO(0x2718), 0xaaaaaaaa },
  116. { _MMIO(0x271c), 0xaaaaaaaa },
  117. { _MMIO(0x2720), 0x00000000 },
  118. { _MMIO(0x2724), 0x00800000 },
  119. { _MMIO(0x2728), 0xaaaaaaaa },
  120. { _MMIO(0x272c), 0xaaaaaaaa },
  121. { _MMIO(0x2740), 0x00000000 },
  122. { _MMIO(0x2744), 0x00000000 },
  123. { _MMIO(0x2748), 0x00000000 },
  124. { _MMIO(0x274c), 0x00000000 },
  125. { _MMIO(0x2750), 0x00000000 },
  126. { _MMIO(0x2754), 0x00000000 },
  127. { _MMIO(0x2758), 0x00000000 },
  128. { _MMIO(0x275c), 0x00000000 },
  129. { _MMIO(0x236c), 0x00000000 },
  130. };
  131. static const struct i915_oa_reg mux_config_compute_basic[] = {
  132. { _MMIO(0x253a4), 0x00000000 },
  133. { _MMIO(0x2681c), 0x01f00800 },
  134. { _MMIO(0x26820), 0x00001000 },
  135. { _MMIO(0x2781c), 0x01f00800 },
  136. { _MMIO(0x26520), 0x00000007 },
  137. { _MMIO(0x265a0), 0x00000007 },
  138. { _MMIO(0x25380), 0x00000010 },
  139. { _MMIO(0x2538c), 0x00300000 },
  140. { _MMIO(0x25384), 0xaa8aaaaa },
  141. { _MMIO(0x25404), 0xffffffff },
  142. { _MMIO(0x26800), 0x00004202 },
  143. { _MMIO(0x26808), 0x00605817 },
  144. { _MMIO(0x2680c), 0x10001005 },
  145. { _MMIO(0x26804), 0x00000000 },
  146. { _MMIO(0x27800), 0x00000102 },
  147. { _MMIO(0x27808), 0x0c0701e0 },
  148. { _MMIO(0x2780c), 0x000200a0 },
  149. { _MMIO(0x27804), 0x00000000 },
  150. { _MMIO(0x26484), 0x44000000 },
  151. { _MMIO(0x26704), 0x44000000 },
  152. { _MMIO(0x26500), 0x00000006 },
  153. { _MMIO(0x26510), 0x00000001 },
  154. { _MMIO(0x26504), 0x88000000 },
  155. { _MMIO(0x26580), 0x00000006 },
  156. { _MMIO(0x26590), 0x00000020 },
  157. { _MMIO(0x26584), 0x00000000 },
  158. { _MMIO(0x26104), 0x55822222 },
  159. { _MMIO(0x26184), 0xaa866666 },
  160. { _MMIO(0x25420), 0x08320c83 },
  161. { _MMIO(0x25424), 0x06820c83 },
  162. { _MMIO(0x2541c), 0x00000000 },
  163. { _MMIO(0x25428), 0x00000c03 },
  164. };
  165. static const struct i915_oa_reg *
  166. get_compute_basic_mux_config(struct drm_i915_private *dev_priv,
  167. int *len)
  168. {
  169. *len = ARRAY_SIZE(mux_config_compute_basic);
  170. return mux_config_compute_basic;
  171. }
  172. static const struct i915_oa_reg b_counter_config_compute_extended[] = {
  173. { _MMIO(0x2724), 0xf0800000 },
  174. { _MMIO(0x2720), 0x00000000 },
  175. { _MMIO(0x2714), 0xf0800000 },
  176. { _MMIO(0x2710), 0x00000000 },
  177. { _MMIO(0x2770), 0x0007fe2a },
  178. { _MMIO(0x2774), 0x0000ff00 },
  179. { _MMIO(0x2778), 0x0007fe6a },
  180. { _MMIO(0x277c), 0x0000ff00 },
  181. { _MMIO(0x2780), 0x0007fe92 },
  182. { _MMIO(0x2784), 0x0000ff00 },
  183. { _MMIO(0x2788), 0x0007fea2 },
  184. { _MMIO(0x278c), 0x0000ff00 },
  185. { _MMIO(0x2790), 0x0007fe32 },
  186. { _MMIO(0x2794), 0x0000ff00 },
  187. { _MMIO(0x2798), 0x0007fe9a },
  188. { _MMIO(0x279c), 0x0000ff00 },
  189. { _MMIO(0x27a0), 0x0007ff23 },
  190. { _MMIO(0x27a4), 0x0000ff00 },
  191. { _MMIO(0x27a8), 0x0007fff3 },
  192. { _MMIO(0x27ac), 0x0000fffe },
  193. };
  194. static const struct i915_oa_reg mux_config_compute_extended[] = {
  195. { _MMIO(0x2681c), 0x3eb00800 },
  196. { _MMIO(0x26820), 0x00900000 },
  197. { _MMIO(0x25384), 0x02aaaaaa },
  198. { _MMIO(0x25404), 0x03ffffff },
  199. { _MMIO(0x26800), 0x00142284 },
  200. { _MMIO(0x26808), 0x0e629062 },
  201. { _MMIO(0x2680c), 0x3f6f55cb },
  202. { _MMIO(0x26810), 0x00000014 },
  203. { _MMIO(0x26804), 0x00000000 },
  204. { _MMIO(0x26104), 0x02aaaaaa },
  205. { _MMIO(0x26184), 0x02aaaaaa },
  206. { _MMIO(0x25420), 0x00000000 },
  207. { _MMIO(0x25424), 0x00000000 },
  208. { _MMIO(0x2541c), 0x00000000 },
  209. { _MMIO(0x25428), 0x00000000 },
  210. };
  211. static const struct i915_oa_reg *
  212. get_compute_extended_mux_config(struct drm_i915_private *dev_priv,
  213. int *len)
  214. {
  215. *len = ARRAY_SIZE(mux_config_compute_extended);
  216. return mux_config_compute_extended;
  217. }
  218. static const struct i915_oa_reg b_counter_config_memory_reads[] = {
  219. { _MMIO(0x2724), 0xf0800000 },
  220. { _MMIO(0x2720), 0x00000000 },
  221. { _MMIO(0x2714), 0xf0800000 },
  222. { _MMIO(0x2710), 0x00000000 },
  223. { _MMIO(0x274c), 0x76543298 },
  224. { _MMIO(0x2748), 0x98989898 },
  225. { _MMIO(0x2744), 0x000000e4 },
  226. { _MMIO(0x2740), 0x00000000 },
  227. { _MMIO(0x275c), 0x98a98a98 },
  228. { _MMIO(0x2758), 0x88888888 },
  229. { _MMIO(0x2754), 0x000c5500 },
  230. { _MMIO(0x2750), 0x00000000 },
  231. { _MMIO(0x2770), 0x0007f81a },
  232. { _MMIO(0x2774), 0x0000fc00 },
  233. { _MMIO(0x2778), 0x0007f82a },
  234. { _MMIO(0x277c), 0x0000fc00 },
  235. { _MMIO(0x2780), 0x0007f872 },
  236. { _MMIO(0x2784), 0x0000fc00 },
  237. { _MMIO(0x2788), 0x0007f8ba },
  238. { _MMIO(0x278c), 0x0000fc00 },
  239. { _MMIO(0x2790), 0x0007f87a },
  240. { _MMIO(0x2794), 0x0000fc00 },
  241. { _MMIO(0x2798), 0x0007f8ea },
  242. { _MMIO(0x279c), 0x0000fc00 },
  243. { _MMIO(0x27a0), 0x0007f8e2 },
  244. { _MMIO(0x27a4), 0x0000fc00 },
  245. { _MMIO(0x27a8), 0x0007f8f2 },
  246. { _MMIO(0x27ac), 0x0000fc00 },
  247. };
  248. static const struct i915_oa_reg mux_config_memory_reads[] = {
  249. { _MMIO(0x253a4), 0x34300000 },
  250. { _MMIO(0x25440), 0x2d800000 },
  251. { _MMIO(0x25444), 0x00000008 },
  252. { _MMIO(0x25128), 0x0e600000 },
  253. { _MMIO(0x25380), 0x00000450 },
  254. { _MMIO(0x25390), 0x00052c43 },
  255. { _MMIO(0x25384), 0x00000000 },
  256. { _MMIO(0x25400), 0x00006144 },
  257. { _MMIO(0x25408), 0x0a418820 },
  258. { _MMIO(0x2540c), 0x000820e6 },
  259. { _MMIO(0x25404), 0xff500000 },
  260. { _MMIO(0x25100), 0x000005d6 },
  261. { _MMIO(0x2510c), 0x0ef00000 },
  262. { _MMIO(0x25104), 0x00000000 },
  263. { _MMIO(0x25420), 0x02108421 },
  264. { _MMIO(0x25424), 0x00008421 },
  265. { _MMIO(0x2541c), 0x00000000 },
  266. { _MMIO(0x25428), 0x00000000 },
  267. };
  268. static const struct i915_oa_reg *
  269. get_memory_reads_mux_config(struct drm_i915_private *dev_priv,
  270. int *len)
  271. {
  272. *len = ARRAY_SIZE(mux_config_memory_reads);
  273. return mux_config_memory_reads;
  274. }
  275. static const struct i915_oa_reg b_counter_config_memory_writes[] = {
  276. { _MMIO(0x2724), 0xf0800000 },
  277. { _MMIO(0x2720), 0x00000000 },
  278. { _MMIO(0x2714), 0xf0800000 },
  279. { _MMIO(0x2710), 0x00000000 },
  280. { _MMIO(0x274c), 0x76543298 },
  281. { _MMIO(0x2748), 0x98989898 },
  282. { _MMIO(0x2744), 0x000000e4 },
  283. { _MMIO(0x2740), 0x00000000 },
  284. { _MMIO(0x275c), 0xbabababa },
  285. { _MMIO(0x2758), 0x88888888 },
  286. { _MMIO(0x2754), 0x000c5500 },
  287. { _MMIO(0x2750), 0x00000000 },
  288. { _MMIO(0x2770), 0x0007f81a },
  289. { _MMIO(0x2774), 0x0000fc00 },
  290. { _MMIO(0x2778), 0x0007f82a },
  291. { _MMIO(0x277c), 0x0000fc00 },
  292. { _MMIO(0x2780), 0x0007f822 },
  293. { _MMIO(0x2784), 0x0000fc00 },
  294. { _MMIO(0x2788), 0x0007f8ba },
  295. { _MMIO(0x278c), 0x0000fc00 },
  296. { _MMIO(0x2790), 0x0007f87a },
  297. { _MMIO(0x2794), 0x0000fc00 },
  298. { _MMIO(0x2798), 0x0007f8ea },
  299. { _MMIO(0x279c), 0x0000fc00 },
  300. { _MMIO(0x27a0), 0x0007f8e2 },
  301. { _MMIO(0x27a4), 0x0000fc00 },
  302. { _MMIO(0x27a8), 0x0007f8f2 },
  303. { _MMIO(0x27ac), 0x0000fc00 },
  304. };
  305. static const struct i915_oa_reg mux_config_memory_writes[] = {
  306. { _MMIO(0x253a4), 0x34300000 },
  307. { _MMIO(0x25440), 0x01500000 },
  308. { _MMIO(0x25444), 0x00000120 },
  309. { _MMIO(0x25128), 0x0c200000 },
  310. { _MMIO(0x25380), 0x00000450 },
  311. { _MMIO(0x25390), 0x00052c43 },
  312. { _MMIO(0x25384), 0x00000000 },
  313. { _MMIO(0x25400), 0x00007184 },
  314. { _MMIO(0x25408), 0x0a418820 },
  315. { _MMIO(0x2540c), 0x000820e6 },
  316. { _MMIO(0x25404), 0xff500000 },
  317. { _MMIO(0x25100), 0x000005d6 },
  318. { _MMIO(0x2510c), 0x1e700000 },
  319. { _MMIO(0x25104), 0x00000000 },
  320. { _MMIO(0x25420), 0x02108421 },
  321. { _MMIO(0x25424), 0x00008421 },
  322. { _MMIO(0x2541c), 0x00000000 },
  323. { _MMIO(0x25428), 0x00000000 },
  324. };
  325. static const struct i915_oa_reg *
  326. get_memory_writes_mux_config(struct drm_i915_private *dev_priv,
  327. int *len)
  328. {
  329. *len = ARRAY_SIZE(mux_config_memory_writes);
  330. return mux_config_memory_writes;
  331. }
  332. static const struct i915_oa_reg b_counter_config_sampler_balance[] = {
  333. { _MMIO(0x2740), 0x00000000 },
  334. { _MMIO(0x2744), 0x00800000 },
  335. { _MMIO(0x2710), 0x00000000 },
  336. { _MMIO(0x2714), 0x00800000 },
  337. { _MMIO(0x2720), 0x00000000 },
  338. { _MMIO(0x2724), 0x00800000 },
  339. };
  340. static const struct i915_oa_reg mux_config_sampler_balance[] = {
  341. { _MMIO(0x2eb9c), 0x01906400 },
  342. { _MMIO(0x2fb9c), 0x01906400 },
  343. { _MMIO(0x253a4), 0x00000000 },
  344. { _MMIO(0x26b9c), 0x01906400 },
  345. { _MMIO(0x27b9c), 0x01906400 },
  346. { _MMIO(0x27104), 0x00a00000 },
  347. { _MMIO(0x27184), 0x00a50000 },
  348. { _MMIO(0x2e804), 0x00500000 },
  349. { _MMIO(0x2e984), 0x00500000 },
  350. { _MMIO(0x2eb04), 0x00500000 },
  351. { _MMIO(0x2eb80), 0x00000084 },
  352. { _MMIO(0x2eb8c), 0x14200000 },
  353. { _MMIO(0x2eb84), 0x00000000 },
  354. { _MMIO(0x2f804), 0x00050000 },
  355. { _MMIO(0x2f984), 0x00050000 },
  356. { _MMIO(0x2fb04), 0x00050000 },
  357. { _MMIO(0x2fb80), 0x00000084 },
  358. { _MMIO(0x2fb8c), 0x00050800 },
  359. { _MMIO(0x2fb84), 0x00000000 },
  360. { _MMIO(0x25380), 0x00000010 },
  361. { _MMIO(0x2538c), 0x000000c0 },
  362. { _MMIO(0x25384), 0xaa550000 },
  363. { _MMIO(0x25404), 0xffffc000 },
  364. { _MMIO(0x26804), 0x50000000 },
  365. { _MMIO(0x26984), 0x50000000 },
  366. { _MMIO(0x26b04), 0x50000000 },
  367. { _MMIO(0x26b80), 0x00000084 },
  368. { _MMIO(0x26b90), 0x00050800 },
  369. { _MMIO(0x26b84), 0x00000000 },
  370. { _MMIO(0x27804), 0x05000000 },
  371. { _MMIO(0x27984), 0x05000000 },
  372. { _MMIO(0x27b04), 0x05000000 },
  373. { _MMIO(0x27b80), 0x00000084 },
  374. { _MMIO(0x27b90), 0x00000142 },
  375. { _MMIO(0x27b84), 0x00000000 },
  376. { _MMIO(0x26104), 0xa0000000 },
  377. { _MMIO(0x26184), 0xa5000000 },
  378. { _MMIO(0x25424), 0x00008620 },
  379. { _MMIO(0x2541c), 0x00000000 },
  380. { _MMIO(0x25428), 0x0004a54a },
  381. };
  382. static const struct i915_oa_reg *
  383. get_sampler_balance_mux_config(struct drm_i915_private *dev_priv,
  384. int *len)
  385. {
  386. *len = ARRAY_SIZE(mux_config_sampler_balance);
  387. return mux_config_sampler_balance;
  388. }
  389. int i915_oa_select_metric_set_hsw(struct drm_i915_private *dev_priv)
  390. {
  391. dev_priv->perf.oa.mux_regs = NULL;
  392. dev_priv->perf.oa.mux_regs_len = 0;
  393. dev_priv->perf.oa.b_counter_regs = NULL;
  394. dev_priv->perf.oa.b_counter_regs_len = 0;
  395. switch (dev_priv->perf.oa.metrics_set) {
  396. case METRIC_SET_ID_RENDER_BASIC:
  397. dev_priv->perf.oa.mux_regs =
  398. get_render_basic_mux_config(dev_priv,
  399. &dev_priv->perf.oa.mux_regs_len);
  400. if (!dev_priv->perf.oa.mux_regs) {
  401. DRM_DEBUG_DRIVER("No suitable MUX config for \"RENDER_BASIC\" metric set");
  402. /* EINVAL because *_register_sysfs already checked this
  403. * and so it wouldn't have been advertised so userspace and
  404. * so shouldn't have been requested
  405. */
  406. return -EINVAL;
  407. }
  408. dev_priv->perf.oa.b_counter_regs =
  409. b_counter_config_render_basic;
  410. dev_priv->perf.oa.b_counter_regs_len =
  411. ARRAY_SIZE(b_counter_config_render_basic);
  412. return 0;
  413. case METRIC_SET_ID_COMPUTE_BASIC:
  414. dev_priv->perf.oa.mux_regs =
  415. get_compute_basic_mux_config(dev_priv,
  416. &dev_priv->perf.oa.mux_regs_len);
  417. if (!dev_priv->perf.oa.mux_regs) {
  418. DRM_DEBUG_DRIVER("No suitable MUX config for \"COMPUTE_BASIC\" metric set");
  419. /* EINVAL because *_register_sysfs already checked this
  420. * and so it wouldn't have been advertised so userspace and
  421. * so shouldn't have been requested
  422. */
  423. return -EINVAL;
  424. }
  425. dev_priv->perf.oa.b_counter_regs =
  426. b_counter_config_compute_basic;
  427. dev_priv->perf.oa.b_counter_regs_len =
  428. ARRAY_SIZE(b_counter_config_compute_basic);
  429. return 0;
  430. case METRIC_SET_ID_COMPUTE_EXTENDED:
  431. dev_priv->perf.oa.mux_regs =
  432. get_compute_extended_mux_config(dev_priv,
  433. &dev_priv->perf.oa.mux_regs_len);
  434. if (!dev_priv->perf.oa.mux_regs) {
  435. DRM_DEBUG_DRIVER("No suitable MUX config for \"COMPUTE_EXTENDED\" metric set");
  436. /* EINVAL because *_register_sysfs already checked this
  437. * and so it wouldn't have been advertised so userspace and
  438. * so shouldn't have been requested
  439. */
  440. return -EINVAL;
  441. }
  442. dev_priv->perf.oa.b_counter_regs =
  443. b_counter_config_compute_extended;
  444. dev_priv->perf.oa.b_counter_regs_len =
  445. ARRAY_SIZE(b_counter_config_compute_extended);
  446. return 0;
  447. case METRIC_SET_ID_MEMORY_READS:
  448. dev_priv->perf.oa.mux_regs =
  449. get_memory_reads_mux_config(dev_priv,
  450. &dev_priv->perf.oa.mux_regs_len);
  451. if (!dev_priv->perf.oa.mux_regs) {
  452. DRM_DEBUG_DRIVER("No suitable MUX config for \"MEMORY_READS\" metric set");
  453. /* EINVAL because *_register_sysfs already checked this
  454. * and so it wouldn't have been advertised so userspace and
  455. * so shouldn't have been requested
  456. */
  457. return -EINVAL;
  458. }
  459. dev_priv->perf.oa.b_counter_regs =
  460. b_counter_config_memory_reads;
  461. dev_priv->perf.oa.b_counter_regs_len =
  462. ARRAY_SIZE(b_counter_config_memory_reads);
  463. return 0;
  464. case METRIC_SET_ID_MEMORY_WRITES:
  465. dev_priv->perf.oa.mux_regs =
  466. get_memory_writes_mux_config(dev_priv,
  467. &dev_priv->perf.oa.mux_regs_len);
  468. if (!dev_priv->perf.oa.mux_regs) {
  469. DRM_DEBUG_DRIVER("No suitable MUX config for \"MEMORY_WRITES\" metric set");
  470. /* EINVAL because *_register_sysfs already checked this
  471. * and so it wouldn't have been advertised so userspace and
  472. * so shouldn't have been requested
  473. */
  474. return -EINVAL;
  475. }
  476. dev_priv->perf.oa.b_counter_regs =
  477. b_counter_config_memory_writes;
  478. dev_priv->perf.oa.b_counter_regs_len =
  479. ARRAY_SIZE(b_counter_config_memory_writes);
  480. return 0;
  481. case METRIC_SET_ID_SAMPLER_BALANCE:
  482. dev_priv->perf.oa.mux_regs =
  483. get_sampler_balance_mux_config(dev_priv,
  484. &dev_priv->perf.oa.mux_regs_len);
  485. if (!dev_priv->perf.oa.mux_regs) {
  486. DRM_DEBUG_DRIVER("No suitable MUX config for \"SAMPLER_BALANCE\" metric set");
  487. /* EINVAL because *_register_sysfs already checked this
  488. * and so it wouldn't have been advertised so userspace and
  489. * so shouldn't have been requested
  490. */
  491. return -EINVAL;
  492. }
  493. dev_priv->perf.oa.b_counter_regs =
  494. b_counter_config_sampler_balance;
  495. dev_priv->perf.oa.b_counter_regs_len =
  496. ARRAY_SIZE(b_counter_config_sampler_balance);
  497. return 0;
  498. default:
  499. return -ENODEV;
  500. }
  501. }
  502. static ssize_t
  503. show_render_basic_id(struct device *kdev, struct device_attribute *attr, char *buf)
  504. {
  505. return sprintf(buf, "%d\n", METRIC_SET_ID_RENDER_BASIC);
  506. }
  507. static struct device_attribute dev_attr_render_basic_id = {
  508. .attr = { .name = "id", .mode = 0444 },
  509. .show = show_render_basic_id,
  510. .store = NULL,
  511. };
  512. static struct attribute *attrs_render_basic[] = {
  513. &dev_attr_render_basic_id.attr,
  514. NULL,
  515. };
  516. static struct attribute_group group_render_basic = {
  517. .name = "403d8832-1a27-4aa6-a64e-f5389ce7b212",
  518. .attrs = attrs_render_basic,
  519. };
  520. static ssize_t
  521. show_compute_basic_id(struct device *kdev, struct device_attribute *attr, char *buf)
  522. {
  523. return sprintf(buf, "%d\n", METRIC_SET_ID_COMPUTE_BASIC);
  524. }
  525. static struct device_attribute dev_attr_compute_basic_id = {
  526. .attr = { .name = "id", .mode = 0444 },
  527. .show = show_compute_basic_id,
  528. .store = NULL,
  529. };
  530. static struct attribute *attrs_compute_basic[] = {
  531. &dev_attr_compute_basic_id.attr,
  532. NULL,
  533. };
  534. static struct attribute_group group_compute_basic = {
  535. .name = "39ad14bc-2380-45c4-91eb-fbcb3aa7ae7b",
  536. .attrs = attrs_compute_basic,
  537. };
  538. static ssize_t
  539. show_compute_extended_id(struct device *kdev, struct device_attribute *attr, char *buf)
  540. {
  541. return sprintf(buf, "%d\n", METRIC_SET_ID_COMPUTE_EXTENDED);
  542. }
  543. static struct device_attribute dev_attr_compute_extended_id = {
  544. .attr = { .name = "id", .mode = 0444 },
  545. .show = show_compute_extended_id,
  546. .store = NULL,
  547. };
  548. static struct attribute *attrs_compute_extended[] = {
  549. &dev_attr_compute_extended_id.attr,
  550. NULL,
  551. };
  552. static struct attribute_group group_compute_extended = {
  553. .name = "3865be28-6982-49fe-9494-e4d1b4795413",
  554. .attrs = attrs_compute_extended,
  555. };
  556. static ssize_t
  557. show_memory_reads_id(struct device *kdev, struct device_attribute *attr, char *buf)
  558. {
  559. return sprintf(buf, "%d\n", METRIC_SET_ID_MEMORY_READS);
  560. }
  561. static struct device_attribute dev_attr_memory_reads_id = {
  562. .attr = { .name = "id", .mode = 0444 },
  563. .show = show_memory_reads_id,
  564. .store = NULL,
  565. };
  566. static struct attribute *attrs_memory_reads[] = {
  567. &dev_attr_memory_reads_id.attr,
  568. NULL,
  569. };
  570. static struct attribute_group group_memory_reads = {
  571. .name = "bb5ed49b-2497-4095-94f6-26ba294db88a",
  572. .attrs = attrs_memory_reads,
  573. };
  574. static ssize_t
  575. show_memory_writes_id(struct device *kdev, struct device_attribute *attr, char *buf)
  576. {
  577. return sprintf(buf, "%d\n", METRIC_SET_ID_MEMORY_WRITES);
  578. }
  579. static struct device_attribute dev_attr_memory_writes_id = {
  580. .attr = { .name = "id", .mode = 0444 },
  581. .show = show_memory_writes_id,
  582. .store = NULL,
  583. };
  584. static struct attribute *attrs_memory_writes[] = {
  585. &dev_attr_memory_writes_id.attr,
  586. NULL,
  587. };
  588. static struct attribute_group group_memory_writes = {
  589. .name = "3358d639-9b5f-45ab-976d-9b08cbfc6240",
  590. .attrs = attrs_memory_writes,
  591. };
  592. static ssize_t
  593. show_sampler_balance_id(struct device *kdev, struct device_attribute *attr, char *buf)
  594. {
  595. return sprintf(buf, "%d\n", METRIC_SET_ID_SAMPLER_BALANCE);
  596. }
  597. static struct device_attribute dev_attr_sampler_balance_id = {
  598. .attr = { .name = "id", .mode = 0444 },
  599. .show = show_sampler_balance_id,
  600. .store = NULL,
  601. };
  602. static struct attribute *attrs_sampler_balance[] = {
  603. &dev_attr_sampler_balance_id.attr,
  604. NULL,
  605. };
  606. static struct attribute_group group_sampler_balance = {
  607. .name = "bc274488-b4b6-40c7-90da-b77d7ad16189",
  608. .attrs = attrs_sampler_balance,
  609. };
  610. int
  611. i915_perf_register_sysfs_hsw(struct drm_i915_private *dev_priv)
  612. {
  613. int mux_len;
  614. int ret = 0;
  615. if (get_render_basic_mux_config(dev_priv, &mux_len)) {
  616. ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_render_basic);
  617. if (ret)
  618. goto error_render_basic;
  619. }
  620. if (get_compute_basic_mux_config(dev_priv, &mux_len)) {
  621. ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_compute_basic);
  622. if (ret)
  623. goto error_compute_basic;
  624. }
  625. if (get_compute_extended_mux_config(dev_priv, &mux_len)) {
  626. ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_compute_extended);
  627. if (ret)
  628. goto error_compute_extended;
  629. }
  630. if (get_memory_reads_mux_config(dev_priv, &mux_len)) {
  631. ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_memory_reads);
  632. if (ret)
  633. goto error_memory_reads;
  634. }
  635. if (get_memory_writes_mux_config(dev_priv, &mux_len)) {
  636. ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_memory_writes);
  637. if (ret)
  638. goto error_memory_writes;
  639. }
  640. if (get_sampler_balance_mux_config(dev_priv, &mux_len)) {
  641. ret = sysfs_create_group(dev_priv->perf.metrics_kobj, &group_sampler_balance);
  642. if (ret)
  643. goto error_sampler_balance;
  644. }
  645. return 0;
  646. error_sampler_balance:
  647. if (get_sampler_balance_mux_config(dev_priv, &mux_len))
  648. sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_memory_writes);
  649. error_memory_writes:
  650. if (get_sampler_balance_mux_config(dev_priv, &mux_len))
  651. sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_memory_reads);
  652. error_memory_reads:
  653. if (get_sampler_balance_mux_config(dev_priv, &mux_len))
  654. sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_compute_extended);
  655. error_compute_extended:
  656. if (get_sampler_balance_mux_config(dev_priv, &mux_len))
  657. sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_compute_basic);
  658. error_compute_basic:
  659. if (get_sampler_balance_mux_config(dev_priv, &mux_len))
  660. sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_render_basic);
  661. error_render_basic:
  662. return ret;
  663. }
  664. void
  665. i915_perf_unregister_sysfs_hsw(struct drm_i915_private *dev_priv)
  666. {
  667. int mux_len;
  668. if (get_render_basic_mux_config(dev_priv, &mux_len))
  669. sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_render_basic);
  670. if (get_compute_basic_mux_config(dev_priv, &mux_len))
  671. sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_compute_basic);
  672. if (get_compute_extended_mux_config(dev_priv, &mux_len))
  673. sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_compute_extended);
  674. if (get_memory_reads_mux_config(dev_priv, &mux_len))
  675. sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_memory_reads);
  676. if (get_memory_writes_mux_config(dev_priv, &mux_len))
  677. sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_memory_writes);
  678. if (get_sampler_balance_mux_config(dev_priv, &mux_len))
  679. sysfs_remove_group(dev_priv->perf.metrics_kobj, &group_sampler_balance);
  680. }