gfx_v6_0.c 117 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673
  1. /*
  2. * Copyright 2015 Advanced Micro Devices, Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. */
  23. #include <linux/firmware.h>
  24. #include "amdgpu.h"
  25. #include "amdgpu_ih.h"
  26. #include "amdgpu_gfx.h"
  27. #include "amdgpu_ucode.h"
  28. #include "clearstate_si.h"
  29. #include "bif/bif_3_0_d.h"
  30. #include "bif/bif_3_0_sh_mask.h"
  31. #include "oss/oss_1_0_d.h"
  32. #include "oss/oss_1_0_sh_mask.h"
  33. #include "gca/gfx_6_0_d.h"
  34. #include "gca/gfx_6_0_sh_mask.h"
  35. #include "gmc/gmc_6_0_d.h"
  36. #include "gmc/gmc_6_0_sh_mask.h"
  37. #include "dce/dce_6_0_d.h"
  38. #include "dce/dce_6_0_sh_mask.h"
  39. #include "gca/gfx_7_2_enum.h"
  40. #include "si_enums.h"
  41. static void gfx_v6_0_set_ring_funcs(struct amdgpu_device *adev);
  42. static void gfx_v6_0_set_irq_funcs(struct amdgpu_device *adev);
  43. static void gfx_v6_0_get_cu_info(struct amdgpu_device *adev);
  44. MODULE_FIRMWARE("radeon/tahiti_pfp.bin");
  45. MODULE_FIRMWARE("radeon/tahiti_me.bin");
  46. MODULE_FIRMWARE("radeon/tahiti_ce.bin");
  47. MODULE_FIRMWARE("radeon/tahiti_rlc.bin");
  48. MODULE_FIRMWARE("radeon/pitcairn_pfp.bin");
  49. MODULE_FIRMWARE("radeon/pitcairn_me.bin");
  50. MODULE_FIRMWARE("radeon/pitcairn_ce.bin");
  51. MODULE_FIRMWARE("radeon/pitcairn_rlc.bin");
  52. MODULE_FIRMWARE("radeon/verde_pfp.bin");
  53. MODULE_FIRMWARE("radeon/verde_me.bin");
  54. MODULE_FIRMWARE("radeon/verde_ce.bin");
  55. MODULE_FIRMWARE("radeon/verde_rlc.bin");
  56. MODULE_FIRMWARE("radeon/oland_pfp.bin");
  57. MODULE_FIRMWARE("radeon/oland_me.bin");
  58. MODULE_FIRMWARE("radeon/oland_ce.bin");
  59. MODULE_FIRMWARE("radeon/oland_rlc.bin");
  60. MODULE_FIRMWARE("radeon/hainan_pfp.bin");
  61. MODULE_FIRMWARE("radeon/hainan_me.bin");
  62. MODULE_FIRMWARE("radeon/hainan_ce.bin");
  63. MODULE_FIRMWARE("radeon/hainan_rlc.bin");
  64. static u32 gfx_v6_0_get_csb_size(struct amdgpu_device *adev);
  65. static void gfx_v6_0_get_csb_buffer(struct amdgpu_device *adev, volatile u32 *buffer);
  66. //static void gfx_v6_0_init_cp_pg_table(struct amdgpu_device *adev);
  67. static void gfx_v6_0_init_pg(struct amdgpu_device *adev);
  68. #define ARRAY_MODE(x) ((x) << GB_TILE_MODE0__ARRAY_MODE__SHIFT)
  69. #define PIPE_CONFIG(x) ((x) << GB_TILE_MODE0__PIPE_CONFIG__SHIFT)
  70. #define TILE_SPLIT(x) ((x) << GB_TILE_MODE0__TILE_SPLIT__SHIFT)
  71. #define MICRO_TILE_MODE(x) ((x) << 0)
  72. #define SAMPLE_SPLIT(x) ((x) << GB_TILE_MODE0__SAMPLE_SPLIT__SHIFT)
  73. #define BANK_WIDTH(x) ((x) << 14)
  74. #define BANK_HEIGHT(x) ((x) << 16)
  75. #define MACRO_TILE_ASPECT(x) ((x) << 18)
  76. #define NUM_BANKS(x) ((x) << 20)
  77. static const u32 verde_rlc_save_restore_register_list[] =
  78. {
  79. (0x8000 << 16) | (0x98f4 >> 2),
  80. 0x00000000,
  81. (0x8040 << 16) | (0x98f4 >> 2),
  82. 0x00000000,
  83. (0x8000 << 16) | (0xe80 >> 2),
  84. 0x00000000,
  85. (0x8040 << 16) | (0xe80 >> 2),
  86. 0x00000000,
  87. (0x8000 << 16) | (0x89bc >> 2),
  88. 0x00000000,
  89. (0x8040 << 16) | (0x89bc >> 2),
  90. 0x00000000,
  91. (0x8000 << 16) | (0x8c1c >> 2),
  92. 0x00000000,
  93. (0x8040 << 16) | (0x8c1c >> 2),
  94. 0x00000000,
  95. (0x9c00 << 16) | (0x98f0 >> 2),
  96. 0x00000000,
  97. (0x9c00 << 16) | (0xe7c >> 2),
  98. 0x00000000,
  99. (0x8000 << 16) | (0x9148 >> 2),
  100. 0x00000000,
  101. (0x8040 << 16) | (0x9148 >> 2),
  102. 0x00000000,
  103. (0x9c00 << 16) | (0x9150 >> 2),
  104. 0x00000000,
  105. (0x9c00 << 16) | (0x897c >> 2),
  106. 0x00000000,
  107. (0x9c00 << 16) | (0x8d8c >> 2),
  108. 0x00000000,
  109. (0x9c00 << 16) | (0xac54 >> 2),
  110. 0X00000000,
  111. 0x3,
  112. (0x9c00 << 16) | (0x98f8 >> 2),
  113. 0x00000000,
  114. (0x9c00 << 16) | (0x9910 >> 2),
  115. 0x00000000,
  116. (0x9c00 << 16) | (0x9914 >> 2),
  117. 0x00000000,
  118. (0x9c00 << 16) | (0x9918 >> 2),
  119. 0x00000000,
  120. (0x9c00 << 16) | (0x991c >> 2),
  121. 0x00000000,
  122. (0x9c00 << 16) | (0x9920 >> 2),
  123. 0x00000000,
  124. (0x9c00 << 16) | (0x9924 >> 2),
  125. 0x00000000,
  126. (0x9c00 << 16) | (0x9928 >> 2),
  127. 0x00000000,
  128. (0x9c00 << 16) | (0x992c >> 2),
  129. 0x00000000,
  130. (0x9c00 << 16) | (0x9930 >> 2),
  131. 0x00000000,
  132. (0x9c00 << 16) | (0x9934 >> 2),
  133. 0x00000000,
  134. (0x9c00 << 16) | (0x9938 >> 2),
  135. 0x00000000,
  136. (0x9c00 << 16) | (0x993c >> 2),
  137. 0x00000000,
  138. (0x9c00 << 16) | (0x9940 >> 2),
  139. 0x00000000,
  140. (0x9c00 << 16) | (0x9944 >> 2),
  141. 0x00000000,
  142. (0x9c00 << 16) | (0x9948 >> 2),
  143. 0x00000000,
  144. (0x9c00 << 16) | (0x994c >> 2),
  145. 0x00000000,
  146. (0x9c00 << 16) | (0x9950 >> 2),
  147. 0x00000000,
  148. (0x9c00 << 16) | (0x9954 >> 2),
  149. 0x00000000,
  150. (0x9c00 << 16) | (0x9958 >> 2),
  151. 0x00000000,
  152. (0x9c00 << 16) | (0x995c >> 2),
  153. 0x00000000,
  154. (0x9c00 << 16) | (0x9960 >> 2),
  155. 0x00000000,
  156. (0x9c00 << 16) | (0x9964 >> 2),
  157. 0x00000000,
  158. (0x9c00 << 16) | (0x9968 >> 2),
  159. 0x00000000,
  160. (0x9c00 << 16) | (0x996c >> 2),
  161. 0x00000000,
  162. (0x9c00 << 16) | (0x9970 >> 2),
  163. 0x00000000,
  164. (0x9c00 << 16) | (0x9974 >> 2),
  165. 0x00000000,
  166. (0x9c00 << 16) | (0x9978 >> 2),
  167. 0x00000000,
  168. (0x9c00 << 16) | (0x997c >> 2),
  169. 0x00000000,
  170. (0x9c00 << 16) | (0x9980 >> 2),
  171. 0x00000000,
  172. (0x9c00 << 16) | (0x9984 >> 2),
  173. 0x00000000,
  174. (0x9c00 << 16) | (0x9988 >> 2),
  175. 0x00000000,
  176. (0x9c00 << 16) | (0x998c >> 2),
  177. 0x00000000,
  178. (0x9c00 << 16) | (0x8c00 >> 2),
  179. 0x00000000,
  180. (0x9c00 << 16) | (0x8c14 >> 2),
  181. 0x00000000,
  182. (0x9c00 << 16) | (0x8c04 >> 2),
  183. 0x00000000,
  184. (0x9c00 << 16) | (0x8c08 >> 2),
  185. 0x00000000,
  186. (0x8000 << 16) | (0x9b7c >> 2),
  187. 0x00000000,
  188. (0x8040 << 16) | (0x9b7c >> 2),
  189. 0x00000000,
  190. (0x8000 << 16) | (0xe84 >> 2),
  191. 0x00000000,
  192. (0x8040 << 16) | (0xe84 >> 2),
  193. 0x00000000,
  194. (0x8000 << 16) | (0x89c0 >> 2),
  195. 0x00000000,
  196. (0x8040 << 16) | (0x89c0 >> 2),
  197. 0x00000000,
  198. (0x8000 << 16) | (0x914c >> 2),
  199. 0x00000000,
  200. (0x8040 << 16) | (0x914c >> 2),
  201. 0x00000000,
  202. (0x8000 << 16) | (0x8c20 >> 2),
  203. 0x00000000,
  204. (0x8040 << 16) | (0x8c20 >> 2),
  205. 0x00000000,
  206. (0x8000 << 16) | (0x9354 >> 2),
  207. 0x00000000,
  208. (0x8040 << 16) | (0x9354 >> 2),
  209. 0x00000000,
  210. (0x9c00 << 16) | (0x9060 >> 2),
  211. 0x00000000,
  212. (0x9c00 << 16) | (0x9364 >> 2),
  213. 0x00000000,
  214. (0x9c00 << 16) | (0x9100 >> 2),
  215. 0x00000000,
  216. (0x9c00 << 16) | (0x913c >> 2),
  217. 0x00000000,
  218. (0x8000 << 16) | (0x90e0 >> 2),
  219. 0x00000000,
  220. (0x8000 << 16) | (0x90e4 >> 2),
  221. 0x00000000,
  222. (0x8000 << 16) | (0x90e8 >> 2),
  223. 0x00000000,
  224. (0x8040 << 16) | (0x90e0 >> 2),
  225. 0x00000000,
  226. (0x8040 << 16) | (0x90e4 >> 2),
  227. 0x00000000,
  228. (0x8040 << 16) | (0x90e8 >> 2),
  229. 0x00000000,
  230. (0x9c00 << 16) | (0x8bcc >> 2),
  231. 0x00000000,
  232. (0x9c00 << 16) | (0x8b24 >> 2),
  233. 0x00000000,
  234. (0x9c00 << 16) | (0x88c4 >> 2),
  235. 0x00000000,
  236. (0x9c00 << 16) | (0x8e50 >> 2),
  237. 0x00000000,
  238. (0x9c00 << 16) | (0x8c0c >> 2),
  239. 0x00000000,
  240. (0x9c00 << 16) | (0x8e58 >> 2),
  241. 0x00000000,
  242. (0x9c00 << 16) | (0x8e5c >> 2),
  243. 0x00000000,
  244. (0x9c00 << 16) | (0x9508 >> 2),
  245. 0x00000000,
  246. (0x9c00 << 16) | (0x950c >> 2),
  247. 0x00000000,
  248. (0x9c00 << 16) | (0x9494 >> 2),
  249. 0x00000000,
  250. (0x9c00 << 16) | (0xac0c >> 2),
  251. 0x00000000,
  252. (0x9c00 << 16) | (0xac10 >> 2),
  253. 0x00000000,
  254. (0x9c00 << 16) | (0xac14 >> 2),
  255. 0x00000000,
  256. (0x9c00 << 16) | (0xae00 >> 2),
  257. 0x00000000,
  258. (0x9c00 << 16) | (0xac08 >> 2),
  259. 0x00000000,
  260. (0x9c00 << 16) | (0x88d4 >> 2),
  261. 0x00000000,
  262. (0x9c00 << 16) | (0x88c8 >> 2),
  263. 0x00000000,
  264. (0x9c00 << 16) | (0x88cc >> 2),
  265. 0x00000000,
  266. (0x9c00 << 16) | (0x89b0 >> 2),
  267. 0x00000000,
  268. (0x9c00 << 16) | (0x8b10 >> 2),
  269. 0x00000000,
  270. (0x9c00 << 16) | (0x8a14 >> 2),
  271. 0x00000000,
  272. (0x9c00 << 16) | (0x9830 >> 2),
  273. 0x00000000,
  274. (0x9c00 << 16) | (0x9834 >> 2),
  275. 0x00000000,
  276. (0x9c00 << 16) | (0x9838 >> 2),
  277. 0x00000000,
  278. (0x9c00 << 16) | (0x9a10 >> 2),
  279. 0x00000000,
  280. (0x8000 << 16) | (0x9870 >> 2),
  281. 0x00000000,
  282. (0x8000 << 16) | (0x9874 >> 2),
  283. 0x00000000,
  284. (0x8001 << 16) | (0x9870 >> 2),
  285. 0x00000000,
  286. (0x8001 << 16) | (0x9874 >> 2),
  287. 0x00000000,
  288. (0x8040 << 16) | (0x9870 >> 2),
  289. 0x00000000,
  290. (0x8040 << 16) | (0x9874 >> 2),
  291. 0x00000000,
  292. (0x8041 << 16) | (0x9870 >> 2),
  293. 0x00000000,
  294. (0x8041 << 16) | (0x9874 >> 2),
  295. 0x00000000,
  296. 0x00000000
  297. };
  298. static int gfx_v6_0_init_microcode(struct amdgpu_device *adev)
  299. {
  300. const char *chip_name;
  301. char fw_name[30];
  302. int err;
  303. const struct gfx_firmware_header_v1_0 *cp_hdr;
  304. const struct rlc_firmware_header_v1_0 *rlc_hdr;
  305. DRM_DEBUG("\n");
  306. switch (adev->asic_type) {
  307. case CHIP_TAHITI:
  308. chip_name = "tahiti";
  309. break;
  310. case CHIP_PITCAIRN:
  311. chip_name = "pitcairn";
  312. break;
  313. case CHIP_VERDE:
  314. chip_name = "verde";
  315. break;
  316. case CHIP_OLAND:
  317. chip_name = "oland";
  318. break;
  319. case CHIP_HAINAN:
  320. chip_name = "hainan";
  321. break;
  322. default: BUG();
  323. }
  324. snprintf(fw_name, sizeof(fw_name), "radeon/%s_pfp.bin", chip_name);
  325. err = request_firmware(&adev->gfx.pfp_fw, fw_name, adev->dev);
  326. if (err)
  327. goto out;
  328. err = amdgpu_ucode_validate(adev->gfx.pfp_fw);
  329. if (err)
  330. goto out;
  331. cp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.pfp_fw->data;
  332. adev->gfx.pfp_fw_version = le32_to_cpu(cp_hdr->header.ucode_version);
  333. adev->gfx.pfp_feature_version = le32_to_cpu(cp_hdr->ucode_feature_version);
  334. snprintf(fw_name, sizeof(fw_name), "radeon/%s_me.bin", chip_name);
  335. err = request_firmware(&adev->gfx.me_fw, fw_name, adev->dev);
  336. if (err)
  337. goto out;
  338. err = amdgpu_ucode_validate(adev->gfx.me_fw);
  339. if (err)
  340. goto out;
  341. cp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.me_fw->data;
  342. adev->gfx.me_fw_version = le32_to_cpu(cp_hdr->header.ucode_version);
  343. adev->gfx.me_feature_version = le32_to_cpu(cp_hdr->ucode_feature_version);
  344. snprintf(fw_name, sizeof(fw_name), "radeon/%s_ce.bin", chip_name);
  345. err = request_firmware(&adev->gfx.ce_fw, fw_name, adev->dev);
  346. if (err)
  347. goto out;
  348. err = amdgpu_ucode_validate(adev->gfx.ce_fw);
  349. if (err)
  350. goto out;
  351. cp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.ce_fw->data;
  352. adev->gfx.ce_fw_version = le32_to_cpu(cp_hdr->header.ucode_version);
  353. adev->gfx.ce_feature_version = le32_to_cpu(cp_hdr->ucode_feature_version);
  354. snprintf(fw_name, sizeof(fw_name), "radeon/%s_rlc.bin", chip_name);
  355. err = request_firmware(&adev->gfx.rlc_fw, fw_name, adev->dev);
  356. if (err)
  357. goto out;
  358. err = amdgpu_ucode_validate(adev->gfx.rlc_fw);
  359. rlc_hdr = (const struct rlc_firmware_header_v1_0 *)adev->gfx.rlc_fw->data;
  360. adev->gfx.rlc_fw_version = le32_to_cpu(rlc_hdr->header.ucode_version);
  361. adev->gfx.rlc_feature_version = le32_to_cpu(rlc_hdr->ucode_feature_version);
  362. out:
  363. if (err) {
  364. pr_err("gfx6: Failed to load firmware \"%s\"\n", fw_name);
  365. release_firmware(adev->gfx.pfp_fw);
  366. adev->gfx.pfp_fw = NULL;
  367. release_firmware(adev->gfx.me_fw);
  368. adev->gfx.me_fw = NULL;
  369. release_firmware(adev->gfx.ce_fw);
  370. adev->gfx.ce_fw = NULL;
  371. release_firmware(adev->gfx.rlc_fw);
  372. adev->gfx.rlc_fw = NULL;
  373. }
  374. return err;
  375. }
  376. static void gfx_v6_0_tiling_mode_table_init(struct amdgpu_device *adev)
  377. {
  378. const u32 num_tile_mode_states = ARRAY_SIZE(adev->gfx.config.tile_mode_array);
  379. u32 reg_offset, split_equal_to_row_size, *tilemode;
  380. memset(adev->gfx.config.tile_mode_array, 0, sizeof(adev->gfx.config.tile_mode_array));
  381. tilemode = adev->gfx.config.tile_mode_array;
  382. switch (adev->gfx.config.mem_row_size_in_kb) {
  383. case 1:
  384. split_equal_to_row_size = ADDR_SURF_TILE_SPLIT_1KB;
  385. break;
  386. case 2:
  387. default:
  388. split_equal_to_row_size = ADDR_SURF_TILE_SPLIT_2KB;
  389. break;
  390. case 4:
  391. split_equal_to_row_size = ADDR_SURF_TILE_SPLIT_4KB;
  392. break;
  393. }
  394. if (adev->asic_type == CHIP_VERDE) {
  395. tilemode[0] = MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
  396. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  397. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  398. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) |
  399. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  400. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  401. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  402. NUM_BANKS(ADDR_SURF_16_BANK);
  403. tilemode[1] = MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
  404. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  405. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  406. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B) |
  407. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  408. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  409. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  410. NUM_BANKS(ADDR_SURF_16_BANK);
  411. tilemode[2] = MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
  412. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  413. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  414. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  415. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  416. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  417. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  418. NUM_BANKS(ADDR_SURF_16_BANK);
  419. tilemode[3] = MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
  420. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  421. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  422. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  423. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  424. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  425. NUM_BANKS(ADDR_SURF_8_BANK) |
  426. TILE_SPLIT(split_equal_to_row_size);
  427. tilemode[4] = MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
  428. ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
  429. PIPE_CONFIG(ADDR_SURF_P4_8x16);
  430. tilemode[5] = MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
  431. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  432. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  433. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) |
  434. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  435. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  436. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  437. NUM_BANKS(ADDR_SURF_4_BANK);
  438. tilemode[6] = MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
  439. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  440. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  441. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  442. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  443. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  444. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  445. NUM_BANKS(ADDR_SURF_4_BANK);
  446. tilemode[7] = MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
  447. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  448. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  449. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) |
  450. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  451. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  452. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  453. NUM_BANKS(ADDR_SURF_2_BANK);
  454. tilemode[8] = ARRAY_MODE(ARRAY_LINEAR_ALIGNED);
  455. tilemode[9] = MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) |
  456. ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
  457. PIPE_CONFIG(ADDR_SURF_P4_8x16);
  458. tilemode[10] = MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) |
  459. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  460. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  461. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  462. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  463. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  464. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  465. NUM_BANKS(ADDR_SURF_16_BANK);
  466. tilemode[11] = MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) |
  467. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  468. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  469. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  470. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  471. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  472. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  473. NUM_BANKS(ADDR_SURF_16_BANK);
  474. tilemode[12] = MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) |
  475. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  476. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  477. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) |
  478. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  479. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  480. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  481. NUM_BANKS(ADDR_SURF_16_BANK);
  482. tilemode[13] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  483. ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
  484. PIPE_CONFIG(ADDR_SURF_P4_8x16);
  485. tilemode[14] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  486. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  487. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  488. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  489. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  490. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  491. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  492. NUM_BANKS(ADDR_SURF_16_BANK);
  493. tilemode[15] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  494. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  495. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  496. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  497. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  498. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  499. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  500. NUM_BANKS(ADDR_SURF_16_BANK);
  501. tilemode[16] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  502. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  503. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  504. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) |
  505. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  506. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  507. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  508. NUM_BANKS(ADDR_SURF_16_BANK);
  509. tilemode[17] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  510. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  511. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  512. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  513. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  514. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  515. NUM_BANKS(ADDR_SURF_16_BANK) |
  516. TILE_SPLIT(split_equal_to_row_size);
  517. tilemode[18] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  518. ARRAY_MODE(ARRAY_1D_TILED_THICK) |
  519. PIPE_CONFIG(ADDR_SURF_P4_8x16);
  520. tilemode[19] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  521. ARRAY_MODE(ARRAY_2D_TILED_XTHICK) |
  522. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  523. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  524. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  525. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  526. NUM_BANKS(ADDR_SURF_16_BANK) |
  527. TILE_SPLIT(split_equal_to_row_size);
  528. tilemode[20] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  529. ARRAY_MODE(ARRAY_2D_TILED_THICK) |
  530. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  531. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  532. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  533. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  534. NUM_BANKS(ADDR_SURF_16_BANK) |
  535. TILE_SPLIT(split_equal_to_row_size);
  536. tilemode[21] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  537. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  538. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  539. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  540. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  541. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  542. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  543. NUM_BANKS(ADDR_SURF_8_BANK);
  544. tilemode[22] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  545. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  546. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  547. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  548. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  549. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  550. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  551. NUM_BANKS(ADDR_SURF_8_BANK);
  552. tilemode[23] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  553. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  554. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  555. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  556. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  557. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  558. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  559. NUM_BANKS(ADDR_SURF_4_BANK);
  560. tilemode[24] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  561. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  562. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  563. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) |
  564. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  565. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  566. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  567. NUM_BANKS(ADDR_SURF_4_BANK);
  568. tilemode[25] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  569. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  570. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  571. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) |
  572. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  573. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  574. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  575. NUM_BANKS(ADDR_SURF_2_BANK);
  576. tilemode[26] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  577. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  578. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  579. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) |
  580. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  581. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  582. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  583. NUM_BANKS(ADDR_SURF_2_BANK);
  584. tilemode[27] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  585. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  586. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  587. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) |
  588. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  589. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  590. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  591. NUM_BANKS(ADDR_SURF_2_BANK);
  592. tilemode[28] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  593. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  594. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  595. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) |
  596. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  597. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  598. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  599. NUM_BANKS(ADDR_SURF_2_BANK);
  600. tilemode[29] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  601. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  602. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  603. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) |
  604. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  605. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  606. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  607. NUM_BANKS(ADDR_SURF_2_BANK);
  608. tilemode[30] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  609. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  610. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  611. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_2KB) |
  612. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  613. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  614. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  615. NUM_BANKS(ADDR_SURF_2_BANK);
  616. for (reg_offset = 0; reg_offset < num_tile_mode_states; reg_offset++)
  617. WREG32(mmGB_TILE_MODE0 + reg_offset, tilemode[reg_offset]);
  618. } else if (adev->asic_type == CHIP_OLAND) {
  619. tilemode[0] = MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
  620. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  621. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  622. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) |
  623. NUM_BANKS(ADDR_SURF_16_BANK) |
  624. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  625. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  626. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4);
  627. tilemode[1] = MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
  628. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  629. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  630. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B) |
  631. NUM_BANKS(ADDR_SURF_16_BANK) |
  632. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  633. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  634. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4);
  635. tilemode[2] = MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
  636. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  637. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  638. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  639. NUM_BANKS(ADDR_SURF_16_BANK) |
  640. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  641. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  642. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4);
  643. tilemode[3] = MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
  644. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  645. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  646. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B) |
  647. NUM_BANKS(ADDR_SURF_16_BANK) |
  648. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  649. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  650. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4);
  651. tilemode[4] = MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
  652. ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
  653. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  654. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) |
  655. NUM_BANKS(ADDR_SURF_16_BANK) |
  656. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  657. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  658. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2);
  659. tilemode[5] = MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
  660. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  661. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  662. TILE_SPLIT(split_equal_to_row_size) |
  663. NUM_BANKS(ADDR_SURF_16_BANK) |
  664. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  665. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  666. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2);
  667. tilemode[6] = MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
  668. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  669. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  670. TILE_SPLIT(split_equal_to_row_size) |
  671. NUM_BANKS(ADDR_SURF_16_BANK) |
  672. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  673. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  674. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2);
  675. tilemode[7] = MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
  676. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  677. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  678. TILE_SPLIT(split_equal_to_row_size) |
  679. NUM_BANKS(ADDR_SURF_16_BANK) |
  680. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  681. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  682. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4);
  683. tilemode[8] = MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) |
  684. ARRAY_MODE(ARRAY_LINEAR_ALIGNED) |
  685. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  686. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) |
  687. NUM_BANKS(ADDR_SURF_16_BANK) |
  688. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  689. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  690. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2);
  691. tilemode[9] = MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) |
  692. ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
  693. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  694. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) |
  695. NUM_BANKS(ADDR_SURF_16_BANK) |
  696. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  697. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  698. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2);
  699. tilemode[10] = MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) |
  700. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  701. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  702. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  703. NUM_BANKS(ADDR_SURF_16_BANK) |
  704. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  705. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  706. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4);
  707. tilemode[11] = MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) |
  708. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  709. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  710. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  711. NUM_BANKS(ADDR_SURF_16_BANK) |
  712. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  713. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  714. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2);
  715. tilemode[12] = MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) |
  716. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  717. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  718. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) |
  719. NUM_BANKS(ADDR_SURF_16_BANK) |
  720. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  721. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  722. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2);
  723. tilemode[13] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  724. ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
  725. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  726. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) |
  727. NUM_BANKS(ADDR_SURF_16_BANK) |
  728. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  729. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  730. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2);
  731. tilemode[14] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  732. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  733. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  734. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  735. NUM_BANKS(ADDR_SURF_16_BANK) |
  736. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  737. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  738. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2);
  739. tilemode[15] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  740. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  741. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  742. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  743. NUM_BANKS(ADDR_SURF_16_BANK) |
  744. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  745. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  746. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2);
  747. tilemode[16] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  748. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  749. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  750. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) |
  751. NUM_BANKS(ADDR_SURF_16_BANK) |
  752. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  753. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  754. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2);
  755. tilemode[17] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  756. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  757. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  758. TILE_SPLIT(split_equal_to_row_size) |
  759. NUM_BANKS(ADDR_SURF_16_BANK) |
  760. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  761. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  762. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2);
  763. tilemode[21] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  764. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  765. PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
  766. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  767. NUM_BANKS(ADDR_SURF_16_BANK) |
  768. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2) |
  769. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  770. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2);
  771. tilemode[22] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  772. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  773. PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
  774. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  775. NUM_BANKS(ADDR_SURF_16_BANK) |
  776. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  777. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  778. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4);
  779. tilemode[23] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  780. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  781. PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
  782. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  783. NUM_BANKS(ADDR_SURF_16_BANK) |
  784. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  785. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  786. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2);
  787. tilemode[24] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  788. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  789. PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
  790. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) |
  791. NUM_BANKS(ADDR_SURF_16_BANK) |
  792. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  793. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  794. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2);
  795. tilemode[25] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  796. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  797. PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
  798. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) |
  799. NUM_BANKS(ADDR_SURF_8_BANK) |
  800. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  801. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  802. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1);
  803. for (reg_offset = 0; reg_offset < num_tile_mode_states; reg_offset++)
  804. WREG32(mmGB_TILE_MODE0 + reg_offset, tilemode[reg_offset]);
  805. } else if (adev->asic_type == CHIP_HAINAN) {
  806. tilemode[0] = MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
  807. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  808. PIPE_CONFIG(ADDR_SURF_P2) |
  809. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) |
  810. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  811. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  812. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  813. NUM_BANKS(ADDR_SURF_16_BANK);
  814. tilemode[1] = MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
  815. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  816. PIPE_CONFIG(ADDR_SURF_P2) |
  817. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B) |
  818. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  819. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  820. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  821. NUM_BANKS(ADDR_SURF_16_BANK);
  822. tilemode[2] = MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
  823. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  824. PIPE_CONFIG(ADDR_SURF_P2) |
  825. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  826. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  827. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  828. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  829. NUM_BANKS(ADDR_SURF_16_BANK);
  830. tilemode[3] = MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
  831. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  832. PIPE_CONFIG(ADDR_SURF_P2) |
  833. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  834. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  835. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  836. NUM_BANKS(ADDR_SURF_8_BANK) |
  837. TILE_SPLIT(split_equal_to_row_size);
  838. tilemode[4] = MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
  839. ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
  840. PIPE_CONFIG(ADDR_SURF_P2);
  841. tilemode[5] = MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
  842. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  843. PIPE_CONFIG(ADDR_SURF_P2) |
  844. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) |
  845. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  846. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  847. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  848. NUM_BANKS(ADDR_SURF_8_BANK);
  849. tilemode[6] = MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
  850. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  851. PIPE_CONFIG(ADDR_SURF_P2) |
  852. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  853. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  854. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  855. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  856. NUM_BANKS(ADDR_SURF_8_BANK);
  857. tilemode[7] = MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
  858. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  859. PIPE_CONFIG(ADDR_SURF_P2) |
  860. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) |
  861. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  862. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  863. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  864. NUM_BANKS(ADDR_SURF_4_BANK);
  865. tilemode[8] = ARRAY_MODE(ARRAY_LINEAR_ALIGNED);
  866. tilemode[9] = MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) |
  867. ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
  868. PIPE_CONFIG(ADDR_SURF_P2);
  869. tilemode[10] = MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) |
  870. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  871. PIPE_CONFIG(ADDR_SURF_P2) |
  872. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  873. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  874. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  875. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  876. NUM_BANKS(ADDR_SURF_16_BANK);
  877. tilemode[11] = MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) |
  878. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  879. PIPE_CONFIG(ADDR_SURF_P2) |
  880. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  881. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  882. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  883. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  884. NUM_BANKS(ADDR_SURF_16_BANK);
  885. tilemode[12] = MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) |
  886. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  887. PIPE_CONFIG(ADDR_SURF_P2) |
  888. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) |
  889. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  890. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  891. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  892. NUM_BANKS(ADDR_SURF_16_BANK);
  893. tilemode[13] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  894. ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
  895. PIPE_CONFIG(ADDR_SURF_P2);
  896. tilemode[14] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  897. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  898. PIPE_CONFIG(ADDR_SURF_P2) |
  899. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  900. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  901. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  902. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  903. NUM_BANKS(ADDR_SURF_16_BANK);
  904. tilemode[15] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  905. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  906. PIPE_CONFIG(ADDR_SURF_P2) |
  907. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  908. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  909. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  910. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  911. NUM_BANKS(ADDR_SURF_16_BANK);
  912. tilemode[16] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  913. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  914. PIPE_CONFIG(ADDR_SURF_P2) |
  915. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) |
  916. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  917. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  918. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  919. NUM_BANKS(ADDR_SURF_16_BANK);
  920. tilemode[17] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  921. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  922. PIPE_CONFIG(ADDR_SURF_P2) |
  923. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  924. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  925. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  926. NUM_BANKS(ADDR_SURF_16_BANK) |
  927. TILE_SPLIT(split_equal_to_row_size);
  928. tilemode[18] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  929. ARRAY_MODE(ARRAY_1D_TILED_THICK) |
  930. PIPE_CONFIG(ADDR_SURF_P2);
  931. tilemode[19] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  932. ARRAY_MODE(ARRAY_2D_TILED_XTHICK) |
  933. PIPE_CONFIG(ADDR_SURF_P2) |
  934. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  935. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  936. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  937. NUM_BANKS(ADDR_SURF_16_BANK) |
  938. TILE_SPLIT(split_equal_to_row_size);
  939. tilemode[20] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  940. ARRAY_MODE(ARRAY_2D_TILED_THICK) |
  941. PIPE_CONFIG(ADDR_SURF_P2) |
  942. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  943. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  944. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  945. NUM_BANKS(ADDR_SURF_16_BANK) |
  946. TILE_SPLIT(split_equal_to_row_size);
  947. tilemode[21] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  948. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  949. PIPE_CONFIG(ADDR_SURF_P2) |
  950. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  951. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2) |
  952. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  953. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  954. NUM_BANKS(ADDR_SURF_8_BANK);
  955. tilemode[22] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  956. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  957. PIPE_CONFIG(ADDR_SURF_P2) |
  958. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  959. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2) |
  960. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  961. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  962. NUM_BANKS(ADDR_SURF_8_BANK);
  963. tilemode[23] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  964. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  965. PIPE_CONFIG(ADDR_SURF_P2) |
  966. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  967. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  968. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  969. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  970. NUM_BANKS(ADDR_SURF_8_BANK);
  971. tilemode[24] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  972. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  973. PIPE_CONFIG(ADDR_SURF_P2) |
  974. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) |
  975. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  976. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  977. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  978. NUM_BANKS(ADDR_SURF_8_BANK);
  979. tilemode[25] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  980. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  981. PIPE_CONFIG(ADDR_SURF_P2) |
  982. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) |
  983. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  984. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  985. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  986. NUM_BANKS(ADDR_SURF_4_BANK);
  987. tilemode[26] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  988. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  989. PIPE_CONFIG(ADDR_SURF_P2) |
  990. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) |
  991. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  992. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  993. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  994. NUM_BANKS(ADDR_SURF_4_BANK);
  995. tilemode[27] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  996. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  997. PIPE_CONFIG(ADDR_SURF_P2) |
  998. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) |
  999. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1000. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  1001. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  1002. NUM_BANKS(ADDR_SURF_4_BANK);
  1003. tilemode[28] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  1004. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1005. PIPE_CONFIG(ADDR_SURF_P2) |
  1006. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) |
  1007. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1008. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  1009. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  1010. NUM_BANKS(ADDR_SURF_4_BANK);
  1011. tilemode[29] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  1012. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1013. PIPE_CONFIG(ADDR_SURF_P2) |
  1014. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) |
  1015. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1016. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  1017. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  1018. NUM_BANKS(ADDR_SURF_4_BANK);
  1019. tilemode[30] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  1020. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1021. PIPE_CONFIG(ADDR_SURF_P2) |
  1022. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_2KB) |
  1023. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1024. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  1025. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  1026. NUM_BANKS(ADDR_SURF_4_BANK);
  1027. for (reg_offset = 0; reg_offset < num_tile_mode_states; reg_offset++)
  1028. WREG32(mmGB_TILE_MODE0 + reg_offset, tilemode[reg_offset]);
  1029. } else if ((adev->asic_type == CHIP_TAHITI) || (adev->asic_type == CHIP_PITCAIRN)) {
  1030. tilemode[0] = MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
  1031. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1032. PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
  1033. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) |
  1034. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1035. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  1036. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  1037. NUM_BANKS(ADDR_SURF_16_BANK);
  1038. tilemode[1] = MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
  1039. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1040. PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
  1041. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B) |
  1042. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1043. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  1044. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  1045. NUM_BANKS(ADDR_SURF_16_BANK);
  1046. tilemode[2] = MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
  1047. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1048. PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
  1049. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  1050. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1051. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  1052. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  1053. NUM_BANKS(ADDR_SURF_16_BANK);
  1054. tilemode[3] = MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
  1055. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1056. PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
  1057. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1058. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  1059. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  1060. NUM_BANKS(ADDR_SURF_4_BANK) |
  1061. TILE_SPLIT(split_equal_to_row_size);
  1062. tilemode[4] = MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
  1063. ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
  1064. PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16);
  1065. tilemode[5] = MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
  1066. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1067. PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
  1068. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) |
  1069. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1070. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  1071. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  1072. NUM_BANKS(ADDR_SURF_2_BANK);
  1073. tilemode[6] = MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
  1074. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1075. PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
  1076. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  1077. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1078. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_8) |
  1079. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  1080. NUM_BANKS(ADDR_SURF_2_BANK);
  1081. tilemode[7] = MICRO_TILE_MODE(ADDR_SURF_DEPTH_MICRO_TILING) |
  1082. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1083. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  1084. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) |
  1085. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1086. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  1087. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  1088. NUM_BANKS(ADDR_SURF_2_BANK);
  1089. tilemode[8] = ARRAY_MODE(ARRAY_LINEAR_ALIGNED);
  1090. tilemode[9] = MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) |
  1091. ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
  1092. PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16);
  1093. tilemode[10] = MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) |
  1094. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1095. PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
  1096. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  1097. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1098. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  1099. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  1100. NUM_BANKS(ADDR_SURF_16_BANK);
  1101. tilemode[11] = MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) |
  1102. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1103. PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
  1104. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  1105. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1106. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  1107. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  1108. NUM_BANKS(ADDR_SURF_16_BANK);
  1109. tilemode[12] = MICRO_TILE_MODE(ADDR_SURF_DISPLAY_MICRO_TILING) |
  1110. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1111. PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
  1112. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) |
  1113. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1114. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  1115. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  1116. NUM_BANKS(ADDR_SURF_16_BANK);
  1117. tilemode[13] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  1118. ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
  1119. PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16);
  1120. tilemode[14] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  1121. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1122. PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
  1123. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  1124. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1125. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  1126. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  1127. NUM_BANKS(ADDR_SURF_16_BANK);
  1128. tilemode[15] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  1129. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1130. PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
  1131. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  1132. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1133. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  1134. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  1135. NUM_BANKS(ADDR_SURF_16_BANK);
  1136. tilemode[16] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  1137. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1138. PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
  1139. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) |
  1140. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1141. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  1142. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  1143. NUM_BANKS(ADDR_SURF_16_BANK);
  1144. tilemode[17] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  1145. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1146. PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
  1147. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1148. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  1149. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  1150. NUM_BANKS(ADDR_SURF_16_BANK) |
  1151. TILE_SPLIT(split_equal_to_row_size);
  1152. tilemode[18] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  1153. ARRAY_MODE(ARRAY_1D_TILED_THICK) |
  1154. PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16);
  1155. tilemode[19] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  1156. ARRAY_MODE(ARRAY_2D_TILED_XTHICK) |
  1157. PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
  1158. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1159. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  1160. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  1161. NUM_BANKS(ADDR_SURF_16_BANK) |
  1162. TILE_SPLIT(split_equal_to_row_size);
  1163. tilemode[20] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  1164. ARRAY_MODE(ARRAY_2D_TILED_THICK) |
  1165. PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
  1166. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1167. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  1168. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  1169. NUM_BANKS(ADDR_SURF_16_BANK) |
  1170. TILE_SPLIT(split_equal_to_row_size);
  1171. tilemode[21] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  1172. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1173. PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
  1174. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  1175. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1176. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_8) |
  1177. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  1178. NUM_BANKS(ADDR_SURF_4_BANK);
  1179. tilemode[22] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  1180. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1181. PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
  1182. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  1183. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1184. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  1185. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  1186. NUM_BANKS(ADDR_SURF_4_BANK);
  1187. tilemode[23] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  1188. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1189. PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
  1190. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  1191. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1192. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_8) |
  1193. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  1194. NUM_BANKS(ADDR_SURF_2_BANK);
  1195. tilemode[24] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  1196. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1197. PIPE_CONFIG(ADDR_SURF_P8_32x32_8x16) |
  1198. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) |
  1199. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1200. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  1201. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  1202. NUM_BANKS(ADDR_SURF_2_BANK);
  1203. tilemode[25] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  1204. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1205. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  1206. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) |
  1207. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1208. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  1209. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  1210. NUM_BANKS(ADDR_SURF_2_BANK);
  1211. tilemode[26] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  1212. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1213. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  1214. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) |
  1215. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1216. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  1217. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  1218. NUM_BANKS(ADDR_SURF_2_BANK);
  1219. tilemode[27] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  1220. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1221. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  1222. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) |
  1223. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1224. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  1225. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  1226. NUM_BANKS(ADDR_SURF_2_BANK);
  1227. tilemode[28] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  1228. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1229. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  1230. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) |
  1231. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1232. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  1233. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  1234. NUM_BANKS(ADDR_SURF_2_BANK);
  1235. tilemode[29] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  1236. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1237. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  1238. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_1KB) |
  1239. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1240. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  1241. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  1242. NUM_BANKS(ADDR_SURF_2_BANK);
  1243. tilemode[30] = MICRO_TILE_MODE(ADDR_SURF_THIN_MICRO_TILING) |
  1244. ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1245. PIPE_CONFIG(ADDR_SURF_P4_8x16) |
  1246. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_2KB) |
  1247. BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1248. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  1249. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  1250. NUM_BANKS(ADDR_SURF_2_BANK);
  1251. for (reg_offset = 0; reg_offset < num_tile_mode_states; reg_offset++)
  1252. WREG32(mmGB_TILE_MODE0 + reg_offset, tilemode[reg_offset]);
  1253. } else {
  1254. DRM_ERROR("unknown asic: 0x%x\n", adev->asic_type);
  1255. }
  1256. }
  1257. static void gfx_v6_0_select_se_sh(struct amdgpu_device *adev, u32 se_num,
  1258. u32 sh_num, u32 instance)
  1259. {
  1260. u32 data;
  1261. if (instance == 0xffffffff)
  1262. data = REG_SET_FIELD(0, GRBM_GFX_INDEX, INSTANCE_BROADCAST_WRITES, 1);
  1263. else
  1264. data = REG_SET_FIELD(0, GRBM_GFX_INDEX, INSTANCE_INDEX, instance);
  1265. if ((se_num == 0xffffffff) && (sh_num == 0xffffffff))
  1266. data |= GRBM_GFX_INDEX__SH_BROADCAST_WRITES_MASK |
  1267. GRBM_GFX_INDEX__SE_BROADCAST_WRITES_MASK;
  1268. else if (se_num == 0xffffffff)
  1269. data |= GRBM_GFX_INDEX__SE_BROADCAST_WRITES_MASK |
  1270. (sh_num << GRBM_GFX_INDEX__SH_INDEX__SHIFT);
  1271. else if (sh_num == 0xffffffff)
  1272. data |= GRBM_GFX_INDEX__SH_BROADCAST_WRITES_MASK |
  1273. (se_num << GRBM_GFX_INDEX__SE_INDEX__SHIFT);
  1274. else
  1275. data |= (sh_num << GRBM_GFX_INDEX__SH_INDEX__SHIFT) |
  1276. (se_num << GRBM_GFX_INDEX__SE_INDEX__SHIFT);
  1277. WREG32(mmGRBM_GFX_INDEX, data);
  1278. }
  1279. static u32 gfx_v6_0_get_rb_active_bitmap(struct amdgpu_device *adev)
  1280. {
  1281. u32 data, mask;
  1282. data = RREG32(mmCC_RB_BACKEND_DISABLE) |
  1283. RREG32(mmGC_USER_RB_BACKEND_DISABLE);
  1284. data = REG_GET_FIELD(data, GC_USER_RB_BACKEND_DISABLE, BACKEND_DISABLE);
  1285. mask = amdgpu_gfx_create_bitmask(adev->gfx.config.max_backends_per_se/
  1286. adev->gfx.config.max_sh_per_se);
  1287. return ~data & mask;
  1288. }
  1289. static void gfx_v6_0_raster_config(struct amdgpu_device *adev, u32 *rconf)
  1290. {
  1291. switch (adev->asic_type) {
  1292. case CHIP_TAHITI:
  1293. case CHIP_PITCAIRN:
  1294. *rconf |=
  1295. (2 << PA_SC_RASTER_CONFIG__RB_XSEL2__SHIFT) |
  1296. (1 << PA_SC_RASTER_CONFIG__RB_XSEL__SHIFT) |
  1297. (2 << PA_SC_RASTER_CONFIG__PKR_MAP__SHIFT) |
  1298. (1 << PA_SC_RASTER_CONFIG__PKR_YSEL__SHIFT) |
  1299. (2 << PA_SC_RASTER_CONFIG__SE_MAP__SHIFT) |
  1300. (2 << PA_SC_RASTER_CONFIG__SE_XSEL__SHIFT) |
  1301. (2 << PA_SC_RASTER_CONFIG__SE_YSEL__SHIFT);
  1302. break;
  1303. case CHIP_VERDE:
  1304. *rconf |=
  1305. (1 << PA_SC_RASTER_CONFIG__RB_XSEL__SHIFT) |
  1306. (2 << PA_SC_RASTER_CONFIG__PKR_MAP__SHIFT) |
  1307. (1 << PA_SC_RASTER_CONFIG__PKR_YSEL__SHIFT);
  1308. break;
  1309. case CHIP_OLAND:
  1310. *rconf |= (1 << PA_SC_RASTER_CONFIG__RB_YSEL__SHIFT);
  1311. break;
  1312. case CHIP_HAINAN:
  1313. *rconf |= 0x0;
  1314. break;
  1315. default:
  1316. DRM_ERROR("unknown asic: 0x%x\n", adev->asic_type);
  1317. break;
  1318. }
  1319. }
  1320. static void gfx_v6_0_write_harvested_raster_configs(struct amdgpu_device *adev,
  1321. u32 raster_config, unsigned rb_mask,
  1322. unsigned num_rb)
  1323. {
  1324. unsigned sh_per_se = max_t(unsigned, adev->gfx.config.max_sh_per_se, 1);
  1325. unsigned num_se = max_t(unsigned, adev->gfx.config.max_shader_engines, 1);
  1326. unsigned rb_per_pkr = min_t(unsigned, num_rb / num_se / sh_per_se, 2);
  1327. unsigned rb_per_se = num_rb / num_se;
  1328. unsigned se_mask[4];
  1329. unsigned se;
  1330. se_mask[0] = ((1 << rb_per_se) - 1) & rb_mask;
  1331. se_mask[1] = (se_mask[0] << rb_per_se) & rb_mask;
  1332. se_mask[2] = (se_mask[1] << rb_per_se) & rb_mask;
  1333. se_mask[3] = (se_mask[2] << rb_per_se) & rb_mask;
  1334. WARN_ON(!(num_se == 1 || num_se == 2 || num_se == 4));
  1335. WARN_ON(!(sh_per_se == 1 || sh_per_se == 2));
  1336. WARN_ON(!(rb_per_pkr == 1 || rb_per_pkr == 2));
  1337. for (se = 0; se < num_se; se++) {
  1338. unsigned raster_config_se = raster_config;
  1339. unsigned pkr0_mask = ((1 << rb_per_pkr) - 1) << (se * rb_per_se);
  1340. unsigned pkr1_mask = pkr0_mask << rb_per_pkr;
  1341. int idx = (se / 2) * 2;
  1342. if ((num_se > 1) && (!se_mask[idx] || !se_mask[idx + 1])) {
  1343. raster_config_se &= ~PA_SC_RASTER_CONFIG__SE_MAP_MASK;
  1344. if (!se_mask[idx])
  1345. raster_config_se |= RASTER_CONFIG_SE_MAP_3 << PA_SC_RASTER_CONFIG__SE_MAP__SHIFT;
  1346. else
  1347. raster_config_se |= RASTER_CONFIG_SE_MAP_0 << PA_SC_RASTER_CONFIG__SE_MAP__SHIFT;
  1348. }
  1349. pkr0_mask &= rb_mask;
  1350. pkr1_mask &= rb_mask;
  1351. if (rb_per_se > 2 && (!pkr0_mask || !pkr1_mask)) {
  1352. raster_config_se &= ~PA_SC_RASTER_CONFIG__PKR_MAP_MASK;
  1353. if (!pkr0_mask)
  1354. raster_config_se |= RASTER_CONFIG_PKR_MAP_3 << PA_SC_RASTER_CONFIG__PKR_MAP__SHIFT;
  1355. else
  1356. raster_config_se |= RASTER_CONFIG_PKR_MAP_0 << PA_SC_RASTER_CONFIG__PKR_MAP__SHIFT;
  1357. }
  1358. if (rb_per_se >= 2) {
  1359. unsigned rb0_mask = 1 << (se * rb_per_se);
  1360. unsigned rb1_mask = rb0_mask << 1;
  1361. rb0_mask &= rb_mask;
  1362. rb1_mask &= rb_mask;
  1363. if (!rb0_mask || !rb1_mask) {
  1364. raster_config_se &= ~PA_SC_RASTER_CONFIG__RB_MAP_PKR0_MASK;
  1365. if (!rb0_mask)
  1366. raster_config_se |=
  1367. RASTER_CONFIG_RB_MAP_3 << PA_SC_RASTER_CONFIG__RB_MAP_PKR0__SHIFT;
  1368. else
  1369. raster_config_se |=
  1370. RASTER_CONFIG_RB_MAP_0 << PA_SC_RASTER_CONFIG__RB_MAP_PKR0__SHIFT;
  1371. }
  1372. if (rb_per_se > 2) {
  1373. rb0_mask = 1 << (se * rb_per_se + rb_per_pkr);
  1374. rb1_mask = rb0_mask << 1;
  1375. rb0_mask &= rb_mask;
  1376. rb1_mask &= rb_mask;
  1377. if (!rb0_mask || !rb1_mask) {
  1378. raster_config_se &= ~PA_SC_RASTER_CONFIG__RB_MAP_PKR1_MASK;
  1379. if (!rb0_mask)
  1380. raster_config_se |=
  1381. RASTER_CONFIG_RB_MAP_3 << PA_SC_RASTER_CONFIG__RB_MAP_PKR1__SHIFT;
  1382. else
  1383. raster_config_se |=
  1384. RASTER_CONFIG_RB_MAP_0 << PA_SC_RASTER_CONFIG__RB_MAP_PKR1__SHIFT;
  1385. }
  1386. }
  1387. }
  1388. /* GRBM_GFX_INDEX has a different offset on SI */
  1389. gfx_v6_0_select_se_sh(adev, se, 0xffffffff, 0xffffffff);
  1390. WREG32(mmPA_SC_RASTER_CONFIG, raster_config_se);
  1391. }
  1392. /* GRBM_GFX_INDEX has a different offset on SI */
  1393. gfx_v6_0_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff);
  1394. }
  1395. static void gfx_v6_0_setup_rb(struct amdgpu_device *adev)
  1396. {
  1397. int i, j;
  1398. u32 data;
  1399. u32 raster_config = 0;
  1400. u32 active_rbs = 0;
  1401. u32 rb_bitmap_width_per_sh = adev->gfx.config.max_backends_per_se /
  1402. adev->gfx.config.max_sh_per_se;
  1403. unsigned num_rb_pipes;
  1404. mutex_lock(&adev->grbm_idx_mutex);
  1405. for (i = 0; i < adev->gfx.config.max_shader_engines; i++) {
  1406. for (j = 0; j < adev->gfx.config.max_sh_per_se; j++) {
  1407. gfx_v6_0_select_se_sh(adev, i, j, 0xffffffff);
  1408. data = gfx_v6_0_get_rb_active_bitmap(adev);
  1409. active_rbs |= data <<
  1410. ((i * adev->gfx.config.max_sh_per_se + j) *
  1411. rb_bitmap_width_per_sh);
  1412. }
  1413. }
  1414. gfx_v6_0_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff);
  1415. adev->gfx.config.backend_enable_mask = active_rbs;
  1416. adev->gfx.config.num_rbs = hweight32(active_rbs);
  1417. num_rb_pipes = min_t(unsigned, adev->gfx.config.max_backends_per_se *
  1418. adev->gfx.config.max_shader_engines, 16);
  1419. gfx_v6_0_raster_config(adev, &raster_config);
  1420. if (!adev->gfx.config.backend_enable_mask ||
  1421. adev->gfx.config.num_rbs >= num_rb_pipes)
  1422. WREG32(mmPA_SC_RASTER_CONFIG, raster_config);
  1423. else
  1424. gfx_v6_0_write_harvested_raster_configs(adev, raster_config,
  1425. adev->gfx.config.backend_enable_mask,
  1426. num_rb_pipes);
  1427. /* cache the values for userspace */
  1428. for (i = 0; i < adev->gfx.config.max_shader_engines; i++) {
  1429. for (j = 0; j < adev->gfx.config.max_sh_per_se; j++) {
  1430. gfx_v6_0_select_se_sh(adev, i, j, 0xffffffff);
  1431. adev->gfx.config.rb_config[i][j].rb_backend_disable =
  1432. RREG32(mmCC_RB_BACKEND_DISABLE);
  1433. adev->gfx.config.rb_config[i][j].user_rb_backend_disable =
  1434. RREG32(mmGC_USER_RB_BACKEND_DISABLE);
  1435. adev->gfx.config.rb_config[i][j].raster_config =
  1436. RREG32(mmPA_SC_RASTER_CONFIG);
  1437. }
  1438. }
  1439. gfx_v6_0_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff);
  1440. mutex_unlock(&adev->grbm_idx_mutex);
  1441. }
  1442. static void gfx_v6_0_set_user_cu_inactive_bitmap(struct amdgpu_device *adev,
  1443. u32 bitmap)
  1444. {
  1445. u32 data;
  1446. if (!bitmap)
  1447. return;
  1448. data = bitmap << GC_USER_SHADER_ARRAY_CONFIG__INACTIVE_CUS__SHIFT;
  1449. data &= GC_USER_SHADER_ARRAY_CONFIG__INACTIVE_CUS_MASK;
  1450. WREG32(mmGC_USER_SHADER_ARRAY_CONFIG, data);
  1451. }
  1452. static u32 gfx_v6_0_get_cu_enabled(struct amdgpu_device *adev)
  1453. {
  1454. u32 data, mask;
  1455. data = RREG32(mmCC_GC_SHADER_ARRAY_CONFIG) |
  1456. RREG32(mmGC_USER_SHADER_ARRAY_CONFIG);
  1457. mask = amdgpu_gfx_create_bitmask(adev->gfx.config.max_cu_per_sh);
  1458. return ~REG_GET_FIELD(data, CC_GC_SHADER_ARRAY_CONFIG, INACTIVE_CUS) & mask;
  1459. }
  1460. static void gfx_v6_0_setup_spi(struct amdgpu_device *adev)
  1461. {
  1462. int i, j, k;
  1463. u32 data, mask;
  1464. u32 active_cu = 0;
  1465. mutex_lock(&adev->grbm_idx_mutex);
  1466. for (i = 0; i < adev->gfx.config.max_shader_engines; i++) {
  1467. for (j = 0; j < adev->gfx.config.max_sh_per_se; j++) {
  1468. gfx_v6_0_select_se_sh(adev, i, j, 0xffffffff);
  1469. data = RREG32(mmSPI_STATIC_THREAD_MGMT_3);
  1470. active_cu = gfx_v6_0_get_cu_enabled(adev);
  1471. mask = 1;
  1472. for (k = 0; k < 16; k++) {
  1473. mask <<= k;
  1474. if (active_cu & mask) {
  1475. data &= ~mask;
  1476. WREG32(mmSPI_STATIC_THREAD_MGMT_3, data);
  1477. break;
  1478. }
  1479. }
  1480. }
  1481. }
  1482. gfx_v6_0_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff);
  1483. mutex_unlock(&adev->grbm_idx_mutex);
  1484. }
  1485. static void gfx_v6_0_config_init(struct amdgpu_device *adev)
  1486. {
  1487. adev->gfx.config.double_offchip_lds_buf = 0;
  1488. }
  1489. static void gfx_v6_0_gpu_init(struct amdgpu_device *adev)
  1490. {
  1491. u32 gb_addr_config = 0;
  1492. u32 mc_shared_chmap, mc_arb_ramcfg;
  1493. u32 sx_debug_1;
  1494. u32 hdp_host_path_cntl;
  1495. u32 tmp;
  1496. switch (adev->asic_type) {
  1497. case CHIP_TAHITI:
  1498. adev->gfx.config.max_shader_engines = 2;
  1499. adev->gfx.config.max_tile_pipes = 12;
  1500. adev->gfx.config.max_cu_per_sh = 8;
  1501. adev->gfx.config.max_sh_per_se = 2;
  1502. adev->gfx.config.max_backends_per_se = 4;
  1503. adev->gfx.config.max_texture_channel_caches = 12;
  1504. adev->gfx.config.max_gprs = 256;
  1505. adev->gfx.config.max_gs_threads = 32;
  1506. adev->gfx.config.max_hw_contexts = 8;
  1507. adev->gfx.config.sc_prim_fifo_size_frontend = 0x20;
  1508. adev->gfx.config.sc_prim_fifo_size_backend = 0x100;
  1509. adev->gfx.config.sc_hiz_tile_fifo_size = 0x30;
  1510. adev->gfx.config.sc_earlyz_tile_fifo_size = 0x130;
  1511. gb_addr_config = TAHITI_GB_ADDR_CONFIG_GOLDEN;
  1512. break;
  1513. case CHIP_PITCAIRN:
  1514. adev->gfx.config.max_shader_engines = 2;
  1515. adev->gfx.config.max_tile_pipes = 8;
  1516. adev->gfx.config.max_cu_per_sh = 5;
  1517. adev->gfx.config.max_sh_per_se = 2;
  1518. adev->gfx.config.max_backends_per_se = 4;
  1519. adev->gfx.config.max_texture_channel_caches = 8;
  1520. adev->gfx.config.max_gprs = 256;
  1521. adev->gfx.config.max_gs_threads = 32;
  1522. adev->gfx.config.max_hw_contexts = 8;
  1523. adev->gfx.config.sc_prim_fifo_size_frontend = 0x20;
  1524. adev->gfx.config.sc_prim_fifo_size_backend = 0x100;
  1525. adev->gfx.config.sc_hiz_tile_fifo_size = 0x30;
  1526. adev->gfx.config.sc_earlyz_tile_fifo_size = 0x130;
  1527. gb_addr_config = TAHITI_GB_ADDR_CONFIG_GOLDEN;
  1528. break;
  1529. case CHIP_VERDE:
  1530. adev->gfx.config.max_shader_engines = 1;
  1531. adev->gfx.config.max_tile_pipes = 4;
  1532. adev->gfx.config.max_cu_per_sh = 5;
  1533. adev->gfx.config.max_sh_per_se = 2;
  1534. adev->gfx.config.max_backends_per_se = 4;
  1535. adev->gfx.config.max_texture_channel_caches = 4;
  1536. adev->gfx.config.max_gprs = 256;
  1537. adev->gfx.config.max_gs_threads = 32;
  1538. adev->gfx.config.max_hw_contexts = 8;
  1539. adev->gfx.config.sc_prim_fifo_size_frontend = 0x20;
  1540. adev->gfx.config.sc_prim_fifo_size_backend = 0x40;
  1541. adev->gfx.config.sc_hiz_tile_fifo_size = 0x30;
  1542. adev->gfx.config.sc_earlyz_tile_fifo_size = 0x130;
  1543. gb_addr_config = VERDE_GB_ADDR_CONFIG_GOLDEN;
  1544. break;
  1545. case CHIP_OLAND:
  1546. adev->gfx.config.max_shader_engines = 1;
  1547. adev->gfx.config.max_tile_pipes = 4;
  1548. adev->gfx.config.max_cu_per_sh = 6;
  1549. adev->gfx.config.max_sh_per_se = 1;
  1550. adev->gfx.config.max_backends_per_se = 2;
  1551. adev->gfx.config.max_texture_channel_caches = 4;
  1552. adev->gfx.config.max_gprs = 256;
  1553. adev->gfx.config.max_gs_threads = 16;
  1554. adev->gfx.config.max_hw_contexts = 8;
  1555. adev->gfx.config.sc_prim_fifo_size_frontend = 0x20;
  1556. adev->gfx.config.sc_prim_fifo_size_backend = 0x40;
  1557. adev->gfx.config.sc_hiz_tile_fifo_size = 0x30;
  1558. adev->gfx.config.sc_earlyz_tile_fifo_size = 0x130;
  1559. gb_addr_config = VERDE_GB_ADDR_CONFIG_GOLDEN;
  1560. break;
  1561. case CHIP_HAINAN:
  1562. adev->gfx.config.max_shader_engines = 1;
  1563. adev->gfx.config.max_tile_pipes = 4;
  1564. adev->gfx.config.max_cu_per_sh = 5;
  1565. adev->gfx.config.max_sh_per_se = 1;
  1566. adev->gfx.config.max_backends_per_se = 1;
  1567. adev->gfx.config.max_texture_channel_caches = 2;
  1568. adev->gfx.config.max_gprs = 256;
  1569. adev->gfx.config.max_gs_threads = 16;
  1570. adev->gfx.config.max_hw_contexts = 8;
  1571. adev->gfx.config.sc_prim_fifo_size_frontend = 0x20;
  1572. adev->gfx.config.sc_prim_fifo_size_backend = 0x40;
  1573. adev->gfx.config.sc_hiz_tile_fifo_size = 0x30;
  1574. adev->gfx.config.sc_earlyz_tile_fifo_size = 0x130;
  1575. gb_addr_config = HAINAN_GB_ADDR_CONFIG_GOLDEN;
  1576. break;
  1577. default:
  1578. BUG();
  1579. break;
  1580. }
  1581. WREG32(mmGRBM_CNTL, (0xff << GRBM_CNTL__READ_TIMEOUT__SHIFT));
  1582. WREG32(mmSRBM_INT_CNTL, 1);
  1583. WREG32(mmSRBM_INT_ACK, 1);
  1584. WREG32(mmBIF_FB_EN, BIF_FB_EN__FB_READ_EN_MASK | BIF_FB_EN__FB_WRITE_EN_MASK);
  1585. mc_shared_chmap = RREG32(mmMC_SHARED_CHMAP);
  1586. adev->gfx.config.mc_arb_ramcfg = RREG32(mmMC_ARB_RAMCFG);
  1587. mc_arb_ramcfg = adev->gfx.config.mc_arb_ramcfg;
  1588. adev->gfx.config.num_tile_pipes = adev->gfx.config.max_tile_pipes;
  1589. adev->gfx.config.mem_max_burst_length_bytes = 256;
  1590. tmp = (mc_arb_ramcfg & MC_ARB_RAMCFG__NOOFCOLS_MASK) >> MC_ARB_RAMCFG__NOOFCOLS__SHIFT;
  1591. adev->gfx.config.mem_row_size_in_kb = (4 * (1 << (8 + tmp))) / 1024;
  1592. if (adev->gfx.config.mem_row_size_in_kb > 4)
  1593. adev->gfx.config.mem_row_size_in_kb = 4;
  1594. adev->gfx.config.shader_engine_tile_size = 32;
  1595. adev->gfx.config.num_gpus = 1;
  1596. adev->gfx.config.multi_gpu_tile_size = 64;
  1597. gb_addr_config &= ~GB_ADDR_CONFIG__ROW_SIZE_MASK;
  1598. switch (adev->gfx.config.mem_row_size_in_kb) {
  1599. case 1:
  1600. default:
  1601. gb_addr_config |= 0 << GB_ADDR_CONFIG__ROW_SIZE__SHIFT;
  1602. break;
  1603. case 2:
  1604. gb_addr_config |= 1 << GB_ADDR_CONFIG__ROW_SIZE__SHIFT;
  1605. break;
  1606. case 4:
  1607. gb_addr_config |= 2 << GB_ADDR_CONFIG__ROW_SIZE__SHIFT;
  1608. break;
  1609. }
  1610. gb_addr_config &= ~GB_ADDR_CONFIG__NUM_SHADER_ENGINES_MASK;
  1611. if (adev->gfx.config.max_shader_engines == 2)
  1612. gb_addr_config |= 1 << GB_ADDR_CONFIG__NUM_SHADER_ENGINES__SHIFT;
  1613. adev->gfx.config.gb_addr_config = gb_addr_config;
  1614. WREG32(mmGB_ADDR_CONFIG, gb_addr_config);
  1615. WREG32(mmDMIF_ADDR_CONFIG, gb_addr_config);
  1616. WREG32(mmDMIF_ADDR_CALC, gb_addr_config);
  1617. WREG32(mmHDP_ADDR_CONFIG, gb_addr_config);
  1618. WREG32(mmDMA_TILING_CONFIG + DMA0_REGISTER_OFFSET, gb_addr_config);
  1619. WREG32(mmDMA_TILING_CONFIG + DMA1_REGISTER_OFFSET, gb_addr_config);
  1620. #if 0
  1621. if (adev->has_uvd) {
  1622. WREG32(mmUVD_UDEC_ADDR_CONFIG, gb_addr_config);
  1623. WREG32(mmUVD_UDEC_DB_ADDR_CONFIG, gb_addr_config);
  1624. WREG32(mmUVD_UDEC_DBW_ADDR_CONFIG, gb_addr_config);
  1625. }
  1626. #endif
  1627. gfx_v6_0_tiling_mode_table_init(adev);
  1628. gfx_v6_0_setup_rb(adev);
  1629. gfx_v6_0_setup_spi(adev);
  1630. gfx_v6_0_get_cu_info(adev);
  1631. gfx_v6_0_config_init(adev);
  1632. WREG32(mmCP_QUEUE_THRESHOLDS, ((0x16 << CP_QUEUE_THRESHOLDS__ROQ_IB1_START__SHIFT) |
  1633. (0x2b << CP_QUEUE_THRESHOLDS__ROQ_IB2_START__SHIFT)));
  1634. WREG32(mmCP_MEQ_THRESHOLDS, (0x30 << CP_MEQ_THRESHOLDS__MEQ1_START__SHIFT) |
  1635. (0x60 << CP_MEQ_THRESHOLDS__MEQ2_START__SHIFT));
  1636. sx_debug_1 = RREG32(mmSX_DEBUG_1);
  1637. WREG32(mmSX_DEBUG_1, sx_debug_1);
  1638. WREG32(mmSPI_CONFIG_CNTL_1, (4 << SPI_CONFIG_CNTL_1__VTX_DONE_DELAY__SHIFT));
  1639. WREG32(mmPA_SC_FIFO_SIZE, ((adev->gfx.config.sc_prim_fifo_size_frontend << PA_SC_FIFO_SIZE__SC_FRONTEND_PRIM_FIFO_SIZE__SHIFT) |
  1640. (adev->gfx.config.sc_prim_fifo_size_backend << PA_SC_FIFO_SIZE__SC_BACKEND_PRIM_FIFO_SIZE__SHIFT) |
  1641. (adev->gfx.config.sc_hiz_tile_fifo_size << PA_SC_FIFO_SIZE__SC_HIZ_TILE_FIFO_SIZE__SHIFT) |
  1642. (adev->gfx.config.sc_earlyz_tile_fifo_size << PA_SC_FIFO_SIZE__SC_EARLYZ_TILE_FIFO_SIZE__SHIFT)));
  1643. WREG32(mmVGT_NUM_INSTANCES, 1);
  1644. WREG32(mmCP_PERFMON_CNTL, 0);
  1645. WREG32(mmSQ_CONFIG, 0);
  1646. WREG32(mmPA_SC_FORCE_EOV_MAX_CNTS, ((4095 << PA_SC_FORCE_EOV_MAX_CNTS__FORCE_EOV_MAX_CLK_CNT__SHIFT) |
  1647. (255 << PA_SC_FORCE_EOV_MAX_CNTS__FORCE_EOV_MAX_REZ_CNT__SHIFT)));
  1648. WREG32(mmVGT_CACHE_INVALIDATION,
  1649. (VC_AND_TC << VGT_CACHE_INVALIDATION__CACHE_INVALIDATION__SHIFT) |
  1650. (ES_AND_GS_AUTO << VGT_CACHE_INVALIDATION__AUTO_INVLD_EN__SHIFT));
  1651. WREG32(mmVGT_GS_VERTEX_REUSE, 16);
  1652. WREG32(mmPA_SC_LINE_STIPPLE_STATE, 0);
  1653. WREG32(mmCB_PERFCOUNTER0_SELECT0, 0);
  1654. WREG32(mmCB_PERFCOUNTER0_SELECT1, 0);
  1655. WREG32(mmCB_PERFCOUNTER1_SELECT0, 0);
  1656. WREG32(mmCB_PERFCOUNTER1_SELECT1, 0);
  1657. WREG32(mmCB_PERFCOUNTER2_SELECT0, 0);
  1658. WREG32(mmCB_PERFCOUNTER2_SELECT1, 0);
  1659. WREG32(mmCB_PERFCOUNTER3_SELECT0, 0);
  1660. WREG32(mmCB_PERFCOUNTER3_SELECT1, 0);
  1661. hdp_host_path_cntl = RREG32(mmHDP_HOST_PATH_CNTL);
  1662. WREG32(mmHDP_HOST_PATH_CNTL, hdp_host_path_cntl);
  1663. WREG32(mmPA_CL_ENHANCE, PA_CL_ENHANCE__CLIP_VTX_REORDER_ENA_MASK |
  1664. (3 << PA_CL_ENHANCE__NUM_CLIP_SEQ__SHIFT));
  1665. udelay(50);
  1666. }
  1667. static void gfx_v6_0_scratch_init(struct amdgpu_device *adev)
  1668. {
  1669. adev->gfx.scratch.num_reg = 8;
  1670. adev->gfx.scratch.reg_base = mmSCRATCH_REG0;
  1671. adev->gfx.scratch.free_mask = (1u << adev->gfx.scratch.num_reg) - 1;
  1672. }
  1673. static int gfx_v6_0_ring_test_ring(struct amdgpu_ring *ring)
  1674. {
  1675. struct amdgpu_device *adev = ring->adev;
  1676. uint32_t scratch;
  1677. uint32_t tmp = 0;
  1678. unsigned i;
  1679. int r;
  1680. r = amdgpu_gfx_scratch_get(adev, &scratch);
  1681. if (r) {
  1682. DRM_ERROR("amdgpu: cp failed to get scratch reg (%d).\n", r);
  1683. return r;
  1684. }
  1685. WREG32(scratch, 0xCAFEDEAD);
  1686. r = amdgpu_ring_alloc(ring, 3);
  1687. if (r) {
  1688. DRM_ERROR("amdgpu: cp failed to lock ring %d (%d).\n", ring->idx, r);
  1689. amdgpu_gfx_scratch_free(adev, scratch);
  1690. return r;
  1691. }
  1692. amdgpu_ring_write(ring, PACKET3(PACKET3_SET_CONFIG_REG, 1));
  1693. amdgpu_ring_write(ring, (scratch - PACKET3_SET_CONFIG_REG_START));
  1694. amdgpu_ring_write(ring, 0xDEADBEEF);
  1695. amdgpu_ring_commit(ring);
  1696. for (i = 0; i < adev->usec_timeout; i++) {
  1697. tmp = RREG32(scratch);
  1698. if (tmp == 0xDEADBEEF)
  1699. break;
  1700. DRM_UDELAY(1);
  1701. }
  1702. if (i < adev->usec_timeout) {
  1703. DRM_INFO("ring test on %d succeeded in %d usecs\n", ring->idx, i);
  1704. } else {
  1705. DRM_ERROR("amdgpu: ring %d test failed (scratch(0x%04X)=0x%08X)\n",
  1706. ring->idx, scratch, tmp);
  1707. r = -EINVAL;
  1708. }
  1709. amdgpu_gfx_scratch_free(adev, scratch);
  1710. return r;
  1711. }
  1712. static void gfx_v6_0_ring_emit_hdp_flush(struct amdgpu_ring *ring)
  1713. {
  1714. /* flush hdp cache */
  1715. amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));
  1716. amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(1) |
  1717. WRITE_DATA_DST_SEL(0)));
  1718. amdgpu_ring_write(ring, mmHDP_MEM_COHERENCY_FLUSH_CNTL);
  1719. amdgpu_ring_write(ring, 0);
  1720. amdgpu_ring_write(ring, 0x1);
  1721. }
  1722. static void gfx_v6_0_ring_emit_vgt_flush(struct amdgpu_ring *ring)
  1723. {
  1724. amdgpu_ring_write(ring, PACKET3(PACKET3_EVENT_WRITE, 0));
  1725. amdgpu_ring_write(ring, EVENT_TYPE(VGT_FLUSH) |
  1726. EVENT_INDEX(0));
  1727. }
  1728. /**
  1729. * gfx_v6_0_ring_emit_hdp_invalidate - emit an hdp invalidate on the cp
  1730. *
  1731. * @adev: amdgpu_device pointer
  1732. * @ridx: amdgpu ring index
  1733. *
  1734. * Emits an hdp invalidate on the cp.
  1735. */
  1736. static void gfx_v6_0_ring_emit_hdp_invalidate(struct amdgpu_ring *ring)
  1737. {
  1738. amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));
  1739. amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(1) |
  1740. WRITE_DATA_DST_SEL(0)));
  1741. amdgpu_ring_write(ring, mmHDP_DEBUG0);
  1742. amdgpu_ring_write(ring, 0);
  1743. amdgpu_ring_write(ring, 0x1);
  1744. }
  1745. static void gfx_v6_0_ring_emit_fence(struct amdgpu_ring *ring, u64 addr,
  1746. u64 seq, unsigned flags)
  1747. {
  1748. bool write64bit = flags & AMDGPU_FENCE_FLAG_64BIT;
  1749. bool int_sel = flags & AMDGPU_FENCE_FLAG_INT;
  1750. /* flush read cache over gart */
  1751. amdgpu_ring_write(ring, PACKET3(PACKET3_SET_CONFIG_REG, 1));
  1752. amdgpu_ring_write(ring, (mmCP_COHER_CNTL2 - PACKET3_SET_CONFIG_REG_START));
  1753. amdgpu_ring_write(ring, 0);
  1754. amdgpu_ring_write(ring, PACKET3(PACKET3_SURFACE_SYNC, 3));
  1755. amdgpu_ring_write(ring, PACKET3_TCL1_ACTION_ENA |
  1756. PACKET3_TC_ACTION_ENA |
  1757. PACKET3_SH_KCACHE_ACTION_ENA |
  1758. PACKET3_SH_ICACHE_ACTION_ENA);
  1759. amdgpu_ring_write(ring, 0xFFFFFFFF);
  1760. amdgpu_ring_write(ring, 0);
  1761. amdgpu_ring_write(ring, 10); /* poll interval */
  1762. /* EVENT_WRITE_EOP - flush caches, send int */
  1763. amdgpu_ring_write(ring, PACKET3(PACKET3_EVENT_WRITE_EOP, 4));
  1764. amdgpu_ring_write(ring, EVENT_TYPE(CACHE_FLUSH_AND_INV_TS_EVENT) | EVENT_INDEX(5));
  1765. amdgpu_ring_write(ring, addr & 0xfffffffc);
  1766. amdgpu_ring_write(ring, (upper_32_bits(addr) & 0xffff) |
  1767. ((write64bit ? 2 : 1) << CP_EOP_DONE_DATA_CNTL__DATA_SEL__SHIFT) |
  1768. ((int_sel ? 2 : 0) << CP_EOP_DONE_DATA_CNTL__INT_SEL__SHIFT));
  1769. amdgpu_ring_write(ring, lower_32_bits(seq));
  1770. amdgpu_ring_write(ring, upper_32_bits(seq));
  1771. }
  1772. static void gfx_v6_0_ring_emit_ib(struct amdgpu_ring *ring,
  1773. struct amdgpu_ib *ib,
  1774. unsigned vm_id, bool ctx_switch)
  1775. {
  1776. u32 header, control = 0;
  1777. /* insert SWITCH_BUFFER packet before first IB in the ring frame */
  1778. if (ctx_switch) {
  1779. amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0));
  1780. amdgpu_ring_write(ring, 0);
  1781. }
  1782. if (ib->flags & AMDGPU_IB_FLAG_CE)
  1783. header = PACKET3(PACKET3_INDIRECT_BUFFER_CONST, 2);
  1784. else
  1785. header = PACKET3(PACKET3_INDIRECT_BUFFER, 2);
  1786. control |= ib->length_dw | (vm_id << 24);
  1787. amdgpu_ring_write(ring, header);
  1788. amdgpu_ring_write(ring,
  1789. #ifdef __BIG_ENDIAN
  1790. (2 << 0) |
  1791. #endif
  1792. (ib->gpu_addr & 0xFFFFFFFC));
  1793. amdgpu_ring_write(ring, upper_32_bits(ib->gpu_addr) & 0xFFFF);
  1794. amdgpu_ring_write(ring, control);
  1795. }
  1796. /**
  1797. * gfx_v6_0_ring_test_ib - basic ring IB test
  1798. *
  1799. * @ring: amdgpu_ring structure holding ring information
  1800. *
  1801. * Allocate an IB and execute it on the gfx ring (SI).
  1802. * Provides a basic gfx ring test to verify that IBs are working.
  1803. * Returns 0 on success, error on failure.
  1804. */
  1805. static int gfx_v6_0_ring_test_ib(struct amdgpu_ring *ring, long timeout)
  1806. {
  1807. struct amdgpu_device *adev = ring->adev;
  1808. struct amdgpu_ib ib;
  1809. struct dma_fence *f = NULL;
  1810. uint32_t scratch;
  1811. uint32_t tmp = 0;
  1812. long r;
  1813. r = amdgpu_gfx_scratch_get(adev, &scratch);
  1814. if (r) {
  1815. DRM_ERROR("amdgpu: failed to get scratch reg (%ld).\n", r);
  1816. return r;
  1817. }
  1818. WREG32(scratch, 0xCAFEDEAD);
  1819. memset(&ib, 0, sizeof(ib));
  1820. r = amdgpu_ib_get(adev, NULL, 256, &ib);
  1821. if (r) {
  1822. DRM_ERROR("amdgpu: failed to get ib (%ld).\n", r);
  1823. goto err1;
  1824. }
  1825. ib.ptr[0] = PACKET3(PACKET3_SET_CONFIG_REG, 1);
  1826. ib.ptr[1] = ((scratch - PACKET3_SET_CONFIG_REG_START));
  1827. ib.ptr[2] = 0xDEADBEEF;
  1828. ib.length_dw = 3;
  1829. r = amdgpu_ib_schedule(ring, 1, &ib, NULL, &f);
  1830. if (r)
  1831. goto err2;
  1832. r = dma_fence_wait_timeout(f, false, timeout);
  1833. if (r == 0) {
  1834. DRM_ERROR("amdgpu: IB test timed out\n");
  1835. r = -ETIMEDOUT;
  1836. goto err2;
  1837. } else if (r < 0) {
  1838. DRM_ERROR("amdgpu: fence wait failed (%ld).\n", r);
  1839. goto err2;
  1840. }
  1841. tmp = RREG32(scratch);
  1842. if (tmp == 0xDEADBEEF) {
  1843. DRM_INFO("ib test on ring %d succeeded\n", ring->idx);
  1844. r = 0;
  1845. } else {
  1846. DRM_ERROR("amdgpu: ib test failed (scratch(0x%04X)=0x%08X)\n",
  1847. scratch, tmp);
  1848. r = -EINVAL;
  1849. }
  1850. err2:
  1851. amdgpu_ib_free(adev, &ib, NULL);
  1852. dma_fence_put(f);
  1853. err1:
  1854. amdgpu_gfx_scratch_free(adev, scratch);
  1855. return r;
  1856. }
  1857. static void gfx_v6_0_cp_gfx_enable(struct amdgpu_device *adev, bool enable)
  1858. {
  1859. int i;
  1860. if (enable) {
  1861. WREG32(mmCP_ME_CNTL, 0);
  1862. } else {
  1863. WREG32(mmCP_ME_CNTL, (CP_ME_CNTL__ME_HALT_MASK |
  1864. CP_ME_CNTL__PFP_HALT_MASK |
  1865. CP_ME_CNTL__CE_HALT_MASK));
  1866. WREG32(mmSCRATCH_UMSK, 0);
  1867. for (i = 0; i < adev->gfx.num_gfx_rings; i++)
  1868. adev->gfx.gfx_ring[i].ready = false;
  1869. for (i = 0; i < adev->gfx.num_compute_rings; i++)
  1870. adev->gfx.compute_ring[i].ready = false;
  1871. }
  1872. udelay(50);
  1873. }
  1874. static int gfx_v6_0_cp_gfx_load_microcode(struct amdgpu_device *adev)
  1875. {
  1876. unsigned i;
  1877. const struct gfx_firmware_header_v1_0 *pfp_hdr;
  1878. const struct gfx_firmware_header_v1_0 *ce_hdr;
  1879. const struct gfx_firmware_header_v1_0 *me_hdr;
  1880. const __le32 *fw_data;
  1881. u32 fw_size;
  1882. if (!adev->gfx.me_fw || !adev->gfx.pfp_fw || !adev->gfx.ce_fw)
  1883. return -EINVAL;
  1884. gfx_v6_0_cp_gfx_enable(adev, false);
  1885. pfp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.pfp_fw->data;
  1886. ce_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.ce_fw->data;
  1887. me_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.me_fw->data;
  1888. amdgpu_ucode_print_gfx_hdr(&pfp_hdr->header);
  1889. amdgpu_ucode_print_gfx_hdr(&ce_hdr->header);
  1890. amdgpu_ucode_print_gfx_hdr(&me_hdr->header);
  1891. /* PFP */
  1892. fw_data = (const __le32 *)
  1893. (adev->gfx.pfp_fw->data + le32_to_cpu(pfp_hdr->header.ucode_array_offset_bytes));
  1894. fw_size = le32_to_cpu(pfp_hdr->header.ucode_size_bytes) / 4;
  1895. WREG32(mmCP_PFP_UCODE_ADDR, 0);
  1896. for (i = 0; i < fw_size; i++)
  1897. WREG32(mmCP_PFP_UCODE_DATA, le32_to_cpup(fw_data++));
  1898. WREG32(mmCP_PFP_UCODE_ADDR, 0);
  1899. /* CE */
  1900. fw_data = (const __le32 *)
  1901. (adev->gfx.ce_fw->data + le32_to_cpu(ce_hdr->header.ucode_array_offset_bytes));
  1902. fw_size = le32_to_cpu(ce_hdr->header.ucode_size_bytes) / 4;
  1903. WREG32(mmCP_CE_UCODE_ADDR, 0);
  1904. for (i = 0; i < fw_size; i++)
  1905. WREG32(mmCP_CE_UCODE_DATA, le32_to_cpup(fw_data++));
  1906. WREG32(mmCP_CE_UCODE_ADDR, 0);
  1907. /* ME */
  1908. fw_data = (const __be32 *)
  1909. (adev->gfx.me_fw->data + le32_to_cpu(me_hdr->header.ucode_array_offset_bytes));
  1910. fw_size = le32_to_cpu(me_hdr->header.ucode_size_bytes) / 4;
  1911. WREG32(mmCP_ME_RAM_WADDR, 0);
  1912. for (i = 0; i < fw_size; i++)
  1913. WREG32(mmCP_ME_RAM_DATA, le32_to_cpup(fw_data++));
  1914. WREG32(mmCP_ME_RAM_WADDR, 0);
  1915. WREG32(mmCP_PFP_UCODE_ADDR, 0);
  1916. WREG32(mmCP_CE_UCODE_ADDR, 0);
  1917. WREG32(mmCP_ME_RAM_WADDR, 0);
  1918. WREG32(mmCP_ME_RAM_RADDR, 0);
  1919. return 0;
  1920. }
  1921. static int gfx_v6_0_cp_gfx_start(struct amdgpu_device *adev)
  1922. {
  1923. const struct cs_section_def *sect = NULL;
  1924. const struct cs_extent_def *ext = NULL;
  1925. struct amdgpu_ring *ring = &adev->gfx.gfx_ring[0];
  1926. int r, i;
  1927. r = amdgpu_ring_alloc(ring, 7 + 4);
  1928. if (r) {
  1929. DRM_ERROR("amdgpu: cp failed to lock ring (%d).\n", r);
  1930. return r;
  1931. }
  1932. amdgpu_ring_write(ring, PACKET3(PACKET3_ME_INITIALIZE, 5));
  1933. amdgpu_ring_write(ring, 0x1);
  1934. amdgpu_ring_write(ring, 0x0);
  1935. amdgpu_ring_write(ring, adev->gfx.config.max_hw_contexts - 1);
  1936. amdgpu_ring_write(ring, PACKET3_ME_INITIALIZE_DEVICE_ID(1));
  1937. amdgpu_ring_write(ring, 0);
  1938. amdgpu_ring_write(ring, 0);
  1939. amdgpu_ring_write(ring, PACKET3(PACKET3_SET_BASE, 2));
  1940. amdgpu_ring_write(ring, PACKET3_BASE_INDEX(CE_PARTITION_BASE));
  1941. amdgpu_ring_write(ring, 0xc000);
  1942. amdgpu_ring_write(ring, 0xe000);
  1943. amdgpu_ring_commit(ring);
  1944. gfx_v6_0_cp_gfx_enable(adev, true);
  1945. r = amdgpu_ring_alloc(ring, gfx_v6_0_get_csb_size(adev) + 10);
  1946. if (r) {
  1947. DRM_ERROR("amdgpu: cp failed to lock ring (%d).\n", r);
  1948. return r;
  1949. }
  1950. amdgpu_ring_write(ring, PACKET3(PACKET3_PREAMBLE_CNTL, 0));
  1951. amdgpu_ring_write(ring, PACKET3_PREAMBLE_BEGIN_CLEAR_STATE);
  1952. for (sect = adev->gfx.rlc.cs_data; sect->section != NULL; ++sect) {
  1953. for (ext = sect->section; ext->extent != NULL; ++ext) {
  1954. if (sect->id == SECT_CONTEXT) {
  1955. amdgpu_ring_write(ring,
  1956. PACKET3(PACKET3_SET_CONTEXT_REG, ext->reg_count));
  1957. amdgpu_ring_write(ring, ext->reg_index - PACKET3_SET_CONTEXT_REG_START);
  1958. for (i = 0; i < ext->reg_count; i++)
  1959. amdgpu_ring_write(ring, ext->extent[i]);
  1960. }
  1961. }
  1962. }
  1963. amdgpu_ring_write(ring, PACKET3(PACKET3_PREAMBLE_CNTL, 0));
  1964. amdgpu_ring_write(ring, PACKET3_PREAMBLE_END_CLEAR_STATE);
  1965. amdgpu_ring_write(ring, PACKET3(PACKET3_CLEAR_STATE, 0));
  1966. amdgpu_ring_write(ring, 0);
  1967. amdgpu_ring_write(ring, PACKET3(PACKET3_SET_CONTEXT_REG, 2));
  1968. amdgpu_ring_write(ring, 0x00000316);
  1969. amdgpu_ring_write(ring, 0x0000000e);
  1970. amdgpu_ring_write(ring, 0x00000010);
  1971. amdgpu_ring_commit(ring);
  1972. return 0;
  1973. }
  1974. static int gfx_v6_0_cp_gfx_resume(struct amdgpu_device *adev)
  1975. {
  1976. struct amdgpu_ring *ring;
  1977. u32 tmp;
  1978. u32 rb_bufsz;
  1979. int r;
  1980. u64 rptr_addr;
  1981. WREG32(mmCP_SEM_WAIT_TIMER, 0x0);
  1982. WREG32(mmCP_SEM_INCOMPLETE_TIMER_CNTL, 0x0);
  1983. /* Set the write pointer delay */
  1984. WREG32(mmCP_RB_WPTR_DELAY, 0);
  1985. WREG32(mmCP_DEBUG, 0);
  1986. WREG32(mmSCRATCH_ADDR, 0);
  1987. /* ring 0 - compute and gfx */
  1988. /* Set ring buffer size */
  1989. ring = &adev->gfx.gfx_ring[0];
  1990. rb_bufsz = order_base_2(ring->ring_size / 8);
  1991. tmp = (order_base_2(AMDGPU_GPU_PAGE_SIZE/8) << 8) | rb_bufsz;
  1992. #ifdef __BIG_ENDIAN
  1993. tmp |= BUF_SWAP_32BIT;
  1994. #endif
  1995. WREG32(mmCP_RB0_CNTL, tmp);
  1996. /* Initialize the ring buffer's read and write pointers */
  1997. WREG32(mmCP_RB0_CNTL, tmp | CP_RB0_CNTL__RB_RPTR_WR_ENA_MASK);
  1998. ring->wptr = 0;
  1999. WREG32(mmCP_RB0_WPTR, ring->wptr);
  2000. /* set the wb address whether it's enabled or not */
  2001. rptr_addr = adev->wb.gpu_addr + (ring->rptr_offs * 4);
  2002. WREG32(mmCP_RB0_RPTR_ADDR, lower_32_bits(rptr_addr));
  2003. WREG32(mmCP_RB0_RPTR_ADDR_HI, upper_32_bits(rptr_addr) & 0xFF);
  2004. WREG32(mmSCRATCH_UMSK, 0);
  2005. mdelay(1);
  2006. WREG32(mmCP_RB0_CNTL, tmp);
  2007. WREG32(mmCP_RB0_BASE, ring->gpu_addr >> 8);
  2008. /* start the rings */
  2009. gfx_v6_0_cp_gfx_start(adev);
  2010. ring->ready = true;
  2011. r = amdgpu_ring_test_ring(ring);
  2012. if (r) {
  2013. ring->ready = false;
  2014. return r;
  2015. }
  2016. return 0;
  2017. }
  2018. static u64 gfx_v6_0_ring_get_rptr(struct amdgpu_ring *ring)
  2019. {
  2020. return ring->adev->wb.wb[ring->rptr_offs];
  2021. }
  2022. static u64 gfx_v6_0_ring_get_wptr(struct amdgpu_ring *ring)
  2023. {
  2024. struct amdgpu_device *adev = ring->adev;
  2025. if (ring == &adev->gfx.gfx_ring[0])
  2026. return RREG32(mmCP_RB0_WPTR);
  2027. else if (ring == &adev->gfx.compute_ring[0])
  2028. return RREG32(mmCP_RB1_WPTR);
  2029. else if (ring == &adev->gfx.compute_ring[1])
  2030. return RREG32(mmCP_RB2_WPTR);
  2031. else
  2032. BUG();
  2033. }
  2034. static void gfx_v6_0_ring_set_wptr_gfx(struct amdgpu_ring *ring)
  2035. {
  2036. struct amdgpu_device *adev = ring->adev;
  2037. WREG32(mmCP_RB0_WPTR, lower_32_bits(ring->wptr));
  2038. (void)RREG32(mmCP_RB0_WPTR);
  2039. }
  2040. static void gfx_v6_0_ring_set_wptr_compute(struct amdgpu_ring *ring)
  2041. {
  2042. struct amdgpu_device *adev = ring->adev;
  2043. if (ring == &adev->gfx.compute_ring[0]) {
  2044. WREG32(mmCP_RB1_WPTR, lower_32_bits(ring->wptr));
  2045. (void)RREG32(mmCP_RB1_WPTR);
  2046. } else if (ring == &adev->gfx.compute_ring[1]) {
  2047. WREG32(mmCP_RB2_WPTR, lower_32_bits(ring->wptr));
  2048. (void)RREG32(mmCP_RB2_WPTR);
  2049. } else {
  2050. BUG();
  2051. }
  2052. }
  2053. static int gfx_v6_0_cp_compute_resume(struct amdgpu_device *adev)
  2054. {
  2055. struct amdgpu_ring *ring;
  2056. u32 tmp;
  2057. u32 rb_bufsz;
  2058. int i, r;
  2059. u64 rptr_addr;
  2060. /* ring1 - compute only */
  2061. /* Set ring buffer size */
  2062. ring = &adev->gfx.compute_ring[0];
  2063. rb_bufsz = order_base_2(ring->ring_size / 8);
  2064. tmp = (order_base_2(AMDGPU_GPU_PAGE_SIZE/8) << 8) | rb_bufsz;
  2065. #ifdef __BIG_ENDIAN
  2066. tmp |= BUF_SWAP_32BIT;
  2067. #endif
  2068. WREG32(mmCP_RB1_CNTL, tmp);
  2069. WREG32(mmCP_RB1_CNTL, tmp | CP_RB1_CNTL__RB_RPTR_WR_ENA_MASK);
  2070. ring->wptr = 0;
  2071. WREG32(mmCP_RB1_WPTR, ring->wptr);
  2072. rptr_addr = adev->wb.gpu_addr + (ring->rptr_offs * 4);
  2073. WREG32(mmCP_RB1_RPTR_ADDR, lower_32_bits(rptr_addr));
  2074. WREG32(mmCP_RB1_RPTR_ADDR_HI, upper_32_bits(rptr_addr) & 0xFF);
  2075. mdelay(1);
  2076. WREG32(mmCP_RB1_CNTL, tmp);
  2077. WREG32(mmCP_RB1_BASE, ring->gpu_addr >> 8);
  2078. ring = &adev->gfx.compute_ring[1];
  2079. rb_bufsz = order_base_2(ring->ring_size / 8);
  2080. tmp = (order_base_2(AMDGPU_GPU_PAGE_SIZE/8) << 8) | rb_bufsz;
  2081. #ifdef __BIG_ENDIAN
  2082. tmp |= BUF_SWAP_32BIT;
  2083. #endif
  2084. WREG32(mmCP_RB2_CNTL, tmp);
  2085. WREG32(mmCP_RB2_CNTL, tmp | CP_RB2_CNTL__RB_RPTR_WR_ENA_MASK);
  2086. ring->wptr = 0;
  2087. WREG32(mmCP_RB2_WPTR, ring->wptr);
  2088. rptr_addr = adev->wb.gpu_addr + (ring->rptr_offs * 4);
  2089. WREG32(mmCP_RB2_RPTR_ADDR, lower_32_bits(rptr_addr));
  2090. WREG32(mmCP_RB2_RPTR_ADDR_HI, upper_32_bits(rptr_addr) & 0xFF);
  2091. mdelay(1);
  2092. WREG32(mmCP_RB2_CNTL, tmp);
  2093. WREG32(mmCP_RB2_BASE, ring->gpu_addr >> 8);
  2094. adev->gfx.compute_ring[0].ready = false;
  2095. adev->gfx.compute_ring[1].ready = false;
  2096. for (i = 0; i < 2; i++) {
  2097. r = amdgpu_ring_test_ring(&adev->gfx.compute_ring[i]);
  2098. if (r)
  2099. return r;
  2100. adev->gfx.compute_ring[i].ready = true;
  2101. }
  2102. return 0;
  2103. }
  2104. static void gfx_v6_0_cp_enable(struct amdgpu_device *adev, bool enable)
  2105. {
  2106. gfx_v6_0_cp_gfx_enable(adev, enable);
  2107. }
  2108. static int gfx_v6_0_cp_load_microcode(struct amdgpu_device *adev)
  2109. {
  2110. return gfx_v6_0_cp_gfx_load_microcode(adev);
  2111. }
  2112. static void gfx_v6_0_enable_gui_idle_interrupt(struct amdgpu_device *adev,
  2113. bool enable)
  2114. {
  2115. u32 tmp = RREG32(mmCP_INT_CNTL_RING0);
  2116. u32 mask;
  2117. int i;
  2118. if (enable)
  2119. tmp |= (CP_INT_CNTL__CNTX_BUSY_INT_ENABLE_MASK |
  2120. CP_INT_CNTL__CNTX_EMPTY_INT_ENABLE_MASK);
  2121. else
  2122. tmp &= ~(CP_INT_CNTL__CNTX_BUSY_INT_ENABLE_MASK |
  2123. CP_INT_CNTL__CNTX_EMPTY_INT_ENABLE_MASK);
  2124. WREG32(mmCP_INT_CNTL_RING0, tmp);
  2125. if (!enable) {
  2126. /* read a gfx register */
  2127. tmp = RREG32(mmDB_DEPTH_INFO);
  2128. mask = RLC_BUSY_STATUS | GFX_POWER_STATUS | GFX_CLOCK_STATUS | GFX_LS_STATUS;
  2129. for (i = 0; i < adev->usec_timeout; i++) {
  2130. if ((RREG32(mmRLC_STAT) & mask) == (GFX_CLOCK_STATUS | GFX_POWER_STATUS))
  2131. break;
  2132. udelay(1);
  2133. }
  2134. }
  2135. }
  2136. static int gfx_v6_0_cp_resume(struct amdgpu_device *adev)
  2137. {
  2138. int r;
  2139. gfx_v6_0_enable_gui_idle_interrupt(adev, false);
  2140. r = gfx_v6_0_cp_load_microcode(adev);
  2141. if (r)
  2142. return r;
  2143. r = gfx_v6_0_cp_gfx_resume(adev);
  2144. if (r)
  2145. return r;
  2146. r = gfx_v6_0_cp_compute_resume(adev);
  2147. if (r)
  2148. return r;
  2149. gfx_v6_0_enable_gui_idle_interrupt(adev, true);
  2150. return 0;
  2151. }
  2152. static void gfx_v6_0_ring_emit_pipeline_sync(struct amdgpu_ring *ring)
  2153. {
  2154. int usepfp = (ring->funcs->type == AMDGPU_RING_TYPE_GFX);
  2155. uint32_t seq = ring->fence_drv.sync_seq;
  2156. uint64_t addr = ring->fence_drv.gpu_addr;
  2157. amdgpu_ring_write(ring, PACKET3(PACKET3_WAIT_REG_MEM, 5));
  2158. amdgpu_ring_write(ring, (WAIT_REG_MEM_MEM_SPACE(1) | /* memory */
  2159. WAIT_REG_MEM_FUNCTION(3) | /* equal */
  2160. WAIT_REG_MEM_ENGINE(usepfp))); /* pfp or me */
  2161. amdgpu_ring_write(ring, addr & 0xfffffffc);
  2162. amdgpu_ring_write(ring, upper_32_bits(addr) & 0xffffffff);
  2163. amdgpu_ring_write(ring, seq);
  2164. amdgpu_ring_write(ring, 0xffffffff);
  2165. amdgpu_ring_write(ring, 4); /* poll interval */
  2166. if (usepfp) {
  2167. /* synce CE with ME to prevent CE fetch CEIB before context switch done */
  2168. amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0));
  2169. amdgpu_ring_write(ring, 0);
  2170. amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0));
  2171. amdgpu_ring_write(ring, 0);
  2172. }
  2173. }
  2174. static void gfx_v6_0_ring_emit_vm_flush(struct amdgpu_ring *ring,
  2175. unsigned vm_id, uint64_t pd_addr)
  2176. {
  2177. int usepfp = (ring->funcs->type == AMDGPU_RING_TYPE_GFX);
  2178. /* write new base address */
  2179. amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));
  2180. amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(1) |
  2181. WRITE_DATA_DST_SEL(0)));
  2182. if (vm_id < 8) {
  2183. amdgpu_ring_write(ring, (mmVM_CONTEXT0_PAGE_TABLE_BASE_ADDR + vm_id ));
  2184. } else {
  2185. amdgpu_ring_write(ring, (mmVM_CONTEXT8_PAGE_TABLE_BASE_ADDR + (vm_id - 8)));
  2186. }
  2187. amdgpu_ring_write(ring, 0);
  2188. amdgpu_ring_write(ring, pd_addr >> 12);
  2189. /* bits 0-15 are the VM contexts0-15 */
  2190. amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));
  2191. amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(1) |
  2192. WRITE_DATA_DST_SEL(0)));
  2193. amdgpu_ring_write(ring, mmVM_INVALIDATE_REQUEST);
  2194. amdgpu_ring_write(ring, 0);
  2195. amdgpu_ring_write(ring, 1 << vm_id);
  2196. /* wait for the invalidate to complete */
  2197. amdgpu_ring_write(ring, PACKET3(PACKET3_WAIT_REG_MEM, 5));
  2198. amdgpu_ring_write(ring, (WAIT_REG_MEM_FUNCTION(0) | /* always */
  2199. WAIT_REG_MEM_ENGINE(0))); /* me */
  2200. amdgpu_ring_write(ring, mmVM_INVALIDATE_REQUEST);
  2201. amdgpu_ring_write(ring, 0);
  2202. amdgpu_ring_write(ring, 0); /* ref */
  2203. amdgpu_ring_write(ring, 0); /* mask */
  2204. amdgpu_ring_write(ring, 0x20); /* poll interval */
  2205. if (usepfp) {
  2206. /* sync PFP to ME, otherwise we might get invalid PFP reads */
  2207. amdgpu_ring_write(ring, PACKET3(PACKET3_PFP_SYNC_ME, 0));
  2208. amdgpu_ring_write(ring, 0x0);
  2209. /* synce CE with ME to prevent CE fetch CEIB before context switch done */
  2210. amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0));
  2211. amdgpu_ring_write(ring, 0);
  2212. amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0));
  2213. amdgpu_ring_write(ring, 0);
  2214. }
  2215. }
  2216. static void gfx_v6_0_rlc_fini(struct amdgpu_device *adev)
  2217. {
  2218. amdgpu_bo_free_kernel(&adev->gfx.rlc.save_restore_obj, NULL, NULL);
  2219. amdgpu_bo_free_kernel(&adev->gfx.rlc.clear_state_obj, NULL, NULL);
  2220. amdgpu_bo_free_kernel(&adev->gfx.rlc.cp_table_obj, NULL, NULL);
  2221. }
  2222. static int gfx_v6_0_rlc_init(struct amdgpu_device *adev)
  2223. {
  2224. const u32 *src_ptr;
  2225. volatile u32 *dst_ptr;
  2226. u32 dws, i;
  2227. u64 reg_list_mc_addr;
  2228. const struct cs_section_def *cs_data;
  2229. int r;
  2230. adev->gfx.rlc.reg_list = verde_rlc_save_restore_register_list;
  2231. adev->gfx.rlc.reg_list_size =
  2232. (u32)ARRAY_SIZE(verde_rlc_save_restore_register_list);
  2233. adev->gfx.rlc.cs_data = si_cs_data;
  2234. src_ptr = adev->gfx.rlc.reg_list;
  2235. dws = adev->gfx.rlc.reg_list_size;
  2236. cs_data = adev->gfx.rlc.cs_data;
  2237. if (src_ptr) {
  2238. /* save restore block */
  2239. r = amdgpu_bo_create_reserved(adev, dws * 4, PAGE_SIZE,
  2240. AMDGPU_GEM_DOMAIN_VRAM,
  2241. &adev->gfx.rlc.save_restore_obj,
  2242. &adev->gfx.rlc.save_restore_gpu_addr,
  2243. (void **)&adev->gfx.rlc.sr_ptr);
  2244. if (r) {
  2245. dev_warn(adev->dev, "(%d) create RLC sr bo failed\n",
  2246. r);
  2247. gfx_v6_0_rlc_fini(adev);
  2248. return r;
  2249. }
  2250. /* write the sr buffer */
  2251. dst_ptr = adev->gfx.rlc.sr_ptr;
  2252. for (i = 0; i < adev->gfx.rlc.reg_list_size; i++)
  2253. dst_ptr[i] = cpu_to_le32(src_ptr[i]);
  2254. amdgpu_bo_kunmap(adev->gfx.rlc.save_restore_obj);
  2255. amdgpu_bo_unreserve(adev->gfx.rlc.save_restore_obj);
  2256. }
  2257. if (cs_data) {
  2258. /* clear state block */
  2259. adev->gfx.rlc.clear_state_size = gfx_v6_0_get_csb_size(adev);
  2260. dws = adev->gfx.rlc.clear_state_size + (256 / 4);
  2261. r = amdgpu_bo_create_reserved(adev, dws * 4, PAGE_SIZE,
  2262. AMDGPU_GEM_DOMAIN_VRAM,
  2263. &adev->gfx.rlc.clear_state_obj,
  2264. &adev->gfx.rlc.clear_state_gpu_addr,
  2265. (void **)&adev->gfx.rlc.cs_ptr);
  2266. if (r) {
  2267. dev_warn(adev->dev, "(%d) create RLC c bo failed\n", r);
  2268. gfx_v6_0_rlc_fini(adev);
  2269. return r;
  2270. }
  2271. /* set up the cs buffer */
  2272. dst_ptr = adev->gfx.rlc.cs_ptr;
  2273. reg_list_mc_addr = adev->gfx.rlc.clear_state_gpu_addr + 256;
  2274. dst_ptr[0] = cpu_to_le32(upper_32_bits(reg_list_mc_addr));
  2275. dst_ptr[1] = cpu_to_le32(lower_32_bits(reg_list_mc_addr));
  2276. dst_ptr[2] = cpu_to_le32(adev->gfx.rlc.clear_state_size);
  2277. gfx_v6_0_get_csb_buffer(adev, &dst_ptr[(256/4)]);
  2278. amdgpu_bo_kunmap(adev->gfx.rlc.clear_state_obj);
  2279. amdgpu_bo_unreserve(adev->gfx.rlc.clear_state_obj);
  2280. }
  2281. return 0;
  2282. }
  2283. static void gfx_v6_0_enable_lbpw(struct amdgpu_device *adev, bool enable)
  2284. {
  2285. WREG32_FIELD(RLC_LB_CNTL, LOAD_BALANCE_ENABLE, enable ? 1 : 0);
  2286. if (!enable) {
  2287. gfx_v6_0_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff);
  2288. WREG32(mmSPI_LB_CU_MASK, 0x00ff);
  2289. }
  2290. }
  2291. static void gfx_v6_0_wait_for_rlc_serdes(struct amdgpu_device *adev)
  2292. {
  2293. int i;
  2294. for (i = 0; i < adev->usec_timeout; i++) {
  2295. if (RREG32(mmRLC_SERDES_MASTER_BUSY_0) == 0)
  2296. break;
  2297. udelay(1);
  2298. }
  2299. for (i = 0; i < adev->usec_timeout; i++) {
  2300. if (RREG32(mmRLC_SERDES_MASTER_BUSY_1) == 0)
  2301. break;
  2302. udelay(1);
  2303. }
  2304. }
  2305. static void gfx_v6_0_update_rlc(struct amdgpu_device *adev, u32 rlc)
  2306. {
  2307. u32 tmp;
  2308. tmp = RREG32(mmRLC_CNTL);
  2309. if (tmp != rlc)
  2310. WREG32(mmRLC_CNTL, rlc);
  2311. }
  2312. static u32 gfx_v6_0_halt_rlc(struct amdgpu_device *adev)
  2313. {
  2314. u32 data, orig;
  2315. orig = data = RREG32(mmRLC_CNTL);
  2316. if (data & RLC_CNTL__RLC_ENABLE_F32_MASK) {
  2317. data &= ~RLC_CNTL__RLC_ENABLE_F32_MASK;
  2318. WREG32(mmRLC_CNTL, data);
  2319. gfx_v6_0_wait_for_rlc_serdes(adev);
  2320. }
  2321. return orig;
  2322. }
  2323. static void gfx_v6_0_rlc_stop(struct amdgpu_device *adev)
  2324. {
  2325. WREG32(mmRLC_CNTL, 0);
  2326. gfx_v6_0_enable_gui_idle_interrupt(adev, false);
  2327. gfx_v6_0_wait_for_rlc_serdes(adev);
  2328. }
  2329. static void gfx_v6_0_rlc_start(struct amdgpu_device *adev)
  2330. {
  2331. WREG32(mmRLC_CNTL, RLC_CNTL__RLC_ENABLE_F32_MASK);
  2332. gfx_v6_0_enable_gui_idle_interrupt(adev, true);
  2333. udelay(50);
  2334. }
  2335. static void gfx_v6_0_rlc_reset(struct amdgpu_device *adev)
  2336. {
  2337. WREG32_FIELD(GRBM_SOFT_RESET, SOFT_RESET_RLC, 1);
  2338. udelay(50);
  2339. WREG32_FIELD(GRBM_SOFT_RESET, SOFT_RESET_RLC, 0);
  2340. udelay(50);
  2341. }
  2342. static bool gfx_v6_0_lbpw_supported(struct amdgpu_device *adev)
  2343. {
  2344. u32 tmp;
  2345. /* Enable LBPW only for DDR3 */
  2346. tmp = RREG32(mmMC_SEQ_MISC0);
  2347. if ((tmp & 0xF0000000) == 0xB0000000)
  2348. return true;
  2349. return false;
  2350. }
  2351. static void gfx_v6_0_init_cg(struct amdgpu_device *adev)
  2352. {
  2353. }
  2354. static int gfx_v6_0_rlc_resume(struct amdgpu_device *adev)
  2355. {
  2356. u32 i;
  2357. const struct rlc_firmware_header_v1_0 *hdr;
  2358. const __le32 *fw_data;
  2359. u32 fw_size;
  2360. if (!adev->gfx.rlc_fw)
  2361. return -EINVAL;
  2362. gfx_v6_0_rlc_stop(adev);
  2363. gfx_v6_0_rlc_reset(adev);
  2364. gfx_v6_0_init_pg(adev);
  2365. gfx_v6_0_init_cg(adev);
  2366. WREG32(mmRLC_RL_BASE, 0);
  2367. WREG32(mmRLC_RL_SIZE, 0);
  2368. WREG32(mmRLC_LB_CNTL, 0);
  2369. WREG32(mmRLC_LB_CNTR_MAX, 0xffffffff);
  2370. WREG32(mmRLC_LB_CNTR_INIT, 0);
  2371. WREG32(mmRLC_LB_INIT_CU_MASK, 0xffffffff);
  2372. WREG32(mmRLC_MC_CNTL, 0);
  2373. WREG32(mmRLC_UCODE_CNTL, 0);
  2374. hdr = (const struct rlc_firmware_header_v1_0 *)adev->gfx.rlc_fw->data;
  2375. fw_size = le32_to_cpu(hdr->header.ucode_size_bytes) / 4;
  2376. fw_data = (const __le32 *)
  2377. (adev->gfx.rlc_fw->data + le32_to_cpu(hdr->header.ucode_array_offset_bytes));
  2378. amdgpu_ucode_print_rlc_hdr(&hdr->header);
  2379. for (i = 0; i < fw_size; i++) {
  2380. WREG32(mmRLC_UCODE_ADDR, i);
  2381. WREG32(mmRLC_UCODE_DATA, le32_to_cpup(fw_data++));
  2382. }
  2383. WREG32(mmRLC_UCODE_ADDR, 0);
  2384. gfx_v6_0_enable_lbpw(adev, gfx_v6_0_lbpw_supported(adev));
  2385. gfx_v6_0_rlc_start(adev);
  2386. return 0;
  2387. }
  2388. static void gfx_v6_0_enable_cgcg(struct amdgpu_device *adev, bool enable)
  2389. {
  2390. u32 data, orig, tmp;
  2391. orig = data = RREG32(mmRLC_CGCG_CGLS_CTRL);
  2392. if (enable && (adev->cg_flags & AMD_CG_SUPPORT_GFX_CGCG)) {
  2393. gfx_v6_0_enable_gui_idle_interrupt(adev, true);
  2394. WREG32(mmRLC_GCPM_GENERAL_3, 0x00000080);
  2395. tmp = gfx_v6_0_halt_rlc(adev);
  2396. WREG32(mmRLC_SERDES_WR_MASTER_MASK_0, 0xffffffff);
  2397. WREG32(mmRLC_SERDES_WR_MASTER_MASK_1, 0xffffffff);
  2398. WREG32(mmRLC_SERDES_WR_CTRL, 0x00b000ff);
  2399. gfx_v6_0_wait_for_rlc_serdes(adev);
  2400. gfx_v6_0_update_rlc(adev, tmp);
  2401. WREG32(mmRLC_SERDES_WR_CTRL, 0x007000ff);
  2402. data |= RLC_CGCG_CGLS_CTRL__CGCG_EN_MASK | RLC_CGCG_CGLS_CTRL__CGLS_EN_MASK;
  2403. } else {
  2404. gfx_v6_0_enable_gui_idle_interrupt(adev, false);
  2405. RREG32(mmCB_CGTT_SCLK_CTRL);
  2406. RREG32(mmCB_CGTT_SCLK_CTRL);
  2407. RREG32(mmCB_CGTT_SCLK_CTRL);
  2408. RREG32(mmCB_CGTT_SCLK_CTRL);
  2409. data &= ~(RLC_CGCG_CGLS_CTRL__CGCG_EN_MASK | RLC_CGCG_CGLS_CTRL__CGLS_EN_MASK);
  2410. }
  2411. if (orig != data)
  2412. WREG32(mmRLC_CGCG_CGLS_CTRL, data);
  2413. }
  2414. static void gfx_v6_0_enable_mgcg(struct amdgpu_device *adev, bool enable)
  2415. {
  2416. u32 data, orig, tmp = 0;
  2417. if (enable && (adev->cg_flags & AMD_CG_SUPPORT_GFX_MGCG)) {
  2418. orig = data = RREG32(mmCGTS_SM_CTRL_REG);
  2419. data = 0x96940200;
  2420. if (orig != data)
  2421. WREG32(mmCGTS_SM_CTRL_REG, data);
  2422. if (adev->cg_flags & AMD_CG_SUPPORT_GFX_CP_LS) {
  2423. orig = data = RREG32(mmCP_MEM_SLP_CNTL);
  2424. data |= CP_MEM_SLP_CNTL__CP_MEM_LS_EN_MASK;
  2425. if (orig != data)
  2426. WREG32(mmCP_MEM_SLP_CNTL, data);
  2427. }
  2428. orig = data = RREG32(mmRLC_CGTT_MGCG_OVERRIDE);
  2429. data &= 0xffffffc0;
  2430. if (orig != data)
  2431. WREG32(mmRLC_CGTT_MGCG_OVERRIDE, data);
  2432. tmp = gfx_v6_0_halt_rlc(adev);
  2433. WREG32(mmRLC_SERDES_WR_MASTER_MASK_0, 0xffffffff);
  2434. WREG32(mmRLC_SERDES_WR_MASTER_MASK_1, 0xffffffff);
  2435. WREG32(mmRLC_SERDES_WR_CTRL, 0x00d000ff);
  2436. gfx_v6_0_update_rlc(adev, tmp);
  2437. } else {
  2438. orig = data = RREG32(mmRLC_CGTT_MGCG_OVERRIDE);
  2439. data |= 0x00000003;
  2440. if (orig != data)
  2441. WREG32(mmRLC_CGTT_MGCG_OVERRIDE, data);
  2442. data = RREG32(mmCP_MEM_SLP_CNTL);
  2443. if (data & CP_MEM_SLP_CNTL__CP_MEM_LS_EN_MASK) {
  2444. data &= ~CP_MEM_SLP_CNTL__CP_MEM_LS_EN_MASK;
  2445. WREG32(mmCP_MEM_SLP_CNTL, data);
  2446. }
  2447. orig = data = RREG32(mmCGTS_SM_CTRL_REG);
  2448. data |= CGTS_SM_CTRL_REG__LS_OVERRIDE_MASK | CGTS_SM_CTRL_REG__OVERRIDE_MASK;
  2449. if (orig != data)
  2450. WREG32(mmCGTS_SM_CTRL_REG, data);
  2451. tmp = gfx_v6_0_halt_rlc(adev);
  2452. WREG32(mmRLC_SERDES_WR_MASTER_MASK_0, 0xffffffff);
  2453. WREG32(mmRLC_SERDES_WR_MASTER_MASK_1, 0xffffffff);
  2454. WREG32(mmRLC_SERDES_WR_CTRL, 0x00e000ff);
  2455. gfx_v6_0_update_rlc(adev, tmp);
  2456. }
  2457. }
  2458. /*
  2459. static void gfx_v6_0_update_cg(struct amdgpu_device *adev,
  2460. bool enable)
  2461. {
  2462. gfx_v6_0_enable_gui_idle_interrupt(adev, false);
  2463. if (enable) {
  2464. gfx_v6_0_enable_mgcg(adev, true);
  2465. gfx_v6_0_enable_cgcg(adev, true);
  2466. } else {
  2467. gfx_v6_0_enable_cgcg(adev, false);
  2468. gfx_v6_0_enable_mgcg(adev, false);
  2469. }
  2470. gfx_v6_0_enable_gui_idle_interrupt(adev, true);
  2471. }
  2472. */
  2473. static void gfx_v6_0_enable_sclk_slowdown_on_pu(struct amdgpu_device *adev,
  2474. bool enable)
  2475. {
  2476. }
  2477. static void gfx_v6_0_enable_sclk_slowdown_on_pd(struct amdgpu_device *adev,
  2478. bool enable)
  2479. {
  2480. }
  2481. static void gfx_v6_0_enable_cp_pg(struct amdgpu_device *adev, bool enable)
  2482. {
  2483. u32 data, orig;
  2484. orig = data = RREG32(mmRLC_PG_CNTL);
  2485. if (enable && (adev->pg_flags & AMD_PG_SUPPORT_CP))
  2486. data &= ~0x8000;
  2487. else
  2488. data |= 0x8000;
  2489. if (orig != data)
  2490. WREG32(mmRLC_PG_CNTL, data);
  2491. }
  2492. static void gfx_v6_0_enable_gds_pg(struct amdgpu_device *adev, bool enable)
  2493. {
  2494. }
  2495. /*
  2496. static void gfx_v6_0_init_cp_pg_table(struct amdgpu_device *adev)
  2497. {
  2498. const __le32 *fw_data;
  2499. volatile u32 *dst_ptr;
  2500. int me, i, max_me = 4;
  2501. u32 bo_offset = 0;
  2502. u32 table_offset, table_size;
  2503. if (adev->asic_type == CHIP_KAVERI)
  2504. max_me = 5;
  2505. if (adev->gfx.rlc.cp_table_ptr == NULL)
  2506. return;
  2507. dst_ptr = adev->gfx.rlc.cp_table_ptr;
  2508. for (me = 0; me < max_me; me++) {
  2509. if (me == 0) {
  2510. const struct gfx_firmware_header_v1_0 *hdr =
  2511. (const struct gfx_firmware_header_v1_0 *)adev->gfx.ce_fw->data;
  2512. fw_data = (const __le32 *)
  2513. (adev->gfx.ce_fw->data +
  2514. le32_to_cpu(hdr->header.ucode_array_offset_bytes));
  2515. table_offset = le32_to_cpu(hdr->jt_offset);
  2516. table_size = le32_to_cpu(hdr->jt_size);
  2517. } else if (me == 1) {
  2518. const struct gfx_firmware_header_v1_0 *hdr =
  2519. (const struct gfx_firmware_header_v1_0 *)adev->gfx.pfp_fw->data;
  2520. fw_data = (const __le32 *)
  2521. (adev->gfx.pfp_fw->data +
  2522. le32_to_cpu(hdr->header.ucode_array_offset_bytes));
  2523. table_offset = le32_to_cpu(hdr->jt_offset);
  2524. table_size = le32_to_cpu(hdr->jt_size);
  2525. } else if (me == 2) {
  2526. const struct gfx_firmware_header_v1_0 *hdr =
  2527. (const struct gfx_firmware_header_v1_0 *)adev->gfx.me_fw->data;
  2528. fw_data = (const __le32 *)
  2529. (adev->gfx.me_fw->data +
  2530. le32_to_cpu(hdr->header.ucode_array_offset_bytes));
  2531. table_offset = le32_to_cpu(hdr->jt_offset);
  2532. table_size = le32_to_cpu(hdr->jt_size);
  2533. } else if (me == 3) {
  2534. const struct gfx_firmware_header_v1_0 *hdr =
  2535. (const struct gfx_firmware_header_v1_0 *)adev->gfx.mec_fw->data;
  2536. fw_data = (const __le32 *)
  2537. (adev->gfx.mec_fw->data +
  2538. le32_to_cpu(hdr->header.ucode_array_offset_bytes));
  2539. table_offset = le32_to_cpu(hdr->jt_offset);
  2540. table_size = le32_to_cpu(hdr->jt_size);
  2541. } else {
  2542. const struct gfx_firmware_header_v1_0 *hdr =
  2543. (const struct gfx_firmware_header_v1_0 *)adev->gfx.mec2_fw->data;
  2544. fw_data = (const __le32 *)
  2545. (adev->gfx.mec2_fw->data +
  2546. le32_to_cpu(hdr->header.ucode_array_offset_bytes));
  2547. table_offset = le32_to_cpu(hdr->jt_offset);
  2548. table_size = le32_to_cpu(hdr->jt_size);
  2549. }
  2550. for (i = 0; i < table_size; i ++) {
  2551. dst_ptr[bo_offset + i] =
  2552. cpu_to_le32(le32_to_cpu(fw_data[table_offset + i]));
  2553. }
  2554. bo_offset += table_size;
  2555. }
  2556. }
  2557. */
  2558. static void gfx_v6_0_enable_gfx_cgpg(struct amdgpu_device *adev,
  2559. bool enable)
  2560. {
  2561. if (enable && (adev->pg_flags & AMD_PG_SUPPORT_GFX_PG)) {
  2562. WREG32(mmRLC_TTOP_D, RLC_PUD(0x10) | RLC_PDD(0x10) | RLC_TTPD(0x10) | RLC_MSD(0x10));
  2563. WREG32_FIELD(RLC_PG_CNTL, GFX_POWER_GATING_ENABLE, 1);
  2564. WREG32_FIELD(RLC_AUTO_PG_CTRL, AUTO_PG_EN, 1);
  2565. } else {
  2566. WREG32_FIELD(RLC_AUTO_PG_CTRL, AUTO_PG_EN, 0);
  2567. (void)RREG32(mmDB_RENDER_CONTROL);
  2568. }
  2569. }
  2570. static void gfx_v6_0_init_ao_cu_mask(struct amdgpu_device *adev)
  2571. {
  2572. u32 tmp;
  2573. WREG32(mmRLC_PG_ALWAYS_ON_CU_MASK, adev->gfx.cu_info.ao_cu_mask);
  2574. tmp = RREG32(mmRLC_MAX_PG_CU);
  2575. tmp &= ~RLC_MAX_PG_CU__MAX_POWERED_UP_CU_MASK;
  2576. tmp |= (adev->gfx.cu_info.number << RLC_MAX_PG_CU__MAX_POWERED_UP_CU__SHIFT);
  2577. WREG32(mmRLC_MAX_PG_CU, tmp);
  2578. }
  2579. static void gfx_v6_0_enable_gfx_static_mgpg(struct amdgpu_device *adev,
  2580. bool enable)
  2581. {
  2582. u32 data, orig;
  2583. orig = data = RREG32(mmRLC_PG_CNTL);
  2584. if (enable && (adev->pg_flags & AMD_PG_SUPPORT_GFX_SMG))
  2585. data |= RLC_PG_CNTL__STATIC_PER_CU_PG_ENABLE_MASK;
  2586. else
  2587. data &= ~RLC_PG_CNTL__STATIC_PER_CU_PG_ENABLE_MASK;
  2588. if (orig != data)
  2589. WREG32(mmRLC_PG_CNTL, data);
  2590. }
  2591. static void gfx_v6_0_enable_gfx_dynamic_mgpg(struct amdgpu_device *adev,
  2592. bool enable)
  2593. {
  2594. u32 data, orig;
  2595. orig = data = RREG32(mmRLC_PG_CNTL);
  2596. if (enable && (adev->pg_flags & AMD_PG_SUPPORT_GFX_DMG))
  2597. data |= RLC_PG_CNTL__DYN_PER_CU_PG_ENABLE_MASK;
  2598. else
  2599. data &= ~RLC_PG_CNTL__DYN_PER_CU_PG_ENABLE_MASK;
  2600. if (orig != data)
  2601. WREG32(mmRLC_PG_CNTL, data);
  2602. }
  2603. static void gfx_v6_0_init_gfx_cgpg(struct amdgpu_device *adev)
  2604. {
  2605. u32 tmp;
  2606. WREG32(mmRLC_SAVE_AND_RESTORE_BASE, adev->gfx.rlc.save_restore_gpu_addr >> 8);
  2607. WREG32_FIELD(RLC_PG_CNTL, GFX_POWER_GATING_SRC, 1);
  2608. WREG32(mmRLC_CLEAR_STATE_RESTORE_BASE, adev->gfx.rlc.clear_state_gpu_addr >> 8);
  2609. tmp = RREG32(mmRLC_AUTO_PG_CTRL);
  2610. tmp &= ~RLC_AUTO_PG_CTRL__GRBM_REG_SAVE_GFX_IDLE_THRESHOLD_MASK;
  2611. tmp |= (0x700 << RLC_AUTO_PG_CTRL__GRBM_REG_SAVE_GFX_IDLE_THRESHOLD__SHIFT);
  2612. tmp &= ~RLC_AUTO_PG_CTRL__PG_AFTER_GRBM_REG_SAVE_THRESHOLD_MASK;
  2613. WREG32(mmRLC_AUTO_PG_CTRL, tmp);
  2614. }
  2615. static void gfx_v6_0_update_gfx_pg(struct amdgpu_device *adev, bool enable)
  2616. {
  2617. gfx_v6_0_enable_gfx_cgpg(adev, enable);
  2618. gfx_v6_0_enable_gfx_static_mgpg(adev, enable);
  2619. gfx_v6_0_enable_gfx_dynamic_mgpg(adev, enable);
  2620. }
  2621. static u32 gfx_v6_0_get_csb_size(struct amdgpu_device *adev)
  2622. {
  2623. u32 count = 0;
  2624. const struct cs_section_def *sect = NULL;
  2625. const struct cs_extent_def *ext = NULL;
  2626. if (adev->gfx.rlc.cs_data == NULL)
  2627. return 0;
  2628. /* begin clear state */
  2629. count += 2;
  2630. /* context control state */
  2631. count += 3;
  2632. for (sect = adev->gfx.rlc.cs_data; sect->section != NULL; ++sect) {
  2633. for (ext = sect->section; ext->extent != NULL; ++ext) {
  2634. if (sect->id == SECT_CONTEXT)
  2635. count += 2 + ext->reg_count;
  2636. else
  2637. return 0;
  2638. }
  2639. }
  2640. /* pa_sc_raster_config */
  2641. count += 3;
  2642. /* end clear state */
  2643. count += 2;
  2644. /* clear state */
  2645. count += 2;
  2646. return count;
  2647. }
  2648. static void gfx_v6_0_get_csb_buffer(struct amdgpu_device *adev,
  2649. volatile u32 *buffer)
  2650. {
  2651. u32 count = 0, i;
  2652. const struct cs_section_def *sect = NULL;
  2653. const struct cs_extent_def *ext = NULL;
  2654. if (adev->gfx.rlc.cs_data == NULL)
  2655. return;
  2656. if (buffer == NULL)
  2657. return;
  2658. buffer[count++] = cpu_to_le32(PACKET3(PACKET3_PREAMBLE_CNTL, 0));
  2659. buffer[count++] = cpu_to_le32(PACKET3_PREAMBLE_BEGIN_CLEAR_STATE);
  2660. buffer[count++] = cpu_to_le32(PACKET3(PACKET3_CONTEXT_CONTROL, 1));
  2661. buffer[count++] = cpu_to_le32(0x80000000);
  2662. buffer[count++] = cpu_to_le32(0x80000000);
  2663. for (sect = adev->gfx.rlc.cs_data; sect->section != NULL; ++sect) {
  2664. for (ext = sect->section; ext->extent != NULL; ++ext) {
  2665. if (sect->id == SECT_CONTEXT) {
  2666. buffer[count++] =
  2667. cpu_to_le32(PACKET3(PACKET3_SET_CONTEXT_REG, ext->reg_count));
  2668. buffer[count++] = cpu_to_le32(ext->reg_index - 0xa000);
  2669. for (i = 0; i < ext->reg_count; i++)
  2670. buffer[count++] = cpu_to_le32(ext->extent[i]);
  2671. } else {
  2672. return;
  2673. }
  2674. }
  2675. }
  2676. buffer[count++] = cpu_to_le32(PACKET3(PACKET3_SET_CONTEXT_REG, 1));
  2677. buffer[count++] = cpu_to_le32(mmPA_SC_RASTER_CONFIG - PACKET3_SET_CONTEXT_REG_START);
  2678. switch (adev->asic_type) {
  2679. case CHIP_TAHITI:
  2680. case CHIP_PITCAIRN:
  2681. buffer[count++] = cpu_to_le32(0x2a00126a);
  2682. break;
  2683. case CHIP_VERDE:
  2684. buffer[count++] = cpu_to_le32(0x0000124a);
  2685. break;
  2686. case CHIP_OLAND:
  2687. buffer[count++] = cpu_to_le32(0x00000082);
  2688. break;
  2689. case CHIP_HAINAN:
  2690. buffer[count++] = cpu_to_le32(0x00000000);
  2691. break;
  2692. default:
  2693. buffer[count++] = cpu_to_le32(0x00000000);
  2694. break;
  2695. }
  2696. buffer[count++] = cpu_to_le32(PACKET3(PACKET3_PREAMBLE_CNTL, 0));
  2697. buffer[count++] = cpu_to_le32(PACKET3_PREAMBLE_END_CLEAR_STATE);
  2698. buffer[count++] = cpu_to_le32(PACKET3(PACKET3_CLEAR_STATE, 0));
  2699. buffer[count++] = cpu_to_le32(0);
  2700. }
  2701. static void gfx_v6_0_init_pg(struct amdgpu_device *adev)
  2702. {
  2703. if (adev->pg_flags & (AMD_PG_SUPPORT_GFX_PG |
  2704. AMD_PG_SUPPORT_GFX_SMG |
  2705. AMD_PG_SUPPORT_GFX_DMG |
  2706. AMD_PG_SUPPORT_CP |
  2707. AMD_PG_SUPPORT_GDS |
  2708. AMD_PG_SUPPORT_RLC_SMU_HS)) {
  2709. gfx_v6_0_enable_sclk_slowdown_on_pu(adev, true);
  2710. gfx_v6_0_enable_sclk_slowdown_on_pd(adev, true);
  2711. if (adev->pg_flags & AMD_PG_SUPPORT_GFX_PG) {
  2712. gfx_v6_0_init_gfx_cgpg(adev);
  2713. gfx_v6_0_enable_cp_pg(adev, true);
  2714. gfx_v6_0_enable_gds_pg(adev, true);
  2715. } else {
  2716. WREG32(mmRLC_SAVE_AND_RESTORE_BASE, adev->gfx.rlc.save_restore_gpu_addr >> 8);
  2717. WREG32(mmRLC_CLEAR_STATE_RESTORE_BASE, adev->gfx.rlc.clear_state_gpu_addr >> 8);
  2718. }
  2719. gfx_v6_0_init_ao_cu_mask(adev);
  2720. gfx_v6_0_update_gfx_pg(adev, true);
  2721. } else {
  2722. WREG32(mmRLC_SAVE_AND_RESTORE_BASE, adev->gfx.rlc.save_restore_gpu_addr >> 8);
  2723. WREG32(mmRLC_CLEAR_STATE_RESTORE_BASE, adev->gfx.rlc.clear_state_gpu_addr >> 8);
  2724. }
  2725. }
  2726. static void gfx_v6_0_fini_pg(struct amdgpu_device *adev)
  2727. {
  2728. if (adev->pg_flags & (AMD_PG_SUPPORT_GFX_PG |
  2729. AMD_PG_SUPPORT_GFX_SMG |
  2730. AMD_PG_SUPPORT_GFX_DMG |
  2731. AMD_PG_SUPPORT_CP |
  2732. AMD_PG_SUPPORT_GDS |
  2733. AMD_PG_SUPPORT_RLC_SMU_HS)) {
  2734. gfx_v6_0_update_gfx_pg(adev, false);
  2735. if (adev->pg_flags & AMD_PG_SUPPORT_GFX_PG) {
  2736. gfx_v6_0_enable_cp_pg(adev, false);
  2737. gfx_v6_0_enable_gds_pg(adev, false);
  2738. }
  2739. }
  2740. }
  2741. static uint64_t gfx_v6_0_get_gpu_clock_counter(struct amdgpu_device *adev)
  2742. {
  2743. uint64_t clock;
  2744. mutex_lock(&adev->gfx.gpu_clock_mutex);
  2745. WREG32(mmRLC_CAPTURE_GPU_CLOCK_COUNT, 1);
  2746. clock = (uint64_t)RREG32(mmRLC_GPU_CLOCK_COUNT_LSB) |
  2747. ((uint64_t)RREG32(mmRLC_GPU_CLOCK_COUNT_MSB) << 32ULL);
  2748. mutex_unlock(&adev->gfx.gpu_clock_mutex);
  2749. return clock;
  2750. }
  2751. static void gfx_v6_ring_emit_cntxcntl(struct amdgpu_ring *ring, uint32_t flags)
  2752. {
  2753. if (flags & AMDGPU_HAVE_CTX_SWITCH)
  2754. gfx_v6_0_ring_emit_vgt_flush(ring);
  2755. amdgpu_ring_write(ring, PACKET3(PACKET3_CONTEXT_CONTROL, 1));
  2756. amdgpu_ring_write(ring, 0x80000000);
  2757. amdgpu_ring_write(ring, 0);
  2758. }
  2759. static uint32_t wave_read_ind(struct amdgpu_device *adev, uint32_t simd, uint32_t wave, uint32_t address)
  2760. {
  2761. WREG32(mmSQ_IND_INDEX,
  2762. (wave << SQ_IND_INDEX__WAVE_ID__SHIFT) |
  2763. (simd << SQ_IND_INDEX__SIMD_ID__SHIFT) |
  2764. (address << SQ_IND_INDEX__INDEX__SHIFT) |
  2765. (SQ_IND_INDEX__FORCE_READ_MASK));
  2766. return RREG32(mmSQ_IND_DATA);
  2767. }
  2768. static void wave_read_regs(struct amdgpu_device *adev, uint32_t simd,
  2769. uint32_t wave, uint32_t thread,
  2770. uint32_t regno, uint32_t num, uint32_t *out)
  2771. {
  2772. WREG32(mmSQ_IND_INDEX,
  2773. (wave << SQ_IND_INDEX__WAVE_ID__SHIFT) |
  2774. (simd << SQ_IND_INDEX__SIMD_ID__SHIFT) |
  2775. (regno << SQ_IND_INDEX__INDEX__SHIFT) |
  2776. (thread << SQ_IND_INDEX__THREAD_ID__SHIFT) |
  2777. (SQ_IND_INDEX__FORCE_READ_MASK) |
  2778. (SQ_IND_INDEX__AUTO_INCR_MASK));
  2779. while (num--)
  2780. *(out++) = RREG32(mmSQ_IND_DATA);
  2781. }
  2782. static void gfx_v6_0_read_wave_data(struct amdgpu_device *adev, uint32_t simd, uint32_t wave, uint32_t *dst, int *no_fields)
  2783. {
  2784. /* type 0 wave data */
  2785. dst[(*no_fields)++] = 0;
  2786. dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_STATUS);
  2787. dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_PC_LO);
  2788. dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_PC_HI);
  2789. dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_EXEC_LO);
  2790. dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_EXEC_HI);
  2791. dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_HW_ID);
  2792. dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_INST_DW0);
  2793. dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_INST_DW1);
  2794. dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_GPR_ALLOC);
  2795. dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_LDS_ALLOC);
  2796. dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_TRAPSTS);
  2797. dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_IB_STS);
  2798. dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_TBA_LO);
  2799. dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_TBA_HI);
  2800. dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_TMA_LO);
  2801. dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_TMA_HI);
  2802. dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_IB_DBG0);
  2803. dst[(*no_fields)++] = wave_read_ind(adev, simd, wave, ixSQ_WAVE_M0);
  2804. }
  2805. static void gfx_v6_0_read_wave_sgprs(struct amdgpu_device *adev, uint32_t simd,
  2806. uint32_t wave, uint32_t start,
  2807. uint32_t size, uint32_t *dst)
  2808. {
  2809. wave_read_regs(
  2810. adev, simd, wave, 0,
  2811. start + SQIND_WAVE_SGPRS_OFFSET, size, dst);
  2812. }
  2813. static const struct amdgpu_gfx_funcs gfx_v6_0_gfx_funcs = {
  2814. .get_gpu_clock_counter = &gfx_v6_0_get_gpu_clock_counter,
  2815. .select_se_sh = &gfx_v6_0_select_se_sh,
  2816. .read_wave_data = &gfx_v6_0_read_wave_data,
  2817. .read_wave_sgprs = &gfx_v6_0_read_wave_sgprs,
  2818. };
  2819. static int gfx_v6_0_early_init(void *handle)
  2820. {
  2821. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  2822. adev->gfx.num_gfx_rings = GFX6_NUM_GFX_RINGS;
  2823. adev->gfx.num_compute_rings = GFX6_NUM_COMPUTE_RINGS;
  2824. adev->gfx.funcs = &gfx_v6_0_gfx_funcs;
  2825. gfx_v6_0_set_ring_funcs(adev);
  2826. gfx_v6_0_set_irq_funcs(adev);
  2827. return 0;
  2828. }
  2829. static int gfx_v6_0_sw_init(void *handle)
  2830. {
  2831. struct amdgpu_ring *ring;
  2832. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  2833. int i, r;
  2834. r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 181, &adev->gfx.eop_irq);
  2835. if (r)
  2836. return r;
  2837. r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 184, &adev->gfx.priv_reg_irq);
  2838. if (r)
  2839. return r;
  2840. r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 185, &adev->gfx.priv_inst_irq);
  2841. if (r)
  2842. return r;
  2843. gfx_v6_0_scratch_init(adev);
  2844. r = gfx_v6_0_init_microcode(adev);
  2845. if (r) {
  2846. DRM_ERROR("Failed to load gfx firmware!\n");
  2847. return r;
  2848. }
  2849. r = gfx_v6_0_rlc_init(adev);
  2850. if (r) {
  2851. DRM_ERROR("Failed to init rlc BOs!\n");
  2852. return r;
  2853. }
  2854. for (i = 0; i < adev->gfx.num_gfx_rings; i++) {
  2855. ring = &adev->gfx.gfx_ring[i];
  2856. ring->ring_obj = NULL;
  2857. sprintf(ring->name, "gfx");
  2858. r = amdgpu_ring_init(adev, ring, 1024,
  2859. &adev->gfx.eop_irq, AMDGPU_CP_IRQ_GFX_EOP);
  2860. if (r)
  2861. return r;
  2862. }
  2863. for (i = 0; i < adev->gfx.num_compute_rings; i++) {
  2864. unsigned irq_type;
  2865. if ((i >= 32) || (i >= AMDGPU_MAX_COMPUTE_RINGS)) {
  2866. DRM_ERROR("Too many (%d) compute rings!\n", i);
  2867. break;
  2868. }
  2869. ring = &adev->gfx.compute_ring[i];
  2870. ring->ring_obj = NULL;
  2871. ring->use_doorbell = false;
  2872. ring->doorbell_index = 0;
  2873. ring->me = 1;
  2874. ring->pipe = i;
  2875. ring->queue = i;
  2876. sprintf(ring->name, "comp_%d.%d.%d", ring->me, ring->pipe, ring->queue);
  2877. irq_type = AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE0_EOP + ring->pipe;
  2878. r = amdgpu_ring_init(adev, ring, 1024,
  2879. &adev->gfx.eop_irq, irq_type);
  2880. if (r)
  2881. return r;
  2882. }
  2883. return r;
  2884. }
  2885. static int gfx_v6_0_sw_fini(void *handle)
  2886. {
  2887. int i;
  2888. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  2889. for (i = 0; i < adev->gfx.num_gfx_rings; i++)
  2890. amdgpu_ring_fini(&adev->gfx.gfx_ring[i]);
  2891. for (i = 0; i < adev->gfx.num_compute_rings; i++)
  2892. amdgpu_ring_fini(&adev->gfx.compute_ring[i]);
  2893. gfx_v6_0_rlc_fini(adev);
  2894. return 0;
  2895. }
  2896. static int gfx_v6_0_hw_init(void *handle)
  2897. {
  2898. int r;
  2899. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  2900. gfx_v6_0_gpu_init(adev);
  2901. r = gfx_v6_0_rlc_resume(adev);
  2902. if (r)
  2903. return r;
  2904. r = gfx_v6_0_cp_resume(adev);
  2905. if (r)
  2906. return r;
  2907. adev->gfx.ce_ram_size = 0x8000;
  2908. return r;
  2909. }
  2910. static int gfx_v6_0_hw_fini(void *handle)
  2911. {
  2912. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  2913. gfx_v6_0_cp_enable(adev, false);
  2914. gfx_v6_0_rlc_stop(adev);
  2915. gfx_v6_0_fini_pg(adev);
  2916. return 0;
  2917. }
  2918. static int gfx_v6_0_suspend(void *handle)
  2919. {
  2920. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  2921. return gfx_v6_0_hw_fini(adev);
  2922. }
  2923. static int gfx_v6_0_resume(void *handle)
  2924. {
  2925. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  2926. return gfx_v6_0_hw_init(adev);
  2927. }
  2928. static bool gfx_v6_0_is_idle(void *handle)
  2929. {
  2930. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  2931. if (RREG32(mmGRBM_STATUS) & GRBM_STATUS__GUI_ACTIVE_MASK)
  2932. return false;
  2933. else
  2934. return true;
  2935. }
  2936. static int gfx_v6_0_wait_for_idle(void *handle)
  2937. {
  2938. unsigned i;
  2939. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  2940. for (i = 0; i < adev->usec_timeout; i++) {
  2941. if (gfx_v6_0_is_idle(handle))
  2942. return 0;
  2943. udelay(1);
  2944. }
  2945. return -ETIMEDOUT;
  2946. }
  2947. static int gfx_v6_0_soft_reset(void *handle)
  2948. {
  2949. return 0;
  2950. }
  2951. static void gfx_v6_0_set_gfx_eop_interrupt_state(struct amdgpu_device *adev,
  2952. enum amdgpu_interrupt_state state)
  2953. {
  2954. u32 cp_int_cntl;
  2955. switch (state) {
  2956. case AMDGPU_IRQ_STATE_DISABLE:
  2957. cp_int_cntl = RREG32(mmCP_INT_CNTL_RING0);
  2958. cp_int_cntl &= ~CP_INT_CNTL_RING0__TIME_STAMP_INT_ENABLE_MASK;
  2959. WREG32(mmCP_INT_CNTL_RING0, cp_int_cntl);
  2960. break;
  2961. case AMDGPU_IRQ_STATE_ENABLE:
  2962. cp_int_cntl = RREG32(mmCP_INT_CNTL_RING0);
  2963. cp_int_cntl |= CP_INT_CNTL_RING0__TIME_STAMP_INT_ENABLE_MASK;
  2964. WREG32(mmCP_INT_CNTL_RING0, cp_int_cntl);
  2965. break;
  2966. default:
  2967. break;
  2968. }
  2969. }
  2970. static void gfx_v6_0_set_compute_eop_interrupt_state(struct amdgpu_device *adev,
  2971. int ring,
  2972. enum amdgpu_interrupt_state state)
  2973. {
  2974. u32 cp_int_cntl;
  2975. switch (state){
  2976. case AMDGPU_IRQ_STATE_DISABLE:
  2977. if (ring == 0) {
  2978. cp_int_cntl = RREG32(mmCP_INT_CNTL_RING1);
  2979. cp_int_cntl &= ~CP_INT_CNTL_RING1__TIME_STAMP_INT_ENABLE_MASK;
  2980. WREG32(mmCP_INT_CNTL_RING1, cp_int_cntl);
  2981. break;
  2982. } else {
  2983. cp_int_cntl = RREG32(mmCP_INT_CNTL_RING2);
  2984. cp_int_cntl &= ~CP_INT_CNTL_RING2__TIME_STAMP_INT_ENABLE_MASK;
  2985. WREG32(mmCP_INT_CNTL_RING2, cp_int_cntl);
  2986. break;
  2987. }
  2988. case AMDGPU_IRQ_STATE_ENABLE:
  2989. if (ring == 0) {
  2990. cp_int_cntl = RREG32(mmCP_INT_CNTL_RING1);
  2991. cp_int_cntl |= CP_INT_CNTL_RING1__TIME_STAMP_INT_ENABLE_MASK;
  2992. WREG32(mmCP_INT_CNTL_RING1, cp_int_cntl);
  2993. break;
  2994. } else {
  2995. cp_int_cntl = RREG32(mmCP_INT_CNTL_RING2);
  2996. cp_int_cntl |= CP_INT_CNTL_RING2__TIME_STAMP_INT_ENABLE_MASK;
  2997. WREG32(mmCP_INT_CNTL_RING2, cp_int_cntl);
  2998. break;
  2999. }
  3000. default:
  3001. BUG();
  3002. break;
  3003. }
  3004. }
  3005. static int gfx_v6_0_set_priv_reg_fault_state(struct amdgpu_device *adev,
  3006. struct amdgpu_irq_src *src,
  3007. unsigned type,
  3008. enum amdgpu_interrupt_state state)
  3009. {
  3010. u32 cp_int_cntl;
  3011. switch (state) {
  3012. case AMDGPU_IRQ_STATE_DISABLE:
  3013. cp_int_cntl = RREG32(mmCP_INT_CNTL_RING0);
  3014. cp_int_cntl &= ~CP_INT_CNTL_RING0__PRIV_REG_INT_ENABLE_MASK;
  3015. WREG32(mmCP_INT_CNTL_RING0, cp_int_cntl);
  3016. break;
  3017. case AMDGPU_IRQ_STATE_ENABLE:
  3018. cp_int_cntl = RREG32(mmCP_INT_CNTL_RING0);
  3019. cp_int_cntl |= CP_INT_CNTL_RING0__PRIV_REG_INT_ENABLE_MASK;
  3020. WREG32(mmCP_INT_CNTL_RING0, cp_int_cntl);
  3021. break;
  3022. default:
  3023. break;
  3024. }
  3025. return 0;
  3026. }
  3027. static int gfx_v6_0_set_priv_inst_fault_state(struct amdgpu_device *adev,
  3028. struct amdgpu_irq_src *src,
  3029. unsigned type,
  3030. enum amdgpu_interrupt_state state)
  3031. {
  3032. u32 cp_int_cntl;
  3033. switch (state) {
  3034. case AMDGPU_IRQ_STATE_DISABLE:
  3035. cp_int_cntl = RREG32(mmCP_INT_CNTL_RING0);
  3036. cp_int_cntl &= ~CP_INT_CNTL_RING0__PRIV_INSTR_INT_ENABLE_MASK;
  3037. WREG32(mmCP_INT_CNTL_RING0, cp_int_cntl);
  3038. break;
  3039. case AMDGPU_IRQ_STATE_ENABLE:
  3040. cp_int_cntl = RREG32(mmCP_INT_CNTL_RING0);
  3041. cp_int_cntl |= CP_INT_CNTL_RING0__PRIV_INSTR_INT_ENABLE_MASK;
  3042. WREG32(mmCP_INT_CNTL_RING0, cp_int_cntl);
  3043. break;
  3044. default:
  3045. break;
  3046. }
  3047. return 0;
  3048. }
  3049. static int gfx_v6_0_set_eop_interrupt_state(struct amdgpu_device *adev,
  3050. struct amdgpu_irq_src *src,
  3051. unsigned type,
  3052. enum amdgpu_interrupt_state state)
  3053. {
  3054. switch (type) {
  3055. case AMDGPU_CP_IRQ_GFX_EOP:
  3056. gfx_v6_0_set_gfx_eop_interrupt_state(adev, state);
  3057. break;
  3058. case AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE0_EOP:
  3059. gfx_v6_0_set_compute_eop_interrupt_state(adev, 0, state);
  3060. break;
  3061. case AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE1_EOP:
  3062. gfx_v6_0_set_compute_eop_interrupt_state(adev, 1, state);
  3063. break;
  3064. default:
  3065. break;
  3066. }
  3067. return 0;
  3068. }
  3069. static int gfx_v6_0_eop_irq(struct amdgpu_device *adev,
  3070. struct amdgpu_irq_src *source,
  3071. struct amdgpu_iv_entry *entry)
  3072. {
  3073. switch (entry->ring_id) {
  3074. case 0:
  3075. amdgpu_fence_process(&adev->gfx.gfx_ring[0]);
  3076. break;
  3077. case 1:
  3078. case 2:
  3079. amdgpu_fence_process(&adev->gfx.compute_ring[entry->ring_id - 1]);
  3080. break;
  3081. default:
  3082. break;
  3083. }
  3084. return 0;
  3085. }
  3086. static int gfx_v6_0_priv_reg_irq(struct amdgpu_device *adev,
  3087. struct amdgpu_irq_src *source,
  3088. struct amdgpu_iv_entry *entry)
  3089. {
  3090. DRM_ERROR("Illegal register access in command stream\n");
  3091. schedule_work(&adev->reset_work);
  3092. return 0;
  3093. }
  3094. static int gfx_v6_0_priv_inst_irq(struct amdgpu_device *adev,
  3095. struct amdgpu_irq_src *source,
  3096. struct amdgpu_iv_entry *entry)
  3097. {
  3098. DRM_ERROR("Illegal instruction in command stream\n");
  3099. schedule_work(&adev->reset_work);
  3100. return 0;
  3101. }
  3102. static int gfx_v6_0_set_clockgating_state(void *handle,
  3103. enum amd_clockgating_state state)
  3104. {
  3105. bool gate = false;
  3106. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  3107. if (state == AMD_CG_STATE_GATE)
  3108. gate = true;
  3109. gfx_v6_0_enable_gui_idle_interrupt(adev, false);
  3110. if (gate) {
  3111. gfx_v6_0_enable_mgcg(adev, true);
  3112. gfx_v6_0_enable_cgcg(adev, true);
  3113. } else {
  3114. gfx_v6_0_enable_cgcg(adev, false);
  3115. gfx_v6_0_enable_mgcg(adev, false);
  3116. }
  3117. gfx_v6_0_enable_gui_idle_interrupt(adev, true);
  3118. return 0;
  3119. }
  3120. static int gfx_v6_0_set_powergating_state(void *handle,
  3121. enum amd_powergating_state state)
  3122. {
  3123. bool gate = false;
  3124. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  3125. if (state == AMD_PG_STATE_GATE)
  3126. gate = true;
  3127. if (adev->pg_flags & (AMD_PG_SUPPORT_GFX_PG |
  3128. AMD_PG_SUPPORT_GFX_SMG |
  3129. AMD_PG_SUPPORT_GFX_DMG |
  3130. AMD_PG_SUPPORT_CP |
  3131. AMD_PG_SUPPORT_GDS |
  3132. AMD_PG_SUPPORT_RLC_SMU_HS)) {
  3133. gfx_v6_0_update_gfx_pg(adev, gate);
  3134. if (adev->pg_flags & AMD_PG_SUPPORT_GFX_PG) {
  3135. gfx_v6_0_enable_cp_pg(adev, gate);
  3136. gfx_v6_0_enable_gds_pg(adev, gate);
  3137. }
  3138. }
  3139. return 0;
  3140. }
  3141. static const struct amd_ip_funcs gfx_v6_0_ip_funcs = {
  3142. .name = "gfx_v6_0",
  3143. .early_init = gfx_v6_0_early_init,
  3144. .late_init = NULL,
  3145. .sw_init = gfx_v6_0_sw_init,
  3146. .sw_fini = gfx_v6_0_sw_fini,
  3147. .hw_init = gfx_v6_0_hw_init,
  3148. .hw_fini = gfx_v6_0_hw_fini,
  3149. .suspend = gfx_v6_0_suspend,
  3150. .resume = gfx_v6_0_resume,
  3151. .is_idle = gfx_v6_0_is_idle,
  3152. .wait_for_idle = gfx_v6_0_wait_for_idle,
  3153. .soft_reset = gfx_v6_0_soft_reset,
  3154. .set_clockgating_state = gfx_v6_0_set_clockgating_state,
  3155. .set_powergating_state = gfx_v6_0_set_powergating_state,
  3156. };
  3157. static const struct amdgpu_ring_funcs gfx_v6_0_ring_funcs_gfx = {
  3158. .type = AMDGPU_RING_TYPE_GFX,
  3159. .align_mask = 0xff,
  3160. .nop = 0x80000000,
  3161. .support_64bit_ptrs = false,
  3162. .get_rptr = gfx_v6_0_ring_get_rptr,
  3163. .get_wptr = gfx_v6_0_ring_get_wptr,
  3164. .set_wptr = gfx_v6_0_ring_set_wptr_gfx,
  3165. .emit_frame_size =
  3166. 5 + /* gfx_v6_0_ring_emit_hdp_flush */
  3167. 5 + /* gfx_v6_0_ring_emit_hdp_invalidate */
  3168. 14 + 14 + 14 + /* gfx_v6_0_ring_emit_fence x3 for user fence, vm fence */
  3169. 7 + 4 + /* gfx_v6_0_ring_emit_pipeline_sync */
  3170. 17 + 6 + /* gfx_v6_0_ring_emit_vm_flush */
  3171. 3 + 2, /* gfx_v6_ring_emit_cntxcntl including vgt flush */
  3172. .emit_ib_size = 6, /* gfx_v6_0_ring_emit_ib */
  3173. .emit_ib = gfx_v6_0_ring_emit_ib,
  3174. .emit_fence = gfx_v6_0_ring_emit_fence,
  3175. .emit_pipeline_sync = gfx_v6_0_ring_emit_pipeline_sync,
  3176. .emit_vm_flush = gfx_v6_0_ring_emit_vm_flush,
  3177. .emit_hdp_flush = gfx_v6_0_ring_emit_hdp_flush,
  3178. .emit_hdp_invalidate = gfx_v6_0_ring_emit_hdp_invalidate,
  3179. .test_ring = gfx_v6_0_ring_test_ring,
  3180. .test_ib = gfx_v6_0_ring_test_ib,
  3181. .insert_nop = amdgpu_ring_insert_nop,
  3182. .emit_cntxcntl = gfx_v6_ring_emit_cntxcntl,
  3183. };
  3184. static const struct amdgpu_ring_funcs gfx_v6_0_ring_funcs_compute = {
  3185. .type = AMDGPU_RING_TYPE_COMPUTE,
  3186. .align_mask = 0xff,
  3187. .nop = 0x80000000,
  3188. .get_rptr = gfx_v6_0_ring_get_rptr,
  3189. .get_wptr = gfx_v6_0_ring_get_wptr,
  3190. .set_wptr = gfx_v6_0_ring_set_wptr_compute,
  3191. .emit_frame_size =
  3192. 5 + /* gfx_v6_0_ring_emit_hdp_flush */
  3193. 5 + /* gfx_v6_0_ring_emit_hdp_invalidate */
  3194. 7 + /* gfx_v6_0_ring_emit_pipeline_sync */
  3195. 17 + /* gfx_v6_0_ring_emit_vm_flush */
  3196. 14 + 14 + 14, /* gfx_v6_0_ring_emit_fence x3 for user fence, vm fence */
  3197. .emit_ib_size = 6, /* gfx_v6_0_ring_emit_ib */
  3198. .emit_ib = gfx_v6_0_ring_emit_ib,
  3199. .emit_fence = gfx_v6_0_ring_emit_fence,
  3200. .emit_pipeline_sync = gfx_v6_0_ring_emit_pipeline_sync,
  3201. .emit_vm_flush = gfx_v6_0_ring_emit_vm_flush,
  3202. .emit_hdp_flush = gfx_v6_0_ring_emit_hdp_flush,
  3203. .emit_hdp_invalidate = gfx_v6_0_ring_emit_hdp_invalidate,
  3204. .test_ring = gfx_v6_0_ring_test_ring,
  3205. .test_ib = gfx_v6_0_ring_test_ib,
  3206. .insert_nop = amdgpu_ring_insert_nop,
  3207. };
  3208. static void gfx_v6_0_set_ring_funcs(struct amdgpu_device *adev)
  3209. {
  3210. int i;
  3211. for (i = 0; i < adev->gfx.num_gfx_rings; i++)
  3212. adev->gfx.gfx_ring[i].funcs = &gfx_v6_0_ring_funcs_gfx;
  3213. for (i = 0; i < adev->gfx.num_compute_rings; i++)
  3214. adev->gfx.compute_ring[i].funcs = &gfx_v6_0_ring_funcs_compute;
  3215. }
  3216. static const struct amdgpu_irq_src_funcs gfx_v6_0_eop_irq_funcs = {
  3217. .set = gfx_v6_0_set_eop_interrupt_state,
  3218. .process = gfx_v6_0_eop_irq,
  3219. };
  3220. static const struct amdgpu_irq_src_funcs gfx_v6_0_priv_reg_irq_funcs = {
  3221. .set = gfx_v6_0_set_priv_reg_fault_state,
  3222. .process = gfx_v6_0_priv_reg_irq,
  3223. };
  3224. static const struct amdgpu_irq_src_funcs gfx_v6_0_priv_inst_irq_funcs = {
  3225. .set = gfx_v6_0_set_priv_inst_fault_state,
  3226. .process = gfx_v6_0_priv_inst_irq,
  3227. };
  3228. static void gfx_v6_0_set_irq_funcs(struct amdgpu_device *adev)
  3229. {
  3230. adev->gfx.eop_irq.num_types = AMDGPU_CP_IRQ_LAST;
  3231. adev->gfx.eop_irq.funcs = &gfx_v6_0_eop_irq_funcs;
  3232. adev->gfx.priv_reg_irq.num_types = 1;
  3233. adev->gfx.priv_reg_irq.funcs = &gfx_v6_0_priv_reg_irq_funcs;
  3234. adev->gfx.priv_inst_irq.num_types = 1;
  3235. adev->gfx.priv_inst_irq.funcs = &gfx_v6_0_priv_inst_irq_funcs;
  3236. }
  3237. static void gfx_v6_0_get_cu_info(struct amdgpu_device *adev)
  3238. {
  3239. int i, j, k, counter, active_cu_number = 0;
  3240. u32 mask, bitmap, ao_bitmap, ao_cu_mask = 0;
  3241. struct amdgpu_cu_info *cu_info = &adev->gfx.cu_info;
  3242. unsigned disable_masks[4 * 2];
  3243. u32 ao_cu_num;
  3244. if (adev->flags & AMD_IS_APU)
  3245. ao_cu_num = 2;
  3246. else
  3247. ao_cu_num = adev->gfx.config.max_cu_per_sh;
  3248. memset(cu_info, 0, sizeof(*cu_info));
  3249. amdgpu_gfx_parse_disable_cu(disable_masks, 4, 2);
  3250. mutex_lock(&adev->grbm_idx_mutex);
  3251. for (i = 0; i < adev->gfx.config.max_shader_engines; i++) {
  3252. for (j = 0; j < adev->gfx.config.max_sh_per_se; j++) {
  3253. mask = 1;
  3254. ao_bitmap = 0;
  3255. counter = 0;
  3256. gfx_v6_0_select_se_sh(adev, i, j, 0xffffffff);
  3257. if (i < 4 && j < 2)
  3258. gfx_v6_0_set_user_cu_inactive_bitmap(
  3259. adev, disable_masks[i * 2 + j]);
  3260. bitmap = gfx_v6_0_get_cu_enabled(adev);
  3261. cu_info->bitmap[i][j] = bitmap;
  3262. for (k = 0; k < adev->gfx.config.max_cu_per_sh; k++) {
  3263. if (bitmap & mask) {
  3264. if (counter < ao_cu_num)
  3265. ao_bitmap |= mask;
  3266. counter ++;
  3267. }
  3268. mask <<= 1;
  3269. }
  3270. active_cu_number += counter;
  3271. if (i < 2 && j < 2)
  3272. ao_cu_mask |= (ao_bitmap << (i * 16 + j * 8));
  3273. cu_info->ao_cu_bitmap[i][j] = ao_bitmap;
  3274. }
  3275. }
  3276. gfx_v6_0_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff);
  3277. mutex_unlock(&adev->grbm_idx_mutex);
  3278. cu_info->number = active_cu_number;
  3279. cu_info->ao_cu_mask = ao_cu_mask;
  3280. }
  3281. const struct amdgpu_ip_block_version gfx_v6_0_ip_block =
  3282. {
  3283. .type = AMD_IP_BLOCK_TYPE_GFX,
  3284. .major = 6,
  3285. .minor = 0,
  3286. .rev = 0,
  3287. .funcs = &gfx_v6_0_ip_funcs,
  3288. };