etnaviv_gpu.c 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750
  1. /*
  2. * Copyright (C) 2015 Etnaviv Project
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License version 2 as published by
  6. * the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful, but WITHOUT
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. * more details.
  12. *
  13. * You should have received a copy of the GNU General Public License along with
  14. * this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include <linux/component.h>
  17. #include <linux/fence.h>
  18. #include <linux/moduleparam.h>
  19. #include <linux/of_device.h>
  20. #include "etnaviv_dump.h"
  21. #include "etnaviv_gpu.h"
  22. #include "etnaviv_gem.h"
  23. #include "etnaviv_mmu.h"
  24. #include "common.xml.h"
  25. #include "state.xml.h"
  26. #include "state_hi.xml.h"
  27. #include "cmdstream.xml.h"
  28. static const struct platform_device_id gpu_ids[] = {
  29. { .name = "etnaviv-gpu,2d" },
  30. { },
  31. };
  32. static bool etnaviv_dump_core = true;
  33. module_param_named(dump_core, etnaviv_dump_core, bool, 0600);
  34. /*
  35. * Driver functions:
  36. */
  37. int etnaviv_gpu_get_param(struct etnaviv_gpu *gpu, u32 param, u64 *value)
  38. {
  39. switch (param) {
  40. case ETNAVIV_PARAM_GPU_MODEL:
  41. *value = gpu->identity.model;
  42. break;
  43. case ETNAVIV_PARAM_GPU_REVISION:
  44. *value = gpu->identity.revision;
  45. break;
  46. case ETNAVIV_PARAM_GPU_FEATURES_0:
  47. *value = gpu->identity.features;
  48. break;
  49. case ETNAVIV_PARAM_GPU_FEATURES_1:
  50. *value = gpu->identity.minor_features0;
  51. break;
  52. case ETNAVIV_PARAM_GPU_FEATURES_2:
  53. *value = gpu->identity.minor_features1;
  54. break;
  55. case ETNAVIV_PARAM_GPU_FEATURES_3:
  56. *value = gpu->identity.minor_features2;
  57. break;
  58. case ETNAVIV_PARAM_GPU_FEATURES_4:
  59. *value = gpu->identity.minor_features3;
  60. break;
  61. case ETNAVIV_PARAM_GPU_FEATURES_5:
  62. *value = gpu->identity.minor_features4;
  63. break;
  64. case ETNAVIV_PARAM_GPU_FEATURES_6:
  65. *value = gpu->identity.minor_features5;
  66. break;
  67. case ETNAVIV_PARAM_GPU_STREAM_COUNT:
  68. *value = gpu->identity.stream_count;
  69. break;
  70. case ETNAVIV_PARAM_GPU_REGISTER_MAX:
  71. *value = gpu->identity.register_max;
  72. break;
  73. case ETNAVIV_PARAM_GPU_THREAD_COUNT:
  74. *value = gpu->identity.thread_count;
  75. break;
  76. case ETNAVIV_PARAM_GPU_VERTEX_CACHE_SIZE:
  77. *value = gpu->identity.vertex_cache_size;
  78. break;
  79. case ETNAVIV_PARAM_GPU_SHADER_CORE_COUNT:
  80. *value = gpu->identity.shader_core_count;
  81. break;
  82. case ETNAVIV_PARAM_GPU_PIXEL_PIPES:
  83. *value = gpu->identity.pixel_pipes;
  84. break;
  85. case ETNAVIV_PARAM_GPU_VERTEX_OUTPUT_BUFFER_SIZE:
  86. *value = gpu->identity.vertex_output_buffer_size;
  87. break;
  88. case ETNAVIV_PARAM_GPU_BUFFER_SIZE:
  89. *value = gpu->identity.buffer_size;
  90. break;
  91. case ETNAVIV_PARAM_GPU_INSTRUCTION_COUNT:
  92. *value = gpu->identity.instruction_count;
  93. break;
  94. case ETNAVIV_PARAM_GPU_NUM_CONSTANTS:
  95. *value = gpu->identity.num_constants;
  96. break;
  97. case ETNAVIV_PARAM_GPU_NUM_VARYINGS:
  98. *value = gpu->identity.varyings_count;
  99. break;
  100. default:
  101. DBG("%s: invalid param: %u", dev_name(gpu->dev), param);
  102. return -EINVAL;
  103. }
  104. return 0;
  105. }
  106. #define etnaviv_is_model_rev(gpu, mod, rev) \
  107. ((gpu)->identity.model == chipModel_##mod && \
  108. (gpu)->identity.revision == rev)
  109. #define etnaviv_field(val, field) \
  110. (((val) & field##__MASK) >> field##__SHIFT)
  111. static void etnaviv_hw_specs(struct etnaviv_gpu *gpu)
  112. {
  113. if (gpu->identity.minor_features0 &
  114. chipMinorFeatures0_MORE_MINOR_FEATURES) {
  115. u32 specs[4];
  116. unsigned int streams;
  117. specs[0] = gpu_read(gpu, VIVS_HI_CHIP_SPECS);
  118. specs[1] = gpu_read(gpu, VIVS_HI_CHIP_SPECS_2);
  119. specs[2] = gpu_read(gpu, VIVS_HI_CHIP_SPECS_3);
  120. specs[3] = gpu_read(gpu, VIVS_HI_CHIP_SPECS_4);
  121. gpu->identity.stream_count = etnaviv_field(specs[0],
  122. VIVS_HI_CHIP_SPECS_STREAM_COUNT);
  123. gpu->identity.register_max = etnaviv_field(specs[0],
  124. VIVS_HI_CHIP_SPECS_REGISTER_MAX);
  125. gpu->identity.thread_count = etnaviv_field(specs[0],
  126. VIVS_HI_CHIP_SPECS_THREAD_COUNT);
  127. gpu->identity.vertex_cache_size = etnaviv_field(specs[0],
  128. VIVS_HI_CHIP_SPECS_VERTEX_CACHE_SIZE);
  129. gpu->identity.shader_core_count = etnaviv_field(specs[0],
  130. VIVS_HI_CHIP_SPECS_SHADER_CORE_COUNT);
  131. gpu->identity.pixel_pipes = etnaviv_field(specs[0],
  132. VIVS_HI_CHIP_SPECS_PIXEL_PIPES);
  133. gpu->identity.vertex_output_buffer_size =
  134. etnaviv_field(specs[0],
  135. VIVS_HI_CHIP_SPECS_VERTEX_OUTPUT_BUFFER_SIZE);
  136. gpu->identity.buffer_size = etnaviv_field(specs[1],
  137. VIVS_HI_CHIP_SPECS_2_BUFFER_SIZE);
  138. gpu->identity.instruction_count = etnaviv_field(specs[1],
  139. VIVS_HI_CHIP_SPECS_2_INSTRUCTION_COUNT);
  140. gpu->identity.num_constants = etnaviv_field(specs[1],
  141. VIVS_HI_CHIP_SPECS_2_NUM_CONSTANTS);
  142. gpu->identity.varyings_count = etnaviv_field(specs[2],
  143. VIVS_HI_CHIP_SPECS_3_VARYINGS_COUNT);
  144. /* This overrides the value from older register if non-zero */
  145. streams = etnaviv_field(specs[3],
  146. VIVS_HI_CHIP_SPECS_4_STREAM_COUNT);
  147. if (streams)
  148. gpu->identity.stream_count = streams;
  149. }
  150. /* Fill in the stream count if not specified */
  151. if (gpu->identity.stream_count == 0) {
  152. if (gpu->identity.model >= 0x1000)
  153. gpu->identity.stream_count = 4;
  154. else
  155. gpu->identity.stream_count = 1;
  156. }
  157. /* Convert the register max value */
  158. if (gpu->identity.register_max)
  159. gpu->identity.register_max = 1 << gpu->identity.register_max;
  160. else if (gpu->identity.model == chipModel_GC400)
  161. gpu->identity.register_max = 32;
  162. else
  163. gpu->identity.register_max = 64;
  164. /* Convert thread count */
  165. if (gpu->identity.thread_count)
  166. gpu->identity.thread_count = 1 << gpu->identity.thread_count;
  167. else if (gpu->identity.model == chipModel_GC400)
  168. gpu->identity.thread_count = 64;
  169. else if (gpu->identity.model == chipModel_GC500 ||
  170. gpu->identity.model == chipModel_GC530)
  171. gpu->identity.thread_count = 128;
  172. else
  173. gpu->identity.thread_count = 256;
  174. if (gpu->identity.vertex_cache_size == 0)
  175. gpu->identity.vertex_cache_size = 8;
  176. if (gpu->identity.shader_core_count == 0) {
  177. if (gpu->identity.model >= 0x1000)
  178. gpu->identity.shader_core_count = 2;
  179. else
  180. gpu->identity.shader_core_count = 1;
  181. }
  182. if (gpu->identity.pixel_pipes == 0)
  183. gpu->identity.pixel_pipes = 1;
  184. /* Convert virtex buffer size */
  185. if (gpu->identity.vertex_output_buffer_size) {
  186. gpu->identity.vertex_output_buffer_size =
  187. 1 << gpu->identity.vertex_output_buffer_size;
  188. } else if (gpu->identity.model == chipModel_GC400) {
  189. if (gpu->identity.revision < 0x4000)
  190. gpu->identity.vertex_output_buffer_size = 512;
  191. else if (gpu->identity.revision < 0x4200)
  192. gpu->identity.vertex_output_buffer_size = 256;
  193. else
  194. gpu->identity.vertex_output_buffer_size = 128;
  195. } else {
  196. gpu->identity.vertex_output_buffer_size = 512;
  197. }
  198. switch (gpu->identity.instruction_count) {
  199. case 0:
  200. if (etnaviv_is_model_rev(gpu, GC2000, 0x5108) ||
  201. gpu->identity.model == chipModel_GC880)
  202. gpu->identity.instruction_count = 512;
  203. else
  204. gpu->identity.instruction_count = 256;
  205. break;
  206. case 1:
  207. gpu->identity.instruction_count = 1024;
  208. break;
  209. case 2:
  210. gpu->identity.instruction_count = 2048;
  211. break;
  212. default:
  213. gpu->identity.instruction_count = 256;
  214. break;
  215. }
  216. if (gpu->identity.num_constants == 0)
  217. gpu->identity.num_constants = 168;
  218. if (gpu->identity.varyings_count == 0) {
  219. if (gpu->identity.minor_features1 & chipMinorFeatures1_HALTI0)
  220. gpu->identity.varyings_count = 12;
  221. else
  222. gpu->identity.varyings_count = 8;
  223. }
  224. /*
  225. * For some cores, two varyings are consumed for position, so the
  226. * maximum varying count needs to be reduced by one.
  227. */
  228. if (etnaviv_is_model_rev(gpu, GC5000, 0x5434) ||
  229. etnaviv_is_model_rev(gpu, GC4000, 0x5222) ||
  230. etnaviv_is_model_rev(gpu, GC4000, 0x5245) ||
  231. etnaviv_is_model_rev(gpu, GC4000, 0x5208) ||
  232. etnaviv_is_model_rev(gpu, GC3000, 0x5435) ||
  233. etnaviv_is_model_rev(gpu, GC2200, 0x5244) ||
  234. etnaviv_is_model_rev(gpu, GC2100, 0x5108) ||
  235. etnaviv_is_model_rev(gpu, GC2000, 0x5108) ||
  236. etnaviv_is_model_rev(gpu, GC1500, 0x5246) ||
  237. etnaviv_is_model_rev(gpu, GC880, 0x5107) ||
  238. etnaviv_is_model_rev(gpu, GC880, 0x5106))
  239. gpu->identity.varyings_count -= 1;
  240. }
  241. static void etnaviv_hw_identify(struct etnaviv_gpu *gpu)
  242. {
  243. u32 chipIdentity;
  244. chipIdentity = gpu_read(gpu, VIVS_HI_CHIP_IDENTITY);
  245. /* Special case for older graphic cores. */
  246. if (etnaviv_field(chipIdentity, VIVS_HI_CHIP_IDENTITY_FAMILY) == 0x01) {
  247. gpu->identity.model = chipModel_GC500;
  248. gpu->identity.revision = etnaviv_field(chipIdentity,
  249. VIVS_HI_CHIP_IDENTITY_REVISION);
  250. } else {
  251. gpu->identity.model = gpu_read(gpu, VIVS_HI_CHIP_MODEL);
  252. gpu->identity.revision = gpu_read(gpu, VIVS_HI_CHIP_REV);
  253. /*
  254. * !!!! HACK ALERT !!!!
  255. * Because people change device IDs without letting software
  256. * know about it - here is the hack to make it all look the
  257. * same. Only for GC400 family.
  258. */
  259. if ((gpu->identity.model & 0xff00) == 0x0400 &&
  260. gpu->identity.model != chipModel_GC420) {
  261. gpu->identity.model = gpu->identity.model & 0x0400;
  262. }
  263. /* Another special case */
  264. if (etnaviv_is_model_rev(gpu, GC300, 0x2201)) {
  265. u32 chipDate = gpu_read(gpu, VIVS_HI_CHIP_DATE);
  266. u32 chipTime = gpu_read(gpu, VIVS_HI_CHIP_TIME);
  267. if (chipDate == 0x20080814 && chipTime == 0x12051100) {
  268. /*
  269. * This IP has an ECO; put the correct
  270. * revision in it.
  271. */
  272. gpu->identity.revision = 0x1051;
  273. }
  274. }
  275. /*
  276. * NXP likes to call the GPU on the i.MX6QP GC2000+, but in
  277. * reality it's just a re-branded GC3000. We can identify this
  278. * core by the upper half of the revision register being all 1.
  279. * Fix model/rev here, so all other places can refer to this
  280. * core by its real identity.
  281. */
  282. if (etnaviv_is_model_rev(gpu, GC2000, 0xffff5450)) {
  283. gpu->identity.model = chipModel_GC3000;
  284. gpu->identity.revision &= 0xffff;
  285. }
  286. }
  287. dev_info(gpu->dev, "model: GC%x, revision: %x\n",
  288. gpu->identity.model, gpu->identity.revision);
  289. gpu->identity.features = gpu_read(gpu, VIVS_HI_CHIP_FEATURE);
  290. /* Disable fast clear on GC700. */
  291. if (gpu->identity.model == chipModel_GC700)
  292. gpu->identity.features &= ~chipFeatures_FAST_CLEAR;
  293. if ((gpu->identity.model == chipModel_GC500 &&
  294. gpu->identity.revision < 2) ||
  295. (gpu->identity.model == chipModel_GC300 &&
  296. gpu->identity.revision < 0x2000)) {
  297. /*
  298. * GC500 rev 1.x and GC300 rev < 2.0 doesn't have these
  299. * registers.
  300. */
  301. gpu->identity.minor_features0 = 0;
  302. gpu->identity.minor_features1 = 0;
  303. gpu->identity.minor_features2 = 0;
  304. gpu->identity.minor_features3 = 0;
  305. gpu->identity.minor_features4 = 0;
  306. gpu->identity.minor_features5 = 0;
  307. } else
  308. gpu->identity.minor_features0 =
  309. gpu_read(gpu, VIVS_HI_CHIP_MINOR_FEATURE_0);
  310. if (gpu->identity.minor_features0 &
  311. chipMinorFeatures0_MORE_MINOR_FEATURES) {
  312. gpu->identity.minor_features1 =
  313. gpu_read(gpu, VIVS_HI_CHIP_MINOR_FEATURE_1);
  314. gpu->identity.minor_features2 =
  315. gpu_read(gpu, VIVS_HI_CHIP_MINOR_FEATURE_2);
  316. gpu->identity.minor_features3 =
  317. gpu_read(gpu, VIVS_HI_CHIP_MINOR_FEATURE_3);
  318. gpu->identity.minor_features4 =
  319. gpu_read(gpu, VIVS_HI_CHIP_MINOR_FEATURE_4);
  320. gpu->identity.minor_features5 =
  321. gpu_read(gpu, VIVS_HI_CHIP_MINOR_FEATURE_5);
  322. }
  323. /* GC600 idle register reports zero bits where modules aren't present */
  324. if (gpu->identity.model == chipModel_GC600) {
  325. gpu->idle_mask = VIVS_HI_IDLE_STATE_TX |
  326. VIVS_HI_IDLE_STATE_RA |
  327. VIVS_HI_IDLE_STATE_SE |
  328. VIVS_HI_IDLE_STATE_PA |
  329. VIVS_HI_IDLE_STATE_SH |
  330. VIVS_HI_IDLE_STATE_PE |
  331. VIVS_HI_IDLE_STATE_DE |
  332. VIVS_HI_IDLE_STATE_FE;
  333. } else {
  334. gpu->idle_mask = ~VIVS_HI_IDLE_STATE_AXI_LP;
  335. }
  336. etnaviv_hw_specs(gpu);
  337. }
  338. static void etnaviv_gpu_load_clock(struct etnaviv_gpu *gpu, u32 clock)
  339. {
  340. gpu_write(gpu, VIVS_HI_CLOCK_CONTROL, clock |
  341. VIVS_HI_CLOCK_CONTROL_FSCALE_CMD_LOAD);
  342. gpu_write(gpu, VIVS_HI_CLOCK_CONTROL, clock);
  343. }
  344. static int etnaviv_hw_reset(struct etnaviv_gpu *gpu)
  345. {
  346. u32 control, idle;
  347. unsigned long timeout;
  348. bool failed = true;
  349. /* TODO
  350. *
  351. * - clock gating
  352. * - puls eater
  353. * - what about VG?
  354. */
  355. /* We hope that the GPU resets in under one second */
  356. timeout = jiffies + msecs_to_jiffies(1000);
  357. while (time_is_after_jiffies(timeout)) {
  358. control = VIVS_HI_CLOCK_CONTROL_DISABLE_DEBUG_REGISTERS |
  359. VIVS_HI_CLOCK_CONTROL_FSCALE_VAL(0x40);
  360. /* enable clock */
  361. etnaviv_gpu_load_clock(gpu, control);
  362. /* Wait for stable clock. Vivante's code waited for 1ms */
  363. usleep_range(1000, 10000);
  364. /* isolate the GPU. */
  365. control |= VIVS_HI_CLOCK_CONTROL_ISOLATE_GPU;
  366. gpu_write(gpu, VIVS_HI_CLOCK_CONTROL, control);
  367. /* set soft reset. */
  368. control |= VIVS_HI_CLOCK_CONTROL_SOFT_RESET;
  369. gpu_write(gpu, VIVS_HI_CLOCK_CONTROL, control);
  370. /* wait for reset. */
  371. msleep(1);
  372. /* reset soft reset bit. */
  373. control &= ~VIVS_HI_CLOCK_CONTROL_SOFT_RESET;
  374. gpu_write(gpu, VIVS_HI_CLOCK_CONTROL, control);
  375. /* reset GPU isolation. */
  376. control &= ~VIVS_HI_CLOCK_CONTROL_ISOLATE_GPU;
  377. gpu_write(gpu, VIVS_HI_CLOCK_CONTROL, control);
  378. /* read idle register. */
  379. idle = gpu_read(gpu, VIVS_HI_IDLE_STATE);
  380. /* try reseting again if FE it not idle */
  381. if ((idle & VIVS_HI_IDLE_STATE_FE) == 0) {
  382. dev_dbg(gpu->dev, "FE is not idle\n");
  383. continue;
  384. }
  385. /* read reset register. */
  386. control = gpu_read(gpu, VIVS_HI_CLOCK_CONTROL);
  387. /* is the GPU idle? */
  388. if (((control & VIVS_HI_CLOCK_CONTROL_IDLE_3D) == 0) ||
  389. ((control & VIVS_HI_CLOCK_CONTROL_IDLE_2D) == 0)) {
  390. dev_dbg(gpu->dev, "GPU is not idle\n");
  391. continue;
  392. }
  393. failed = false;
  394. break;
  395. }
  396. if (failed) {
  397. idle = gpu_read(gpu, VIVS_HI_IDLE_STATE);
  398. control = gpu_read(gpu, VIVS_HI_CLOCK_CONTROL);
  399. dev_err(gpu->dev, "GPU failed to reset: FE %sidle, 3D %sidle, 2D %sidle\n",
  400. idle & VIVS_HI_IDLE_STATE_FE ? "" : "not ",
  401. control & VIVS_HI_CLOCK_CONTROL_IDLE_3D ? "" : "not ",
  402. control & VIVS_HI_CLOCK_CONTROL_IDLE_2D ? "" : "not ");
  403. return -EBUSY;
  404. }
  405. /* We rely on the GPU running, so program the clock */
  406. control = VIVS_HI_CLOCK_CONTROL_DISABLE_DEBUG_REGISTERS |
  407. VIVS_HI_CLOCK_CONTROL_FSCALE_VAL(0x40);
  408. /* enable clock */
  409. etnaviv_gpu_load_clock(gpu, control);
  410. return 0;
  411. }
  412. static void etnaviv_gpu_enable_mlcg(struct etnaviv_gpu *gpu)
  413. {
  414. u32 pmc, ppc;
  415. /* enable clock gating */
  416. ppc = gpu_read(gpu, VIVS_PM_POWER_CONTROLS);
  417. ppc |= VIVS_PM_POWER_CONTROLS_ENABLE_MODULE_CLOCK_GATING;
  418. /* Disable stall module clock gating for 4.3.0.1 and 4.3.0.2 revs */
  419. if (gpu->identity.revision == 0x4301 ||
  420. gpu->identity.revision == 0x4302)
  421. ppc |= VIVS_PM_POWER_CONTROLS_DISABLE_STALL_MODULE_CLOCK_GATING;
  422. gpu_write(gpu, VIVS_PM_POWER_CONTROLS, ppc);
  423. pmc = gpu_read(gpu, VIVS_PM_MODULE_CONTROLS);
  424. /* Disable PA clock gating for GC400+ except for GC420 */
  425. if (gpu->identity.model >= chipModel_GC400 &&
  426. gpu->identity.model != chipModel_GC420)
  427. pmc |= VIVS_PM_MODULE_CONTROLS_DISABLE_MODULE_CLOCK_GATING_PA;
  428. /*
  429. * Disable PE clock gating on revs < 5.0.0.0 when HZ is
  430. * present without a bug fix.
  431. */
  432. if (gpu->identity.revision < 0x5000 &&
  433. gpu->identity.minor_features0 & chipMinorFeatures0_HZ &&
  434. !(gpu->identity.minor_features1 &
  435. chipMinorFeatures1_DISABLE_PE_GATING))
  436. pmc |= VIVS_PM_MODULE_CONTROLS_DISABLE_MODULE_CLOCK_GATING_PE;
  437. if (gpu->identity.revision < 0x5422)
  438. pmc |= BIT(15); /* Unknown bit */
  439. pmc |= VIVS_PM_MODULE_CONTROLS_DISABLE_MODULE_CLOCK_GATING_RA_HZ;
  440. pmc |= VIVS_PM_MODULE_CONTROLS_DISABLE_MODULE_CLOCK_GATING_RA_EZ;
  441. gpu_write(gpu, VIVS_PM_MODULE_CONTROLS, pmc);
  442. }
  443. void etnaviv_gpu_start_fe(struct etnaviv_gpu *gpu, u32 address, u16 prefetch)
  444. {
  445. gpu_write(gpu, VIVS_FE_COMMAND_ADDRESS, address);
  446. gpu_write(gpu, VIVS_FE_COMMAND_CONTROL,
  447. VIVS_FE_COMMAND_CONTROL_ENABLE |
  448. VIVS_FE_COMMAND_CONTROL_PREFETCH(prefetch));
  449. }
  450. static void etnaviv_gpu_hw_init(struct etnaviv_gpu *gpu)
  451. {
  452. u16 prefetch;
  453. if ((etnaviv_is_model_rev(gpu, GC320, 0x5007) ||
  454. etnaviv_is_model_rev(gpu, GC320, 0x5220)) &&
  455. gpu_read(gpu, VIVS_HI_CHIP_TIME) != 0x2062400) {
  456. u32 mc_memory_debug;
  457. mc_memory_debug = gpu_read(gpu, VIVS_MC_DEBUG_MEMORY) & ~0xff;
  458. if (gpu->identity.revision == 0x5007)
  459. mc_memory_debug |= 0x0c;
  460. else
  461. mc_memory_debug |= 0x08;
  462. gpu_write(gpu, VIVS_MC_DEBUG_MEMORY, mc_memory_debug);
  463. }
  464. /* enable module-level clock gating */
  465. etnaviv_gpu_enable_mlcg(gpu);
  466. /*
  467. * Update GPU AXI cache atttribute to "cacheable, no allocate".
  468. * This is necessary to prevent the iMX6 SoC locking up.
  469. */
  470. gpu_write(gpu, VIVS_HI_AXI_CONFIG,
  471. VIVS_HI_AXI_CONFIG_AWCACHE(2) |
  472. VIVS_HI_AXI_CONFIG_ARCACHE(2));
  473. /* GC2000 rev 5108 needs a special bus config */
  474. if (etnaviv_is_model_rev(gpu, GC2000, 0x5108)) {
  475. u32 bus_config = gpu_read(gpu, VIVS_MC_BUS_CONFIG);
  476. bus_config &= ~(VIVS_MC_BUS_CONFIG_FE_BUS_CONFIG__MASK |
  477. VIVS_MC_BUS_CONFIG_TX_BUS_CONFIG__MASK);
  478. bus_config |= VIVS_MC_BUS_CONFIG_FE_BUS_CONFIG(1) |
  479. VIVS_MC_BUS_CONFIG_TX_BUS_CONFIG(0);
  480. gpu_write(gpu, VIVS_MC_BUS_CONFIG, bus_config);
  481. }
  482. /* setup the MMU */
  483. etnaviv_iommu_restore(gpu);
  484. /* Start command processor */
  485. prefetch = etnaviv_buffer_init(gpu);
  486. gpu_write(gpu, VIVS_HI_INTR_ENBL, ~0U);
  487. etnaviv_gpu_start_fe(gpu, etnaviv_iommu_get_cmdbuf_va(gpu, gpu->buffer),
  488. prefetch);
  489. }
  490. int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
  491. {
  492. int ret, i;
  493. ret = pm_runtime_get_sync(gpu->dev);
  494. if (ret < 0) {
  495. dev_err(gpu->dev, "Failed to enable GPU power domain\n");
  496. return ret;
  497. }
  498. etnaviv_hw_identify(gpu);
  499. if (gpu->identity.model == 0) {
  500. dev_err(gpu->dev, "Unknown GPU model\n");
  501. ret = -ENXIO;
  502. goto fail;
  503. }
  504. /* Exclude VG cores with FE2.0 */
  505. if (gpu->identity.features & chipFeatures_PIPE_VG &&
  506. gpu->identity.features & chipFeatures_FE20) {
  507. dev_info(gpu->dev, "Ignoring GPU with VG and FE2.0\n");
  508. ret = -ENXIO;
  509. goto fail;
  510. }
  511. /*
  512. * Set the GPU linear window to be at the end of the DMA window, where
  513. * the CMA area is likely to reside. This ensures that we are able to
  514. * map the command buffers while having the linear window overlap as
  515. * much RAM as possible, so we can optimize mappings for other buffers.
  516. *
  517. * For 3D cores only do this if MC2.0 is present, as with MC1.0 it leads
  518. * to different views of the memory on the individual engines.
  519. */
  520. if (!(gpu->identity.features & chipFeatures_PIPE_3D) ||
  521. (gpu->identity.minor_features0 & chipMinorFeatures0_MC20)) {
  522. u32 dma_mask = (u32)dma_get_required_mask(gpu->dev);
  523. if (dma_mask < PHYS_OFFSET + SZ_2G)
  524. gpu->memory_base = PHYS_OFFSET;
  525. else
  526. gpu->memory_base = dma_mask - SZ_2G + 1;
  527. }
  528. ret = etnaviv_hw_reset(gpu);
  529. if (ret) {
  530. dev_err(gpu->dev, "GPU reset failed\n");
  531. goto fail;
  532. }
  533. gpu->mmu = etnaviv_iommu_new(gpu);
  534. if (IS_ERR(gpu->mmu)) {
  535. dev_err(gpu->dev, "Failed to instantiate GPU IOMMU\n");
  536. ret = PTR_ERR(gpu->mmu);
  537. goto fail;
  538. }
  539. /* Create buffer: */
  540. gpu->buffer = etnaviv_gpu_cmdbuf_new(gpu, PAGE_SIZE, 0);
  541. if (!gpu->buffer) {
  542. ret = -ENOMEM;
  543. dev_err(gpu->dev, "could not create command buffer\n");
  544. goto destroy_iommu;
  545. }
  546. if (gpu->mmu->version == ETNAVIV_IOMMU_V1 &&
  547. gpu->buffer->paddr - gpu->memory_base > 0x80000000) {
  548. ret = -EINVAL;
  549. dev_err(gpu->dev,
  550. "command buffer outside valid memory window\n");
  551. goto free_buffer;
  552. }
  553. /* Setup event management */
  554. spin_lock_init(&gpu->event_spinlock);
  555. init_completion(&gpu->event_free);
  556. for (i = 0; i < ARRAY_SIZE(gpu->event); i++) {
  557. gpu->event[i].used = false;
  558. complete(&gpu->event_free);
  559. }
  560. /* Now program the hardware */
  561. mutex_lock(&gpu->lock);
  562. etnaviv_gpu_hw_init(gpu);
  563. gpu->exec_state = -1;
  564. mutex_unlock(&gpu->lock);
  565. pm_runtime_mark_last_busy(gpu->dev);
  566. pm_runtime_put_autosuspend(gpu->dev);
  567. return 0;
  568. free_buffer:
  569. etnaviv_gpu_cmdbuf_free(gpu->buffer);
  570. gpu->buffer = NULL;
  571. destroy_iommu:
  572. etnaviv_iommu_destroy(gpu->mmu);
  573. gpu->mmu = NULL;
  574. fail:
  575. pm_runtime_mark_last_busy(gpu->dev);
  576. pm_runtime_put_autosuspend(gpu->dev);
  577. return ret;
  578. }
  579. #ifdef CONFIG_DEBUG_FS
  580. struct dma_debug {
  581. u32 address[2];
  582. u32 state[2];
  583. };
  584. static void verify_dma(struct etnaviv_gpu *gpu, struct dma_debug *debug)
  585. {
  586. u32 i;
  587. debug->address[0] = gpu_read(gpu, VIVS_FE_DMA_ADDRESS);
  588. debug->state[0] = gpu_read(gpu, VIVS_FE_DMA_DEBUG_STATE);
  589. for (i = 0; i < 500; i++) {
  590. debug->address[1] = gpu_read(gpu, VIVS_FE_DMA_ADDRESS);
  591. debug->state[1] = gpu_read(gpu, VIVS_FE_DMA_DEBUG_STATE);
  592. if (debug->address[0] != debug->address[1])
  593. break;
  594. if (debug->state[0] != debug->state[1])
  595. break;
  596. }
  597. }
  598. int etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct seq_file *m)
  599. {
  600. struct dma_debug debug;
  601. u32 dma_lo, dma_hi, axi, idle;
  602. int ret;
  603. seq_printf(m, "%s Status:\n", dev_name(gpu->dev));
  604. ret = pm_runtime_get_sync(gpu->dev);
  605. if (ret < 0)
  606. return ret;
  607. dma_lo = gpu_read(gpu, VIVS_FE_DMA_LOW);
  608. dma_hi = gpu_read(gpu, VIVS_FE_DMA_HIGH);
  609. axi = gpu_read(gpu, VIVS_HI_AXI_STATUS);
  610. idle = gpu_read(gpu, VIVS_HI_IDLE_STATE);
  611. verify_dma(gpu, &debug);
  612. seq_puts(m, "\tfeatures\n");
  613. seq_printf(m, "\t minor_features0: 0x%08x\n",
  614. gpu->identity.minor_features0);
  615. seq_printf(m, "\t minor_features1: 0x%08x\n",
  616. gpu->identity.minor_features1);
  617. seq_printf(m, "\t minor_features2: 0x%08x\n",
  618. gpu->identity.minor_features2);
  619. seq_printf(m, "\t minor_features3: 0x%08x\n",
  620. gpu->identity.minor_features3);
  621. seq_printf(m, "\t minor_features4: 0x%08x\n",
  622. gpu->identity.minor_features4);
  623. seq_printf(m, "\t minor_features5: 0x%08x\n",
  624. gpu->identity.minor_features5);
  625. seq_puts(m, "\tspecs\n");
  626. seq_printf(m, "\t stream_count: %d\n",
  627. gpu->identity.stream_count);
  628. seq_printf(m, "\t register_max: %d\n",
  629. gpu->identity.register_max);
  630. seq_printf(m, "\t thread_count: %d\n",
  631. gpu->identity.thread_count);
  632. seq_printf(m, "\t vertex_cache_size: %d\n",
  633. gpu->identity.vertex_cache_size);
  634. seq_printf(m, "\t shader_core_count: %d\n",
  635. gpu->identity.shader_core_count);
  636. seq_printf(m, "\t pixel_pipes: %d\n",
  637. gpu->identity.pixel_pipes);
  638. seq_printf(m, "\t vertex_output_buffer_size: %d\n",
  639. gpu->identity.vertex_output_buffer_size);
  640. seq_printf(m, "\t buffer_size: %d\n",
  641. gpu->identity.buffer_size);
  642. seq_printf(m, "\t instruction_count: %d\n",
  643. gpu->identity.instruction_count);
  644. seq_printf(m, "\t num_constants: %d\n",
  645. gpu->identity.num_constants);
  646. seq_printf(m, "\t varyings_count: %d\n",
  647. gpu->identity.varyings_count);
  648. seq_printf(m, "\taxi: 0x%08x\n", axi);
  649. seq_printf(m, "\tidle: 0x%08x\n", idle);
  650. idle |= ~gpu->idle_mask & ~VIVS_HI_IDLE_STATE_AXI_LP;
  651. if ((idle & VIVS_HI_IDLE_STATE_FE) == 0)
  652. seq_puts(m, "\t FE is not idle\n");
  653. if ((idle & VIVS_HI_IDLE_STATE_DE) == 0)
  654. seq_puts(m, "\t DE is not idle\n");
  655. if ((idle & VIVS_HI_IDLE_STATE_PE) == 0)
  656. seq_puts(m, "\t PE is not idle\n");
  657. if ((idle & VIVS_HI_IDLE_STATE_SH) == 0)
  658. seq_puts(m, "\t SH is not idle\n");
  659. if ((idle & VIVS_HI_IDLE_STATE_PA) == 0)
  660. seq_puts(m, "\t PA is not idle\n");
  661. if ((idle & VIVS_HI_IDLE_STATE_SE) == 0)
  662. seq_puts(m, "\t SE is not idle\n");
  663. if ((idle & VIVS_HI_IDLE_STATE_RA) == 0)
  664. seq_puts(m, "\t RA is not idle\n");
  665. if ((idle & VIVS_HI_IDLE_STATE_TX) == 0)
  666. seq_puts(m, "\t TX is not idle\n");
  667. if ((idle & VIVS_HI_IDLE_STATE_VG) == 0)
  668. seq_puts(m, "\t VG is not idle\n");
  669. if ((idle & VIVS_HI_IDLE_STATE_IM) == 0)
  670. seq_puts(m, "\t IM is not idle\n");
  671. if ((idle & VIVS_HI_IDLE_STATE_FP) == 0)
  672. seq_puts(m, "\t FP is not idle\n");
  673. if ((idle & VIVS_HI_IDLE_STATE_TS) == 0)
  674. seq_puts(m, "\t TS is not idle\n");
  675. if (idle & VIVS_HI_IDLE_STATE_AXI_LP)
  676. seq_puts(m, "\t AXI low power mode\n");
  677. if (gpu->identity.features & chipFeatures_DEBUG_MODE) {
  678. u32 read0 = gpu_read(gpu, VIVS_MC_DEBUG_READ0);
  679. u32 read1 = gpu_read(gpu, VIVS_MC_DEBUG_READ1);
  680. u32 write = gpu_read(gpu, VIVS_MC_DEBUG_WRITE);
  681. seq_puts(m, "\tMC\n");
  682. seq_printf(m, "\t read0: 0x%08x\n", read0);
  683. seq_printf(m, "\t read1: 0x%08x\n", read1);
  684. seq_printf(m, "\t write: 0x%08x\n", write);
  685. }
  686. seq_puts(m, "\tDMA ");
  687. if (debug.address[0] == debug.address[1] &&
  688. debug.state[0] == debug.state[1]) {
  689. seq_puts(m, "seems to be stuck\n");
  690. } else if (debug.address[0] == debug.address[1]) {
  691. seq_puts(m, "address is constant\n");
  692. } else {
  693. seq_puts(m, "is running\n");
  694. }
  695. seq_printf(m, "\t address 0: 0x%08x\n", debug.address[0]);
  696. seq_printf(m, "\t address 1: 0x%08x\n", debug.address[1]);
  697. seq_printf(m, "\t state 0: 0x%08x\n", debug.state[0]);
  698. seq_printf(m, "\t state 1: 0x%08x\n", debug.state[1]);
  699. seq_printf(m, "\t last fetch 64 bit word: 0x%08x 0x%08x\n",
  700. dma_lo, dma_hi);
  701. ret = 0;
  702. pm_runtime_mark_last_busy(gpu->dev);
  703. pm_runtime_put_autosuspend(gpu->dev);
  704. return ret;
  705. }
  706. #endif
  707. /*
  708. * Hangcheck detection for locked gpu:
  709. */
  710. static void recover_worker(struct work_struct *work)
  711. {
  712. struct etnaviv_gpu *gpu = container_of(work, struct etnaviv_gpu,
  713. recover_work);
  714. unsigned long flags;
  715. unsigned int i;
  716. dev_err(gpu->dev, "hangcheck recover!\n");
  717. if (pm_runtime_get_sync(gpu->dev) < 0)
  718. return;
  719. mutex_lock(&gpu->lock);
  720. /* Only catch the first event, or when manually re-armed */
  721. if (etnaviv_dump_core) {
  722. etnaviv_core_dump(gpu);
  723. etnaviv_dump_core = false;
  724. }
  725. etnaviv_hw_reset(gpu);
  726. /* complete all events, the GPU won't do it after the reset */
  727. spin_lock_irqsave(&gpu->event_spinlock, flags);
  728. for (i = 0; i < ARRAY_SIZE(gpu->event); i++) {
  729. if (!gpu->event[i].used)
  730. continue;
  731. fence_signal(gpu->event[i].fence);
  732. gpu->event[i].fence = NULL;
  733. gpu->event[i].used = false;
  734. complete(&gpu->event_free);
  735. }
  736. spin_unlock_irqrestore(&gpu->event_spinlock, flags);
  737. gpu->completed_fence = gpu->active_fence;
  738. etnaviv_gpu_hw_init(gpu);
  739. gpu->lastctx = NULL;
  740. gpu->exec_state = -1;
  741. mutex_unlock(&gpu->lock);
  742. pm_runtime_mark_last_busy(gpu->dev);
  743. pm_runtime_put_autosuspend(gpu->dev);
  744. /* Retire the buffer objects in a work */
  745. etnaviv_queue_work(gpu->drm, &gpu->retire_work);
  746. }
  747. static void hangcheck_timer_reset(struct etnaviv_gpu *gpu)
  748. {
  749. DBG("%s", dev_name(gpu->dev));
  750. mod_timer(&gpu->hangcheck_timer,
  751. round_jiffies_up(jiffies + DRM_ETNAVIV_HANGCHECK_JIFFIES));
  752. }
  753. static void hangcheck_handler(unsigned long data)
  754. {
  755. struct etnaviv_gpu *gpu = (struct etnaviv_gpu *)data;
  756. u32 fence = gpu->completed_fence;
  757. bool progress = false;
  758. if (fence != gpu->hangcheck_fence) {
  759. gpu->hangcheck_fence = fence;
  760. progress = true;
  761. }
  762. if (!progress) {
  763. u32 dma_addr = gpu_read(gpu, VIVS_FE_DMA_ADDRESS);
  764. int change = dma_addr - gpu->hangcheck_dma_addr;
  765. if (change < 0 || change > 16) {
  766. gpu->hangcheck_dma_addr = dma_addr;
  767. progress = true;
  768. }
  769. }
  770. if (!progress && fence_after(gpu->active_fence, fence)) {
  771. dev_err(gpu->dev, "hangcheck detected gpu lockup!\n");
  772. dev_err(gpu->dev, " completed fence: %u\n", fence);
  773. dev_err(gpu->dev, " active fence: %u\n",
  774. gpu->active_fence);
  775. etnaviv_queue_work(gpu->drm, &gpu->recover_work);
  776. }
  777. /* if still more pending work, reset the hangcheck timer: */
  778. if (fence_after(gpu->active_fence, gpu->hangcheck_fence))
  779. hangcheck_timer_reset(gpu);
  780. }
  781. static void hangcheck_disable(struct etnaviv_gpu *gpu)
  782. {
  783. del_timer_sync(&gpu->hangcheck_timer);
  784. cancel_work_sync(&gpu->recover_work);
  785. }
  786. /* fence object management */
  787. struct etnaviv_fence {
  788. struct etnaviv_gpu *gpu;
  789. struct fence base;
  790. };
  791. static inline struct etnaviv_fence *to_etnaviv_fence(struct fence *fence)
  792. {
  793. return container_of(fence, struct etnaviv_fence, base);
  794. }
  795. static const char *etnaviv_fence_get_driver_name(struct fence *fence)
  796. {
  797. return "etnaviv";
  798. }
  799. static const char *etnaviv_fence_get_timeline_name(struct fence *fence)
  800. {
  801. struct etnaviv_fence *f = to_etnaviv_fence(fence);
  802. return dev_name(f->gpu->dev);
  803. }
  804. static bool etnaviv_fence_enable_signaling(struct fence *fence)
  805. {
  806. return true;
  807. }
  808. static bool etnaviv_fence_signaled(struct fence *fence)
  809. {
  810. struct etnaviv_fence *f = to_etnaviv_fence(fence);
  811. return fence_completed(f->gpu, f->base.seqno);
  812. }
  813. static void etnaviv_fence_release(struct fence *fence)
  814. {
  815. struct etnaviv_fence *f = to_etnaviv_fence(fence);
  816. kfree_rcu(f, base.rcu);
  817. }
  818. static const struct fence_ops etnaviv_fence_ops = {
  819. .get_driver_name = etnaviv_fence_get_driver_name,
  820. .get_timeline_name = etnaviv_fence_get_timeline_name,
  821. .enable_signaling = etnaviv_fence_enable_signaling,
  822. .signaled = etnaviv_fence_signaled,
  823. .wait = fence_default_wait,
  824. .release = etnaviv_fence_release,
  825. };
  826. static struct fence *etnaviv_gpu_fence_alloc(struct etnaviv_gpu *gpu)
  827. {
  828. struct etnaviv_fence *f;
  829. f = kzalloc(sizeof(*f), GFP_KERNEL);
  830. if (!f)
  831. return NULL;
  832. f->gpu = gpu;
  833. fence_init(&f->base, &etnaviv_fence_ops, &gpu->fence_spinlock,
  834. gpu->fence_context, ++gpu->next_fence);
  835. return &f->base;
  836. }
  837. int etnaviv_gpu_fence_sync_obj(struct etnaviv_gem_object *etnaviv_obj,
  838. unsigned int context, bool exclusive)
  839. {
  840. struct reservation_object *robj = etnaviv_obj->resv;
  841. struct reservation_object_list *fobj;
  842. struct fence *fence;
  843. int i, ret;
  844. if (!exclusive) {
  845. ret = reservation_object_reserve_shared(robj);
  846. if (ret)
  847. return ret;
  848. }
  849. /*
  850. * If we have any shared fences, then the exclusive fence
  851. * should be ignored as it will already have been signalled.
  852. */
  853. fobj = reservation_object_get_list(robj);
  854. if (!fobj || fobj->shared_count == 0) {
  855. /* Wait on any existing exclusive fence which isn't our own */
  856. fence = reservation_object_get_excl(robj);
  857. if (fence && fence->context != context) {
  858. ret = fence_wait(fence, true);
  859. if (ret)
  860. return ret;
  861. }
  862. }
  863. if (!exclusive || !fobj)
  864. return 0;
  865. for (i = 0; i < fobj->shared_count; i++) {
  866. fence = rcu_dereference_protected(fobj->shared[i],
  867. reservation_object_held(robj));
  868. if (fence->context != context) {
  869. ret = fence_wait(fence, true);
  870. if (ret)
  871. return ret;
  872. }
  873. }
  874. return 0;
  875. }
  876. /*
  877. * event management:
  878. */
  879. static unsigned int event_alloc(struct etnaviv_gpu *gpu)
  880. {
  881. unsigned long ret, flags;
  882. unsigned int i, event = ~0U;
  883. ret = wait_for_completion_timeout(&gpu->event_free,
  884. msecs_to_jiffies(10 * 10000));
  885. if (!ret)
  886. dev_err(gpu->dev, "wait_for_completion_timeout failed");
  887. spin_lock_irqsave(&gpu->event_spinlock, flags);
  888. /* find first free event */
  889. for (i = 0; i < ARRAY_SIZE(gpu->event); i++) {
  890. if (gpu->event[i].used == false) {
  891. gpu->event[i].used = true;
  892. event = i;
  893. break;
  894. }
  895. }
  896. spin_unlock_irqrestore(&gpu->event_spinlock, flags);
  897. return event;
  898. }
  899. static void event_free(struct etnaviv_gpu *gpu, unsigned int event)
  900. {
  901. unsigned long flags;
  902. spin_lock_irqsave(&gpu->event_spinlock, flags);
  903. if (gpu->event[event].used == false) {
  904. dev_warn(gpu->dev, "event %u is already marked as free",
  905. event);
  906. spin_unlock_irqrestore(&gpu->event_spinlock, flags);
  907. } else {
  908. gpu->event[event].used = false;
  909. spin_unlock_irqrestore(&gpu->event_spinlock, flags);
  910. complete(&gpu->event_free);
  911. }
  912. }
  913. /*
  914. * Cmdstream submission/retirement:
  915. */
  916. struct etnaviv_cmdbuf *etnaviv_gpu_cmdbuf_new(struct etnaviv_gpu *gpu, u32 size,
  917. size_t nr_bos)
  918. {
  919. struct etnaviv_cmdbuf *cmdbuf;
  920. size_t sz = size_vstruct(nr_bos, sizeof(cmdbuf->bo_map[0]),
  921. sizeof(*cmdbuf));
  922. cmdbuf = kzalloc(sz, GFP_KERNEL);
  923. if (!cmdbuf)
  924. return NULL;
  925. if (gpu->mmu->version == ETNAVIV_IOMMU_V2)
  926. size = ALIGN(size, SZ_4K);
  927. cmdbuf->vaddr = dma_alloc_wc(gpu->dev, size, &cmdbuf->paddr,
  928. GFP_KERNEL);
  929. if (!cmdbuf->vaddr) {
  930. kfree(cmdbuf);
  931. return NULL;
  932. }
  933. cmdbuf->gpu = gpu;
  934. cmdbuf->size = size;
  935. return cmdbuf;
  936. }
  937. void etnaviv_gpu_cmdbuf_free(struct etnaviv_cmdbuf *cmdbuf)
  938. {
  939. etnaviv_iommu_put_cmdbuf_va(cmdbuf->gpu, cmdbuf);
  940. dma_free_wc(cmdbuf->gpu->dev, cmdbuf->size, cmdbuf->vaddr,
  941. cmdbuf->paddr);
  942. kfree(cmdbuf);
  943. }
  944. static void retire_worker(struct work_struct *work)
  945. {
  946. struct etnaviv_gpu *gpu = container_of(work, struct etnaviv_gpu,
  947. retire_work);
  948. u32 fence = gpu->completed_fence;
  949. struct etnaviv_cmdbuf *cmdbuf, *tmp;
  950. unsigned int i;
  951. mutex_lock(&gpu->lock);
  952. list_for_each_entry_safe(cmdbuf, tmp, &gpu->active_cmd_list, node) {
  953. if (!fence_is_signaled(cmdbuf->fence))
  954. break;
  955. list_del(&cmdbuf->node);
  956. fence_put(cmdbuf->fence);
  957. for (i = 0; i < cmdbuf->nr_bos; i++) {
  958. struct etnaviv_vram_mapping *mapping = cmdbuf->bo_map[i];
  959. struct etnaviv_gem_object *etnaviv_obj = mapping->object;
  960. atomic_dec(&etnaviv_obj->gpu_active);
  961. /* drop the refcount taken in etnaviv_gpu_submit */
  962. etnaviv_gem_mapping_unreference(mapping);
  963. }
  964. etnaviv_gpu_cmdbuf_free(cmdbuf);
  965. /*
  966. * We need to balance the runtime PM count caused by
  967. * each submission. Upon submission, we increment
  968. * the runtime PM counter, and allocate one event.
  969. * So here, we put the runtime PM count for each
  970. * completed event.
  971. */
  972. pm_runtime_put_autosuspend(gpu->dev);
  973. }
  974. gpu->retired_fence = fence;
  975. mutex_unlock(&gpu->lock);
  976. wake_up_all(&gpu->fence_event);
  977. }
  978. int etnaviv_gpu_wait_fence_interruptible(struct etnaviv_gpu *gpu,
  979. u32 fence, struct timespec *timeout)
  980. {
  981. int ret;
  982. if (fence_after(fence, gpu->next_fence)) {
  983. DRM_ERROR("waiting on invalid fence: %u (of %u)\n",
  984. fence, gpu->next_fence);
  985. return -EINVAL;
  986. }
  987. if (!timeout) {
  988. /* No timeout was requested: just test for completion */
  989. ret = fence_completed(gpu, fence) ? 0 : -EBUSY;
  990. } else {
  991. unsigned long remaining = etnaviv_timeout_to_jiffies(timeout);
  992. ret = wait_event_interruptible_timeout(gpu->fence_event,
  993. fence_completed(gpu, fence),
  994. remaining);
  995. if (ret == 0) {
  996. DBG("timeout waiting for fence: %u (retired: %u completed: %u)",
  997. fence, gpu->retired_fence,
  998. gpu->completed_fence);
  999. ret = -ETIMEDOUT;
  1000. } else if (ret != -ERESTARTSYS) {
  1001. ret = 0;
  1002. }
  1003. }
  1004. return ret;
  1005. }
  1006. /*
  1007. * Wait for an object to become inactive. This, on it's own, is not race
  1008. * free: the object is moved by the retire worker off the active list, and
  1009. * then the iova is put. Moreover, the object could be re-submitted just
  1010. * after we notice that it's become inactive.
  1011. *
  1012. * Although the retirement happens under the gpu lock, we don't want to hold
  1013. * that lock in this function while waiting.
  1014. */
  1015. int etnaviv_gpu_wait_obj_inactive(struct etnaviv_gpu *gpu,
  1016. struct etnaviv_gem_object *etnaviv_obj, struct timespec *timeout)
  1017. {
  1018. unsigned long remaining;
  1019. long ret;
  1020. if (!timeout)
  1021. return !is_active(etnaviv_obj) ? 0 : -EBUSY;
  1022. remaining = etnaviv_timeout_to_jiffies(timeout);
  1023. ret = wait_event_interruptible_timeout(gpu->fence_event,
  1024. !is_active(etnaviv_obj),
  1025. remaining);
  1026. if (ret > 0) {
  1027. struct etnaviv_drm_private *priv = gpu->drm->dev_private;
  1028. /* Synchronise with the retire worker */
  1029. flush_workqueue(priv->wq);
  1030. return 0;
  1031. } else if (ret == -ERESTARTSYS) {
  1032. return -ERESTARTSYS;
  1033. } else {
  1034. return -ETIMEDOUT;
  1035. }
  1036. }
  1037. int etnaviv_gpu_pm_get_sync(struct etnaviv_gpu *gpu)
  1038. {
  1039. return pm_runtime_get_sync(gpu->dev);
  1040. }
  1041. void etnaviv_gpu_pm_put(struct etnaviv_gpu *gpu)
  1042. {
  1043. pm_runtime_mark_last_busy(gpu->dev);
  1044. pm_runtime_put_autosuspend(gpu->dev);
  1045. }
  1046. /* add bo's to gpu's ring, and kick gpu: */
  1047. int etnaviv_gpu_submit(struct etnaviv_gpu *gpu,
  1048. struct etnaviv_gem_submit *submit, struct etnaviv_cmdbuf *cmdbuf)
  1049. {
  1050. struct fence *fence;
  1051. unsigned int event, i;
  1052. int ret;
  1053. ret = etnaviv_gpu_pm_get_sync(gpu);
  1054. if (ret < 0)
  1055. return ret;
  1056. /*
  1057. * TODO
  1058. *
  1059. * - flush
  1060. * - data endian
  1061. * - prefetch
  1062. *
  1063. */
  1064. event = event_alloc(gpu);
  1065. if (unlikely(event == ~0U)) {
  1066. DRM_ERROR("no free event\n");
  1067. ret = -EBUSY;
  1068. goto out_pm_put;
  1069. }
  1070. mutex_lock(&gpu->lock);
  1071. fence = etnaviv_gpu_fence_alloc(gpu);
  1072. if (!fence) {
  1073. event_free(gpu, event);
  1074. ret = -ENOMEM;
  1075. goto out_unlock;
  1076. }
  1077. gpu->event[event].fence = fence;
  1078. submit->fence = fence->seqno;
  1079. gpu->active_fence = submit->fence;
  1080. if (gpu->lastctx != cmdbuf->ctx) {
  1081. gpu->mmu->need_flush = true;
  1082. gpu->switch_context = true;
  1083. gpu->lastctx = cmdbuf->ctx;
  1084. }
  1085. etnaviv_buffer_queue(gpu, event, cmdbuf);
  1086. cmdbuf->fence = fence;
  1087. list_add_tail(&cmdbuf->node, &gpu->active_cmd_list);
  1088. /* We're committed to adding this command buffer, hold a PM reference */
  1089. pm_runtime_get_noresume(gpu->dev);
  1090. for (i = 0; i < submit->nr_bos; i++) {
  1091. struct etnaviv_gem_object *etnaviv_obj = submit->bos[i].obj;
  1092. /* Each cmdbuf takes a refcount on the mapping */
  1093. etnaviv_gem_mapping_reference(submit->bos[i].mapping);
  1094. cmdbuf->bo_map[i] = submit->bos[i].mapping;
  1095. atomic_inc(&etnaviv_obj->gpu_active);
  1096. if (submit->bos[i].flags & ETNA_SUBMIT_BO_WRITE)
  1097. reservation_object_add_excl_fence(etnaviv_obj->resv,
  1098. fence);
  1099. else
  1100. reservation_object_add_shared_fence(etnaviv_obj->resv,
  1101. fence);
  1102. }
  1103. cmdbuf->nr_bos = submit->nr_bos;
  1104. hangcheck_timer_reset(gpu);
  1105. ret = 0;
  1106. out_unlock:
  1107. mutex_unlock(&gpu->lock);
  1108. out_pm_put:
  1109. etnaviv_gpu_pm_put(gpu);
  1110. return ret;
  1111. }
  1112. /*
  1113. * Init/Cleanup:
  1114. */
  1115. static irqreturn_t irq_handler(int irq, void *data)
  1116. {
  1117. struct etnaviv_gpu *gpu = data;
  1118. irqreturn_t ret = IRQ_NONE;
  1119. u32 intr = gpu_read(gpu, VIVS_HI_INTR_ACKNOWLEDGE);
  1120. if (intr != 0) {
  1121. int event;
  1122. pm_runtime_mark_last_busy(gpu->dev);
  1123. dev_dbg(gpu->dev, "intr 0x%08x\n", intr);
  1124. if (intr & VIVS_HI_INTR_ACKNOWLEDGE_AXI_BUS_ERROR) {
  1125. dev_err(gpu->dev, "AXI bus error\n");
  1126. intr &= ~VIVS_HI_INTR_ACKNOWLEDGE_AXI_BUS_ERROR;
  1127. }
  1128. if (intr & VIVS_HI_INTR_ACKNOWLEDGE_MMU_EXCEPTION) {
  1129. int i;
  1130. dev_err_ratelimited(gpu->dev,
  1131. "MMU fault status 0x%08x\n",
  1132. gpu_read(gpu, VIVS_MMUv2_STATUS));
  1133. for (i = 0; i < 4; i++) {
  1134. dev_err_ratelimited(gpu->dev,
  1135. "MMU %d fault addr 0x%08x\n",
  1136. i, gpu_read(gpu,
  1137. VIVS_MMUv2_EXCEPTION_ADDR(i)));
  1138. }
  1139. intr &= ~VIVS_HI_INTR_ACKNOWLEDGE_MMU_EXCEPTION;
  1140. }
  1141. while ((event = ffs(intr)) != 0) {
  1142. struct fence *fence;
  1143. event -= 1;
  1144. intr &= ~(1 << event);
  1145. dev_dbg(gpu->dev, "event %u\n", event);
  1146. fence = gpu->event[event].fence;
  1147. gpu->event[event].fence = NULL;
  1148. fence_signal(fence);
  1149. /*
  1150. * Events can be processed out of order. Eg,
  1151. * - allocate and queue event 0
  1152. * - allocate event 1
  1153. * - event 0 completes, we process it
  1154. * - allocate and queue event 0
  1155. * - event 1 and event 0 complete
  1156. * we can end up processing event 0 first, then 1.
  1157. */
  1158. if (fence_after(fence->seqno, gpu->completed_fence))
  1159. gpu->completed_fence = fence->seqno;
  1160. event_free(gpu, event);
  1161. }
  1162. /* Retire the buffer objects in a work */
  1163. etnaviv_queue_work(gpu->drm, &gpu->retire_work);
  1164. ret = IRQ_HANDLED;
  1165. }
  1166. return ret;
  1167. }
  1168. static int etnaviv_gpu_clk_enable(struct etnaviv_gpu *gpu)
  1169. {
  1170. int ret;
  1171. if (gpu->clk_bus) {
  1172. ret = clk_prepare_enable(gpu->clk_bus);
  1173. if (ret)
  1174. return ret;
  1175. }
  1176. if (gpu->clk_core) {
  1177. ret = clk_prepare_enable(gpu->clk_core);
  1178. if (ret)
  1179. goto disable_clk_bus;
  1180. }
  1181. if (gpu->clk_shader) {
  1182. ret = clk_prepare_enable(gpu->clk_shader);
  1183. if (ret)
  1184. goto disable_clk_core;
  1185. }
  1186. return 0;
  1187. disable_clk_core:
  1188. if (gpu->clk_core)
  1189. clk_disable_unprepare(gpu->clk_core);
  1190. disable_clk_bus:
  1191. if (gpu->clk_bus)
  1192. clk_disable_unprepare(gpu->clk_bus);
  1193. return ret;
  1194. }
  1195. static int etnaviv_gpu_clk_disable(struct etnaviv_gpu *gpu)
  1196. {
  1197. if (gpu->clk_shader)
  1198. clk_disable_unprepare(gpu->clk_shader);
  1199. if (gpu->clk_core)
  1200. clk_disable_unprepare(gpu->clk_core);
  1201. if (gpu->clk_bus)
  1202. clk_disable_unprepare(gpu->clk_bus);
  1203. return 0;
  1204. }
  1205. int etnaviv_gpu_wait_idle(struct etnaviv_gpu *gpu, unsigned int timeout_ms)
  1206. {
  1207. unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms);
  1208. do {
  1209. u32 idle = gpu_read(gpu, VIVS_HI_IDLE_STATE);
  1210. if ((idle & gpu->idle_mask) == gpu->idle_mask)
  1211. return 0;
  1212. if (time_is_before_jiffies(timeout)) {
  1213. dev_warn(gpu->dev,
  1214. "timed out waiting for idle: idle=0x%x\n",
  1215. idle);
  1216. return -ETIMEDOUT;
  1217. }
  1218. udelay(5);
  1219. } while (1);
  1220. }
  1221. static int etnaviv_gpu_hw_suspend(struct etnaviv_gpu *gpu)
  1222. {
  1223. if (gpu->buffer) {
  1224. /* Replace the last WAIT with END */
  1225. etnaviv_buffer_end(gpu);
  1226. /*
  1227. * We know that only the FE is busy here, this should
  1228. * happen quickly (as the WAIT is only 200 cycles). If
  1229. * we fail, just warn and continue.
  1230. */
  1231. etnaviv_gpu_wait_idle(gpu, 100);
  1232. }
  1233. return etnaviv_gpu_clk_disable(gpu);
  1234. }
  1235. #ifdef CONFIG_PM
  1236. static int etnaviv_gpu_hw_resume(struct etnaviv_gpu *gpu)
  1237. {
  1238. u32 clock;
  1239. int ret;
  1240. ret = mutex_lock_killable(&gpu->lock);
  1241. if (ret)
  1242. return ret;
  1243. clock = VIVS_HI_CLOCK_CONTROL_DISABLE_DEBUG_REGISTERS |
  1244. VIVS_HI_CLOCK_CONTROL_FSCALE_VAL(0x40);
  1245. etnaviv_gpu_load_clock(gpu, clock);
  1246. etnaviv_gpu_hw_init(gpu);
  1247. gpu->switch_context = true;
  1248. gpu->exec_state = -1;
  1249. mutex_unlock(&gpu->lock);
  1250. return 0;
  1251. }
  1252. #endif
  1253. static int etnaviv_gpu_bind(struct device *dev, struct device *master,
  1254. void *data)
  1255. {
  1256. struct drm_device *drm = data;
  1257. struct etnaviv_drm_private *priv = drm->dev_private;
  1258. struct etnaviv_gpu *gpu = dev_get_drvdata(dev);
  1259. int ret;
  1260. #ifdef CONFIG_PM
  1261. ret = pm_runtime_get_sync(gpu->dev);
  1262. #else
  1263. ret = etnaviv_gpu_clk_enable(gpu);
  1264. #endif
  1265. if (ret < 0)
  1266. return ret;
  1267. gpu->drm = drm;
  1268. gpu->fence_context = fence_context_alloc(1);
  1269. spin_lock_init(&gpu->fence_spinlock);
  1270. INIT_LIST_HEAD(&gpu->active_cmd_list);
  1271. INIT_WORK(&gpu->retire_work, retire_worker);
  1272. INIT_WORK(&gpu->recover_work, recover_worker);
  1273. init_waitqueue_head(&gpu->fence_event);
  1274. setup_deferrable_timer(&gpu->hangcheck_timer, hangcheck_handler,
  1275. (unsigned long)gpu);
  1276. priv->gpu[priv->num_gpus++] = gpu;
  1277. pm_runtime_mark_last_busy(gpu->dev);
  1278. pm_runtime_put_autosuspend(gpu->dev);
  1279. return 0;
  1280. }
  1281. static void etnaviv_gpu_unbind(struct device *dev, struct device *master,
  1282. void *data)
  1283. {
  1284. struct etnaviv_gpu *gpu = dev_get_drvdata(dev);
  1285. DBG("%s", dev_name(gpu->dev));
  1286. hangcheck_disable(gpu);
  1287. #ifdef CONFIG_PM
  1288. pm_runtime_get_sync(gpu->dev);
  1289. pm_runtime_put_sync_suspend(gpu->dev);
  1290. #else
  1291. etnaviv_gpu_hw_suspend(gpu);
  1292. #endif
  1293. if (gpu->buffer) {
  1294. etnaviv_gpu_cmdbuf_free(gpu->buffer);
  1295. gpu->buffer = NULL;
  1296. }
  1297. if (gpu->mmu) {
  1298. etnaviv_iommu_destroy(gpu->mmu);
  1299. gpu->mmu = NULL;
  1300. }
  1301. gpu->drm = NULL;
  1302. }
  1303. static const struct component_ops gpu_ops = {
  1304. .bind = etnaviv_gpu_bind,
  1305. .unbind = etnaviv_gpu_unbind,
  1306. };
  1307. static const struct of_device_id etnaviv_gpu_match[] = {
  1308. {
  1309. .compatible = "vivante,gc"
  1310. },
  1311. { /* sentinel */ }
  1312. };
  1313. static int etnaviv_gpu_platform_probe(struct platform_device *pdev)
  1314. {
  1315. struct device *dev = &pdev->dev;
  1316. struct etnaviv_gpu *gpu;
  1317. int err;
  1318. gpu = devm_kzalloc(dev, sizeof(*gpu), GFP_KERNEL);
  1319. if (!gpu)
  1320. return -ENOMEM;
  1321. gpu->dev = &pdev->dev;
  1322. mutex_init(&gpu->lock);
  1323. /* Map registers: */
  1324. gpu->mmio = etnaviv_ioremap(pdev, NULL, dev_name(gpu->dev));
  1325. if (IS_ERR(gpu->mmio))
  1326. return PTR_ERR(gpu->mmio);
  1327. /* Get Interrupt: */
  1328. gpu->irq = platform_get_irq(pdev, 0);
  1329. if (gpu->irq < 0) {
  1330. dev_err(dev, "failed to get irq: %d\n", gpu->irq);
  1331. return gpu->irq;
  1332. }
  1333. err = devm_request_irq(&pdev->dev, gpu->irq, irq_handler, 0,
  1334. dev_name(gpu->dev), gpu);
  1335. if (err) {
  1336. dev_err(dev, "failed to request IRQ%u: %d\n", gpu->irq, err);
  1337. return err;
  1338. }
  1339. /* Get Clocks: */
  1340. gpu->clk_bus = devm_clk_get(&pdev->dev, "bus");
  1341. DBG("clk_bus: %p", gpu->clk_bus);
  1342. if (IS_ERR(gpu->clk_bus))
  1343. gpu->clk_bus = NULL;
  1344. gpu->clk_core = devm_clk_get(&pdev->dev, "core");
  1345. DBG("clk_core: %p", gpu->clk_core);
  1346. if (IS_ERR(gpu->clk_core))
  1347. gpu->clk_core = NULL;
  1348. gpu->clk_shader = devm_clk_get(&pdev->dev, "shader");
  1349. DBG("clk_shader: %p", gpu->clk_shader);
  1350. if (IS_ERR(gpu->clk_shader))
  1351. gpu->clk_shader = NULL;
  1352. /* TODO: figure out max mapped size */
  1353. dev_set_drvdata(dev, gpu);
  1354. /*
  1355. * We treat the device as initially suspended. The runtime PM
  1356. * autosuspend delay is rather arbitary: no measurements have
  1357. * yet been performed to determine an appropriate value.
  1358. */
  1359. pm_runtime_use_autosuspend(gpu->dev);
  1360. pm_runtime_set_autosuspend_delay(gpu->dev, 200);
  1361. pm_runtime_enable(gpu->dev);
  1362. err = component_add(&pdev->dev, &gpu_ops);
  1363. if (err < 0) {
  1364. dev_err(&pdev->dev, "failed to register component: %d\n", err);
  1365. return err;
  1366. }
  1367. return 0;
  1368. }
  1369. static int etnaviv_gpu_platform_remove(struct platform_device *pdev)
  1370. {
  1371. component_del(&pdev->dev, &gpu_ops);
  1372. pm_runtime_disable(&pdev->dev);
  1373. return 0;
  1374. }
  1375. #ifdef CONFIG_PM
  1376. static int etnaviv_gpu_rpm_suspend(struct device *dev)
  1377. {
  1378. struct etnaviv_gpu *gpu = dev_get_drvdata(dev);
  1379. u32 idle, mask;
  1380. /* If we have outstanding fences, we're not idle */
  1381. if (gpu->completed_fence != gpu->active_fence)
  1382. return -EBUSY;
  1383. /* Check whether the hardware (except FE) is idle */
  1384. mask = gpu->idle_mask & ~VIVS_HI_IDLE_STATE_FE;
  1385. idle = gpu_read(gpu, VIVS_HI_IDLE_STATE) & mask;
  1386. if (idle != mask)
  1387. return -EBUSY;
  1388. return etnaviv_gpu_hw_suspend(gpu);
  1389. }
  1390. static int etnaviv_gpu_rpm_resume(struct device *dev)
  1391. {
  1392. struct etnaviv_gpu *gpu = dev_get_drvdata(dev);
  1393. int ret;
  1394. ret = etnaviv_gpu_clk_enable(gpu);
  1395. if (ret)
  1396. return ret;
  1397. /* Re-initialise the basic hardware state */
  1398. if (gpu->drm && gpu->buffer) {
  1399. ret = etnaviv_gpu_hw_resume(gpu);
  1400. if (ret) {
  1401. etnaviv_gpu_clk_disable(gpu);
  1402. return ret;
  1403. }
  1404. }
  1405. return 0;
  1406. }
  1407. #endif
  1408. static const struct dev_pm_ops etnaviv_gpu_pm_ops = {
  1409. SET_RUNTIME_PM_OPS(etnaviv_gpu_rpm_suspend, etnaviv_gpu_rpm_resume,
  1410. NULL)
  1411. };
  1412. struct platform_driver etnaviv_gpu_driver = {
  1413. .driver = {
  1414. .name = "etnaviv-gpu",
  1415. .owner = THIS_MODULE,
  1416. .pm = &etnaviv_gpu_pm_ops,
  1417. .of_match_table = etnaviv_gpu_match,
  1418. },
  1419. .probe = etnaviv_gpu_platform_probe,
  1420. .remove = etnaviv_gpu_platform_remove,
  1421. .id_table = gpu_ids,
  1422. };