gfx_v8_0.c 169 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171
  1. /*
  2. * Copyright 2014 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 "drmP.h"
  25. #include "amdgpu.h"
  26. #include "amdgpu_gfx.h"
  27. #include "vi.h"
  28. #include "vid.h"
  29. #include "amdgpu_ucode.h"
  30. #include "clearstate_vi.h"
  31. #include "gmc/gmc_8_2_d.h"
  32. #include "gmc/gmc_8_2_sh_mask.h"
  33. #include "oss/oss_3_0_d.h"
  34. #include "oss/oss_3_0_sh_mask.h"
  35. #include "bif/bif_5_0_d.h"
  36. #include "bif/bif_5_0_sh_mask.h"
  37. #include "gca/gfx_8_0_d.h"
  38. #include "gca/gfx_8_0_enum.h"
  39. #include "gca/gfx_8_0_sh_mask.h"
  40. #include "gca/gfx_8_0_enum.h"
  41. #include "uvd/uvd_5_0_d.h"
  42. #include "uvd/uvd_5_0_sh_mask.h"
  43. #include "dce/dce_10_0_d.h"
  44. #include "dce/dce_10_0_sh_mask.h"
  45. #define GFX8_NUM_GFX_RINGS 1
  46. #define GFX8_NUM_COMPUTE_RINGS 8
  47. #define TOPAZ_GB_ADDR_CONFIG_GOLDEN 0x22010001
  48. #define CARRIZO_GB_ADDR_CONFIG_GOLDEN 0x22010001
  49. #define TONGA_GB_ADDR_CONFIG_GOLDEN 0x22011003
  50. #define ARRAY_MODE(x) ((x) << GB_TILE_MODE0__ARRAY_MODE__SHIFT)
  51. #define PIPE_CONFIG(x) ((x) << GB_TILE_MODE0__PIPE_CONFIG__SHIFT)
  52. #define TILE_SPLIT(x) ((x) << GB_TILE_MODE0__TILE_SPLIT__SHIFT)
  53. #define MICRO_TILE_MODE_NEW(x) ((x) << GB_TILE_MODE0__MICRO_TILE_MODE_NEW__SHIFT)
  54. #define SAMPLE_SPLIT(x) ((x) << GB_TILE_MODE0__SAMPLE_SPLIT__SHIFT)
  55. #define BANK_WIDTH(x) ((x) << GB_MACROTILE_MODE0__BANK_WIDTH__SHIFT)
  56. #define BANK_HEIGHT(x) ((x) << GB_MACROTILE_MODE0__BANK_HEIGHT__SHIFT)
  57. #define MACRO_TILE_ASPECT(x) ((x) << GB_MACROTILE_MODE0__MACRO_TILE_ASPECT__SHIFT)
  58. #define NUM_BANKS(x) ((x) << GB_MACROTILE_MODE0__NUM_BANKS__SHIFT)
  59. MODULE_FIRMWARE("amdgpu/carrizo_ce.bin");
  60. MODULE_FIRMWARE("amdgpu/carrizo_pfp.bin");
  61. MODULE_FIRMWARE("amdgpu/carrizo_me.bin");
  62. MODULE_FIRMWARE("amdgpu/carrizo_mec.bin");
  63. MODULE_FIRMWARE("amdgpu/carrizo_mec2.bin");
  64. MODULE_FIRMWARE("amdgpu/carrizo_rlc.bin");
  65. MODULE_FIRMWARE("amdgpu/stoney_ce.bin");
  66. MODULE_FIRMWARE("amdgpu/stoney_pfp.bin");
  67. MODULE_FIRMWARE("amdgpu/stoney_me.bin");
  68. MODULE_FIRMWARE("amdgpu/stoney_mec.bin");
  69. MODULE_FIRMWARE("amdgpu/stoney_rlc.bin");
  70. MODULE_FIRMWARE("amdgpu/tonga_ce.bin");
  71. MODULE_FIRMWARE("amdgpu/tonga_pfp.bin");
  72. MODULE_FIRMWARE("amdgpu/tonga_me.bin");
  73. MODULE_FIRMWARE("amdgpu/tonga_mec.bin");
  74. MODULE_FIRMWARE("amdgpu/tonga_mec2.bin");
  75. MODULE_FIRMWARE("amdgpu/tonga_rlc.bin");
  76. MODULE_FIRMWARE("amdgpu/topaz_ce.bin");
  77. MODULE_FIRMWARE("amdgpu/topaz_pfp.bin");
  78. MODULE_FIRMWARE("amdgpu/topaz_me.bin");
  79. MODULE_FIRMWARE("amdgpu/topaz_mec.bin");
  80. MODULE_FIRMWARE("amdgpu/topaz_rlc.bin");
  81. MODULE_FIRMWARE("amdgpu/fiji_ce.bin");
  82. MODULE_FIRMWARE("amdgpu/fiji_pfp.bin");
  83. MODULE_FIRMWARE("amdgpu/fiji_me.bin");
  84. MODULE_FIRMWARE("amdgpu/fiji_mec.bin");
  85. MODULE_FIRMWARE("amdgpu/fiji_mec2.bin");
  86. MODULE_FIRMWARE("amdgpu/fiji_rlc.bin");
  87. static const struct amdgpu_gds_reg_offset amdgpu_gds_reg_offset[] =
  88. {
  89. {mmGDS_VMID0_BASE, mmGDS_VMID0_SIZE, mmGDS_GWS_VMID0, mmGDS_OA_VMID0},
  90. {mmGDS_VMID1_BASE, mmGDS_VMID1_SIZE, mmGDS_GWS_VMID1, mmGDS_OA_VMID1},
  91. {mmGDS_VMID2_BASE, mmGDS_VMID2_SIZE, mmGDS_GWS_VMID2, mmGDS_OA_VMID2},
  92. {mmGDS_VMID3_BASE, mmGDS_VMID3_SIZE, mmGDS_GWS_VMID3, mmGDS_OA_VMID3},
  93. {mmGDS_VMID4_BASE, mmGDS_VMID4_SIZE, mmGDS_GWS_VMID4, mmGDS_OA_VMID4},
  94. {mmGDS_VMID5_BASE, mmGDS_VMID5_SIZE, mmGDS_GWS_VMID5, mmGDS_OA_VMID5},
  95. {mmGDS_VMID6_BASE, mmGDS_VMID6_SIZE, mmGDS_GWS_VMID6, mmGDS_OA_VMID6},
  96. {mmGDS_VMID7_BASE, mmGDS_VMID7_SIZE, mmGDS_GWS_VMID7, mmGDS_OA_VMID7},
  97. {mmGDS_VMID8_BASE, mmGDS_VMID8_SIZE, mmGDS_GWS_VMID8, mmGDS_OA_VMID8},
  98. {mmGDS_VMID9_BASE, mmGDS_VMID9_SIZE, mmGDS_GWS_VMID9, mmGDS_OA_VMID9},
  99. {mmGDS_VMID10_BASE, mmGDS_VMID10_SIZE, mmGDS_GWS_VMID10, mmGDS_OA_VMID10},
  100. {mmGDS_VMID11_BASE, mmGDS_VMID11_SIZE, mmGDS_GWS_VMID11, mmGDS_OA_VMID11},
  101. {mmGDS_VMID12_BASE, mmGDS_VMID12_SIZE, mmGDS_GWS_VMID12, mmGDS_OA_VMID12},
  102. {mmGDS_VMID13_BASE, mmGDS_VMID13_SIZE, mmGDS_GWS_VMID13, mmGDS_OA_VMID13},
  103. {mmGDS_VMID14_BASE, mmGDS_VMID14_SIZE, mmGDS_GWS_VMID14, mmGDS_OA_VMID14},
  104. {mmGDS_VMID15_BASE, mmGDS_VMID15_SIZE, mmGDS_GWS_VMID15, mmGDS_OA_VMID15}
  105. };
  106. static const u32 golden_settings_tonga_a11[] =
  107. {
  108. mmCB_HW_CONTROL, 0xfffdf3cf, 0x00007208,
  109. mmCB_HW_CONTROL_3, 0x00000040, 0x00000040,
  110. mmDB_DEBUG2, 0xf00fffff, 0x00000400,
  111. mmGB_GPU_ID, 0x0000000f, 0x00000000,
  112. mmPA_SC_ENHANCE, 0xffffffff, 0x20000001,
  113. mmPA_SC_FIFO_DEPTH_CNTL, 0x000003ff, 0x000000fc,
  114. mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000,
  115. mmSQ_RANDOM_WAVE_PRI, 0x001fffff, 0x000006fd,
  116. mmTA_CNTL_AUX, 0x000f000f, 0x000b0000,
  117. mmTCC_CTRL, 0x00100000, 0xf31fff7f,
  118. mmTCC_EXE_DISABLE, 0x00000002, 0x00000002,
  119. mmTCP_ADDR_CONFIG, 0x000003ff, 0x000002fb,
  120. mmTCP_CHAN_STEER_HI, 0xffffffff, 0x0000543b,
  121. mmTCP_CHAN_STEER_LO, 0xffffffff, 0xa9210876,
  122. mmVGT_RESET_DEBUG, 0x00000004, 0x00000004,
  123. };
  124. static const u32 tonga_golden_common_all[] =
  125. {
  126. mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000,
  127. mmPA_SC_RASTER_CONFIG, 0xffffffff, 0x16000012,
  128. mmPA_SC_RASTER_CONFIG_1, 0xffffffff, 0x0000002A,
  129. mmGB_ADDR_CONFIG, 0xffffffff, 0x22011003,
  130. mmSPI_RESOURCE_RESERVE_CU_0, 0xffffffff, 0x00000800,
  131. mmSPI_RESOURCE_RESERVE_CU_1, 0xffffffff, 0x00000800,
  132. mmSPI_RESOURCE_RESERVE_EN_CU_0, 0xffffffff, 0x00007FBF,
  133. mmSPI_RESOURCE_RESERVE_EN_CU_1, 0xffffffff, 0x00007FAF
  134. };
  135. static const u32 tonga_mgcg_cgcg_init[] =
  136. {
  137. mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xffffffff,
  138. mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000,
  139. mmCB_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100,
  140. mmCGTT_BCI_CLK_CTRL, 0xffffffff, 0x00000100,
  141. mmCGTT_CP_CLK_CTRL, 0xffffffff, 0x00000100,
  142. mmCGTT_CPC_CLK_CTRL, 0xffffffff, 0x00000100,
  143. mmCGTT_CPF_CLK_CTRL, 0xffffffff, 0x40000100,
  144. mmCGTT_GDS_CLK_CTRL, 0xffffffff, 0x00000100,
  145. mmCGTT_IA_CLK_CTRL, 0xffffffff, 0x06000100,
  146. mmCGTT_PA_CLK_CTRL, 0xffffffff, 0x00000100,
  147. mmCGTT_WD_CLK_CTRL, 0xffffffff, 0x06000100,
  148. mmCGTT_PC_CLK_CTRL, 0xffffffff, 0x00000100,
  149. mmCGTT_RLC_CLK_CTRL, 0xffffffff, 0x00000100,
  150. mmCGTT_SC_CLK_CTRL, 0xffffffff, 0x00000100,
  151. mmCGTT_SPI_CLK_CTRL, 0xffffffff, 0x00000100,
  152. mmCGTT_SQ_CLK_CTRL, 0xffffffff, 0x00000100,
  153. mmCGTT_SQG_CLK_CTRL, 0xffffffff, 0x00000100,
  154. mmCGTT_SX_CLK_CTRL0, 0xffffffff, 0x00000100,
  155. mmCGTT_SX_CLK_CTRL1, 0xffffffff, 0x00000100,
  156. mmCGTT_SX_CLK_CTRL2, 0xffffffff, 0x00000100,
  157. mmCGTT_SX_CLK_CTRL3, 0xffffffff, 0x00000100,
  158. mmCGTT_SX_CLK_CTRL4, 0xffffffff, 0x00000100,
  159. mmCGTT_TCI_CLK_CTRL, 0xffffffff, 0x00000100,
  160. mmCGTT_TCP_CLK_CTRL, 0xffffffff, 0x00000100,
  161. mmCGTT_VGT_CLK_CTRL, 0xffffffff, 0x06000100,
  162. mmDB_CGTT_CLK_CTRL_0, 0xffffffff, 0x00000100,
  163. mmTA_CGTT_CTRL, 0xffffffff, 0x00000100,
  164. mmTCA_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100,
  165. mmTCC_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100,
  166. mmTD_CGTT_CTRL, 0xffffffff, 0x00000100,
  167. mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000,
  168. mmCGTS_CU0_SP0_CTRL_REG, 0xffffffff, 0x00010000,
  169. mmCGTS_CU0_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002,
  170. mmCGTS_CU0_TA_SQC_CTRL_REG, 0xffffffff, 0x00040007,
  171. mmCGTS_CU0_SP1_CTRL_REG, 0xffffffff, 0x00060005,
  172. mmCGTS_CU0_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008,
  173. mmCGTS_CU1_SP0_CTRL_REG, 0xffffffff, 0x00010000,
  174. mmCGTS_CU1_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002,
  175. mmCGTS_CU1_TA_CTRL_REG, 0xffffffff, 0x00040007,
  176. mmCGTS_CU1_SP1_CTRL_REG, 0xffffffff, 0x00060005,
  177. mmCGTS_CU1_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008,
  178. mmCGTS_CU2_SP0_CTRL_REG, 0xffffffff, 0x00010000,
  179. mmCGTS_CU2_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002,
  180. mmCGTS_CU2_TA_CTRL_REG, 0xffffffff, 0x00040007,
  181. mmCGTS_CU2_SP1_CTRL_REG, 0xffffffff, 0x00060005,
  182. mmCGTS_CU2_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008,
  183. mmCGTS_CU3_SP0_CTRL_REG, 0xffffffff, 0x00010000,
  184. mmCGTS_CU3_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002,
  185. mmCGTS_CU3_TA_CTRL_REG, 0xffffffff, 0x00040007,
  186. mmCGTS_CU3_SP1_CTRL_REG, 0xffffffff, 0x00060005,
  187. mmCGTS_CU3_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008,
  188. mmCGTS_CU4_SP0_CTRL_REG, 0xffffffff, 0x00010000,
  189. mmCGTS_CU4_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002,
  190. mmCGTS_CU4_TA_SQC_CTRL_REG, 0xffffffff, 0x00040007,
  191. mmCGTS_CU4_SP1_CTRL_REG, 0xffffffff, 0x00060005,
  192. mmCGTS_CU4_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008,
  193. mmCGTS_CU5_SP0_CTRL_REG, 0xffffffff, 0x00010000,
  194. mmCGTS_CU5_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002,
  195. mmCGTS_CU5_TA_CTRL_REG, 0xffffffff, 0x00040007,
  196. mmCGTS_CU5_SP1_CTRL_REG, 0xffffffff, 0x00060005,
  197. mmCGTS_CU5_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008,
  198. mmCGTS_CU6_SP0_CTRL_REG, 0xffffffff, 0x00010000,
  199. mmCGTS_CU6_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002,
  200. mmCGTS_CU6_TA_CTRL_REG, 0xffffffff, 0x00040007,
  201. mmCGTS_CU6_SP1_CTRL_REG, 0xffffffff, 0x00060005,
  202. mmCGTS_CU6_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008,
  203. mmCGTS_CU7_SP0_CTRL_REG, 0xffffffff, 0x00010000,
  204. mmCGTS_CU7_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002,
  205. mmCGTS_CU7_TA_CTRL_REG, 0xffffffff, 0x00040007,
  206. mmCGTS_CU7_SP1_CTRL_REG, 0xffffffff, 0x00060005,
  207. mmCGTS_CU7_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008,
  208. mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96e00200,
  209. mmCP_RB_WPTR_POLL_CNTL, 0xffffffff, 0x00900100,
  210. mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003c,
  211. mmCP_MEM_SLP_CNTL, 0x00000001, 0x00000001,
  212. };
  213. static const u32 fiji_golden_common_all[] =
  214. {
  215. mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000,
  216. mmPA_SC_RASTER_CONFIG, 0xffffffff, 0x3a00161a,
  217. mmPA_SC_RASTER_CONFIG_1, 0xffffffff, 0x0000002e,
  218. mmGB_ADDR_CONFIG, 0xffffffff, 0x22011003,
  219. mmSPI_RESOURCE_RESERVE_CU_0, 0xffffffff, 0x00000800,
  220. mmSPI_RESOURCE_RESERVE_CU_1, 0xffffffff, 0x00000800,
  221. mmSPI_RESOURCE_RESERVE_EN_CU_0, 0xffffffff, 0x00007FBF,
  222. mmSPI_RESOURCE_RESERVE_EN_CU_1, 0xffffffff, 0x00007FAF,
  223. mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000,
  224. mmSPI_CONFIG_CNTL_1, 0x0000000f, 0x00000009,
  225. };
  226. static const u32 golden_settings_fiji_a10[] =
  227. {
  228. mmCB_HW_CONTROL_3, 0x000001ff, 0x00000040,
  229. mmDB_DEBUG2, 0xf00fffff, 0x00000400,
  230. mmPA_SC_ENHANCE, 0xffffffff, 0x20000001,
  231. mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000,
  232. mmRLC_CGCG_CGLS_CTRL, 0x00000003, 0x0001003c,
  233. mmSQ_RANDOM_WAVE_PRI, 0x001fffff, 0x000006fd,
  234. mmTA_CNTL_AUX, 0x000f000f, 0x000b0000,
  235. mmTCC_CTRL, 0x00100000, 0xf31fff7f,
  236. mmTCC_EXE_DISABLE, 0x00000002, 0x00000002,
  237. mmTCP_ADDR_CONFIG, 0x000003ff, 0x000000ff,
  238. mmVGT_RESET_DEBUG, 0x00000004, 0x00000004,
  239. };
  240. static const u32 fiji_mgcg_cgcg_init[] =
  241. {
  242. mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xffffffff,
  243. mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000,
  244. mmCB_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100,
  245. mmCGTT_BCI_CLK_CTRL, 0xffffffff, 0x00000100,
  246. mmCGTT_CP_CLK_CTRL, 0xffffffff, 0x00000100,
  247. mmCGTT_CPC_CLK_CTRL, 0xffffffff, 0x00000100,
  248. mmCGTT_CPF_CLK_CTRL, 0xffffffff, 0x40000100,
  249. mmCGTT_GDS_CLK_CTRL, 0xffffffff, 0x00000100,
  250. mmCGTT_IA_CLK_CTRL, 0xffffffff, 0x06000100,
  251. mmCGTT_PA_CLK_CTRL, 0xffffffff, 0x00000100,
  252. mmCGTT_WD_CLK_CTRL, 0xffffffff, 0x06000100,
  253. mmCGTT_PC_CLK_CTRL, 0xffffffff, 0x00000100,
  254. mmCGTT_RLC_CLK_CTRL, 0xffffffff, 0x00000100,
  255. mmCGTT_SC_CLK_CTRL, 0xffffffff, 0x00000100,
  256. mmCGTT_SPI_CLK_CTRL, 0xffffffff, 0x00000100,
  257. mmCGTT_SQ_CLK_CTRL, 0xffffffff, 0x00000100,
  258. mmCGTT_SQG_CLK_CTRL, 0xffffffff, 0x00000100,
  259. mmCGTT_SX_CLK_CTRL0, 0xffffffff, 0x00000100,
  260. mmCGTT_SX_CLK_CTRL1, 0xffffffff, 0x00000100,
  261. mmCGTT_SX_CLK_CTRL2, 0xffffffff, 0x00000100,
  262. mmCGTT_SX_CLK_CTRL3, 0xffffffff, 0x00000100,
  263. mmCGTT_SX_CLK_CTRL4, 0xffffffff, 0x00000100,
  264. mmCGTT_TCI_CLK_CTRL, 0xffffffff, 0x00000100,
  265. mmCGTT_TCP_CLK_CTRL, 0xffffffff, 0x00000100,
  266. mmCGTT_VGT_CLK_CTRL, 0xffffffff, 0x06000100,
  267. mmDB_CGTT_CLK_CTRL_0, 0xffffffff, 0x00000100,
  268. mmTA_CGTT_CTRL, 0xffffffff, 0x00000100,
  269. mmTCA_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100,
  270. mmTCC_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100,
  271. mmTD_CGTT_CTRL, 0xffffffff, 0x00000100,
  272. mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000,
  273. mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96e00200,
  274. mmCP_RB_WPTR_POLL_CNTL, 0xffffffff, 0x00900100,
  275. mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003c,
  276. mmCP_MEM_SLP_CNTL, 0x00000001, 0x00000001,
  277. };
  278. static const u32 golden_settings_iceland_a11[] =
  279. {
  280. mmCB_HW_CONTROL_3, 0x00000040, 0x00000040,
  281. mmDB_DEBUG2, 0xf00fffff, 0x00000400,
  282. mmDB_DEBUG3, 0xc0000000, 0xc0000000,
  283. mmGB_GPU_ID, 0x0000000f, 0x00000000,
  284. mmPA_SC_ENHANCE, 0xffffffff, 0x20000001,
  285. mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000,
  286. mmPA_SC_RASTER_CONFIG, 0x3f3fffff, 0x00000002,
  287. mmPA_SC_RASTER_CONFIG_1, 0x0000003f, 0x00000000,
  288. mmSQ_RANDOM_WAVE_PRI, 0x001fffff, 0x000006fd,
  289. mmTA_CNTL_AUX, 0x000f000f, 0x000b0000,
  290. mmTCC_CTRL, 0x00100000, 0xf31fff7f,
  291. mmTCC_EXE_DISABLE, 0x00000002, 0x00000002,
  292. mmTCP_ADDR_CONFIG, 0x000003ff, 0x000000f1,
  293. mmTCP_CHAN_STEER_HI, 0xffffffff, 0x00000000,
  294. mmTCP_CHAN_STEER_LO, 0xffffffff, 0x00000010,
  295. };
  296. static const u32 iceland_golden_common_all[] =
  297. {
  298. mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000,
  299. mmPA_SC_RASTER_CONFIG, 0xffffffff, 0x00000002,
  300. mmPA_SC_RASTER_CONFIG_1, 0xffffffff, 0x00000000,
  301. mmGB_ADDR_CONFIG, 0xffffffff, 0x22010001,
  302. mmSPI_RESOURCE_RESERVE_CU_0, 0xffffffff, 0x00000800,
  303. mmSPI_RESOURCE_RESERVE_CU_1, 0xffffffff, 0x00000800,
  304. mmSPI_RESOURCE_RESERVE_EN_CU_0, 0xffffffff, 0x00007FBF,
  305. mmSPI_RESOURCE_RESERVE_EN_CU_1, 0xffffffff, 0x00007FAF
  306. };
  307. static const u32 iceland_mgcg_cgcg_init[] =
  308. {
  309. mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xffffffff,
  310. mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000,
  311. mmCB_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100,
  312. mmCGTT_BCI_CLK_CTRL, 0xffffffff, 0x00000100,
  313. mmCGTT_CP_CLK_CTRL, 0xffffffff, 0xc0000100,
  314. mmCGTT_CPC_CLK_CTRL, 0xffffffff, 0xc0000100,
  315. mmCGTT_CPF_CLK_CTRL, 0xffffffff, 0xc0000100,
  316. mmCGTT_GDS_CLK_CTRL, 0xffffffff, 0x00000100,
  317. mmCGTT_IA_CLK_CTRL, 0xffffffff, 0x06000100,
  318. mmCGTT_PA_CLK_CTRL, 0xffffffff, 0x00000100,
  319. mmCGTT_WD_CLK_CTRL, 0xffffffff, 0x06000100,
  320. mmCGTT_PC_CLK_CTRL, 0xffffffff, 0x00000100,
  321. mmCGTT_RLC_CLK_CTRL, 0xffffffff, 0x00000100,
  322. mmCGTT_SC_CLK_CTRL, 0xffffffff, 0x00000100,
  323. mmCGTT_SPI_CLK_CTRL, 0xffffffff, 0x00000100,
  324. mmCGTT_SQ_CLK_CTRL, 0xffffffff, 0x00000100,
  325. mmCGTT_SQG_CLK_CTRL, 0xffffffff, 0x00000100,
  326. mmCGTT_SX_CLK_CTRL0, 0xffffffff, 0x00000100,
  327. mmCGTT_SX_CLK_CTRL1, 0xffffffff, 0x00000100,
  328. mmCGTT_SX_CLK_CTRL2, 0xffffffff, 0x00000100,
  329. mmCGTT_SX_CLK_CTRL3, 0xffffffff, 0x00000100,
  330. mmCGTT_SX_CLK_CTRL4, 0xffffffff, 0x00000100,
  331. mmCGTT_TCI_CLK_CTRL, 0xffffffff, 0xff000100,
  332. mmCGTT_TCP_CLK_CTRL, 0xffffffff, 0x00000100,
  333. mmCGTT_VGT_CLK_CTRL, 0xffffffff, 0x06000100,
  334. mmDB_CGTT_CLK_CTRL_0, 0xffffffff, 0x00000100,
  335. mmTA_CGTT_CTRL, 0xffffffff, 0x00000100,
  336. mmTCA_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100,
  337. mmTCC_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100,
  338. mmTD_CGTT_CTRL, 0xffffffff, 0x00000100,
  339. mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000,
  340. mmCGTS_CU0_SP0_CTRL_REG, 0xffffffff, 0x00010000,
  341. mmCGTS_CU0_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002,
  342. mmCGTS_CU0_TA_SQC_CTRL_REG, 0xffffffff, 0x0f840f87,
  343. mmCGTS_CU0_SP1_CTRL_REG, 0xffffffff, 0x00060005,
  344. mmCGTS_CU0_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008,
  345. mmCGTS_CU1_SP0_CTRL_REG, 0xffffffff, 0x00010000,
  346. mmCGTS_CU1_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002,
  347. mmCGTS_CU1_TA_CTRL_REG, 0xffffffff, 0x00040007,
  348. mmCGTS_CU1_SP1_CTRL_REG, 0xffffffff, 0x00060005,
  349. mmCGTS_CU1_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008,
  350. mmCGTS_CU2_SP0_CTRL_REG, 0xffffffff, 0x00010000,
  351. mmCGTS_CU2_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002,
  352. mmCGTS_CU2_TA_CTRL_REG, 0xffffffff, 0x00040007,
  353. mmCGTS_CU2_SP1_CTRL_REG, 0xffffffff, 0x00060005,
  354. mmCGTS_CU2_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008,
  355. mmCGTS_CU3_SP0_CTRL_REG, 0xffffffff, 0x00010000,
  356. mmCGTS_CU3_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002,
  357. mmCGTS_CU3_TA_CTRL_REG, 0xffffffff, 0x00040007,
  358. mmCGTS_CU3_SP1_CTRL_REG, 0xffffffff, 0x00060005,
  359. mmCGTS_CU3_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008,
  360. mmCGTS_CU4_SP0_CTRL_REG, 0xffffffff, 0x00010000,
  361. mmCGTS_CU4_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002,
  362. mmCGTS_CU4_TA_SQC_CTRL_REG, 0xffffffff, 0x0f840f87,
  363. mmCGTS_CU4_SP1_CTRL_REG, 0xffffffff, 0x00060005,
  364. mmCGTS_CU4_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008,
  365. mmCGTS_CU5_SP0_CTRL_REG, 0xffffffff, 0x00010000,
  366. mmCGTS_CU5_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002,
  367. mmCGTS_CU5_TA_CTRL_REG, 0xffffffff, 0x00040007,
  368. mmCGTS_CU5_SP1_CTRL_REG, 0xffffffff, 0x00060005,
  369. mmCGTS_CU5_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008,
  370. mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96e00200,
  371. mmCP_RB_WPTR_POLL_CNTL, 0xffffffff, 0x00900100,
  372. mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003c,
  373. };
  374. static const u32 cz_golden_settings_a11[] =
  375. {
  376. mmCB_HW_CONTROL_3, 0x00000040, 0x00000040,
  377. mmDB_DEBUG2, 0xf00fffff, 0x00000400,
  378. mmGB_GPU_ID, 0x0000000f, 0x00000000,
  379. mmPA_SC_ENHANCE, 0xffffffff, 0x00000001,
  380. mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000,
  381. mmSQ_RANDOM_WAVE_PRI, 0x001fffff, 0x000006fd,
  382. mmTA_CNTL_AUX, 0x000f000f, 0x00010000,
  383. mmTCC_EXE_DISABLE, 0x00000002, 0x00000002,
  384. mmTCP_ADDR_CONFIG, 0x0000000f, 0x000000f3,
  385. mmTCP_CHAN_STEER_LO, 0xffffffff, 0x00001302
  386. };
  387. static const u32 cz_golden_common_all[] =
  388. {
  389. mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000,
  390. mmPA_SC_RASTER_CONFIG, 0xffffffff, 0x00000002,
  391. mmPA_SC_RASTER_CONFIG_1, 0xffffffff, 0x00000000,
  392. mmGB_ADDR_CONFIG, 0xffffffff, 0x22010001,
  393. mmSPI_RESOURCE_RESERVE_CU_0, 0xffffffff, 0x00000800,
  394. mmSPI_RESOURCE_RESERVE_CU_1, 0xffffffff, 0x00000800,
  395. mmSPI_RESOURCE_RESERVE_EN_CU_0, 0xffffffff, 0x00007FBF,
  396. mmSPI_RESOURCE_RESERVE_EN_CU_1, 0xffffffff, 0x00007FAF
  397. };
  398. static const u32 cz_mgcg_cgcg_init[] =
  399. {
  400. mmRLC_CGTT_MGCG_OVERRIDE, 0xffffffff, 0xffffffff,
  401. mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000,
  402. mmCB_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100,
  403. mmCGTT_BCI_CLK_CTRL, 0xffffffff, 0x00000100,
  404. mmCGTT_CP_CLK_CTRL, 0xffffffff, 0x00000100,
  405. mmCGTT_CPC_CLK_CTRL, 0xffffffff, 0x00000100,
  406. mmCGTT_CPF_CLK_CTRL, 0xffffffff, 0x00000100,
  407. mmCGTT_GDS_CLK_CTRL, 0xffffffff, 0x00000100,
  408. mmCGTT_IA_CLK_CTRL, 0xffffffff, 0x06000100,
  409. mmCGTT_PA_CLK_CTRL, 0xffffffff, 0x00000100,
  410. mmCGTT_WD_CLK_CTRL, 0xffffffff, 0x06000100,
  411. mmCGTT_PC_CLK_CTRL, 0xffffffff, 0x00000100,
  412. mmCGTT_RLC_CLK_CTRL, 0xffffffff, 0x00000100,
  413. mmCGTT_SC_CLK_CTRL, 0xffffffff, 0x00000100,
  414. mmCGTT_SPI_CLK_CTRL, 0xffffffff, 0x00000100,
  415. mmCGTT_SQ_CLK_CTRL, 0xffffffff, 0x00000100,
  416. mmCGTT_SQG_CLK_CTRL, 0xffffffff, 0x00000100,
  417. mmCGTT_SX_CLK_CTRL0, 0xffffffff, 0x00000100,
  418. mmCGTT_SX_CLK_CTRL1, 0xffffffff, 0x00000100,
  419. mmCGTT_SX_CLK_CTRL2, 0xffffffff, 0x00000100,
  420. mmCGTT_SX_CLK_CTRL3, 0xffffffff, 0x00000100,
  421. mmCGTT_SX_CLK_CTRL4, 0xffffffff, 0x00000100,
  422. mmCGTT_TCI_CLK_CTRL, 0xffffffff, 0x00000100,
  423. mmCGTT_TCP_CLK_CTRL, 0xffffffff, 0x00000100,
  424. mmCGTT_VGT_CLK_CTRL, 0xffffffff, 0x06000100,
  425. mmDB_CGTT_CLK_CTRL_0, 0xffffffff, 0x00000100,
  426. mmTA_CGTT_CTRL, 0xffffffff, 0x00000100,
  427. mmTCA_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100,
  428. mmTCC_CGTT_SCLK_CTRL, 0xffffffff, 0x00000100,
  429. mmTD_CGTT_CTRL, 0xffffffff, 0x00000100,
  430. mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000,
  431. mmCGTS_CU0_SP0_CTRL_REG, 0xffffffff, 0x00010000,
  432. mmCGTS_CU0_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002,
  433. mmCGTS_CU0_TA_SQC_CTRL_REG, 0xffffffff, 0x00040007,
  434. mmCGTS_CU0_SP1_CTRL_REG, 0xffffffff, 0x00060005,
  435. mmCGTS_CU0_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008,
  436. mmCGTS_CU1_SP0_CTRL_REG, 0xffffffff, 0x00010000,
  437. mmCGTS_CU1_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002,
  438. mmCGTS_CU1_TA_CTRL_REG, 0xffffffff, 0x00040007,
  439. mmCGTS_CU1_SP1_CTRL_REG, 0xffffffff, 0x00060005,
  440. mmCGTS_CU1_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008,
  441. mmCGTS_CU2_SP0_CTRL_REG, 0xffffffff, 0x00010000,
  442. mmCGTS_CU2_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002,
  443. mmCGTS_CU2_TA_CTRL_REG, 0xffffffff, 0x00040007,
  444. mmCGTS_CU2_SP1_CTRL_REG, 0xffffffff, 0x00060005,
  445. mmCGTS_CU2_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008,
  446. mmCGTS_CU3_SP0_CTRL_REG, 0xffffffff, 0x00010000,
  447. mmCGTS_CU3_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002,
  448. mmCGTS_CU3_TA_CTRL_REG, 0xffffffff, 0x00040007,
  449. mmCGTS_CU3_SP1_CTRL_REG, 0xffffffff, 0x00060005,
  450. mmCGTS_CU3_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008,
  451. mmCGTS_CU4_SP0_CTRL_REG, 0xffffffff, 0x00010000,
  452. mmCGTS_CU4_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002,
  453. mmCGTS_CU4_TA_SQC_CTRL_REG, 0xffffffff, 0x00040007,
  454. mmCGTS_CU4_SP1_CTRL_REG, 0xffffffff, 0x00060005,
  455. mmCGTS_CU4_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008,
  456. mmCGTS_CU5_SP0_CTRL_REG, 0xffffffff, 0x00010000,
  457. mmCGTS_CU5_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002,
  458. mmCGTS_CU5_TA_CTRL_REG, 0xffffffff, 0x00040007,
  459. mmCGTS_CU5_SP1_CTRL_REG, 0xffffffff, 0x00060005,
  460. mmCGTS_CU5_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008,
  461. mmCGTS_CU6_SP0_CTRL_REG, 0xffffffff, 0x00010000,
  462. mmCGTS_CU6_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002,
  463. mmCGTS_CU6_TA_CTRL_REG, 0xffffffff, 0x00040007,
  464. mmCGTS_CU6_SP1_CTRL_REG, 0xffffffff, 0x00060005,
  465. mmCGTS_CU6_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008,
  466. mmCGTS_CU7_SP0_CTRL_REG, 0xffffffff, 0x00010000,
  467. mmCGTS_CU7_LDS_SQ_CTRL_REG, 0xffffffff, 0x00030002,
  468. mmCGTS_CU7_TA_CTRL_REG, 0xffffffff, 0x00040007,
  469. mmCGTS_CU7_SP1_CTRL_REG, 0xffffffff, 0x00060005,
  470. mmCGTS_CU7_TD_TCP_CTRL_REG, 0xffffffff, 0x00090008,
  471. mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96e00200,
  472. mmCP_RB_WPTR_POLL_CNTL, 0xffffffff, 0x00900100,
  473. mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003f,
  474. mmCP_MEM_SLP_CNTL, 0x00000001, 0x00000001,
  475. };
  476. static const u32 stoney_golden_settings_a11[] =
  477. {
  478. mmDB_DEBUG2, 0xf00fffff, 0x00000400,
  479. mmGB_GPU_ID, 0x0000000f, 0x00000000,
  480. mmPA_SC_ENHANCE, 0xffffffff, 0x20000001,
  481. mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000,
  482. mmRLC_CGCG_CGLS_CTRL, 0x00000003, 0x0001003c,
  483. mmTA_CNTL_AUX, 0x000f000f, 0x000b0000,
  484. mmTCC_CTRL, 0x00100000, 0xf31fff7f,
  485. mmTCC_EXE_DISABLE, 0x00000002, 0x00000002,
  486. mmTCP_ADDR_CONFIG, 0x0000000f, 0x000000f1,
  487. mmTCP_CHAN_STEER_LO, 0xffffffff, 0x10101010,
  488. };
  489. static const u32 stoney_golden_common_all[] =
  490. {
  491. mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000,
  492. mmPA_SC_RASTER_CONFIG, 0xffffffff, 0x00000000,
  493. mmPA_SC_RASTER_CONFIG_1, 0xffffffff, 0x00000000,
  494. mmGB_ADDR_CONFIG, 0xffffffff, 0x12010001,
  495. mmSPI_RESOURCE_RESERVE_CU_0, 0xffffffff, 0x00000800,
  496. mmSPI_RESOURCE_RESERVE_CU_1, 0xffffffff, 0x00000800,
  497. mmSPI_RESOURCE_RESERVE_EN_CU_0, 0xffffffff, 0x00007FBF,
  498. mmSPI_RESOURCE_RESERVE_EN_CU_1, 0xffffffff, 0x00007FAF,
  499. };
  500. static const u32 stoney_mgcg_cgcg_init[] =
  501. {
  502. mmGRBM_GFX_INDEX, 0xffffffff, 0xe0000000,
  503. mmRLC_CGCG_CGLS_CTRL, 0xffffffff, 0x0020003f,
  504. mmCP_MEM_SLP_CNTL, 0xffffffff, 0x00020201,
  505. mmRLC_MEM_SLP_CNTL, 0xffffffff, 0x00020201,
  506. mmCGTS_SM_CTRL_REG, 0xffffffff, 0x96940200,
  507. mmATC_MISC_CG, 0xffffffff, 0x000c0200,
  508. };
  509. static void gfx_v8_0_set_ring_funcs(struct amdgpu_device *adev);
  510. static void gfx_v8_0_set_irq_funcs(struct amdgpu_device *adev);
  511. static void gfx_v8_0_set_gds_init(struct amdgpu_device *adev);
  512. static void gfx_v8_0_init_golden_registers(struct amdgpu_device *adev)
  513. {
  514. switch (adev->asic_type) {
  515. case CHIP_TOPAZ:
  516. amdgpu_program_register_sequence(adev,
  517. iceland_mgcg_cgcg_init,
  518. (const u32)ARRAY_SIZE(iceland_mgcg_cgcg_init));
  519. amdgpu_program_register_sequence(adev,
  520. golden_settings_iceland_a11,
  521. (const u32)ARRAY_SIZE(golden_settings_iceland_a11));
  522. amdgpu_program_register_sequence(adev,
  523. iceland_golden_common_all,
  524. (const u32)ARRAY_SIZE(iceland_golden_common_all));
  525. break;
  526. case CHIP_FIJI:
  527. amdgpu_program_register_sequence(adev,
  528. fiji_mgcg_cgcg_init,
  529. (const u32)ARRAY_SIZE(fiji_mgcg_cgcg_init));
  530. amdgpu_program_register_sequence(adev,
  531. golden_settings_fiji_a10,
  532. (const u32)ARRAY_SIZE(golden_settings_fiji_a10));
  533. amdgpu_program_register_sequence(adev,
  534. fiji_golden_common_all,
  535. (const u32)ARRAY_SIZE(fiji_golden_common_all));
  536. break;
  537. case CHIP_TONGA:
  538. amdgpu_program_register_sequence(adev,
  539. tonga_mgcg_cgcg_init,
  540. (const u32)ARRAY_SIZE(tonga_mgcg_cgcg_init));
  541. amdgpu_program_register_sequence(adev,
  542. golden_settings_tonga_a11,
  543. (const u32)ARRAY_SIZE(golden_settings_tonga_a11));
  544. amdgpu_program_register_sequence(adev,
  545. tonga_golden_common_all,
  546. (const u32)ARRAY_SIZE(tonga_golden_common_all));
  547. break;
  548. case CHIP_CARRIZO:
  549. amdgpu_program_register_sequence(adev,
  550. cz_mgcg_cgcg_init,
  551. (const u32)ARRAY_SIZE(cz_mgcg_cgcg_init));
  552. amdgpu_program_register_sequence(adev,
  553. cz_golden_settings_a11,
  554. (const u32)ARRAY_SIZE(cz_golden_settings_a11));
  555. amdgpu_program_register_sequence(adev,
  556. cz_golden_common_all,
  557. (const u32)ARRAY_SIZE(cz_golden_common_all));
  558. break;
  559. case CHIP_STONEY:
  560. amdgpu_program_register_sequence(adev,
  561. stoney_mgcg_cgcg_init,
  562. (const u32)ARRAY_SIZE(stoney_mgcg_cgcg_init));
  563. amdgpu_program_register_sequence(adev,
  564. stoney_golden_settings_a11,
  565. (const u32)ARRAY_SIZE(stoney_golden_settings_a11));
  566. amdgpu_program_register_sequence(adev,
  567. stoney_golden_common_all,
  568. (const u32)ARRAY_SIZE(stoney_golden_common_all));
  569. break;
  570. default:
  571. break;
  572. }
  573. }
  574. static void gfx_v8_0_scratch_init(struct amdgpu_device *adev)
  575. {
  576. int i;
  577. adev->gfx.scratch.num_reg = 7;
  578. adev->gfx.scratch.reg_base = mmSCRATCH_REG0;
  579. for (i = 0; i < adev->gfx.scratch.num_reg; i++) {
  580. adev->gfx.scratch.free[i] = true;
  581. adev->gfx.scratch.reg[i] = adev->gfx.scratch.reg_base + i;
  582. }
  583. }
  584. static int gfx_v8_0_ring_test_ring(struct amdgpu_ring *ring)
  585. {
  586. struct amdgpu_device *adev = ring->adev;
  587. uint32_t scratch;
  588. uint32_t tmp = 0;
  589. unsigned i;
  590. int r;
  591. r = amdgpu_gfx_scratch_get(adev, &scratch);
  592. if (r) {
  593. DRM_ERROR("amdgpu: cp failed to get scratch reg (%d).\n", r);
  594. return r;
  595. }
  596. WREG32(scratch, 0xCAFEDEAD);
  597. r = amdgpu_ring_lock(ring, 3);
  598. if (r) {
  599. DRM_ERROR("amdgpu: cp failed to lock ring %d (%d).\n",
  600. ring->idx, r);
  601. amdgpu_gfx_scratch_free(adev, scratch);
  602. return r;
  603. }
  604. amdgpu_ring_write(ring, PACKET3(PACKET3_SET_UCONFIG_REG, 1));
  605. amdgpu_ring_write(ring, (scratch - PACKET3_SET_UCONFIG_REG_START));
  606. amdgpu_ring_write(ring, 0xDEADBEEF);
  607. amdgpu_ring_unlock_commit(ring);
  608. for (i = 0; i < adev->usec_timeout; i++) {
  609. tmp = RREG32(scratch);
  610. if (tmp == 0xDEADBEEF)
  611. break;
  612. DRM_UDELAY(1);
  613. }
  614. if (i < adev->usec_timeout) {
  615. DRM_INFO("ring test on %d succeeded in %d usecs\n",
  616. ring->idx, i);
  617. } else {
  618. DRM_ERROR("amdgpu: ring %d test failed (scratch(0x%04X)=0x%08X)\n",
  619. ring->idx, scratch, tmp);
  620. r = -EINVAL;
  621. }
  622. amdgpu_gfx_scratch_free(adev, scratch);
  623. return r;
  624. }
  625. static int gfx_v8_0_ring_test_ib(struct amdgpu_ring *ring)
  626. {
  627. struct amdgpu_device *adev = ring->adev;
  628. struct amdgpu_ib ib;
  629. struct fence *f = NULL;
  630. uint32_t scratch;
  631. uint32_t tmp = 0;
  632. unsigned i;
  633. int r;
  634. r = amdgpu_gfx_scratch_get(adev, &scratch);
  635. if (r) {
  636. DRM_ERROR("amdgpu: failed to get scratch reg (%d).\n", r);
  637. return r;
  638. }
  639. WREG32(scratch, 0xCAFEDEAD);
  640. memset(&ib, 0, sizeof(ib));
  641. r = amdgpu_ib_get(ring, NULL, 256, &ib);
  642. if (r) {
  643. DRM_ERROR("amdgpu: failed to get ib (%d).\n", r);
  644. goto err1;
  645. }
  646. ib.ptr[0] = PACKET3(PACKET3_SET_UCONFIG_REG, 1);
  647. ib.ptr[1] = ((scratch - PACKET3_SET_UCONFIG_REG_START));
  648. ib.ptr[2] = 0xDEADBEEF;
  649. ib.length_dw = 3;
  650. r = amdgpu_sched_ib_submit_kernel_helper(adev, ring, &ib, 1, NULL,
  651. AMDGPU_FENCE_OWNER_UNDEFINED,
  652. &f);
  653. if (r)
  654. goto err2;
  655. r = fence_wait(f, false);
  656. if (r) {
  657. DRM_ERROR("amdgpu: fence wait failed (%d).\n", r);
  658. goto err2;
  659. }
  660. for (i = 0; i < adev->usec_timeout; i++) {
  661. tmp = RREG32(scratch);
  662. if (tmp == 0xDEADBEEF)
  663. break;
  664. DRM_UDELAY(1);
  665. }
  666. if (i < adev->usec_timeout) {
  667. DRM_INFO("ib test on ring %d succeeded in %u usecs\n",
  668. ring->idx, i);
  669. goto err2;
  670. } else {
  671. DRM_ERROR("amdgpu: ib test failed (scratch(0x%04X)=0x%08X)\n",
  672. scratch, tmp);
  673. r = -EINVAL;
  674. }
  675. err2:
  676. fence_put(f);
  677. amdgpu_ib_free(adev, &ib);
  678. err1:
  679. amdgpu_gfx_scratch_free(adev, scratch);
  680. return r;
  681. }
  682. static int gfx_v8_0_init_microcode(struct amdgpu_device *adev)
  683. {
  684. const char *chip_name;
  685. char fw_name[30];
  686. int err;
  687. struct amdgpu_firmware_info *info = NULL;
  688. const struct common_firmware_header *header = NULL;
  689. const struct gfx_firmware_header_v1_0 *cp_hdr;
  690. DRM_DEBUG("\n");
  691. switch (adev->asic_type) {
  692. case CHIP_TOPAZ:
  693. chip_name = "topaz";
  694. break;
  695. case CHIP_TONGA:
  696. chip_name = "tonga";
  697. break;
  698. case CHIP_CARRIZO:
  699. chip_name = "carrizo";
  700. break;
  701. case CHIP_FIJI:
  702. chip_name = "fiji";
  703. break;
  704. case CHIP_STONEY:
  705. chip_name = "stoney";
  706. break;
  707. default:
  708. BUG();
  709. }
  710. snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_pfp.bin", chip_name);
  711. err = request_firmware(&adev->gfx.pfp_fw, fw_name, adev->dev);
  712. if (err)
  713. goto out;
  714. err = amdgpu_ucode_validate(adev->gfx.pfp_fw);
  715. if (err)
  716. goto out;
  717. cp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.pfp_fw->data;
  718. adev->gfx.pfp_fw_version = le32_to_cpu(cp_hdr->header.ucode_version);
  719. adev->gfx.pfp_feature_version = le32_to_cpu(cp_hdr->ucode_feature_version);
  720. snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_me.bin", chip_name);
  721. err = request_firmware(&adev->gfx.me_fw, fw_name, adev->dev);
  722. if (err)
  723. goto out;
  724. err = amdgpu_ucode_validate(adev->gfx.me_fw);
  725. if (err)
  726. goto out;
  727. cp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.me_fw->data;
  728. adev->gfx.me_fw_version = le32_to_cpu(cp_hdr->header.ucode_version);
  729. adev->gfx.me_feature_version = le32_to_cpu(cp_hdr->ucode_feature_version);
  730. snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_ce.bin", chip_name);
  731. err = request_firmware(&adev->gfx.ce_fw, fw_name, adev->dev);
  732. if (err)
  733. goto out;
  734. err = amdgpu_ucode_validate(adev->gfx.ce_fw);
  735. if (err)
  736. goto out;
  737. cp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.ce_fw->data;
  738. adev->gfx.ce_fw_version = le32_to_cpu(cp_hdr->header.ucode_version);
  739. adev->gfx.ce_feature_version = le32_to_cpu(cp_hdr->ucode_feature_version);
  740. snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_rlc.bin", chip_name);
  741. err = request_firmware(&adev->gfx.rlc_fw, fw_name, adev->dev);
  742. if (err)
  743. goto out;
  744. err = amdgpu_ucode_validate(adev->gfx.rlc_fw);
  745. cp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.rlc_fw->data;
  746. adev->gfx.rlc_fw_version = le32_to_cpu(cp_hdr->header.ucode_version);
  747. adev->gfx.rlc_feature_version = le32_to_cpu(cp_hdr->ucode_feature_version);
  748. snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mec.bin", chip_name);
  749. err = request_firmware(&adev->gfx.mec_fw, fw_name, adev->dev);
  750. if (err)
  751. goto out;
  752. err = amdgpu_ucode_validate(adev->gfx.mec_fw);
  753. if (err)
  754. goto out;
  755. cp_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.mec_fw->data;
  756. adev->gfx.mec_fw_version = le32_to_cpu(cp_hdr->header.ucode_version);
  757. adev->gfx.mec_feature_version = le32_to_cpu(cp_hdr->ucode_feature_version);
  758. if ((adev->asic_type != CHIP_STONEY) &&
  759. (adev->asic_type != CHIP_TOPAZ)) {
  760. snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mec2.bin", chip_name);
  761. err = request_firmware(&adev->gfx.mec2_fw, fw_name, adev->dev);
  762. if (!err) {
  763. err = amdgpu_ucode_validate(adev->gfx.mec2_fw);
  764. if (err)
  765. goto out;
  766. cp_hdr = (const struct gfx_firmware_header_v1_0 *)
  767. adev->gfx.mec2_fw->data;
  768. adev->gfx.mec2_fw_version =
  769. le32_to_cpu(cp_hdr->header.ucode_version);
  770. adev->gfx.mec2_feature_version =
  771. le32_to_cpu(cp_hdr->ucode_feature_version);
  772. } else {
  773. err = 0;
  774. adev->gfx.mec2_fw = NULL;
  775. }
  776. }
  777. if (adev->firmware.smu_load) {
  778. info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_PFP];
  779. info->ucode_id = AMDGPU_UCODE_ID_CP_PFP;
  780. info->fw = adev->gfx.pfp_fw;
  781. header = (const struct common_firmware_header *)info->fw->data;
  782. adev->firmware.fw_size +=
  783. ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE);
  784. info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_ME];
  785. info->ucode_id = AMDGPU_UCODE_ID_CP_ME;
  786. info->fw = adev->gfx.me_fw;
  787. header = (const struct common_firmware_header *)info->fw->data;
  788. adev->firmware.fw_size +=
  789. ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE);
  790. info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_CE];
  791. info->ucode_id = AMDGPU_UCODE_ID_CP_CE;
  792. info->fw = adev->gfx.ce_fw;
  793. header = (const struct common_firmware_header *)info->fw->data;
  794. adev->firmware.fw_size +=
  795. ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE);
  796. info = &adev->firmware.ucode[AMDGPU_UCODE_ID_RLC_G];
  797. info->ucode_id = AMDGPU_UCODE_ID_RLC_G;
  798. info->fw = adev->gfx.rlc_fw;
  799. header = (const struct common_firmware_header *)info->fw->data;
  800. adev->firmware.fw_size +=
  801. ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE);
  802. info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_MEC1];
  803. info->ucode_id = AMDGPU_UCODE_ID_CP_MEC1;
  804. info->fw = adev->gfx.mec_fw;
  805. header = (const struct common_firmware_header *)info->fw->data;
  806. adev->firmware.fw_size +=
  807. ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE);
  808. if (adev->gfx.mec2_fw) {
  809. info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CP_MEC2];
  810. info->ucode_id = AMDGPU_UCODE_ID_CP_MEC2;
  811. info->fw = adev->gfx.mec2_fw;
  812. header = (const struct common_firmware_header *)info->fw->data;
  813. adev->firmware.fw_size +=
  814. ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE);
  815. }
  816. }
  817. out:
  818. if (err) {
  819. dev_err(adev->dev,
  820. "gfx8: Failed to load firmware \"%s\"\n",
  821. fw_name);
  822. release_firmware(adev->gfx.pfp_fw);
  823. adev->gfx.pfp_fw = NULL;
  824. release_firmware(adev->gfx.me_fw);
  825. adev->gfx.me_fw = NULL;
  826. release_firmware(adev->gfx.ce_fw);
  827. adev->gfx.ce_fw = NULL;
  828. release_firmware(adev->gfx.rlc_fw);
  829. adev->gfx.rlc_fw = NULL;
  830. release_firmware(adev->gfx.mec_fw);
  831. adev->gfx.mec_fw = NULL;
  832. release_firmware(adev->gfx.mec2_fw);
  833. adev->gfx.mec2_fw = NULL;
  834. }
  835. return err;
  836. }
  837. static void gfx_v8_0_mec_fini(struct amdgpu_device *adev)
  838. {
  839. int r;
  840. if (adev->gfx.mec.hpd_eop_obj) {
  841. r = amdgpu_bo_reserve(adev->gfx.mec.hpd_eop_obj, false);
  842. if (unlikely(r != 0))
  843. dev_warn(adev->dev, "(%d) reserve HPD EOP bo failed\n", r);
  844. amdgpu_bo_unpin(adev->gfx.mec.hpd_eop_obj);
  845. amdgpu_bo_unreserve(adev->gfx.mec.hpd_eop_obj);
  846. amdgpu_bo_unref(&adev->gfx.mec.hpd_eop_obj);
  847. adev->gfx.mec.hpd_eop_obj = NULL;
  848. }
  849. }
  850. #define MEC_HPD_SIZE 2048
  851. static int gfx_v8_0_mec_init(struct amdgpu_device *adev)
  852. {
  853. int r;
  854. u32 *hpd;
  855. /*
  856. * we assign only 1 pipe because all other pipes will
  857. * be handled by KFD
  858. */
  859. adev->gfx.mec.num_mec = 1;
  860. adev->gfx.mec.num_pipe = 1;
  861. adev->gfx.mec.num_queue = adev->gfx.mec.num_mec * adev->gfx.mec.num_pipe * 8;
  862. if (adev->gfx.mec.hpd_eop_obj == NULL) {
  863. r = amdgpu_bo_create(adev,
  864. adev->gfx.mec.num_mec *adev->gfx.mec.num_pipe * MEC_HPD_SIZE * 2,
  865. PAGE_SIZE, true,
  866. AMDGPU_GEM_DOMAIN_GTT, 0, NULL, NULL,
  867. &adev->gfx.mec.hpd_eop_obj);
  868. if (r) {
  869. dev_warn(adev->dev, "(%d) create HDP EOP bo failed\n", r);
  870. return r;
  871. }
  872. }
  873. r = amdgpu_bo_reserve(adev->gfx.mec.hpd_eop_obj, false);
  874. if (unlikely(r != 0)) {
  875. gfx_v8_0_mec_fini(adev);
  876. return r;
  877. }
  878. r = amdgpu_bo_pin(adev->gfx.mec.hpd_eop_obj, AMDGPU_GEM_DOMAIN_GTT,
  879. &adev->gfx.mec.hpd_eop_gpu_addr);
  880. if (r) {
  881. dev_warn(adev->dev, "(%d) pin HDP EOP bo failed\n", r);
  882. gfx_v8_0_mec_fini(adev);
  883. return r;
  884. }
  885. r = amdgpu_bo_kmap(adev->gfx.mec.hpd_eop_obj, (void **)&hpd);
  886. if (r) {
  887. dev_warn(adev->dev, "(%d) map HDP EOP bo failed\n", r);
  888. gfx_v8_0_mec_fini(adev);
  889. return r;
  890. }
  891. memset(hpd, 0, adev->gfx.mec.num_mec *adev->gfx.mec.num_pipe * MEC_HPD_SIZE * 2);
  892. amdgpu_bo_kunmap(adev->gfx.mec.hpd_eop_obj);
  893. amdgpu_bo_unreserve(adev->gfx.mec.hpd_eop_obj);
  894. return 0;
  895. }
  896. static void gfx_v8_0_gpu_early_init(struct amdgpu_device *adev)
  897. {
  898. u32 gb_addr_config;
  899. u32 mc_shared_chmap, mc_arb_ramcfg;
  900. u32 dimm00_addr_map, dimm01_addr_map, dimm10_addr_map, dimm11_addr_map;
  901. u32 tmp;
  902. switch (adev->asic_type) {
  903. case CHIP_TOPAZ:
  904. adev->gfx.config.max_shader_engines = 1;
  905. adev->gfx.config.max_tile_pipes = 2;
  906. adev->gfx.config.max_cu_per_sh = 6;
  907. adev->gfx.config.max_sh_per_se = 1;
  908. adev->gfx.config.max_backends_per_se = 2;
  909. adev->gfx.config.max_texture_channel_caches = 2;
  910. adev->gfx.config.max_gprs = 256;
  911. adev->gfx.config.max_gs_threads = 32;
  912. adev->gfx.config.max_hw_contexts = 8;
  913. adev->gfx.config.sc_prim_fifo_size_frontend = 0x20;
  914. adev->gfx.config.sc_prim_fifo_size_backend = 0x100;
  915. adev->gfx.config.sc_hiz_tile_fifo_size = 0x30;
  916. adev->gfx.config.sc_earlyz_tile_fifo_size = 0x130;
  917. gb_addr_config = TOPAZ_GB_ADDR_CONFIG_GOLDEN;
  918. break;
  919. case CHIP_FIJI:
  920. adev->gfx.config.max_shader_engines = 4;
  921. adev->gfx.config.max_tile_pipes = 16;
  922. adev->gfx.config.max_cu_per_sh = 16;
  923. adev->gfx.config.max_sh_per_se = 1;
  924. adev->gfx.config.max_backends_per_se = 4;
  925. adev->gfx.config.max_texture_channel_caches = 16;
  926. adev->gfx.config.max_gprs = 256;
  927. adev->gfx.config.max_gs_threads = 32;
  928. adev->gfx.config.max_hw_contexts = 8;
  929. adev->gfx.config.sc_prim_fifo_size_frontend = 0x20;
  930. adev->gfx.config.sc_prim_fifo_size_backend = 0x100;
  931. adev->gfx.config.sc_hiz_tile_fifo_size = 0x30;
  932. adev->gfx.config.sc_earlyz_tile_fifo_size = 0x130;
  933. gb_addr_config = TONGA_GB_ADDR_CONFIG_GOLDEN;
  934. break;
  935. case CHIP_TONGA:
  936. adev->gfx.config.max_shader_engines = 4;
  937. adev->gfx.config.max_tile_pipes = 8;
  938. adev->gfx.config.max_cu_per_sh = 8;
  939. adev->gfx.config.max_sh_per_se = 1;
  940. adev->gfx.config.max_backends_per_se = 2;
  941. adev->gfx.config.max_texture_channel_caches = 8;
  942. adev->gfx.config.max_gprs = 256;
  943. adev->gfx.config.max_gs_threads = 32;
  944. adev->gfx.config.max_hw_contexts = 8;
  945. adev->gfx.config.sc_prim_fifo_size_frontend = 0x20;
  946. adev->gfx.config.sc_prim_fifo_size_backend = 0x100;
  947. adev->gfx.config.sc_hiz_tile_fifo_size = 0x30;
  948. adev->gfx.config.sc_earlyz_tile_fifo_size = 0x130;
  949. gb_addr_config = TONGA_GB_ADDR_CONFIG_GOLDEN;
  950. break;
  951. case CHIP_CARRIZO:
  952. adev->gfx.config.max_shader_engines = 1;
  953. adev->gfx.config.max_tile_pipes = 2;
  954. adev->gfx.config.max_sh_per_se = 1;
  955. adev->gfx.config.max_backends_per_se = 2;
  956. switch (adev->pdev->revision) {
  957. case 0xc4:
  958. case 0x84:
  959. case 0xc8:
  960. case 0xcc:
  961. case 0xe1:
  962. case 0xe3:
  963. /* B10 */
  964. adev->gfx.config.max_cu_per_sh = 8;
  965. break;
  966. case 0xc5:
  967. case 0x81:
  968. case 0x85:
  969. case 0xc9:
  970. case 0xcd:
  971. case 0xe2:
  972. case 0xe4:
  973. /* B8 */
  974. adev->gfx.config.max_cu_per_sh = 6;
  975. break;
  976. case 0xc6:
  977. case 0xca:
  978. case 0xce:
  979. case 0x88:
  980. /* B6 */
  981. adev->gfx.config.max_cu_per_sh = 6;
  982. break;
  983. case 0xc7:
  984. case 0x87:
  985. case 0xcb:
  986. case 0xe5:
  987. case 0x89:
  988. default:
  989. /* B4 */
  990. adev->gfx.config.max_cu_per_sh = 4;
  991. break;
  992. }
  993. adev->gfx.config.max_texture_channel_caches = 2;
  994. adev->gfx.config.max_gprs = 256;
  995. adev->gfx.config.max_gs_threads = 32;
  996. adev->gfx.config.max_hw_contexts = 8;
  997. adev->gfx.config.sc_prim_fifo_size_frontend = 0x20;
  998. adev->gfx.config.sc_prim_fifo_size_backend = 0x100;
  999. adev->gfx.config.sc_hiz_tile_fifo_size = 0x30;
  1000. adev->gfx.config.sc_earlyz_tile_fifo_size = 0x130;
  1001. gb_addr_config = CARRIZO_GB_ADDR_CONFIG_GOLDEN;
  1002. break;
  1003. case CHIP_STONEY:
  1004. adev->gfx.config.max_shader_engines = 1;
  1005. adev->gfx.config.max_tile_pipes = 2;
  1006. adev->gfx.config.max_sh_per_se = 1;
  1007. adev->gfx.config.max_backends_per_se = 1;
  1008. switch (adev->pdev->revision) {
  1009. case 0xc0:
  1010. case 0xc1:
  1011. case 0xc2:
  1012. case 0xc4:
  1013. case 0xc8:
  1014. case 0xc9:
  1015. adev->gfx.config.max_cu_per_sh = 3;
  1016. break;
  1017. case 0xd0:
  1018. case 0xd1:
  1019. case 0xd2:
  1020. default:
  1021. adev->gfx.config.max_cu_per_sh = 2;
  1022. break;
  1023. }
  1024. adev->gfx.config.max_texture_channel_caches = 2;
  1025. adev->gfx.config.max_gprs = 256;
  1026. adev->gfx.config.max_gs_threads = 16;
  1027. adev->gfx.config.max_hw_contexts = 8;
  1028. adev->gfx.config.sc_prim_fifo_size_frontend = 0x20;
  1029. adev->gfx.config.sc_prim_fifo_size_backend = 0x100;
  1030. adev->gfx.config.sc_hiz_tile_fifo_size = 0x30;
  1031. adev->gfx.config.sc_earlyz_tile_fifo_size = 0x130;
  1032. gb_addr_config = CARRIZO_GB_ADDR_CONFIG_GOLDEN;
  1033. break;
  1034. default:
  1035. adev->gfx.config.max_shader_engines = 2;
  1036. adev->gfx.config.max_tile_pipes = 4;
  1037. adev->gfx.config.max_cu_per_sh = 2;
  1038. adev->gfx.config.max_sh_per_se = 1;
  1039. adev->gfx.config.max_backends_per_se = 2;
  1040. adev->gfx.config.max_texture_channel_caches = 4;
  1041. adev->gfx.config.max_gprs = 256;
  1042. adev->gfx.config.max_gs_threads = 32;
  1043. adev->gfx.config.max_hw_contexts = 8;
  1044. adev->gfx.config.sc_prim_fifo_size_frontend = 0x20;
  1045. adev->gfx.config.sc_prim_fifo_size_backend = 0x100;
  1046. adev->gfx.config.sc_hiz_tile_fifo_size = 0x30;
  1047. adev->gfx.config.sc_earlyz_tile_fifo_size = 0x130;
  1048. gb_addr_config = TONGA_GB_ADDR_CONFIG_GOLDEN;
  1049. break;
  1050. }
  1051. mc_shared_chmap = RREG32(mmMC_SHARED_CHMAP);
  1052. adev->gfx.config.mc_arb_ramcfg = RREG32(mmMC_ARB_RAMCFG);
  1053. mc_arb_ramcfg = adev->gfx.config.mc_arb_ramcfg;
  1054. adev->gfx.config.num_tile_pipes = adev->gfx.config.max_tile_pipes;
  1055. adev->gfx.config.mem_max_burst_length_bytes = 256;
  1056. if (adev->flags & AMD_IS_APU) {
  1057. /* Get memory bank mapping mode. */
  1058. tmp = RREG32(mmMC_FUS_DRAM0_BANK_ADDR_MAPPING);
  1059. dimm00_addr_map = REG_GET_FIELD(tmp, MC_FUS_DRAM0_BANK_ADDR_MAPPING, DIMM0ADDRMAP);
  1060. dimm01_addr_map = REG_GET_FIELD(tmp, MC_FUS_DRAM0_BANK_ADDR_MAPPING, DIMM1ADDRMAP);
  1061. tmp = RREG32(mmMC_FUS_DRAM1_BANK_ADDR_MAPPING);
  1062. dimm10_addr_map = REG_GET_FIELD(tmp, MC_FUS_DRAM1_BANK_ADDR_MAPPING, DIMM0ADDRMAP);
  1063. dimm11_addr_map = REG_GET_FIELD(tmp, MC_FUS_DRAM1_BANK_ADDR_MAPPING, DIMM1ADDRMAP);
  1064. /* Validate settings in case only one DIMM installed. */
  1065. if ((dimm00_addr_map == 0) || (dimm00_addr_map == 3) || (dimm00_addr_map == 4) || (dimm00_addr_map > 12))
  1066. dimm00_addr_map = 0;
  1067. if ((dimm01_addr_map == 0) || (dimm01_addr_map == 3) || (dimm01_addr_map == 4) || (dimm01_addr_map > 12))
  1068. dimm01_addr_map = 0;
  1069. if ((dimm10_addr_map == 0) || (dimm10_addr_map == 3) || (dimm10_addr_map == 4) || (dimm10_addr_map > 12))
  1070. dimm10_addr_map = 0;
  1071. if ((dimm11_addr_map == 0) || (dimm11_addr_map == 3) || (dimm11_addr_map == 4) || (dimm11_addr_map > 12))
  1072. dimm11_addr_map = 0;
  1073. /* If DIMM Addr map is 8GB, ROW size should be 2KB. Otherwise 1KB. */
  1074. /* If ROW size(DIMM1) != ROW size(DMIMM0), ROW size should be larger one. */
  1075. if ((dimm00_addr_map == 11) || (dimm01_addr_map == 11) || (dimm10_addr_map == 11) || (dimm11_addr_map == 11))
  1076. adev->gfx.config.mem_row_size_in_kb = 2;
  1077. else
  1078. adev->gfx.config.mem_row_size_in_kb = 1;
  1079. } else {
  1080. tmp = REG_GET_FIELD(mc_arb_ramcfg, MC_ARB_RAMCFG, NOOFCOLS);
  1081. adev->gfx.config.mem_row_size_in_kb = (4 * (1 << (8 + tmp))) / 1024;
  1082. if (adev->gfx.config.mem_row_size_in_kb > 4)
  1083. adev->gfx.config.mem_row_size_in_kb = 4;
  1084. }
  1085. adev->gfx.config.shader_engine_tile_size = 32;
  1086. adev->gfx.config.num_gpus = 1;
  1087. adev->gfx.config.multi_gpu_tile_size = 64;
  1088. /* fix up row size */
  1089. switch (adev->gfx.config.mem_row_size_in_kb) {
  1090. case 1:
  1091. default:
  1092. gb_addr_config = REG_SET_FIELD(gb_addr_config, GB_ADDR_CONFIG, ROW_SIZE, 0);
  1093. break;
  1094. case 2:
  1095. gb_addr_config = REG_SET_FIELD(gb_addr_config, GB_ADDR_CONFIG, ROW_SIZE, 1);
  1096. break;
  1097. case 4:
  1098. gb_addr_config = REG_SET_FIELD(gb_addr_config, GB_ADDR_CONFIG, ROW_SIZE, 2);
  1099. break;
  1100. }
  1101. adev->gfx.config.gb_addr_config = gb_addr_config;
  1102. }
  1103. static int gfx_v8_0_sw_init(void *handle)
  1104. {
  1105. int i, r;
  1106. struct amdgpu_ring *ring;
  1107. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  1108. /* EOP Event */
  1109. r = amdgpu_irq_add_id(adev, 181, &adev->gfx.eop_irq);
  1110. if (r)
  1111. return r;
  1112. /* Privileged reg */
  1113. r = amdgpu_irq_add_id(adev, 184, &adev->gfx.priv_reg_irq);
  1114. if (r)
  1115. return r;
  1116. /* Privileged inst */
  1117. r = amdgpu_irq_add_id(adev, 185, &adev->gfx.priv_inst_irq);
  1118. if (r)
  1119. return r;
  1120. adev->gfx.gfx_current_status = AMDGPU_GFX_NORMAL_MODE;
  1121. gfx_v8_0_scratch_init(adev);
  1122. r = gfx_v8_0_init_microcode(adev);
  1123. if (r) {
  1124. DRM_ERROR("Failed to load gfx firmware!\n");
  1125. return r;
  1126. }
  1127. r = gfx_v8_0_mec_init(adev);
  1128. if (r) {
  1129. DRM_ERROR("Failed to init MEC BOs!\n");
  1130. return r;
  1131. }
  1132. /* set up the gfx ring */
  1133. for (i = 0; i < adev->gfx.num_gfx_rings; i++) {
  1134. ring = &adev->gfx.gfx_ring[i];
  1135. ring->ring_obj = NULL;
  1136. sprintf(ring->name, "gfx");
  1137. /* no gfx doorbells on iceland */
  1138. if (adev->asic_type != CHIP_TOPAZ) {
  1139. ring->use_doorbell = true;
  1140. ring->doorbell_index = AMDGPU_DOORBELL_GFX_RING0;
  1141. }
  1142. r = amdgpu_ring_init(adev, ring, 1024 * 1024,
  1143. PACKET3(PACKET3_NOP, 0x3FFF), 0xf,
  1144. &adev->gfx.eop_irq, AMDGPU_CP_IRQ_GFX_EOP,
  1145. AMDGPU_RING_TYPE_GFX);
  1146. if (r)
  1147. return r;
  1148. }
  1149. /* set up the compute queues */
  1150. for (i = 0; i < adev->gfx.num_compute_rings; i++) {
  1151. unsigned irq_type;
  1152. /* max 32 queues per MEC */
  1153. if ((i >= 32) || (i >= AMDGPU_MAX_COMPUTE_RINGS)) {
  1154. DRM_ERROR("Too many (%d) compute rings!\n", i);
  1155. break;
  1156. }
  1157. ring = &adev->gfx.compute_ring[i];
  1158. ring->ring_obj = NULL;
  1159. ring->use_doorbell = true;
  1160. ring->doorbell_index = AMDGPU_DOORBELL_MEC_RING0 + i;
  1161. ring->me = 1; /* first MEC */
  1162. ring->pipe = i / 8;
  1163. ring->queue = i % 8;
  1164. sprintf(ring->name, "comp %d.%d.%d", ring->me, ring->pipe, ring->queue);
  1165. irq_type = AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE0_EOP + ring->pipe;
  1166. /* type-2 packets are deprecated on MEC, use type-3 instead */
  1167. r = amdgpu_ring_init(adev, ring, 1024 * 1024,
  1168. PACKET3(PACKET3_NOP, 0x3FFF), 0xf,
  1169. &adev->gfx.eop_irq, irq_type,
  1170. AMDGPU_RING_TYPE_COMPUTE);
  1171. if (r)
  1172. return r;
  1173. }
  1174. /* reserve GDS, GWS and OA resource for gfx */
  1175. r = amdgpu_bo_create(adev, adev->gds.mem.gfx_partition_size,
  1176. PAGE_SIZE, true,
  1177. AMDGPU_GEM_DOMAIN_GDS, 0, NULL,
  1178. NULL, &adev->gds.gds_gfx_bo);
  1179. if (r)
  1180. return r;
  1181. r = amdgpu_bo_create(adev, adev->gds.gws.gfx_partition_size,
  1182. PAGE_SIZE, true,
  1183. AMDGPU_GEM_DOMAIN_GWS, 0, NULL,
  1184. NULL, &adev->gds.gws_gfx_bo);
  1185. if (r)
  1186. return r;
  1187. r = amdgpu_bo_create(adev, adev->gds.oa.gfx_partition_size,
  1188. PAGE_SIZE, true,
  1189. AMDGPU_GEM_DOMAIN_OA, 0, NULL,
  1190. NULL, &adev->gds.oa_gfx_bo);
  1191. if (r)
  1192. return r;
  1193. adev->gfx.ce_ram_size = 0x8000;
  1194. gfx_v8_0_gpu_early_init(adev);
  1195. return 0;
  1196. }
  1197. static int gfx_v8_0_sw_fini(void *handle)
  1198. {
  1199. int i;
  1200. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  1201. amdgpu_bo_unref(&adev->gds.oa_gfx_bo);
  1202. amdgpu_bo_unref(&adev->gds.gws_gfx_bo);
  1203. amdgpu_bo_unref(&adev->gds.gds_gfx_bo);
  1204. for (i = 0; i < adev->gfx.num_gfx_rings; i++)
  1205. amdgpu_ring_fini(&adev->gfx.gfx_ring[i]);
  1206. for (i = 0; i < adev->gfx.num_compute_rings; i++)
  1207. amdgpu_ring_fini(&adev->gfx.compute_ring[i]);
  1208. gfx_v8_0_mec_fini(adev);
  1209. return 0;
  1210. }
  1211. static void gfx_v8_0_tiling_mode_table_init(struct amdgpu_device *adev)
  1212. {
  1213. const u32 num_tile_mode_states = 32;
  1214. const u32 num_secondary_tile_mode_states = 16;
  1215. u32 reg_offset, gb_tile_moden, split_equal_to_row_size;
  1216. switch (adev->gfx.config.mem_row_size_in_kb) {
  1217. case 1:
  1218. split_equal_to_row_size = ADDR_SURF_TILE_SPLIT_1KB;
  1219. break;
  1220. case 2:
  1221. default:
  1222. split_equal_to_row_size = ADDR_SURF_TILE_SPLIT_2KB;
  1223. break;
  1224. case 4:
  1225. split_equal_to_row_size = ADDR_SURF_TILE_SPLIT_4KB;
  1226. break;
  1227. }
  1228. switch (adev->asic_type) {
  1229. case CHIP_TOPAZ:
  1230. for (reg_offset = 0; reg_offset < num_tile_mode_states; reg_offset++) {
  1231. switch (reg_offset) {
  1232. case 0:
  1233. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1234. PIPE_CONFIG(ADDR_SURF_P2) |
  1235. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) |
  1236. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  1237. break;
  1238. case 1:
  1239. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1240. PIPE_CONFIG(ADDR_SURF_P2) |
  1241. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B) |
  1242. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  1243. break;
  1244. case 2:
  1245. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1246. PIPE_CONFIG(ADDR_SURF_P2) |
  1247. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  1248. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  1249. break;
  1250. case 3:
  1251. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1252. PIPE_CONFIG(ADDR_SURF_P2) |
  1253. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) |
  1254. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  1255. break;
  1256. case 4:
  1257. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1258. PIPE_CONFIG(ADDR_SURF_P2) |
  1259. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_2KB) |
  1260. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  1261. break;
  1262. case 5:
  1263. gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
  1264. PIPE_CONFIG(ADDR_SURF_P2) |
  1265. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_2KB) |
  1266. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  1267. break;
  1268. case 6:
  1269. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) |
  1270. PIPE_CONFIG(ADDR_SURF_P2) |
  1271. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_2KB) |
  1272. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  1273. break;
  1274. case 8:
  1275. gb_tile_moden = (ARRAY_MODE(ARRAY_LINEAR_ALIGNED) |
  1276. PIPE_CONFIG(ADDR_SURF_P2));
  1277. break;
  1278. case 9:
  1279. gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
  1280. PIPE_CONFIG(ADDR_SURF_P2) |
  1281. MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) |
  1282. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  1283. break;
  1284. case 10:
  1285. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1286. PIPE_CONFIG(ADDR_SURF_P2) |
  1287. MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) |
  1288. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  1289. break;
  1290. case 11:
  1291. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) |
  1292. PIPE_CONFIG(ADDR_SURF_P2) |
  1293. MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) |
  1294. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_8));
  1295. break;
  1296. case 13:
  1297. gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
  1298. PIPE_CONFIG(ADDR_SURF_P2) |
  1299. MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) |
  1300. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  1301. break;
  1302. case 14:
  1303. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1304. PIPE_CONFIG(ADDR_SURF_P2) |
  1305. MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) |
  1306. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  1307. break;
  1308. case 15:
  1309. gb_tile_moden = (ARRAY_MODE(ARRAY_3D_TILED_THIN1) |
  1310. PIPE_CONFIG(ADDR_SURF_P2) |
  1311. MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) |
  1312. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  1313. break;
  1314. case 16:
  1315. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) |
  1316. PIPE_CONFIG(ADDR_SURF_P2) |
  1317. MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) |
  1318. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_8));
  1319. break;
  1320. case 18:
  1321. gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THICK) |
  1322. PIPE_CONFIG(ADDR_SURF_P2) |
  1323. MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) |
  1324. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  1325. break;
  1326. case 19:
  1327. gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THICK) |
  1328. PIPE_CONFIG(ADDR_SURF_P2) |
  1329. MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING) |
  1330. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  1331. break;
  1332. case 20:
  1333. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THICK) |
  1334. PIPE_CONFIG(ADDR_SURF_P2) |
  1335. MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING) |
  1336. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  1337. break;
  1338. case 21:
  1339. gb_tile_moden = (ARRAY_MODE(ARRAY_3D_TILED_THICK) |
  1340. PIPE_CONFIG(ADDR_SURF_P2) |
  1341. MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING) |
  1342. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  1343. break;
  1344. case 22:
  1345. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THICK) |
  1346. PIPE_CONFIG(ADDR_SURF_P2) |
  1347. MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING) |
  1348. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  1349. break;
  1350. case 24:
  1351. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THICK) |
  1352. PIPE_CONFIG(ADDR_SURF_P2) |
  1353. MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) |
  1354. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  1355. break;
  1356. case 25:
  1357. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_XTHICK) |
  1358. PIPE_CONFIG(ADDR_SURF_P2) |
  1359. MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING) |
  1360. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  1361. break;
  1362. case 26:
  1363. gb_tile_moden = (ARRAY_MODE(ARRAY_3D_TILED_XTHICK) |
  1364. PIPE_CONFIG(ADDR_SURF_P2) |
  1365. MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING) |
  1366. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  1367. break;
  1368. case 27:
  1369. gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
  1370. PIPE_CONFIG(ADDR_SURF_P2) |
  1371. MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) |
  1372. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  1373. break;
  1374. case 28:
  1375. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1376. PIPE_CONFIG(ADDR_SURF_P2) |
  1377. MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) |
  1378. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  1379. break;
  1380. case 29:
  1381. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) |
  1382. PIPE_CONFIG(ADDR_SURF_P2) |
  1383. MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) |
  1384. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_8));
  1385. break;
  1386. case 7:
  1387. case 12:
  1388. case 17:
  1389. case 23:
  1390. /* unused idx */
  1391. continue;
  1392. default:
  1393. gb_tile_moden = 0;
  1394. break;
  1395. };
  1396. adev->gfx.config.tile_mode_array[reg_offset] = gb_tile_moden;
  1397. WREG32(mmGB_TILE_MODE0 + reg_offset, gb_tile_moden);
  1398. }
  1399. for (reg_offset = 0; reg_offset < num_secondary_tile_mode_states; reg_offset++) {
  1400. switch (reg_offset) {
  1401. case 0:
  1402. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_4) |
  1403. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  1404. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  1405. NUM_BANKS(ADDR_SURF_8_BANK));
  1406. break;
  1407. case 1:
  1408. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_4) |
  1409. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  1410. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  1411. NUM_BANKS(ADDR_SURF_8_BANK));
  1412. break;
  1413. case 2:
  1414. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2) |
  1415. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  1416. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  1417. NUM_BANKS(ADDR_SURF_8_BANK));
  1418. break;
  1419. case 3:
  1420. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1421. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  1422. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  1423. NUM_BANKS(ADDR_SURF_8_BANK));
  1424. break;
  1425. case 4:
  1426. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1427. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  1428. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  1429. NUM_BANKS(ADDR_SURF_8_BANK));
  1430. break;
  1431. case 5:
  1432. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1433. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  1434. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  1435. NUM_BANKS(ADDR_SURF_8_BANK));
  1436. break;
  1437. case 6:
  1438. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1439. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  1440. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  1441. NUM_BANKS(ADDR_SURF_8_BANK));
  1442. break;
  1443. case 8:
  1444. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_4) |
  1445. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_8) |
  1446. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  1447. NUM_BANKS(ADDR_SURF_16_BANK));
  1448. break;
  1449. case 9:
  1450. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_4) |
  1451. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  1452. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  1453. NUM_BANKS(ADDR_SURF_16_BANK));
  1454. break;
  1455. case 10:
  1456. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2) |
  1457. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  1458. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  1459. NUM_BANKS(ADDR_SURF_16_BANK));
  1460. break;
  1461. case 11:
  1462. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2) |
  1463. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  1464. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  1465. NUM_BANKS(ADDR_SURF_16_BANK));
  1466. break;
  1467. case 12:
  1468. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1469. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  1470. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  1471. NUM_BANKS(ADDR_SURF_16_BANK));
  1472. break;
  1473. case 13:
  1474. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1475. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  1476. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  1477. NUM_BANKS(ADDR_SURF_16_BANK));
  1478. break;
  1479. case 14:
  1480. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1481. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  1482. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  1483. NUM_BANKS(ADDR_SURF_8_BANK));
  1484. break;
  1485. case 7:
  1486. /* unused idx */
  1487. continue;
  1488. default:
  1489. gb_tile_moden = 0;
  1490. break;
  1491. };
  1492. adev->gfx.config.macrotile_mode_array[reg_offset] = gb_tile_moden;
  1493. WREG32(mmGB_MACROTILE_MODE0 + reg_offset, gb_tile_moden);
  1494. }
  1495. case CHIP_FIJI:
  1496. for (reg_offset = 0; reg_offset < num_tile_mode_states; reg_offset++) {
  1497. switch (reg_offset) {
  1498. case 0:
  1499. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1500. PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16) |
  1501. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) |
  1502. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  1503. break;
  1504. case 1:
  1505. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1506. PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16) |
  1507. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B) |
  1508. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  1509. break;
  1510. case 2:
  1511. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1512. PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16) |
  1513. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  1514. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  1515. break;
  1516. case 3:
  1517. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1518. PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16) |
  1519. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) |
  1520. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  1521. break;
  1522. case 4:
  1523. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1524. PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16) |
  1525. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_2KB) |
  1526. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  1527. break;
  1528. case 5:
  1529. gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
  1530. PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16) |
  1531. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_2KB) |
  1532. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  1533. break;
  1534. case 6:
  1535. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) |
  1536. PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16) |
  1537. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_2KB) |
  1538. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  1539. break;
  1540. case 7:
  1541. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) |
  1542. PIPE_CONFIG(ADDR_SURF_P4_16x16) |
  1543. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_2KB) |
  1544. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  1545. break;
  1546. case 8:
  1547. gb_tile_moden = (ARRAY_MODE(ARRAY_LINEAR_ALIGNED) |
  1548. PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16));
  1549. break;
  1550. case 9:
  1551. gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
  1552. PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16) |
  1553. MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) |
  1554. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  1555. break;
  1556. case 10:
  1557. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1558. PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16) |
  1559. MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) |
  1560. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  1561. break;
  1562. case 11:
  1563. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) |
  1564. PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16) |
  1565. MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) |
  1566. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_8));
  1567. break;
  1568. case 12:
  1569. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) |
  1570. PIPE_CONFIG(ADDR_SURF_P4_16x16) |
  1571. MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) |
  1572. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_8));
  1573. break;
  1574. case 13:
  1575. gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
  1576. PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16) |
  1577. MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) |
  1578. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  1579. break;
  1580. case 14:
  1581. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1582. PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16) |
  1583. MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) |
  1584. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  1585. break;
  1586. case 15:
  1587. gb_tile_moden = (ARRAY_MODE(ARRAY_3D_TILED_THIN1) |
  1588. PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16) |
  1589. MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) |
  1590. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  1591. break;
  1592. case 16:
  1593. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) |
  1594. PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16) |
  1595. MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) |
  1596. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_8));
  1597. break;
  1598. case 17:
  1599. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) |
  1600. PIPE_CONFIG(ADDR_SURF_P4_16x16) |
  1601. MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) |
  1602. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_8));
  1603. break;
  1604. case 18:
  1605. gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THICK) |
  1606. PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16) |
  1607. MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) |
  1608. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  1609. break;
  1610. case 19:
  1611. gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THICK) |
  1612. PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16) |
  1613. MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING) |
  1614. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  1615. break;
  1616. case 20:
  1617. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THICK) |
  1618. PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16) |
  1619. MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING) |
  1620. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  1621. break;
  1622. case 21:
  1623. gb_tile_moden = (ARRAY_MODE(ARRAY_3D_TILED_THICK) |
  1624. PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16) |
  1625. MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING) |
  1626. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  1627. break;
  1628. case 22:
  1629. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THICK) |
  1630. PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16) |
  1631. MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING) |
  1632. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  1633. break;
  1634. case 23:
  1635. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THICK) |
  1636. PIPE_CONFIG(ADDR_SURF_P4_16x16) |
  1637. MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING) |
  1638. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  1639. break;
  1640. case 24:
  1641. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THICK) |
  1642. PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16) |
  1643. MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) |
  1644. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  1645. break;
  1646. case 25:
  1647. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_XTHICK) |
  1648. PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16) |
  1649. MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING) |
  1650. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  1651. break;
  1652. case 26:
  1653. gb_tile_moden = (ARRAY_MODE(ARRAY_3D_TILED_XTHICK) |
  1654. PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16) |
  1655. MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING) |
  1656. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  1657. break;
  1658. case 27:
  1659. gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
  1660. PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16) |
  1661. MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) |
  1662. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  1663. break;
  1664. case 28:
  1665. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1666. PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16) |
  1667. MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) |
  1668. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  1669. break;
  1670. case 29:
  1671. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) |
  1672. PIPE_CONFIG(ADDR_SURF_P16_32x32_16x16) |
  1673. MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) |
  1674. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_8));
  1675. break;
  1676. case 30:
  1677. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) |
  1678. PIPE_CONFIG(ADDR_SURF_P4_16x16) |
  1679. MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) |
  1680. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_8));
  1681. break;
  1682. default:
  1683. gb_tile_moden = 0;
  1684. break;
  1685. }
  1686. adev->gfx.config.tile_mode_array[reg_offset] = gb_tile_moden;
  1687. WREG32(mmGB_TILE_MODE0 + reg_offset, gb_tile_moden);
  1688. }
  1689. for (reg_offset = 0; reg_offset < num_secondary_tile_mode_states; reg_offset++) {
  1690. switch (reg_offset) {
  1691. case 0:
  1692. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1693. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  1694. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  1695. NUM_BANKS(ADDR_SURF_8_BANK));
  1696. break;
  1697. case 1:
  1698. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1699. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  1700. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  1701. NUM_BANKS(ADDR_SURF_8_BANK));
  1702. break;
  1703. case 2:
  1704. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1705. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  1706. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  1707. NUM_BANKS(ADDR_SURF_8_BANK));
  1708. break;
  1709. case 3:
  1710. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1711. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  1712. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  1713. NUM_BANKS(ADDR_SURF_8_BANK));
  1714. break;
  1715. case 4:
  1716. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1717. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  1718. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  1719. NUM_BANKS(ADDR_SURF_8_BANK));
  1720. break;
  1721. case 5:
  1722. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1723. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  1724. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  1725. NUM_BANKS(ADDR_SURF_8_BANK));
  1726. break;
  1727. case 6:
  1728. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1729. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  1730. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  1731. NUM_BANKS(ADDR_SURF_8_BANK));
  1732. break;
  1733. case 8:
  1734. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1735. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_8) |
  1736. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  1737. NUM_BANKS(ADDR_SURF_8_BANK));
  1738. break;
  1739. case 9:
  1740. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1741. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  1742. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  1743. NUM_BANKS(ADDR_SURF_8_BANK));
  1744. break;
  1745. case 10:
  1746. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1747. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  1748. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  1749. NUM_BANKS(ADDR_SURF_8_BANK));
  1750. break;
  1751. case 11:
  1752. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1753. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  1754. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  1755. NUM_BANKS(ADDR_SURF_8_BANK));
  1756. break;
  1757. case 12:
  1758. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1759. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  1760. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  1761. NUM_BANKS(ADDR_SURF_8_BANK));
  1762. break;
  1763. case 13:
  1764. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1765. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  1766. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  1767. NUM_BANKS(ADDR_SURF_8_BANK));
  1768. break;
  1769. case 14:
  1770. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1771. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  1772. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  1773. NUM_BANKS(ADDR_SURF_4_BANK));
  1774. break;
  1775. case 7:
  1776. /* unused idx */
  1777. continue;
  1778. default:
  1779. gb_tile_moden = 0;
  1780. break;
  1781. }
  1782. adev->gfx.config.macrotile_mode_array[reg_offset] = gb_tile_moden;
  1783. WREG32(mmGB_MACROTILE_MODE0 + reg_offset, gb_tile_moden);
  1784. }
  1785. break;
  1786. case CHIP_TONGA:
  1787. for (reg_offset = 0; reg_offset < num_tile_mode_states; reg_offset++) {
  1788. switch (reg_offset) {
  1789. case 0:
  1790. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1791. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) |
  1792. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) |
  1793. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  1794. break;
  1795. case 1:
  1796. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1797. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) |
  1798. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B) |
  1799. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  1800. break;
  1801. case 2:
  1802. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1803. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) |
  1804. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  1805. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  1806. break;
  1807. case 3:
  1808. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1809. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) |
  1810. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) |
  1811. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  1812. break;
  1813. case 4:
  1814. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1815. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) |
  1816. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_2KB) |
  1817. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  1818. break;
  1819. case 5:
  1820. gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
  1821. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) |
  1822. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_2KB) |
  1823. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  1824. break;
  1825. case 6:
  1826. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) |
  1827. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) |
  1828. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_2KB) |
  1829. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  1830. break;
  1831. case 7:
  1832. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) |
  1833. PIPE_CONFIG(ADDR_SURF_P4_16x16) |
  1834. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_2KB) |
  1835. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  1836. break;
  1837. case 8:
  1838. gb_tile_moden = (ARRAY_MODE(ARRAY_LINEAR_ALIGNED) |
  1839. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16));
  1840. break;
  1841. case 9:
  1842. gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
  1843. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) |
  1844. MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) |
  1845. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  1846. break;
  1847. case 10:
  1848. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1849. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) |
  1850. MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) |
  1851. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  1852. break;
  1853. case 11:
  1854. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) |
  1855. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) |
  1856. MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) |
  1857. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_8));
  1858. break;
  1859. case 12:
  1860. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) |
  1861. PIPE_CONFIG(ADDR_SURF_P4_16x16) |
  1862. MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) |
  1863. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_8));
  1864. break;
  1865. case 13:
  1866. gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
  1867. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) |
  1868. MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) |
  1869. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  1870. break;
  1871. case 14:
  1872. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1873. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) |
  1874. MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) |
  1875. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  1876. break;
  1877. case 15:
  1878. gb_tile_moden = (ARRAY_MODE(ARRAY_3D_TILED_THIN1) |
  1879. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) |
  1880. MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) |
  1881. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  1882. break;
  1883. case 16:
  1884. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) |
  1885. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) |
  1886. MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) |
  1887. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_8));
  1888. break;
  1889. case 17:
  1890. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) |
  1891. PIPE_CONFIG(ADDR_SURF_P4_16x16) |
  1892. MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) |
  1893. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_8));
  1894. break;
  1895. case 18:
  1896. gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THICK) |
  1897. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) |
  1898. MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) |
  1899. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  1900. break;
  1901. case 19:
  1902. gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THICK) |
  1903. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) |
  1904. MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING) |
  1905. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  1906. break;
  1907. case 20:
  1908. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THICK) |
  1909. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) |
  1910. MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING) |
  1911. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  1912. break;
  1913. case 21:
  1914. gb_tile_moden = (ARRAY_MODE(ARRAY_3D_TILED_THICK) |
  1915. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) |
  1916. MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING) |
  1917. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  1918. break;
  1919. case 22:
  1920. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THICK) |
  1921. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) |
  1922. MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING) |
  1923. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  1924. break;
  1925. case 23:
  1926. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THICK) |
  1927. PIPE_CONFIG(ADDR_SURF_P4_16x16) |
  1928. MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING) |
  1929. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  1930. break;
  1931. case 24:
  1932. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THICK) |
  1933. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) |
  1934. MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) |
  1935. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  1936. break;
  1937. case 25:
  1938. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_XTHICK) |
  1939. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) |
  1940. MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING) |
  1941. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  1942. break;
  1943. case 26:
  1944. gb_tile_moden = (ARRAY_MODE(ARRAY_3D_TILED_XTHICK) |
  1945. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) |
  1946. MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING) |
  1947. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  1948. break;
  1949. case 27:
  1950. gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
  1951. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) |
  1952. MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) |
  1953. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  1954. break;
  1955. case 28:
  1956. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  1957. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) |
  1958. MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) |
  1959. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  1960. break;
  1961. case 29:
  1962. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) |
  1963. PIPE_CONFIG(ADDR_SURF_P8_32x32_16x16) |
  1964. MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) |
  1965. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_8));
  1966. break;
  1967. case 30:
  1968. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) |
  1969. PIPE_CONFIG(ADDR_SURF_P4_16x16) |
  1970. MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) |
  1971. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_8));
  1972. break;
  1973. default:
  1974. gb_tile_moden = 0;
  1975. break;
  1976. };
  1977. adev->gfx.config.tile_mode_array[reg_offset] = gb_tile_moden;
  1978. WREG32(mmGB_TILE_MODE0 + reg_offset, gb_tile_moden);
  1979. }
  1980. for (reg_offset = 0; reg_offset < num_secondary_tile_mode_states; reg_offset++) {
  1981. switch (reg_offset) {
  1982. case 0:
  1983. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1984. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  1985. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  1986. NUM_BANKS(ADDR_SURF_16_BANK));
  1987. break;
  1988. case 1:
  1989. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1990. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  1991. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  1992. NUM_BANKS(ADDR_SURF_16_BANK));
  1993. break;
  1994. case 2:
  1995. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  1996. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  1997. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  1998. NUM_BANKS(ADDR_SURF_16_BANK));
  1999. break;
  2000. case 3:
  2001. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  2002. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  2003. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  2004. NUM_BANKS(ADDR_SURF_16_BANK));
  2005. break;
  2006. case 4:
  2007. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  2008. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  2009. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  2010. NUM_BANKS(ADDR_SURF_16_BANK));
  2011. break;
  2012. case 5:
  2013. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  2014. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  2015. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  2016. NUM_BANKS(ADDR_SURF_16_BANK));
  2017. break;
  2018. case 6:
  2019. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  2020. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  2021. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  2022. NUM_BANKS(ADDR_SURF_16_BANK));
  2023. break;
  2024. case 8:
  2025. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  2026. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_8) |
  2027. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  2028. NUM_BANKS(ADDR_SURF_16_BANK));
  2029. break;
  2030. case 9:
  2031. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  2032. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  2033. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  2034. NUM_BANKS(ADDR_SURF_16_BANK));
  2035. break;
  2036. case 10:
  2037. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  2038. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  2039. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  2040. NUM_BANKS(ADDR_SURF_16_BANK));
  2041. break;
  2042. case 11:
  2043. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  2044. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  2045. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  2046. NUM_BANKS(ADDR_SURF_16_BANK));
  2047. break;
  2048. case 12:
  2049. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  2050. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  2051. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  2052. NUM_BANKS(ADDR_SURF_8_BANK));
  2053. break;
  2054. case 13:
  2055. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  2056. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  2057. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  2058. NUM_BANKS(ADDR_SURF_4_BANK));
  2059. break;
  2060. case 14:
  2061. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  2062. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  2063. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_1) |
  2064. NUM_BANKS(ADDR_SURF_4_BANK));
  2065. break;
  2066. case 7:
  2067. /* unused idx */
  2068. continue;
  2069. default:
  2070. gb_tile_moden = 0;
  2071. break;
  2072. };
  2073. adev->gfx.config.macrotile_mode_array[reg_offset] = gb_tile_moden;
  2074. WREG32(mmGB_MACROTILE_MODE0 + reg_offset, gb_tile_moden);
  2075. }
  2076. break;
  2077. case CHIP_STONEY:
  2078. for (reg_offset = 0; reg_offset < num_tile_mode_states; reg_offset++) {
  2079. switch (reg_offset) {
  2080. case 0:
  2081. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  2082. PIPE_CONFIG(ADDR_SURF_P2) |
  2083. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) |
  2084. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  2085. break;
  2086. case 1:
  2087. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  2088. PIPE_CONFIG(ADDR_SURF_P2) |
  2089. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B) |
  2090. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  2091. break;
  2092. case 2:
  2093. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  2094. PIPE_CONFIG(ADDR_SURF_P2) |
  2095. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  2096. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  2097. break;
  2098. case 3:
  2099. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  2100. PIPE_CONFIG(ADDR_SURF_P2) |
  2101. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) |
  2102. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  2103. break;
  2104. case 4:
  2105. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  2106. PIPE_CONFIG(ADDR_SURF_P2) |
  2107. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_2KB) |
  2108. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  2109. break;
  2110. case 5:
  2111. gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
  2112. PIPE_CONFIG(ADDR_SURF_P2) |
  2113. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_2KB) |
  2114. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  2115. break;
  2116. case 6:
  2117. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) |
  2118. PIPE_CONFIG(ADDR_SURF_P2) |
  2119. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_2KB) |
  2120. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  2121. break;
  2122. case 8:
  2123. gb_tile_moden = (ARRAY_MODE(ARRAY_LINEAR_ALIGNED) |
  2124. PIPE_CONFIG(ADDR_SURF_P2));
  2125. break;
  2126. case 9:
  2127. gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
  2128. PIPE_CONFIG(ADDR_SURF_P2) |
  2129. MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) |
  2130. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  2131. break;
  2132. case 10:
  2133. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  2134. PIPE_CONFIG(ADDR_SURF_P2) |
  2135. MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) |
  2136. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  2137. break;
  2138. case 11:
  2139. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) |
  2140. PIPE_CONFIG(ADDR_SURF_P2) |
  2141. MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) |
  2142. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_8));
  2143. break;
  2144. case 13:
  2145. gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
  2146. PIPE_CONFIG(ADDR_SURF_P2) |
  2147. MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) |
  2148. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  2149. break;
  2150. case 14:
  2151. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  2152. PIPE_CONFIG(ADDR_SURF_P2) |
  2153. MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) |
  2154. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  2155. break;
  2156. case 15:
  2157. gb_tile_moden = (ARRAY_MODE(ARRAY_3D_TILED_THIN1) |
  2158. PIPE_CONFIG(ADDR_SURF_P2) |
  2159. MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) |
  2160. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  2161. break;
  2162. case 16:
  2163. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) |
  2164. PIPE_CONFIG(ADDR_SURF_P2) |
  2165. MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) |
  2166. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_8));
  2167. break;
  2168. case 18:
  2169. gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THICK) |
  2170. PIPE_CONFIG(ADDR_SURF_P2) |
  2171. MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) |
  2172. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  2173. break;
  2174. case 19:
  2175. gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THICK) |
  2176. PIPE_CONFIG(ADDR_SURF_P2) |
  2177. MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING) |
  2178. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  2179. break;
  2180. case 20:
  2181. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THICK) |
  2182. PIPE_CONFIG(ADDR_SURF_P2) |
  2183. MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING) |
  2184. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  2185. break;
  2186. case 21:
  2187. gb_tile_moden = (ARRAY_MODE(ARRAY_3D_TILED_THICK) |
  2188. PIPE_CONFIG(ADDR_SURF_P2) |
  2189. MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING) |
  2190. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  2191. break;
  2192. case 22:
  2193. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THICK) |
  2194. PIPE_CONFIG(ADDR_SURF_P2) |
  2195. MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING) |
  2196. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  2197. break;
  2198. case 24:
  2199. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THICK) |
  2200. PIPE_CONFIG(ADDR_SURF_P2) |
  2201. MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) |
  2202. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  2203. break;
  2204. case 25:
  2205. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_XTHICK) |
  2206. PIPE_CONFIG(ADDR_SURF_P2) |
  2207. MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING) |
  2208. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  2209. break;
  2210. case 26:
  2211. gb_tile_moden = (ARRAY_MODE(ARRAY_3D_TILED_XTHICK) |
  2212. PIPE_CONFIG(ADDR_SURF_P2) |
  2213. MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING) |
  2214. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  2215. break;
  2216. case 27:
  2217. gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
  2218. PIPE_CONFIG(ADDR_SURF_P2) |
  2219. MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) |
  2220. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  2221. break;
  2222. case 28:
  2223. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  2224. PIPE_CONFIG(ADDR_SURF_P2) |
  2225. MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) |
  2226. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  2227. break;
  2228. case 29:
  2229. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) |
  2230. PIPE_CONFIG(ADDR_SURF_P2) |
  2231. MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) |
  2232. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_8));
  2233. break;
  2234. case 7:
  2235. case 12:
  2236. case 17:
  2237. case 23:
  2238. /* unused idx */
  2239. continue;
  2240. default:
  2241. gb_tile_moden = 0;
  2242. break;
  2243. };
  2244. adev->gfx.config.tile_mode_array[reg_offset] = gb_tile_moden;
  2245. WREG32(mmGB_TILE_MODE0 + reg_offset, gb_tile_moden);
  2246. }
  2247. for (reg_offset = 0; reg_offset < num_secondary_tile_mode_states; reg_offset++) {
  2248. switch (reg_offset) {
  2249. case 0:
  2250. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  2251. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  2252. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  2253. NUM_BANKS(ADDR_SURF_8_BANK));
  2254. break;
  2255. case 1:
  2256. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  2257. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  2258. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  2259. NUM_BANKS(ADDR_SURF_8_BANK));
  2260. break;
  2261. case 2:
  2262. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  2263. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  2264. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  2265. NUM_BANKS(ADDR_SURF_8_BANK));
  2266. break;
  2267. case 3:
  2268. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  2269. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  2270. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  2271. NUM_BANKS(ADDR_SURF_8_BANK));
  2272. break;
  2273. case 4:
  2274. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  2275. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  2276. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  2277. NUM_BANKS(ADDR_SURF_8_BANK));
  2278. break;
  2279. case 5:
  2280. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  2281. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  2282. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  2283. NUM_BANKS(ADDR_SURF_8_BANK));
  2284. break;
  2285. case 6:
  2286. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  2287. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  2288. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  2289. NUM_BANKS(ADDR_SURF_8_BANK));
  2290. break;
  2291. case 8:
  2292. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_4) |
  2293. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_8) |
  2294. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  2295. NUM_BANKS(ADDR_SURF_16_BANK));
  2296. break;
  2297. case 9:
  2298. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_4) |
  2299. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  2300. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  2301. NUM_BANKS(ADDR_SURF_16_BANK));
  2302. break;
  2303. case 10:
  2304. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2) |
  2305. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  2306. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  2307. NUM_BANKS(ADDR_SURF_16_BANK));
  2308. break;
  2309. case 11:
  2310. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2) |
  2311. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  2312. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  2313. NUM_BANKS(ADDR_SURF_16_BANK));
  2314. break;
  2315. case 12:
  2316. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  2317. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  2318. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  2319. NUM_BANKS(ADDR_SURF_16_BANK));
  2320. break;
  2321. case 13:
  2322. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  2323. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  2324. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  2325. NUM_BANKS(ADDR_SURF_16_BANK));
  2326. break;
  2327. case 14:
  2328. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  2329. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  2330. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  2331. NUM_BANKS(ADDR_SURF_8_BANK));
  2332. break;
  2333. case 7:
  2334. /* unused idx */
  2335. continue;
  2336. default:
  2337. gb_tile_moden = 0;
  2338. break;
  2339. };
  2340. adev->gfx.config.macrotile_mode_array[reg_offset] = gb_tile_moden;
  2341. WREG32(mmGB_MACROTILE_MODE0 + reg_offset, gb_tile_moden);
  2342. }
  2343. break;
  2344. case CHIP_CARRIZO:
  2345. default:
  2346. for (reg_offset = 0; reg_offset < num_tile_mode_states; reg_offset++) {
  2347. switch (reg_offset) {
  2348. case 0:
  2349. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  2350. PIPE_CONFIG(ADDR_SURF_P2) |
  2351. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_64B) |
  2352. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  2353. break;
  2354. case 1:
  2355. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  2356. PIPE_CONFIG(ADDR_SURF_P2) |
  2357. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_128B) |
  2358. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  2359. break;
  2360. case 2:
  2361. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  2362. PIPE_CONFIG(ADDR_SURF_P2) |
  2363. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_256B) |
  2364. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  2365. break;
  2366. case 3:
  2367. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  2368. PIPE_CONFIG(ADDR_SURF_P2) |
  2369. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_512B) |
  2370. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  2371. break;
  2372. case 4:
  2373. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  2374. PIPE_CONFIG(ADDR_SURF_P2) |
  2375. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_2KB) |
  2376. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  2377. break;
  2378. case 5:
  2379. gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
  2380. PIPE_CONFIG(ADDR_SURF_P2) |
  2381. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_2KB) |
  2382. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  2383. break;
  2384. case 6:
  2385. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) |
  2386. PIPE_CONFIG(ADDR_SURF_P2) |
  2387. TILE_SPLIT(ADDR_SURF_TILE_SPLIT_2KB) |
  2388. MICRO_TILE_MODE_NEW(ADDR_SURF_DEPTH_MICRO_TILING));
  2389. break;
  2390. case 8:
  2391. gb_tile_moden = (ARRAY_MODE(ARRAY_LINEAR_ALIGNED) |
  2392. PIPE_CONFIG(ADDR_SURF_P2));
  2393. break;
  2394. case 9:
  2395. gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
  2396. PIPE_CONFIG(ADDR_SURF_P2) |
  2397. MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) |
  2398. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  2399. break;
  2400. case 10:
  2401. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  2402. PIPE_CONFIG(ADDR_SURF_P2) |
  2403. MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) |
  2404. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  2405. break;
  2406. case 11:
  2407. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) |
  2408. PIPE_CONFIG(ADDR_SURF_P2) |
  2409. MICRO_TILE_MODE_NEW(ADDR_SURF_DISPLAY_MICRO_TILING) |
  2410. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_8));
  2411. break;
  2412. case 13:
  2413. gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
  2414. PIPE_CONFIG(ADDR_SURF_P2) |
  2415. MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) |
  2416. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  2417. break;
  2418. case 14:
  2419. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  2420. PIPE_CONFIG(ADDR_SURF_P2) |
  2421. MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) |
  2422. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  2423. break;
  2424. case 15:
  2425. gb_tile_moden = (ARRAY_MODE(ARRAY_3D_TILED_THIN1) |
  2426. PIPE_CONFIG(ADDR_SURF_P2) |
  2427. MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) |
  2428. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  2429. break;
  2430. case 16:
  2431. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) |
  2432. PIPE_CONFIG(ADDR_SURF_P2) |
  2433. MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) |
  2434. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_8));
  2435. break;
  2436. case 18:
  2437. gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THICK) |
  2438. PIPE_CONFIG(ADDR_SURF_P2) |
  2439. MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) |
  2440. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  2441. break;
  2442. case 19:
  2443. gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THICK) |
  2444. PIPE_CONFIG(ADDR_SURF_P2) |
  2445. MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING) |
  2446. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  2447. break;
  2448. case 20:
  2449. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THICK) |
  2450. PIPE_CONFIG(ADDR_SURF_P2) |
  2451. MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING) |
  2452. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  2453. break;
  2454. case 21:
  2455. gb_tile_moden = (ARRAY_MODE(ARRAY_3D_TILED_THICK) |
  2456. PIPE_CONFIG(ADDR_SURF_P2) |
  2457. MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING) |
  2458. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  2459. break;
  2460. case 22:
  2461. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THICK) |
  2462. PIPE_CONFIG(ADDR_SURF_P2) |
  2463. MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING) |
  2464. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  2465. break;
  2466. case 24:
  2467. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THICK) |
  2468. PIPE_CONFIG(ADDR_SURF_P2) |
  2469. MICRO_TILE_MODE_NEW(ADDR_SURF_THIN_MICRO_TILING) |
  2470. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  2471. break;
  2472. case 25:
  2473. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_XTHICK) |
  2474. PIPE_CONFIG(ADDR_SURF_P2) |
  2475. MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING) |
  2476. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  2477. break;
  2478. case 26:
  2479. gb_tile_moden = (ARRAY_MODE(ARRAY_3D_TILED_XTHICK) |
  2480. PIPE_CONFIG(ADDR_SURF_P2) |
  2481. MICRO_TILE_MODE_NEW(ADDR_SURF_THICK_MICRO_TILING) |
  2482. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_1));
  2483. break;
  2484. case 27:
  2485. gb_tile_moden = (ARRAY_MODE(ARRAY_1D_TILED_THIN1) |
  2486. PIPE_CONFIG(ADDR_SURF_P2) |
  2487. MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) |
  2488. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  2489. break;
  2490. case 28:
  2491. gb_tile_moden = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
  2492. PIPE_CONFIG(ADDR_SURF_P2) |
  2493. MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) |
  2494. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_2));
  2495. break;
  2496. case 29:
  2497. gb_tile_moden = (ARRAY_MODE(ARRAY_PRT_TILED_THIN1) |
  2498. PIPE_CONFIG(ADDR_SURF_P2) |
  2499. MICRO_TILE_MODE_NEW(ADDR_SURF_ROTATED_MICRO_TILING) |
  2500. SAMPLE_SPLIT(ADDR_SURF_SAMPLE_SPLIT_8));
  2501. break;
  2502. case 7:
  2503. case 12:
  2504. case 17:
  2505. case 23:
  2506. /* unused idx */
  2507. continue;
  2508. default:
  2509. gb_tile_moden = 0;
  2510. break;
  2511. };
  2512. adev->gfx.config.tile_mode_array[reg_offset] = gb_tile_moden;
  2513. WREG32(mmGB_TILE_MODE0 + reg_offset, gb_tile_moden);
  2514. }
  2515. for (reg_offset = 0; reg_offset < num_secondary_tile_mode_states; reg_offset++) {
  2516. switch (reg_offset) {
  2517. case 0:
  2518. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  2519. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  2520. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  2521. NUM_BANKS(ADDR_SURF_8_BANK));
  2522. break;
  2523. case 1:
  2524. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  2525. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  2526. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  2527. NUM_BANKS(ADDR_SURF_8_BANK));
  2528. break;
  2529. case 2:
  2530. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  2531. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  2532. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  2533. NUM_BANKS(ADDR_SURF_8_BANK));
  2534. break;
  2535. case 3:
  2536. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  2537. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  2538. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  2539. NUM_BANKS(ADDR_SURF_8_BANK));
  2540. break;
  2541. case 4:
  2542. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  2543. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  2544. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  2545. NUM_BANKS(ADDR_SURF_8_BANK));
  2546. break;
  2547. case 5:
  2548. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  2549. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  2550. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  2551. NUM_BANKS(ADDR_SURF_8_BANK));
  2552. break;
  2553. case 6:
  2554. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  2555. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  2556. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  2557. NUM_BANKS(ADDR_SURF_8_BANK));
  2558. break;
  2559. case 8:
  2560. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_4) |
  2561. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_8) |
  2562. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  2563. NUM_BANKS(ADDR_SURF_16_BANK));
  2564. break;
  2565. case 9:
  2566. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_4) |
  2567. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  2568. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  2569. NUM_BANKS(ADDR_SURF_16_BANK));
  2570. break;
  2571. case 10:
  2572. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2) |
  2573. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_4) |
  2574. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  2575. NUM_BANKS(ADDR_SURF_16_BANK));
  2576. break;
  2577. case 11:
  2578. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_2) |
  2579. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  2580. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  2581. NUM_BANKS(ADDR_SURF_16_BANK));
  2582. break;
  2583. case 12:
  2584. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  2585. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_2) |
  2586. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  2587. NUM_BANKS(ADDR_SURF_16_BANK));
  2588. break;
  2589. case 13:
  2590. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  2591. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  2592. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_4) |
  2593. NUM_BANKS(ADDR_SURF_16_BANK));
  2594. break;
  2595. case 14:
  2596. gb_tile_moden = (BANK_WIDTH(ADDR_SURF_BANK_WIDTH_1) |
  2597. BANK_HEIGHT(ADDR_SURF_BANK_HEIGHT_1) |
  2598. MACRO_TILE_ASPECT(ADDR_SURF_MACRO_ASPECT_2) |
  2599. NUM_BANKS(ADDR_SURF_8_BANK));
  2600. break;
  2601. case 7:
  2602. /* unused idx */
  2603. continue;
  2604. default:
  2605. gb_tile_moden = 0;
  2606. break;
  2607. };
  2608. adev->gfx.config.macrotile_mode_array[reg_offset] = gb_tile_moden;
  2609. WREG32(mmGB_MACROTILE_MODE0 + reg_offset, gb_tile_moden);
  2610. }
  2611. }
  2612. }
  2613. static u32 gfx_v8_0_create_bitmask(u32 bit_width)
  2614. {
  2615. u32 i, mask = 0;
  2616. for (i = 0; i < bit_width; i++) {
  2617. mask <<= 1;
  2618. mask |= 1;
  2619. }
  2620. return mask;
  2621. }
  2622. void gfx_v8_0_select_se_sh(struct amdgpu_device *adev, u32 se_num, u32 sh_num)
  2623. {
  2624. u32 data = REG_SET_FIELD(0, GRBM_GFX_INDEX, INSTANCE_BROADCAST_WRITES, 1);
  2625. if ((se_num == 0xffffffff) && (sh_num == 0xffffffff)) {
  2626. data = REG_SET_FIELD(data, GRBM_GFX_INDEX, SH_BROADCAST_WRITES, 1);
  2627. data = REG_SET_FIELD(data, GRBM_GFX_INDEX, SE_BROADCAST_WRITES, 1);
  2628. } else if (se_num == 0xffffffff) {
  2629. data = REG_SET_FIELD(data, GRBM_GFX_INDEX, SH_INDEX, sh_num);
  2630. data = REG_SET_FIELD(data, GRBM_GFX_INDEX, SE_BROADCAST_WRITES, 1);
  2631. } else if (sh_num == 0xffffffff) {
  2632. data = REG_SET_FIELD(data, GRBM_GFX_INDEX, SH_BROADCAST_WRITES, 1);
  2633. data = REG_SET_FIELD(data, GRBM_GFX_INDEX, SE_INDEX, se_num);
  2634. } else {
  2635. data = REG_SET_FIELD(data, GRBM_GFX_INDEX, SH_INDEX, sh_num);
  2636. data = REG_SET_FIELD(data, GRBM_GFX_INDEX, SE_INDEX, se_num);
  2637. }
  2638. WREG32(mmGRBM_GFX_INDEX, data);
  2639. }
  2640. static u32 gfx_v8_0_get_rb_disabled(struct amdgpu_device *adev,
  2641. u32 max_rb_num_per_se,
  2642. u32 sh_per_se)
  2643. {
  2644. u32 data, mask;
  2645. data = RREG32(mmCC_RB_BACKEND_DISABLE);
  2646. data &= CC_RB_BACKEND_DISABLE__BACKEND_DISABLE_MASK;
  2647. data |= RREG32(mmGC_USER_RB_BACKEND_DISABLE);
  2648. data >>= GC_USER_RB_BACKEND_DISABLE__BACKEND_DISABLE__SHIFT;
  2649. mask = gfx_v8_0_create_bitmask(max_rb_num_per_se / sh_per_se);
  2650. return data & mask;
  2651. }
  2652. static void gfx_v8_0_setup_rb(struct amdgpu_device *adev,
  2653. u32 se_num, u32 sh_per_se,
  2654. u32 max_rb_num_per_se)
  2655. {
  2656. int i, j;
  2657. u32 data, mask;
  2658. u32 disabled_rbs = 0;
  2659. u32 enabled_rbs = 0;
  2660. mutex_lock(&adev->grbm_idx_mutex);
  2661. for (i = 0; i < se_num; i++) {
  2662. for (j = 0; j < sh_per_se; j++) {
  2663. gfx_v8_0_select_se_sh(adev, i, j);
  2664. data = gfx_v8_0_get_rb_disabled(adev,
  2665. max_rb_num_per_se, sh_per_se);
  2666. disabled_rbs |= data << ((i * sh_per_se + j) *
  2667. RB_BITMAP_WIDTH_PER_SH);
  2668. }
  2669. }
  2670. gfx_v8_0_select_se_sh(adev, 0xffffffff, 0xffffffff);
  2671. mutex_unlock(&adev->grbm_idx_mutex);
  2672. mask = 1;
  2673. for (i = 0; i < max_rb_num_per_se * se_num; i++) {
  2674. if (!(disabled_rbs & mask))
  2675. enabled_rbs |= mask;
  2676. mask <<= 1;
  2677. }
  2678. adev->gfx.config.backend_enable_mask = enabled_rbs;
  2679. mutex_lock(&adev->grbm_idx_mutex);
  2680. for (i = 0; i < se_num; i++) {
  2681. gfx_v8_0_select_se_sh(adev, i, 0xffffffff);
  2682. data = 0;
  2683. for (j = 0; j < sh_per_se; j++) {
  2684. switch (enabled_rbs & 3) {
  2685. case 0:
  2686. if (j == 0)
  2687. data |= (RASTER_CONFIG_RB_MAP_3 <<
  2688. PA_SC_RASTER_CONFIG__PKR_MAP__SHIFT);
  2689. else
  2690. data |= (RASTER_CONFIG_RB_MAP_0 <<
  2691. PA_SC_RASTER_CONFIG__PKR_MAP__SHIFT);
  2692. break;
  2693. case 1:
  2694. data |= (RASTER_CONFIG_RB_MAP_0 <<
  2695. (i * sh_per_se + j) * 2);
  2696. break;
  2697. case 2:
  2698. data |= (RASTER_CONFIG_RB_MAP_3 <<
  2699. (i * sh_per_se + j) * 2);
  2700. break;
  2701. case 3:
  2702. default:
  2703. data |= (RASTER_CONFIG_RB_MAP_2 <<
  2704. (i * sh_per_se + j) * 2);
  2705. break;
  2706. }
  2707. enabled_rbs >>= 2;
  2708. }
  2709. WREG32(mmPA_SC_RASTER_CONFIG, data);
  2710. }
  2711. gfx_v8_0_select_se_sh(adev, 0xffffffff, 0xffffffff);
  2712. mutex_unlock(&adev->grbm_idx_mutex);
  2713. }
  2714. /**
  2715. * gfx_v8_0_init_compute_vmid - gart enable
  2716. *
  2717. * @rdev: amdgpu_device pointer
  2718. *
  2719. * Initialize compute vmid sh_mem registers
  2720. *
  2721. */
  2722. #define DEFAULT_SH_MEM_BASES (0x6000)
  2723. #define FIRST_COMPUTE_VMID (8)
  2724. #define LAST_COMPUTE_VMID (16)
  2725. static void gfx_v8_0_init_compute_vmid(struct amdgpu_device *adev)
  2726. {
  2727. int i;
  2728. uint32_t sh_mem_config;
  2729. uint32_t sh_mem_bases;
  2730. /*
  2731. * Configure apertures:
  2732. * LDS: 0x60000000'00000000 - 0x60000001'00000000 (4GB)
  2733. * Scratch: 0x60000001'00000000 - 0x60000002'00000000 (4GB)
  2734. * GPUVM: 0x60010000'00000000 - 0x60020000'00000000 (1TB)
  2735. */
  2736. sh_mem_bases = DEFAULT_SH_MEM_BASES | (DEFAULT_SH_MEM_BASES << 16);
  2737. sh_mem_config = SH_MEM_ADDRESS_MODE_HSA64 <<
  2738. SH_MEM_CONFIG__ADDRESS_MODE__SHIFT |
  2739. SH_MEM_ALIGNMENT_MODE_UNALIGNED <<
  2740. SH_MEM_CONFIG__ALIGNMENT_MODE__SHIFT |
  2741. MTYPE_CC << SH_MEM_CONFIG__DEFAULT_MTYPE__SHIFT |
  2742. SH_MEM_CONFIG__PRIVATE_ATC_MASK;
  2743. mutex_lock(&adev->srbm_mutex);
  2744. for (i = FIRST_COMPUTE_VMID; i < LAST_COMPUTE_VMID; i++) {
  2745. vi_srbm_select(adev, 0, 0, 0, i);
  2746. /* CP and shaders */
  2747. WREG32(mmSH_MEM_CONFIG, sh_mem_config);
  2748. WREG32(mmSH_MEM_APE1_BASE, 1);
  2749. WREG32(mmSH_MEM_APE1_LIMIT, 0);
  2750. WREG32(mmSH_MEM_BASES, sh_mem_bases);
  2751. }
  2752. vi_srbm_select(adev, 0, 0, 0, 0);
  2753. mutex_unlock(&adev->srbm_mutex);
  2754. }
  2755. static void gfx_v8_0_gpu_init(struct amdgpu_device *adev)
  2756. {
  2757. u32 tmp;
  2758. int i;
  2759. tmp = RREG32(mmGRBM_CNTL);
  2760. tmp = REG_SET_FIELD(tmp, GRBM_CNTL, READ_TIMEOUT, 0xff);
  2761. WREG32(mmGRBM_CNTL, tmp);
  2762. WREG32(mmGB_ADDR_CONFIG, adev->gfx.config.gb_addr_config);
  2763. WREG32(mmHDP_ADDR_CONFIG, adev->gfx.config.gb_addr_config);
  2764. WREG32(mmDMIF_ADDR_CALC, adev->gfx.config.gb_addr_config);
  2765. WREG32(mmSDMA0_TILING_CONFIG + SDMA0_REGISTER_OFFSET,
  2766. adev->gfx.config.gb_addr_config & 0x70);
  2767. WREG32(mmSDMA0_TILING_CONFIG + SDMA1_REGISTER_OFFSET,
  2768. adev->gfx.config.gb_addr_config & 0x70);
  2769. WREG32(mmUVD_UDEC_ADDR_CONFIG, adev->gfx.config.gb_addr_config);
  2770. WREG32(mmUVD_UDEC_DB_ADDR_CONFIG, adev->gfx.config.gb_addr_config);
  2771. WREG32(mmUVD_UDEC_DBW_ADDR_CONFIG, adev->gfx.config.gb_addr_config);
  2772. gfx_v8_0_tiling_mode_table_init(adev);
  2773. gfx_v8_0_setup_rb(adev, adev->gfx.config.max_shader_engines,
  2774. adev->gfx.config.max_sh_per_se,
  2775. adev->gfx.config.max_backends_per_se);
  2776. /* XXX SH_MEM regs */
  2777. /* where to put LDS, scratch, GPUVM in FSA64 space */
  2778. mutex_lock(&adev->srbm_mutex);
  2779. for (i = 0; i < 16; i++) {
  2780. vi_srbm_select(adev, 0, 0, 0, i);
  2781. /* CP and shaders */
  2782. if (i == 0) {
  2783. tmp = REG_SET_FIELD(0, SH_MEM_CONFIG, DEFAULT_MTYPE, MTYPE_UC);
  2784. tmp = REG_SET_FIELD(tmp, SH_MEM_CONFIG, APE1_MTYPE, MTYPE_UC);
  2785. tmp = REG_SET_FIELD(tmp, SH_MEM_CONFIG, ALIGNMENT_MODE,
  2786. SH_MEM_ALIGNMENT_MODE_UNALIGNED);
  2787. WREG32(mmSH_MEM_CONFIG, tmp);
  2788. } else {
  2789. tmp = REG_SET_FIELD(0, SH_MEM_CONFIG, DEFAULT_MTYPE, MTYPE_NC);
  2790. tmp = REG_SET_FIELD(tmp, SH_MEM_CONFIG, APE1_MTYPE, MTYPE_NC);
  2791. tmp = REG_SET_FIELD(tmp, SH_MEM_CONFIG, ALIGNMENT_MODE,
  2792. SH_MEM_ALIGNMENT_MODE_UNALIGNED);
  2793. WREG32(mmSH_MEM_CONFIG, tmp);
  2794. }
  2795. WREG32(mmSH_MEM_APE1_BASE, 1);
  2796. WREG32(mmSH_MEM_APE1_LIMIT, 0);
  2797. WREG32(mmSH_MEM_BASES, 0);
  2798. }
  2799. vi_srbm_select(adev, 0, 0, 0, 0);
  2800. mutex_unlock(&adev->srbm_mutex);
  2801. gfx_v8_0_init_compute_vmid(adev);
  2802. mutex_lock(&adev->grbm_idx_mutex);
  2803. /*
  2804. * making sure that the following register writes will be broadcasted
  2805. * to all the shaders
  2806. */
  2807. gfx_v8_0_select_se_sh(adev, 0xffffffff, 0xffffffff);
  2808. WREG32(mmPA_SC_FIFO_SIZE,
  2809. (adev->gfx.config.sc_prim_fifo_size_frontend <<
  2810. PA_SC_FIFO_SIZE__SC_FRONTEND_PRIM_FIFO_SIZE__SHIFT) |
  2811. (adev->gfx.config.sc_prim_fifo_size_backend <<
  2812. PA_SC_FIFO_SIZE__SC_BACKEND_PRIM_FIFO_SIZE__SHIFT) |
  2813. (adev->gfx.config.sc_hiz_tile_fifo_size <<
  2814. PA_SC_FIFO_SIZE__SC_HIZ_TILE_FIFO_SIZE__SHIFT) |
  2815. (adev->gfx.config.sc_earlyz_tile_fifo_size <<
  2816. PA_SC_FIFO_SIZE__SC_EARLYZ_TILE_FIFO_SIZE__SHIFT));
  2817. mutex_unlock(&adev->grbm_idx_mutex);
  2818. }
  2819. static void gfx_v8_0_wait_for_rlc_serdes(struct amdgpu_device *adev)
  2820. {
  2821. u32 i, j, k;
  2822. u32 mask;
  2823. mutex_lock(&adev->grbm_idx_mutex);
  2824. for (i = 0; i < adev->gfx.config.max_shader_engines; i++) {
  2825. for (j = 0; j < adev->gfx.config.max_sh_per_se; j++) {
  2826. gfx_v8_0_select_se_sh(adev, i, j);
  2827. for (k = 0; k < adev->usec_timeout; k++) {
  2828. if (RREG32(mmRLC_SERDES_CU_MASTER_BUSY) == 0)
  2829. break;
  2830. udelay(1);
  2831. }
  2832. }
  2833. }
  2834. gfx_v8_0_select_se_sh(adev, 0xffffffff, 0xffffffff);
  2835. mutex_unlock(&adev->grbm_idx_mutex);
  2836. mask = RLC_SERDES_NONCU_MASTER_BUSY__SE_MASTER_BUSY_MASK |
  2837. RLC_SERDES_NONCU_MASTER_BUSY__GC_MASTER_BUSY_MASK |
  2838. RLC_SERDES_NONCU_MASTER_BUSY__TC0_MASTER_BUSY_MASK |
  2839. RLC_SERDES_NONCU_MASTER_BUSY__TC1_MASTER_BUSY_MASK;
  2840. for (k = 0; k < adev->usec_timeout; k++) {
  2841. if ((RREG32(mmRLC_SERDES_NONCU_MASTER_BUSY) & mask) == 0)
  2842. break;
  2843. udelay(1);
  2844. }
  2845. }
  2846. static void gfx_v8_0_enable_gui_idle_interrupt(struct amdgpu_device *adev,
  2847. bool enable)
  2848. {
  2849. u32 tmp = RREG32(mmCP_INT_CNTL_RING0);
  2850. if (enable) {
  2851. tmp = REG_SET_FIELD(tmp, CP_INT_CNTL_RING0, CNTX_BUSY_INT_ENABLE, 1);
  2852. tmp = REG_SET_FIELD(tmp, CP_INT_CNTL_RING0, CNTX_EMPTY_INT_ENABLE, 1);
  2853. tmp = REG_SET_FIELD(tmp, CP_INT_CNTL_RING0, CMP_BUSY_INT_ENABLE, 1);
  2854. tmp = REG_SET_FIELD(tmp, CP_INT_CNTL_RING0, GFX_IDLE_INT_ENABLE, 1);
  2855. } else {
  2856. tmp = REG_SET_FIELD(tmp, CP_INT_CNTL_RING0, CNTX_BUSY_INT_ENABLE, 0);
  2857. tmp = REG_SET_FIELD(tmp, CP_INT_CNTL_RING0, CNTX_EMPTY_INT_ENABLE, 0);
  2858. tmp = REG_SET_FIELD(tmp, CP_INT_CNTL_RING0, CMP_BUSY_INT_ENABLE, 0);
  2859. tmp = REG_SET_FIELD(tmp, CP_INT_CNTL_RING0, GFX_IDLE_INT_ENABLE, 0);
  2860. }
  2861. WREG32(mmCP_INT_CNTL_RING0, tmp);
  2862. }
  2863. void gfx_v8_0_rlc_stop(struct amdgpu_device *adev)
  2864. {
  2865. u32 tmp = RREG32(mmRLC_CNTL);
  2866. tmp = REG_SET_FIELD(tmp, RLC_CNTL, RLC_ENABLE_F32, 0);
  2867. WREG32(mmRLC_CNTL, tmp);
  2868. gfx_v8_0_enable_gui_idle_interrupt(adev, false);
  2869. gfx_v8_0_wait_for_rlc_serdes(adev);
  2870. }
  2871. static void gfx_v8_0_rlc_reset(struct amdgpu_device *adev)
  2872. {
  2873. u32 tmp = RREG32(mmGRBM_SOFT_RESET);
  2874. tmp = REG_SET_FIELD(tmp, GRBM_SOFT_RESET, SOFT_RESET_RLC, 1);
  2875. WREG32(mmGRBM_SOFT_RESET, tmp);
  2876. udelay(50);
  2877. tmp = REG_SET_FIELD(tmp, GRBM_SOFT_RESET, SOFT_RESET_RLC, 0);
  2878. WREG32(mmGRBM_SOFT_RESET, tmp);
  2879. udelay(50);
  2880. }
  2881. static void gfx_v8_0_rlc_start(struct amdgpu_device *adev)
  2882. {
  2883. u32 tmp = RREG32(mmRLC_CNTL);
  2884. tmp = REG_SET_FIELD(tmp, RLC_CNTL, RLC_ENABLE_F32, 1);
  2885. WREG32(mmRLC_CNTL, tmp);
  2886. /* carrizo do enable cp interrupt after cp inited */
  2887. if (!(adev->flags & AMD_IS_APU))
  2888. gfx_v8_0_enable_gui_idle_interrupt(adev, true);
  2889. udelay(50);
  2890. }
  2891. static int gfx_v8_0_rlc_load_microcode(struct amdgpu_device *adev)
  2892. {
  2893. const struct rlc_firmware_header_v2_0 *hdr;
  2894. const __le32 *fw_data;
  2895. unsigned i, fw_size;
  2896. if (!adev->gfx.rlc_fw)
  2897. return -EINVAL;
  2898. hdr = (const struct rlc_firmware_header_v2_0 *)adev->gfx.rlc_fw->data;
  2899. amdgpu_ucode_print_rlc_hdr(&hdr->header);
  2900. fw_data = (const __le32 *)(adev->gfx.rlc_fw->data +
  2901. le32_to_cpu(hdr->header.ucode_array_offset_bytes));
  2902. fw_size = le32_to_cpu(hdr->header.ucode_size_bytes) / 4;
  2903. WREG32(mmRLC_GPM_UCODE_ADDR, 0);
  2904. for (i = 0; i < fw_size; i++)
  2905. WREG32(mmRLC_GPM_UCODE_DATA, le32_to_cpup(fw_data++));
  2906. WREG32(mmRLC_GPM_UCODE_ADDR, adev->gfx.rlc_fw_version);
  2907. return 0;
  2908. }
  2909. static int gfx_v8_0_rlc_resume(struct amdgpu_device *adev)
  2910. {
  2911. int r;
  2912. gfx_v8_0_rlc_stop(adev);
  2913. /* disable CG */
  2914. WREG32(mmRLC_CGCG_CGLS_CTRL, 0);
  2915. /* disable PG */
  2916. WREG32(mmRLC_PG_CNTL, 0);
  2917. gfx_v8_0_rlc_reset(adev);
  2918. if (!adev->firmware.smu_load) {
  2919. /* legacy rlc firmware loading */
  2920. r = gfx_v8_0_rlc_load_microcode(adev);
  2921. if (r)
  2922. return r;
  2923. } else {
  2924. r = adev->smu.smumgr_funcs->check_fw_load_finish(adev,
  2925. AMDGPU_UCODE_ID_RLC_G);
  2926. if (r)
  2927. return -EINVAL;
  2928. }
  2929. gfx_v8_0_rlc_start(adev);
  2930. return 0;
  2931. }
  2932. static void gfx_v8_0_cp_gfx_enable(struct amdgpu_device *adev, bool enable)
  2933. {
  2934. int i;
  2935. u32 tmp = RREG32(mmCP_ME_CNTL);
  2936. if (enable) {
  2937. tmp = REG_SET_FIELD(tmp, CP_ME_CNTL, ME_HALT, 0);
  2938. tmp = REG_SET_FIELD(tmp, CP_ME_CNTL, PFP_HALT, 0);
  2939. tmp = REG_SET_FIELD(tmp, CP_ME_CNTL, CE_HALT, 0);
  2940. } else {
  2941. tmp = REG_SET_FIELD(tmp, CP_ME_CNTL, ME_HALT, 1);
  2942. tmp = REG_SET_FIELD(tmp, CP_ME_CNTL, PFP_HALT, 1);
  2943. tmp = REG_SET_FIELD(tmp, CP_ME_CNTL, CE_HALT, 1);
  2944. for (i = 0; i < adev->gfx.num_gfx_rings; i++)
  2945. adev->gfx.gfx_ring[i].ready = false;
  2946. }
  2947. WREG32(mmCP_ME_CNTL, tmp);
  2948. udelay(50);
  2949. }
  2950. static int gfx_v8_0_cp_gfx_load_microcode(struct amdgpu_device *adev)
  2951. {
  2952. const struct gfx_firmware_header_v1_0 *pfp_hdr;
  2953. const struct gfx_firmware_header_v1_0 *ce_hdr;
  2954. const struct gfx_firmware_header_v1_0 *me_hdr;
  2955. const __le32 *fw_data;
  2956. unsigned i, fw_size;
  2957. if (!adev->gfx.me_fw || !adev->gfx.pfp_fw || !adev->gfx.ce_fw)
  2958. return -EINVAL;
  2959. pfp_hdr = (const struct gfx_firmware_header_v1_0 *)
  2960. adev->gfx.pfp_fw->data;
  2961. ce_hdr = (const struct gfx_firmware_header_v1_0 *)
  2962. adev->gfx.ce_fw->data;
  2963. me_hdr = (const struct gfx_firmware_header_v1_0 *)
  2964. adev->gfx.me_fw->data;
  2965. amdgpu_ucode_print_gfx_hdr(&pfp_hdr->header);
  2966. amdgpu_ucode_print_gfx_hdr(&ce_hdr->header);
  2967. amdgpu_ucode_print_gfx_hdr(&me_hdr->header);
  2968. gfx_v8_0_cp_gfx_enable(adev, false);
  2969. /* PFP */
  2970. fw_data = (const __le32 *)
  2971. (adev->gfx.pfp_fw->data +
  2972. le32_to_cpu(pfp_hdr->header.ucode_array_offset_bytes));
  2973. fw_size = le32_to_cpu(pfp_hdr->header.ucode_size_bytes) / 4;
  2974. WREG32(mmCP_PFP_UCODE_ADDR, 0);
  2975. for (i = 0; i < fw_size; i++)
  2976. WREG32(mmCP_PFP_UCODE_DATA, le32_to_cpup(fw_data++));
  2977. WREG32(mmCP_PFP_UCODE_ADDR, adev->gfx.pfp_fw_version);
  2978. /* CE */
  2979. fw_data = (const __le32 *)
  2980. (adev->gfx.ce_fw->data +
  2981. le32_to_cpu(ce_hdr->header.ucode_array_offset_bytes));
  2982. fw_size = le32_to_cpu(ce_hdr->header.ucode_size_bytes) / 4;
  2983. WREG32(mmCP_CE_UCODE_ADDR, 0);
  2984. for (i = 0; i < fw_size; i++)
  2985. WREG32(mmCP_CE_UCODE_DATA, le32_to_cpup(fw_data++));
  2986. WREG32(mmCP_CE_UCODE_ADDR, adev->gfx.ce_fw_version);
  2987. /* ME */
  2988. fw_data = (const __le32 *)
  2989. (adev->gfx.me_fw->data +
  2990. le32_to_cpu(me_hdr->header.ucode_array_offset_bytes));
  2991. fw_size = le32_to_cpu(me_hdr->header.ucode_size_bytes) / 4;
  2992. WREG32(mmCP_ME_RAM_WADDR, 0);
  2993. for (i = 0; i < fw_size; i++)
  2994. WREG32(mmCP_ME_RAM_DATA, le32_to_cpup(fw_data++));
  2995. WREG32(mmCP_ME_RAM_WADDR, adev->gfx.me_fw_version);
  2996. return 0;
  2997. }
  2998. static u32 gfx_v8_0_get_csb_size(struct amdgpu_device *adev)
  2999. {
  3000. u32 count = 0;
  3001. const struct cs_section_def *sect = NULL;
  3002. const struct cs_extent_def *ext = NULL;
  3003. /* begin clear state */
  3004. count += 2;
  3005. /* context control state */
  3006. count += 3;
  3007. for (sect = vi_cs_data; sect->section != NULL; ++sect) {
  3008. for (ext = sect->section; ext->extent != NULL; ++ext) {
  3009. if (sect->id == SECT_CONTEXT)
  3010. count += 2 + ext->reg_count;
  3011. else
  3012. return 0;
  3013. }
  3014. }
  3015. /* pa_sc_raster_config/pa_sc_raster_config1 */
  3016. count += 4;
  3017. /* end clear state */
  3018. count += 2;
  3019. /* clear state */
  3020. count += 2;
  3021. return count;
  3022. }
  3023. static int gfx_v8_0_cp_gfx_start(struct amdgpu_device *adev)
  3024. {
  3025. struct amdgpu_ring *ring = &adev->gfx.gfx_ring[0];
  3026. const struct cs_section_def *sect = NULL;
  3027. const struct cs_extent_def *ext = NULL;
  3028. int r, i;
  3029. /* init the CP */
  3030. WREG32(mmCP_MAX_CONTEXT, adev->gfx.config.max_hw_contexts - 1);
  3031. WREG32(mmCP_ENDIAN_SWAP, 0);
  3032. WREG32(mmCP_DEVICE_ID, 1);
  3033. gfx_v8_0_cp_gfx_enable(adev, true);
  3034. r = amdgpu_ring_lock(ring, gfx_v8_0_get_csb_size(adev) + 4);
  3035. if (r) {
  3036. DRM_ERROR("amdgpu: cp failed to lock ring (%d).\n", r);
  3037. return r;
  3038. }
  3039. /* clear state buffer */
  3040. amdgpu_ring_write(ring, PACKET3(PACKET3_PREAMBLE_CNTL, 0));
  3041. amdgpu_ring_write(ring, PACKET3_PREAMBLE_BEGIN_CLEAR_STATE);
  3042. amdgpu_ring_write(ring, PACKET3(PACKET3_CONTEXT_CONTROL, 1));
  3043. amdgpu_ring_write(ring, 0x80000000);
  3044. amdgpu_ring_write(ring, 0x80000000);
  3045. for (sect = vi_cs_data; sect->section != NULL; ++sect) {
  3046. for (ext = sect->section; ext->extent != NULL; ++ext) {
  3047. if (sect->id == SECT_CONTEXT) {
  3048. amdgpu_ring_write(ring,
  3049. PACKET3(PACKET3_SET_CONTEXT_REG,
  3050. ext->reg_count));
  3051. amdgpu_ring_write(ring,
  3052. ext->reg_index - PACKET3_SET_CONTEXT_REG_START);
  3053. for (i = 0; i < ext->reg_count; i++)
  3054. amdgpu_ring_write(ring, ext->extent[i]);
  3055. }
  3056. }
  3057. }
  3058. amdgpu_ring_write(ring, PACKET3(PACKET3_SET_CONTEXT_REG, 2));
  3059. amdgpu_ring_write(ring, mmPA_SC_RASTER_CONFIG - PACKET3_SET_CONTEXT_REG_START);
  3060. switch (adev->asic_type) {
  3061. case CHIP_TONGA:
  3062. amdgpu_ring_write(ring, 0x16000012);
  3063. amdgpu_ring_write(ring, 0x0000002A);
  3064. break;
  3065. case CHIP_FIJI:
  3066. amdgpu_ring_write(ring, 0x3a00161a);
  3067. amdgpu_ring_write(ring, 0x0000002e);
  3068. break;
  3069. case CHIP_TOPAZ:
  3070. case CHIP_CARRIZO:
  3071. amdgpu_ring_write(ring, 0x00000002);
  3072. amdgpu_ring_write(ring, 0x00000000);
  3073. break;
  3074. case CHIP_STONEY:
  3075. amdgpu_ring_write(ring, 0x00000000);
  3076. amdgpu_ring_write(ring, 0x00000000);
  3077. break;
  3078. default:
  3079. BUG();
  3080. }
  3081. amdgpu_ring_write(ring, PACKET3(PACKET3_PREAMBLE_CNTL, 0));
  3082. amdgpu_ring_write(ring, PACKET3_PREAMBLE_END_CLEAR_STATE);
  3083. amdgpu_ring_write(ring, PACKET3(PACKET3_CLEAR_STATE, 0));
  3084. amdgpu_ring_write(ring, 0);
  3085. /* init the CE partitions */
  3086. amdgpu_ring_write(ring, PACKET3(PACKET3_SET_BASE, 2));
  3087. amdgpu_ring_write(ring, PACKET3_BASE_INDEX(CE_PARTITION_BASE));
  3088. amdgpu_ring_write(ring, 0x8000);
  3089. amdgpu_ring_write(ring, 0x8000);
  3090. amdgpu_ring_unlock_commit(ring);
  3091. return 0;
  3092. }
  3093. static int gfx_v8_0_cp_gfx_resume(struct amdgpu_device *adev)
  3094. {
  3095. struct amdgpu_ring *ring;
  3096. u32 tmp;
  3097. u32 rb_bufsz;
  3098. u64 rb_addr, rptr_addr;
  3099. int r;
  3100. /* Set the write pointer delay */
  3101. WREG32(mmCP_RB_WPTR_DELAY, 0);
  3102. /* set the RB to use vmid 0 */
  3103. WREG32(mmCP_RB_VMID, 0);
  3104. /* Set ring buffer size */
  3105. ring = &adev->gfx.gfx_ring[0];
  3106. rb_bufsz = order_base_2(ring->ring_size / 8);
  3107. tmp = REG_SET_FIELD(0, CP_RB0_CNTL, RB_BUFSZ, rb_bufsz);
  3108. tmp = REG_SET_FIELD(tmp, CP_RB0_CNTL, RB_BLKSZ, rb_bufsz - 2);
  3109. tmp = REG_SET_FIELD(tmp, CP_RB0_CNTL, MTYPE, 3);
  3110. tmp = REG_SET_FIELD(tmp, CP_RB0_CNTL, MIN_IB_AVAILSZ, 1);
  3111. #ifdef __BIG_ENDIAN
  3112. tmp = REG_SET_FIELD(tmp, CP_RB0_CNTL, BUF_SWAP, 1);
  3113. #endif
  3114. WREG32(mmCP_RB0_CNTL, tmp);
  3115. /* Initialize the ring buffer's read and write pointers */
  3116. WREG32(mmCP_RB0_CNTL, tmp | CP_RB0_CNTL__RB_RPTR_WR_ENA_MASK);
  3117. ring->wptr = 0;
  3118. WREG32(mmCP_RB0_WPTR, ring->wptr);
  3119. /* set the wb address wether it's enabled or not */
  3120. rptr_addr = adev->wb.gpu_addr + (ring->rptr_offs * 4);
  3121. WREG32(mmCP_RB0_RPTR_ADDR, lower_32_bits(rptr_addr));
  3122. WREG32(mmCP_RB0_RPTR_ADDR_HI, upper_32_bits(rptr_addr) & 0xFF);
  3123. mdelay(1);
  3124. WREG32(mmCP_RB0_CNTL, tmp);
  3125. rb_addr = ring->gpu_addr >> 8;
  3126. WREG32(mmCP_RB0_BASE, rb_addr);
  3127. WREG32(mmCP_RB0_BASE_HI, upper_32_bits(rb_addr));
  3128. /* no gfx doorbells on iceland */
  3129. if (adev->asic_type != CHIP_TOPAZ) {
  3130. tmp = RREG32(mmCP_RB_DOORBELL_CONTROL);
  3131. if (ring->use_doorbell) {
  3132. tmp = REG_SET_FIELD(tmp, CP_RB_DOORBELL_CONTROL,
  3133. DOORBELL_OFFSET, ring->doorbell_index);
  3134. tmp = REG_SET_FIELD(tmp, CP_RB_DOORBELL_CONTROL,
  3135. DOORBELL_EN, 1);
  3136. } else {
  3137. tmp = REG_SET_FIELD(tmp, CP_RB_DOORBELL_CONTROL,
  3138. DOORBELL_EN, 0);
  3139. }
  3140. WREG32(mmCP_RB_DOORBELL_CONTROL, tmp);
  3141. if (adev->asic_type == CHIP_TONGA) {
  3142. tmp = REG_SET_FIELD(0, CP_RB_DOORBELL_RANGE_LOWER,
  3143. DOORBELL_RANGE_LOWER,
  3144. AMDGPU_DOORBELL_GFX_RING0);
  3145. WREG32(mmCP_RB_DOORBELL_RANGE_LOWER, tmp);
  3146. WREG32(mmCP_RB_DOORBELL_RANGE_UPPER,
  3147. CP_RB_DOORBELL_RANGE_UPPER__DOORBELL_RANGE_UPPER_MASK);
  3148. }
  3149. }
  3150. /* start the ring */
  3151. gfx_v8_0_cp_gfx_start(adev);
  3152. ring->ready = true;
  3153. r = amdgpu_ring_test_ring(ring);
  3154. if (r) {
  3155. ring->ready = false;
  3156. return r;
  3157. }
  3158. return 0;
  3159. }
  3160. static void gfx_v8_0_cp_compute_enable(struct amdgpu_device *adev, bool enable)
  3161. {
  3162. int i;
  3163. if (enable) {
  3164. WREG32(mmCP_MEC_CNTL, 0);
  3165. } else {
  3166. WREG32(mmCP_MEC_CNTL, (CP_MEC_CNTL__MEC_ME1_HALT_MASK | CP_MEC_CNTL__MEC_ME2_HALT_MASK));
  3167. for (i = 0; i < adev->gfx.num_compute_rings; i++)
  3168. adev->gfx.compute_ring[i].ready = false;
  3169. }
  3170. udelay(50);
  3171. }
  3172. static int gfx_v8_0_cp_compute_start(struct amdgpu_device *adev)
  3173. {
  3174. gfx_v8_0_cp_compute_enable(adev, true);
  3175. return 0;
  3176. }
  3177. static int gfx_v8_0_cp_compute_load_microcode(struct amdgpu_device *adev)
  3178. {
  3179. const struct gfx_firmware_header_v1_0 *mec_hdr;
  3180. const __le32 *fw_data;
  3181. unsigned i, fw_size;
  3182. if (!adev->gfx.mec_fw)
  3183. return -EINVAL;
  3184. gfx_v8_0_cp_compute_enable(adev, false);
  3185. mec_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.mec_fw->data;
  3186. amdgpu_ucode_print_gfx_hdr(&mec_hdr->header);
  3187. fw_data = (const __le32 *)
  3188. (adev->gfx.mec_fw->data +
  3189. le32_to_cpu(mec_hdr->header.ucode_array_offset_bytes));
  3190. fw_size = le32_to_cpu(mec_hdr->header.ucode_size_bytes) / 4;
  3191. /* MEC1 */
  3192. WREG32(mmCP_MEC_ME1_UCODE_ADDR, 0);
  3193. for (i = 0; i < fw_size; i++)
  3194. WREG32(mmCP_MEC_ME1_UCODE_DATA, le32_to_cpup(fw_data+i));
  3195. WREG32(mmCP_MEC_ME1_UCODE_ADDR, adev->gfx.mec_fw_version);
  3196. /* Loading MEC2 firmware is only necessary if MEC2 should run different microcode than MEC1. */
  3197. if (adev->gfx.mec2_fw) {
  3198. const struct gfx_firmware_header_v1_0 *mec2_hdr;
  3199. mec2_hdr = (const struct gfx_firmware_header_v1_0 *)adev->gfx.mec2_fw->data;
  3200. amdgpu_ucode_print_gfx_hdr(&mec2_hdr->header);
  3201. fw_data = (const __le32 *)
  3202. (adev->gfx.mec2_fw->data +
  3203. le32_to_cpu(mec2_hdr->header.ucode_array_offset_bytes));
  3204. fw_size = le32_to_cpu(mec2_hdr->header.ucode_size_bytes) / 4;
  3205. WREG32(mmCP_MEC_ME2_UCODE_ADDR, 0);
  3206. for (i = 0; i < fw_size; i++)
  3207. WREG32(mmCP_MEC_ME2_UCODE_DATA, le32_to_cpup(fw_data+i));
  3208. WREG32(mmCP_MEC_ME2_UCODE_ADDR, adev->gfx.mec2_fw_version);
  3209. }
  3210. return 0;
  3211. }
  3212. struct vi_mqd {
  3213. uint32_t header; /* ordinal0 */
  3214. uint32_t compute_dispatch_initiator; /* ordinal1 */
  3215. uint32_t compute_dim_x; /* ordinal2 */
  3216. uint32_t compute_dim_y; /* ordinal3 */
  3217. uint32_t compute_dim_z; /* ordinal4 */
  3218. uint32_t compute_start_x; /* ordinal5 */
  3219. uint32_t compute_start_y; /* ordinal6 */
  3220. uint32_t compute_start_z; /* ordinal7 */
  3221. uint32_t compute_num_thread_x; /* ordinal8 */
  3222. uint32_t compute_num_thread_y; /* ordinal9 */
  3223. uint32_t compute_num_thread_z; /* ordinal10 */
  3224. uint32_t compute_pipelinestat_enable; /* ordinal11 */
  3225. uint32_t compute_perfcount_enable; /* ordinal12 */
  3226. uint32_t compute_pgm_lo; /* ordinal13 */
  3227. uint32_t compute_pgm_hi; /* ordinal14 */
  3228. uint32_t compute_tba_lo; /* ordinal15 */
  3229. uint32_t compute_tba_hi; /* ordinal16 */
  3230. uint32_t compute_tma_lo; /* ordinal17 */
  3231. uint32_t compute_tma_hi; /* ordinal18 */
  3232. uint32_t compute_pgm_rsrc1; /* ordinal19 */
  3233. uint32_t compute_pgm_rsrc2; /* ordinal20 */
  3234. uint32_t compute_vmid; /* ordinal21 */
  3235. uint32_t compute_resource_limits; /* ordinal22 */
  3236. uint32_t compute_static_thread_mgmt_se0; /* ordinal23 */
  3237. uint32_t compute_static_thread_mgmt_se1; /* ordinal24 */
  3238. uint32_t compute_tmpring_size; /* ordinal25 */
  3239. uint32_t compute_static_thread_mgmt_se2; /* ordinal26 */
  3240. uint32_t compute_static_thread_mgmt_se3; /* ordinal27 */
  3241. uint32_t compute_restart_x; /* ordinal28 */
  3242. uint32_t compute_restart_y; /* ordinal29 */
  3243. uint32_t compute_restart_z; /* ordinal30 */
  3244. uint32_t compute_thread_trace_enable; /* ordinal31 */
  3245. uint32_t compute_misc_reserved; /* ordinal32 */
  3246. uint32_t compute_dispatch_id; /* ordinal33 */
  3247. uint32_t compute_threadgroup_id; /* ordinal34 */
  3248. uint32_t compute_relaunch; /* ordinal35 */
  3249. uint32_t compute_wave_restore_addr_lo; /* ordinal36 */
  3250. uint32_t compute_wave_restore_addr_hi; /* ordinal37 */
  3251. uint32_t compute_wave_restore_control; /* ordinal38 */
  3252. uint32_t reserved9; /* ordinal39 */
  3253. uint32_t reserved10; /* ordinal40 */
  3254. uint32_t reserved11; /* ordinal41 */
  3255. uint32_t reserved12; /* ordinal42 */
  3256. uint32_t reserved13; /* ordinal43 */
  3257. uint32_t reserved14; /* ordinal44 */
  3258. uint32_t reserved15; /* ordinal45 */
  3259. uint32_t reserved16; /* ordinal46 */
  3260. uint32_t reserved17; /* ordinal47 */
  3261. uint32_t reserved18; /* ordinal48 */
  3262. uint32_t reserved19; /* ordinal49 */
  3263. uint32_t reserved20; /* ordinal50 */
  3264. uint32_t reserved21; /* ordinal51 */
  3265. uint32_t reserved22; /* ordinal52 */
  3266. uint32_t reserved23; /* ordinal53 */
  3267. uint32_t reserved24; /* ordinal54 */
  3268. uint32_t reserved25; /* ordinal55 */
  3269. uint32_t reserved26; /* ordinal56 */
  3270. uint32_t reserved27; /* ordinal57 */
  3271. uint32_t reserved28; /* ordinal58 */
  3272. uint32_t reserved29; /* ordinal59 */
  3273. uint32_t reserved30; /* ordinal60 */
  3274. uint32_t reserved31; /* ordinal61 */
  3275. uint32_t reserved32; /* ordinal62 */
  3276. uint32_t reserved33; /* ordinal63 */
  3277. uint32_t reserved34; /* ordinal64 */
  3278. uint32_t compute_user_data_0; /* ordinal65 */
  3279. uint32_t compute_user_data_1; /* ordinal66 */
  3280. uint32_t compute_user_data_2; /* ordinal67 */
  3281. uint32_t compute_user_data_3; /* ordinal68 */
  3282. uint32_t compute_user_data_4; /* ordinal69 */
  3283. uint32_t compute_user_data_5; /* ordinal70 */
  3284. uint32_t compute_user_data_6; /* ordinal71 */
  3285. uint32_t compute_user_data_7; /* ordinal72 */
  3286. uint32_t compute_user_data_8; /* ordinal73 */
  3287. uint32_t compute_user_data_9; /* ordinal74 */
  3288. uint32_t compute_user_data_10; /* ordinal75 */
  3289. uint32_t compute_user_data_11; /* ordinal76 */
  3290. uint32_t compute_user_data_12; /* ordinal77 */
  3291. uint32_t compute_user_data_13; /* ordinal78 */
  3292. uint32_t compute_user_data_14; /* ordinal79 */
  3293. uint32_t compute_user_data_15; /* ordinal80 */
  3294. uint32_t cp_compute_csinvoc_count_lo; /* ordinal81 */
  3295. uint32_t cp_compute_csinvoc_count_hi; /* ordinal82 */
  3296. uint32_t reserved35; /* ordinal83 */
  3297. uint32_t reserved36; /* ordinal84 */
  3298. uint32_t reserved37; /* ordinal85 */
  3299. uint32_t cp_mqd_query_time_lo; /* ordinal86 */
  3300. uint32_t cp_mqd_query_time_hi; /* ordinal87 */
  3301. uint32_t cp_mqd_connect_start_time_lo; /* ordinal88 */
  3302. uint32_t cp_mqd_connect_start_time_hi; /* ordinal89 */
  3303. uint32_t cp_mqd_connect_end_time_lo; /* ordinal90 */
  3304. uint32_t cp_mqd_connect_end_time_hi; /* ordinal91 */
  3305. uint32_t cp_mqd_connect_end_wf_count; /* ordinal92 */
  3306. uint32_t cp_mqd_connect_end_pq_rptr; /* ordinal93 */
  3307. uint32_t cp_mqd_connect_end_pq_wptr; /* ordinal94 */
  3308. uint32_t cp_mqd_connect_end_ib_rptr; /* ordinal95 */
  3309. uint32_t reserved38; /* ordinal96 */
  3310. uint32_t reserved39; /* ordinal97 */
  3311. uint32_t cp_mqd_save_start_time_lo; /* ordinal98 */
  3312. uint32_t cp_mqd_save_start_time_hi; /* ordinal99 */
  3313. uint32_t cp_mqd_save_end_time_lo; /* ordinal100 */
  3314. uint32_t cp_mqd_save_end_time_hi; /* ordinal101 */
  3315. uint32_t cp_mqd_restore_start_time_lo; /* ordinal102 */
  3316. uint32_t cp_mqd_restore_start_time_hi; /* ordinal103 */
  3317. uint32_t cp_mqd_restore_end_time_lo; /* ordinal104 */
  3318. uint32_t cp_mqd_restore_end_time_hi; /* ordinal105 */
  3319. uint32_t reserved40; /* ordinal106 */
  3320. uint32_t reserved41; /* ordinal107 */
  3321. uint32_t gds_cs_ctxsw_cnt0; /* ordinal108 */
  3322. uint32_t gds_cs_ctxsw_cnt1; /* ordinal109 */
  3323. uint32_t gds_cs_ctxsw_cnt2; /* ordinal110 */
  3324. uint32_t gds_cs_ctxsw_cnt3; /* ordinal111 */
  3325. uint32_t reserved42; /* ordinal112 */
  3326. uint32_t reserved43; /* ordinal113 */
  3327. uint32_t cp_pq_exe_status_lo; /* ordinal114 */
  3328. uint32_t cp_pq_exe_status_hi; /* ordinal115 */
  3329. uint32_t cp_packet_id_lo; /* ordinal116 */
  3330. uint32_t cp_packet_id_hi; /* ordinal117 */
  3331. uint32_t cp_packet_exe_status_lo; /* ordinal118 */
  3332. uint32_t cp_packet_exe_status_hi; /* ordinal119 */
  3333. uint32_t gds_save_base_addr_lo; /* ordinal120 */
  3334. uint32_t gds_save_base_addr_hi; /* ordinal121 */
  3335. uint32_t gds_save_mask_lo; /* ordinal122 */
  3336. uint32_t gds_save_mask_hi; /* ordinal123 */
  3337. uint32_t ctx_save_base_addr_lo; /* ordinal124 */
  3338. uint32_t ctx_save_base_addr_hi; /* ordinal125 */
  3339. uint32_t reserved44; /* ordinal126 */
  3340. uint32_t reserved45; /* ordinal127 */
  3341. uint32_t cp_mqd_base_addr_lo; /* ordinal128 */
  3342. uint32_t cp_mqd_base_addr_hi; /* ordinal129 */
  3343. uint32_t cp_hqd_active; /* ordinal130 */
  3344. uint32_t cp_hqd_vmid; /* ordinal131 */
  3345. uint32_t cp_hqd_persistent_state; /* ordinal132 */
  3346. uint32_t cp_hqd_pipe_priority; /* ordinal133 */
  3347. uint32_t cp_hqd_queue_priority; /* ordinal134 */
  3348. uint32_t cp_hqd_quantum; /* ordinal135 */
  3349. uint32_t cp_hqd_pq_base_lo; /* ordinal136 */
  3350. uint32_t cp_hqd_pq_base_hi; /* ordinal137 */
  3351. uint32_t cp_hqd_pq_rptr; /* ordinal138 */
  3352. uint32_t cp_hqd_pq_rptr_report_addr_lo; /* ordinal139 */
  3353. uint32_t cp_hqd_pq_rptr_report_addr_hi; /* ordinal140 */
  3354. uint32_t cp_hqd_pq_wptr_poll_addr; /* ordinal141 */
  3355. uint32_t cp_hqd_pq_wptr_poll_addr_hi; /* ordinal142 */
  3356. uint32_t cp_hqd_pq_doorbell_control; /* ordinal143 */
  3357. uint32_t cp_hqd_pq_wptr; /* ordinal144 */
  3358. uint32_t cp_hqd_pq_control; /* ordinal145 */
  3359. uint32_t cp_hqd_ib_base_addr_lo; /* ordinal146 */
  3360. uint32_t cp_hqd_ib_base_addr_hi; /* ordinal147 */
  3361. uint32_t cp_hqd_ib_rptr; /* ordinal148 */
  3362. uint32_t cp_hqd_ib_control; /* ordinal149 */
  3363. uint32_t cp_hqd_iq_timer; /* ordinal150 */
  3364. uint32_t cp_hqd_iq_rptr; /* ordinal151 */
  3365. uint32_t cp_hqd_dequeue_request; /* ordinal152 */
  3366. uint32_t cp_hqd_dma_offload; /* ordinal153 */
  3367. uint32_t cp_hqd_sema_cmd; /* ordinal154 */
  3368. uint32_t cp_hqd_msg_type; /* ordinal155 */
  3369. uint32_t cp_hqd_atomic0_preop_lo; /* ordinal156 */
  3370. uint32_t cp_hqd_atomic0_preop_hi; /* ordinal157 */
  3371. uint32_t cp_hqd_atomic1_preop_lo; /* ordinal158 */
  3372. uint32_t cp_hqd_atomic1_preop_hi; /* ordinal159 */
  3373. uint32_t cp_hqd_hq_status0; /* ordinal160 */
  3374. uint32_t cp_hqd_hq_control0; /* ordinal161 */
  3375. uint32_t cp_mqd_control; /* ordinal162 */
  3376. uint32_t cp_hqd_hq_status1; /* ordinal163 */
  3377. uint32_t cp_hqd_hq_control1; /* ordinal164 */
  3378. uint32_t cp_hqd_eop_base_addr_lo; /* ordinal165 */
  3379. uint32_t cp_hqd_eop_base_addr_hi; /* ordinal166 */
  3380. uint32_t cp_hqd_eop_control; /* ordinal167 */
  3381. uint32_t cp_hqd_eop_rptr; /* ordinal168 */
  3382. uint32_t cp_hqd_eop_wptr; /* ordinal169 */
  3383. uint32_t cp_hqd_eop_done_events; /* ordinal170 */
  3384. uint32_t cp_hqd_ctx_save_base_addr_lo; /* ordinal171 */
  3385. uint32_t cp_hqd_ctx_save_base_addr_hi; /* ordinal172 */
  3386. uint32_t cp_hqd_ctx_save_control; /* ordinal173 */
  3387. uint32_t cp_hqd_cntl_stack_offset; /* ordinal174 */
  3388. uint32_t cp_hqd_cntl_stack_size; /* ordinal175 */
  3389. uint32_t cp_hqd_wg_state_offset; /* ordinal176 */
  3390. uint32_t cp_hqd_ctx_save_size; /* ordinal177 */
  3391. uint32_t cp_hqd_gds_resource_state; /* ordinal178 */
  3392. uint32_t cp_hqd_error; /* ordinal179 */
  3393. uint32_t cp_hqd_eop_wptr_mem; /* ordinal180 */
  3394. uint32_t cp_hqd_eop_dones; /* ordinal181 */
  3395. uint32_t reserved46; /* ordinal182 */
  3396. uint32_t reserved47; /* ordinal183 */
  3397. uint32_t reserved48; /* ordinal184 */
  3398. uint32_t reserved49; /* ordinal185 */
  3399. uint32_t reserved50; /* ordinal186 */
  3400. uint32_t reserved51; /* ordinal187 */
  3401. uint32_t reserved52; /* ordinal188 */
  3402. uint32_t reserved53; /* ordinal189 */
  3403. uint32_t reserved54; /* ordinal190 */
  3404. uint32_t reserved55; /* ordinal191 */
  3405. uint32_t iqtimer_pkt_header; /* ordinal192 */
  3406. uint32_t iqtimer_pkt_dw0; /* ordinal193 */
  3407. uint32_t iqtimer_pkt_dw1; /* ordinal194 */
  3408. uint32_t iqtimer_pkt_dw2; /* ordinal195 */
  3409. uint32_t iqtimer_pkt_dw3; /* ordinal196 */
  3410. uint32_t iqtimer_pkt_dw4; /* ordinal197 */
  3411. uint32_t iqtimer_pkt_dw5; /* ordinal198 */
  3412. uint32_t iqtimer_pkt_dw6; /* ordinal199 */
  3413. uint32_t iqtimer_pkt_dw7; /* ordinal200 */
  3414. uint32_t iqtimer_pkt_dw8; /* ordinal201 */
  3415. uint32_t iqtimer_pkt_dw9; /* ordinal202 */
  3416. uint32_t iqtimer_pkt_dw10; /* ordinal203 */
  3417. uint32_t iqtimer_pkt_dw11; /* ordinal204 */
  3418. uint32_t iqtimer_pkt_dw12; /* ordinal205 */
  3419. uint32_t iqtimer_pkt_dw13; /* ordinal206 */
  3420. uint32_t iqtimer_pkt_dw14; /* ordinal207 */
  3421. uint32_t iqtimer_pkt_dw15; /* ordinal208 */
  3422. uint32_t iqtimer_pkt_dw16; /* ordinal209 */
  3423. uint32_t iqtimer_pkt_dw17; /* ordinal210 */
  3424. uint32_t iqtimer_pkt_dw18; /* ordinal211 */
  3425. uint32_t iqtimer_pkt_dw19; /* ordinal212 */
  3426. uint32_t iqtimer_pkt_dw20; /* ordinal213 */
  3427. uint32_t iqtimer_pkt_dw21; /* ordinal214 */
  3428. uint32_t iqtimer_pkt_dw22; /* ordinal215 */
  3429. uint32_t iqtimer_pkt_dw23; /* ordinal216 */
  3430. uint32_t iqtimer_pkt_dw24; /* ordinal217 */
  3431. uint32_t iqtimer_pkt_dw25; /* ordinal218 */
  3432. uint32_t iqtimer_pkt_dw26; /* ordinal219 */
  3433. uint32_t iqtimer_pkt_dw27; /* ordinal220 */
  3434. uint32_t iqtimer_pkt_dw28; /* ordinal221 */
  3435. uint32_t iqtimer_pkt_dw29; /* ordinal222 */
  3436. uint32_t iqtimer_pkt_dw30; /* ordinal223 */
  3437. uint32_t iqtimer_pkt_dw31; /* ordinal224 */
  3438. uint32_t reserved56; /* ordinal225 */
  3439. uint32_t reserved57; /* ordinal226 */
  3440. uint32_t reserved58; /* ordinal227 */
  3441. uint32_t set_resources_header; /* ordinal228 */
  3442. uint32_t set_resources_dw1; /* ordinal229 */
  3443. uint32_t set_resources_dw2; /* ordinal230 */
  3444. uint32_t set_resources_dw3; /* ordinal231 */
  3445. uint32_t set_resources_dw4; /* ordinal232 */
  3446. uint32_t set_resources_dw5; /* ordinal233 */
  3447. uint32_t set_resources_dw6; /* ordinal234 */
  3448. uint32_t set_resources_dw7; /* ordinal235 */
  3449. uint32_t reserved59; /* ordinal236 */
  3450. uint32_t reserved60; /* ordinal237 */
  3451. uint32_t reserved61; /* ordinal238 */
  3452. uint32_t reserved62; /* ordinal239 */
  3453. uint32_t reserved63; /* ordinal240 */
  3454. uint32_t reserved64; /* ordinal241 */
  3455. uint32_t reserved65; /* ordinal242 */
  3456. uint32_t reserved66; /* ordinal243 */
  3457. uint32_t reserved67; /* ordinal244 */
  3458. uint32_t reserved68; /* ordinal245 */
  3459. uint32_t reserved69; /* ordinal246 */
  3460. uint32_t reserved70; /* ordinal247 */
  3461. uint32_t reserved71; /* ordinal248 */
  3462. uint32_t reserved72; /* ordinal249 */
  3463. uint32_t reserved73; /* ordinal250 */
  3464. uint32_t reserved74; /* ordinal251 */
  3465. uint32_t reserved75; /* ordinal252 */
  3466. uint32_t reserved76; /* ordinal253 */
  3467. uint32_t reserved77; /* ordinal254 */
  3468. uint32_t reserved78; /* ordinal255 */
  3469. uint32_t reserved_t[256]; /* Reserve 256 dword buffer used by ucode */
  3470. };
  3471. static void gfx_v8_0_cp_compute_fini(struct amdgpu_device *adev)
  3472. {
  3473. int i, r;
  3474. for (i = 0; i < adev->gfx.num_compute_rings; i++) {
  3475. struct amdgpu_ring *ring = &adev->gfx.compute_ring[i];
  3476. if (ring->mqd_obj) {
  3477. r = amdgpu_bo_reserve(ring->mqd_obj, false);
  3478. if (unlikely(r != 0))
  3479. dev_warn(adev->dev, "(%d) reserve MQD bo failed\n", r);
  3480. amdgpu_bo_unpin(ring->mqd_obj);
  3481. amdgpu_bo_unreserve(ring->mqd_obj);
  3482. amdgpu_bo_unref(&ring->mqd_obj);
  3483. ring->mqd_obj = NULL;
  3484. }
  3485. }
  3486. }
  3487. static int gfx_v8_0_cp_compute_resume(struct amdgpu_device *adev)
  3488. {
  3489. int r, i, j;
  3490. u32 tmp;
  3491. bool use_doorbell = true;
  3492. u64 hqd_gpu_addr;
  3493. u64 mqd_gpu_addr;
  3494. u64 eop_gpu_addr;
  3495. u64 wb_gpu_addr;
  3496. u32 *buf;
  3497. struct vi_mqd *mqd;
  3498. /* init the pipes */
  3499. mutex_lock(&adev->srbm_mutex);
  3500. for (i = 0; i < (adev->gfx.mec.num_pipe * adev->gfx.mec.num_mec); i++) {
  3501. int me = (i < 4) ? 1 : 2;
  3502. int pipe = (i < 4) ? i : (i - 4);
  3503. eop_gpu_addr = adev->gfx.mec.hpd_eop_gpu_addr + (i * MEC_HPD_SIZE);
  3504. eop_gpu_addr >>= 8;
  3505. vi_srbm_select(adev, me, pipe, 0, 0);
  3506. /* write the EOP addr */
  3507. WREG32(mmCP_HQD_EOP_BASE_ADDR, eop_gpu_addr);
  3508. WREG32(mmCP_HQD_EOP_BASE_ADDR_HI, upper_32_bits(eop_gpu_addr));
  3509. /* set the VMID assigned */
  3510. WREG32(mmCP_HQD_VMID, 0);
  3511. /* set the EOP size, register value is 2^(EOP_SIZE+1) dwords */
  3512. tmp = RREG32(mmCP_HQD_EOP_CONTROL);
  3513. tmp = REG_SET_FIELD(tmp, CP_HQD_EOP_CONTROL, EOP_SIZE,
  3514. (order_base_2(MEC_HPD_SIZE / 4) - 1));
  3515. WREG32(mmCP_HQD_EOP_CONTROL, tmp);
  3516. }
  3517. vi_srbm_select(adev, 0, 0, 0, 0);
  3518. mutex_unlock(&adev->srbm_mutex);
  3519. /* init the queues. Just two for now. */
  3520. for (i = 0; i < adev->gfx.num_compute_rings; i++) {
  3521. struct amdgpu_ring *ring = &adev->gfx.compute_ring[i];
  3522. if (ring->mqd_obj == NULL) {
  3523. r = amdgpu_bo_create(adev,
  3524. sizeof(struct vi_mqd),
  3525. PAGE_SIZE, true,
  3526. AMDGPU_GEM_DOMAIN_GTT, 0, NULL,
  3527. NULL, &ring->mqd_obj);
  3528. if (r) {
  3529. dev_warn(adev->dev, "(%d) create MQD bo failed\n", r);
  3530. return r;
  3531. }
  3532. }
  3533. r = amdgpu_bo_reserve(ring->mqd_obj, false);
  3534. if (unlikely(r != 0)) {
  3535. gfx_v8_0_cp_compute_fini(adev);
  3536. return r;
  3537. }
  3538. r = amdgpu_bo_pin(ring->mqd_obj, AMDGPU_GEM_DOMAIN_GTT,
  3539. &mqd_gpu_addr);
  3540. if (r) {
  3541. dev_warn(adev->dev, "(%d) pin MQD bo failed\n", r);
  3542. gfx_v8_0_cp_compute_fini(adev);
  3543. return r;
  3544. }
  3545. r = amdgpu_bo_kmap(ring->mqd_obj, (void **)&buf);
  3546. if (r) {
  3547. dev_warn(adev->dev, "(%d) map MQD bo failed\n", r);
  3548. gfx_v8_0_cp_compute_fini(adev);
  3549. return r;
  3550. }
  3551. /* init the mqd struct */
  3552. memset(buf, 0, sizeof(struct vi_mqd));
  3553. mqd = (struct vi_mqd *)buf;
  3554. mqd->header = 0xC0310800;
  3555. mqd->compute_pipelinestat_enable = 0x00000001;
  3556. mqd->compute_static_thread_mgmt_se0 = 0xffffffff;
  3557. mqd->compute_static_thread_mgmt_se1 = 0xffffffff;
  3558. mqd->compute_static_thread_mgmt_se2 = 0xffffffff;
  3559. mqd->compute_static_thread_mgmt_se3 = 0xffffffff;
  3560. mqd->compute_misc_reserved = 0x00000003;
  3561. mutex_lock(&adev->srbm_mutex);
  3562. vi_srbm_select(adev, ring->me,
  3563. ring->pipe,
  3564. ring->queue, 0);
  3565. /* disable wptr polling */
  3566. tmp = RREG32(mmCP_PQ_WPTR_POLL_CNTL);
  3567. tmp = REG_SET_FIELD(tmp, CP_PQ_WPTR_POLL_CNTL, EN, 0);
  3568. WREG32(mmCP_PQ_WPTR_POLL_CNTL, tmp);
  3569. mqd->cp_hqd_eop_base_addr_lo =
  3570. RREG32(mmCP_HQD_EOP_BASE_ADDR);
  3571. mqd->cp_hqd_eop_base_addr_hi =
  3572. RREG32(mmCP_HQD_EOP_BASE_ADDR_HI);
  3573. /* enable doorbell? */
  3574. tmp = RREG32(mmCP_HQD_PQ_DOORBELL_CONTROL);
  3575. if (use_doorbell) {
  3576. tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL, DOORBELL_EN, 1);
  3577. } else {
  3578. tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL, DOORBELL_EN, 0);
  3579. }
  3580. WREG32(mmCP_HQD_PQ_DOORBELL_CONTROL, tmp);
  3581. mqd->cp_hqd_pq_doorbell_control = tmp;
  3582. /* disable the queue if it's active */
  3583. mqd->cp_hqd_dequeue_request = 0;
  3584. mqd->cp_hqd_pq_rptr = 0;
  3585. mqd->cp_hqd_pq_wptr= 0;
  3586. if (RREG32(mmCP_HQD_ACTIVE) & 1) {
  3587. WREG32(mmCP_HQD_DEQUEUE_REQUEST, 1);
  3588. for (j = 0; j < adev->usec_timeout; j++) {
  3589. if (!(RREG32(mmCP_HQD_ACTIVE) & 1))
  3590. break;
  3591. udelay(1);
  3592. }
  3593. WREG32(mmCP_HQD_DEQUEUE_REQUEST, mqd->cp_hqd_dequeue_request);
  3594. WREG32(mmCP_HQD_PQ_RPTR, mqd->cp_hqd_pq_rptr);
  3595. WREG32(mmCP_HQD_PQ_WPTR, mqd->cp_hqd_pq_wptr);
  3596. }
  3597. /* set the pointer to the MQD */
  3598. mqd->cp_mqd_base_addr_lo = mqd_gpu_addr & 0xfffffffc;
  3599. mqd->cp_mqd_base_addr_hi = upper_32_bits(mqd_gpu_addr);
  3600. WREG32(mmCP_MQD_BASE_ADDR, mqd->cp_mqd_base_addr_lo);
  3601. WREG32(mmCP_MQD_BASE_ADDR_HI, mqd->cp_mqd_base_addr_hi);
  3602. /* set MQD vmid to 0 */
  3603. tmp = RREG32(mmCP_MQD_CONTROL);
  3604. tmp = REG_SET_FIELD(tmp, CP_MQD_CONTROL, VMID, 0);
  3605. WREG32(mmCP_MQD_CONTROL, tmp);
  3606. mqd->cp_mqd_control = tmp;
  3607. /* set the pointer to the HQD, this is similar CP_RB0_BASE/_HI */
  3608. hqd_gpu_addr = ring->gpu_addr >> 8;
  3609. mqd->cp_hqd_pq_base_lo = hqd_gpu_addr;
  3610. mqd->cp_hqd_pq_base_hi = upper_32_bits(hqd_gpu_addr);
  3611. WREG32(mmCP_HQD_PQ_BASE, mqd->cp_hqd_pq_base_lo);
  3612. WREG32(mmCP_HQD_PQ_BASE_HI, mqd->cp_hqd_pq_base_hi);
  3613. /* set up the HQD, this is similar to CP_RB0_CNTL */
  3614. tmp = RREG32(mmCP_HQD_PQ_CONTROL);
  3615. tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, QUEUE_SIZE,
  3616. (order_base_2(ring->ring_size / 4) - 1));
  3617. tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, RPTR_BLOCK_SIZE,
  3618. ((order_base_2(AMDGPU_GPU_PAGE_SIZE / 4) - 1) << 8));
  3619. #ifdef __BIG_ENDIAN
  3620. tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, ENDIAN_SWAP, 1);
  3621. #endif
  3622. tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, UNORD_DISPATCH, 0);
  3623. tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, ROQ_PQ_IB_FLIP, 0);
  3624. tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, PRIV_STATE, 1);
  3625. tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_CONTROL, KMD_QUEUE, 1);
  3626. WREG32(mmCP_HQD_PQ_CONTROL, tmp);
  3627. mqd->cp_hqd_pq_control = tmp;
  3628. /* set the wb address wether it's enabled or not */
  3629. wb_gpu_addr = adev->wb.gpu_addr + (ring->rptr_offs * 4);
  3630. mqd->cp_hqd_pq_rptr_report_addr_lo = wb_gpu_addr & 0xfffffffc;
  3631. mqd->cp_hqd_pq_rptr_report_addr_hi =
  3632. upper_32_bits(wb_gpu_addr) & 0xffff;
  3633. WREG32(mmCP_HQD_PQ_RPTR_REPORT_ADDR,
  3634. mqd->cp_hqd_pq_rptr_report_addr_lo);
  3635. WREG32(mmCP_HQD_PQ_RPTR_REPORT_ADDR_HI,
  3636. mqd->cp_hqd_pq_rptr_report_addr_hi);
  3637. /* only used if CP_PQ_WPTR_POLL_CNTL.CP_PQ_WPTR_POLL_CNTL__EN_MASK=1 */
  3638. wb_gpu_addr = adev->wb.gpu_addr + (ring->wptr_offs * 4);
  3639. mqd->cp_hqd_pq_wptr_poll_addr = wb_gpu_addr & 0xfffffffc;
  3640. mqd->cp_hqd_pq_wptr_poll_addr_hi = upper_32_bits(wb_gpu_addr) & 0xffff;
  3641. WREG32(mmCP_HQD_PQ_WPTR_POLL_ADDR, mqd->cp_hqd_pq_wptr_poll_addr);
  3642. WREG32(mmCP_HQD_PQ_WPTR_POLL_ADDR_HI,
  3643. mqd->cp_hqd_pq_wptr_poll_addr_hi);
  3644. /* enable the doorbell if requested */
  3645. if (use_doorbell) {
  3646. if ((adev->asic_type == CHIP_CARRIZO) ||
  3647. (adev->asic_type == CHIP_FIJI) ||
  3648. (adev->asic_type == CHIP_STONEY)) {
  3649. WREG32(mmCP_MEC_DOORBELL_RANGE_LOWER,
  3650. AMDGPU_DOORBELL_KIQ << 2);
  3651. WREG32(mmCP_MEC_DOORBELL_RANGE_UPPER,
  3652. AMDGPU_DOORBELL_MEC_RING7 << 2);
  3653. }
  3654. tmp = RREG32(mmCP_HQD_PQ_DOORBELL_CONTROL);
  3655. tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL,
  3656. DOORBELL_OFFSET, ring->doorbell_index);
  3657. tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL, DOORBELL_EN, 1);
  3658. tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL, DOORBELL_SOURCE, 0);
  3659. tmp = REG_SET_FIELD(tmp, CP_HQD_PQ_DOORBELL_CONTROL, DOORBELL_HIT, 0);
  3660. mqd->cp_hqd_pq_doorbell_control = tmp;
  3661. } else {
  3662. mqd->cp_hqd_pq_doorbell_control = 0;
  3663. }
  3664. WREG32(mmCP_HQD_PQ_DOORBELL_CONTROL,
  3665. mqd->cp_hqd_pq_doorbell_control);
  3666. /* reset read and write pointers, similar to CP_RB0_WPTR/_RPTR */
  3667. ring->wptr = 0;
  3668. mqd->cp_hqd_pq_wptr = ring->wptr;
  3669. WREG32(mmCP_HQD_PQ_WPTR, mqd->cp_hqd_pq_wptr);
  3670. mqd->cp_hqd_pq_rptr = RREG32(mmCP_HQD_PQ_RPTR);
  3671. /* set the vmid for the queue */
  3672. mqd->cp_hqd_vmid = 0;
  3673. WREG32(mmCP_HQD_VMID, mqd->cp_hqd_vmid);
  3674. tmp = RREG32(mmCP_HQD_PERSISTENT_STATE);
  3675. tmp = REG_SET_FIELD(tmp, CP_HQD_PERSISTENT_STATE, PRELOAD_SIZE, 0x53);
  3676. WREG32(mmCP_HQD_PERSISTENT_STATE, tmp);
  3677. mqd->cp_hqd_persistent_state = tmp;
  3678. /* activate the queue */
  3679. mqd->cp_hqd_active = 1;
  3680. WREG32(mmCP_HQD_ACTIVE, mqd->cp_hqd_active);
  3681. vi_srbm_select(adev, 0, 0, 0, 0);
  3682. mutex_unlock(&adev->srbm_mutex);
  3683. amdgpu_bo_kunmap(ring->mqd_obj);
  3684. amdgpu_bo_unreserve(ring->mqd_obj);
  3685. }
  3686. if (use_doorbell) {
  3687. tmp = RREG32(mmCP_PQ_STATUS);
  3688. tmp = REG_SET_FIELD(tmp, CP_PQ_STATUS, DOORBELL_ENABLE, 1);
  3689. WREG32(mmCP_PQ_STATUS, tmp);
  3690. }
  3691. r = gfx_v8_0_cp_compute_start(adev);
  3692. if (r)
  3693. return r;
  3694. for (i = 0; i < adev->gfx.num_compute_rings; i++) {
  3695. struct amdgpu_ring *ring = &adev->gfx.compute_ring[i];
  3696. ring->ready = true;
  3697. r = amdgpu_ring_test_ring(ring);
  3698. if (r)
  3699. ring->ready = false;
  3700. }
  3701. return 0;
  3702. }
  3703. static int gfx_v8_0_cp_resume(struct amdgpu_device *adev)
  3704. {
  3705. int r;
  3706. if (!(adev->flags & AMD_IS_APU))
  3707. gfx_v8_0_enable_gui_idle_interrupt(adev, false);
  3708. if (!adev->firmware.smu_load) {
  3709. /* legacy firmware loading */
  3710. r = gfx_v8_0_cp_gfx_load_microcode(adev);
  3711. if (r)
  3712. return r;
  3713. r = gfx_v8_0_cp_compute_load_microcode(adev);
  3714. if (r)
  3715. return r;
  3716. } else {
  3717. r = adev->smu.smumgr_funcs->check_fw_load_finish(adev,
  3718. AMDGPU_UCODE_ID_CP_CE);
  3719. if (r)
  3720. return -EINVAL;
  3721. r = adev->smu.smumgr_funcs->check_fw_load_finish(adev,
  3722. AMDGPU_UCODE_ID_CP_PFP);
  3723. if (r)
  3724. return -EINVAL;
  3725. r = adev->smu.smumgr_funcs->check_fw_load_finish(adev,
  3726. AMDGPU_UCODE_ID_CP_ME);
  3727. if (r)
  3728. return -EINVAL;
  3729. r = adev->smu.smumgr_funcs->check_fw_load_finish(adev,
  3730. AMDGPU_UCODE_ID_CP_MEC1);
  3731. if (r)
  3732. return -EINVAL;
  3733. }
  3734. r = gfx_v8_0_cp_gfx_resume(adev);
  3735. if (r)
  3736. return r;
  3737. r = gfx_v8_0_cp_compute_resume(adev);
  3738. if (r)
  3739. return r;
  3740. gfx_v8_0_enable_gui_idle_interrupt(adev, true);
  3741. return 0;
  3742. }
  3743. static void gfx_v8_0_cp_enable(struct amdgpu_device *adev, bool enable)
  3744. {
  3745. gfx_v8_0_cp_gfx_enable(adev, enable);
  3746. gfx_v8_0_cp_compute_enable(adev, enable);
  3747. }
  3748. static int gfx_v8_0_hw_init(void *handle)
  3749. {
  3750. int r;
  3751. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  3752. gfx_v8_0_init_golden_registers(adev);
  3753. gfx_v8_0_gpu_init(adev);
  3754. r = gfx_v8_0_rlc_resume(adev);
  3755. if (r)
  3756. return r;
  3757. r = gfx_v8_0_cp_resume(adev);
  3758. if (r)
  3759. return r;
  3760. return r;
  3761. }
  3762. static int gfx_v8_0_hw_fini(void *handle)
  3763. {
  3764. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  3765. gfx_v8_0_cp_enable(adev, false);
  3766. gfx_v8_0_rlc_stop(adev);
  3767. gfx_v8_0_cp_compute_fini(adev);
  3768. return 0;
  3769. }
  3770. static int gfx_v8_0_suspend(void *handle)
  3771. {
  3772. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  3773. return gfx_v8_0_hw_fini(adev);
  3774. }
  3775. static int gfx_v8_0_resume(void *handle)
  3776. {
  3777. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  3778. return gfx_v8_0_hw_init(adev);
  3779. }
  3780. static bool gfx_v8_0_is_idle(void *handle)
  3781. {
  3782. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  3783. if (REG_GET_FIELD(RREG32(mmGRBM_STATUS), GRBM_STATUS, GUI_ACTIVE))
  3784. return false;
  3785. else
  3786. return true;
  3787. }
  3788. static int gfx_v8_0_wait_for_idle(void *handle)
  3789. {
  3790. unsigned i;
  3791. u32 tmp;
  3792. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  3793. for (i = 0; i < adev->usec_timeout; i++) {
  3794. /* read MC_STATUS */
  3795. tmp = RREG32(mmGRBM_STATUS) & GRBM_STATUS__GUI_ACTIVE_MASK;
  3796. if (!REG_GET_FIELD(tmp, GRBM_STATUS, GUI_ACTIVE))
  3797. return 0;
  3798. udelay(1);
  3799. }
  3800. return -ETIMEDOUT;
  3801. }
  3802. static void gfx_v8_0_print_status(void *handle)
  3803. {
  3804. int i;
  3805. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  3806. dev_info(adev->dev, "GFX 8.x registers\n");
  3807. dev_info(adev->dev, " GRBM_STATUS=0x%08X\n",
  3808. RREG32(mmGRBM_STATUS));
  3809. dev_info(adev->dev, " GRBM_STATUS2=0x%08X\n",
  3810. RREG32(mmGRBM_STATUS2));
  3811. dev_info(adev->dev, " GRBM_STATUS_SE0=0x%08X\n",
  3812. RREG32(mmGRBM_STATUS_SE0));
  3813. dev_info(adev->dev, " GRBM_STATUS_SE1=0x%08X\n",
  3814. RREG32(mmGRBM_STATUS_SE1));
  3815. dev_info(adev->dev, " GRBM_STATUS_SE2=0x%08X\n",
  3816. RREG32(mmGRBM_STATUS_SE2));
  3817. dev_info(adev->dev, " GRBM_STATUS_SE3=0x%08X\n",
  3818. RREG32(mmGRBM_STATUS_SE3));
  3819. dev_info(adev->dev, " CP_STAT = 0x%08x\n", RREG32(mmCP_STAT));
  3820. dev_info(adev->dev, " CP_STALLED_STAT1 = 0x%08x\n",
  3821. RREG32(mmCP_STALLED_STAT1));
  3822. dev_info(adev->dev, " CP_STALLED_STAT2 = 0x%08x\n",
  3823. RREG32(mmCP_STALLED_STAT2));
  3824. dev_info(adev->dev, " CP_STALLED_STAT3 = 0x%08x\n",
  3825. RREG32(mmCP_STALLED_STAT3));
  3826. dev_info(adev->dev, " CP_CPF_BUSY_STAT = 0x%08x\n",
  3827. RREG32(mmCP_CPF_BUSY_STAT));
  3828. dev_info(adev->dev, " CP_CPF_STALLED_STAT1 = 0x%08x\n",
  3829. RREG32(mmCP_CPF_STALLED_STAT1));
  3830. dev_info(adev->dev, " CP_CPF_STATUS = 0x%08x\n", RREG32(mmCP_CPF_STATUS));
  3831. dev_info(adev->dev, " CP_CPC_BUSY_STAT = 0x%08x\n", RREG32(mmCP_CPC_BUSY_STAT));
  3832. dev_info(adev->dev, " CP_CPC_STALLED_STAT1 = 0x%08x\n",
  3833. RREG32(mmCP_CPC_STALLED_STAT1));
  3834. dev_info(adev->dev, " CP_CPC_STATUS = 0x%08x\n", RREG32(mmCP_CPC_STATUS));
  3835. for (i = 0; i < 32; i++) {
  3836. dev_info(adev->dev, " GB_TILE_MODE%d=0x%08X\n",
  3837. i, RREG32(mmGB_TILE_MODE0 + (i * 4)));
  3838. }
  3839. for (i = 0; i < 16; i++) {
  3840. dev_info(adev->dev, " GB_MACROTILE_MODE%d=0x%08X\n",
  3841. i, RREG32(mmGB_MACROTILE_MODE0 + (i * 4)));
  3842. }
  3843. for (i = 0; i < adev->gfx.config.max_shader_engines; i++) {
  3844. dev_info(adev->dev, " se: %d\n", i);
  3845. gfx_v8_0_select_se_sh(adev, i, 0xffffffff);
  3846. dev_info(adev->dev, " PA_SC_RASTER_CONFIG=0x%08X\n",
  3847. RREG32(mmPA_SC_RASTER_CONFIG));
  3848. dev_info(adev->dev, " PA_SC_RASTER_CONFIG_1=0x%08X\n",
  3849. RREG32(mmPA_SC_RASTER_CONFIG_1));
  3850. }
  3851. gfx_v8_0_select_se_sh(adev, 0xffffffff, 0xffffffff);
  3852. dev_info(adev->dev, " GB_ADDR_CONFIG=0x%08X\n",
  3853. RREG32(mmGB_ADDR_CONFIG));
  3854. dev_info(adev->dev, " HDP_ADDR_CONFIG=0x%08X\n",
  3855. RREG32(mmHDP_ADDR_CONFIG));
  3856. dev_info(adev->dev, " DMIF_ADDR_CALC=0x%08X\n",
  3857. RREG32(mmDMIF_ADDR_CALC));
  3858. dev_info(adev->dev, " SDMA0_TILING_CONFIG=0x%08X\n",
  3859. RREG32(mmSDMA0_TILING_CONFIG + SDMA0_REGISTER_OFFSET));
  3860. dev_info(adev->dev, " SDMA1_TILING_CONFIG=0x%08X\n",
  3861. RREG32(mmSDMA0_TILING_CONFIG + SDMA1_REGISTER_OFFSET));
  3862. dev_info(adev->dev, " UVD_UDEC_ADDR_CONFIG=0x%08X\n",
  3863. RREG32(mmUVD_UDEC_ADDR_CONFIG));
  3864. dev_info(adev->dev, " UVD_UDEC_DB_ADDR_CONFIG=0x%08X\n",
  3865. RREG32(mmUVD_UDEC_DB_ADDR_CONFIG));
  3866. dev_info(adev->dev, " UVD_UDEC_DBW_ADDR_CONFIG=0x%08X\n",
  3867. RREG32(mmUVD_UDEC_DBW_ADDR_CONFIG));
  3868. dev_info(adev->dev, " CP_MEQ_THRESHOLDS=0x%08X\n",
  3869. RREG32(mmCP_MEQ_THRESHOLDS));
  3870. dev_info(adev->dev, " SX_DEBUG_1=0x%08X\n",
  3871. RREG32(mmSX_DEBUG_1));
  3872. dev_info(adev->dev, " TA_CNTL_AUX=0x%08X\n",
  3873. RREG32(mmTA_CNTL_AUX));
  3874. dev_info(adev->dev, " SPI_CONFIG_CNTL=0x%08X\n",
  3875. RREG32(mmSPI_CONFIG_CNTL));
  3876. dev_info(adev->dev, " SQ_CONFIG=0x%08X\n",
  3877. RREG32(mmSQ_CONFIG));
  3878. dev_info(adev->dev, " DB_DEBUG=0x%08X\n",
  3879. RREG32(mmDB_DEBUG));
  3880. dev_info(adev->dev, " DB_DEBUG2=0x%08X\n",
  3881. RREG32(mmDB_DEBUG2));
  3882. dev_info(adev->dev, " DB_DEBUG3=0x%08X\n",
  3883. RREG32(mmDB_DEBUG3));
  3884. dev_info(adev->dev, " CB_HW_CONTROL=0x%08X\n",
  3885. RREG32(mmCB_HW_CONTROL));
  3886. dev_info(adev->dev, " SPI_CONFIG_CNTL_1=0x%08X\n",
  3887. RREG32(mmSPI_CONFIG_CNTL_1));
  3888. dev_info(adev->dev, " PA_SC_FIFO_SIZE=0x%08X\n",
  3889. RREG32(mmPA_SC_FIFO_SIZE));
  3890. dev_info(adev->dev, " VGT_NUM_INSTANCES=0x%08X\n",
  3891. RREG32(mmVGT_NUM_INSTANCES));
  3892. dev_info(adev->dev, " CP_PERFMON_CNTL=0x%08X\n",
  3893. RREG32(mmCP_PERFMON_CNTL));
  3894. dev_info(adev->dev, " PA_SC_FORCE_EOV_MAX_CNTS=0x%08X\n",
  3895. RREG32(mmPA_SC_FORCE_EOV_MAX_CNTS));
  3896. dev_info(adev->dev, " VGT_CACHE_INVALIDATION=0x%08X\n",
  3897. RREG32(mmVGT_CACHE_INVALIDATION));
  3898. dev_info(adev->dev, " VGT_GS_VERTEX_REUSE=0x%08X\n",
  3899. RREG32(mmVGT_GS_VERTEX_REUSE));
  3900. dev_info(adev->dev, " PA_SC_LINE_STIPPLE_STATE=0x%08X\n",
  3901. RREG32(mmPA_SC_LINE_STIPPLE_STATE));
  3902. dev_info(adev->dev, " PA_CL_ENHANCE=0x%08X\n",
  3903. RREG32(mmPA_CL_ENHANCE));
  3904. dev_info(adev->dev, " PA_SC_ENHANCE=0x%08X\n",
  3905. RREG32(mmPA_SC_ENHANCE));
  3906. dev_info(adev->dev, " CP_ME_CNTL=0x%08X\n",
  3907. RREG32(mmCP_ME_CNTL));
  3908. dev_info(adev->dev, " CP_MAX_CONTEXT=0x%08X\n",
  3909. RREG32(mmCP_MAX_CONTEXT));
  3910. dev_info(adev->dev, " CP_ENDIAN_SWAP=0x%08X\n",
  3911. RREG32(mmCP_ENDIAN_SWAP));
  3912. dev_info(adev->dev, " CP_DEVICE_ID=0x%08X\n",
  3913. RREG32(mmCP_DEVICE_ID));
  3914. dev_info(adev->dev, " CP_SEM_WAIT_TIMER=0x%08X\n",
  3915. RREG32(mmCP_SEM_WAIT_TIMER));
  3916. dev_info(adev->dev, " CP_RB_WPTR_DELAY=0x%08X\n",
  3917. RREG32(mmCP_RB_WPTR_DELAY));
  3918. dev_info(adev->dev, " CP_RB_VMID=0x%08X\n",
  3919. RREG32(mmCP_RB_VMID));
  3920. dev_info(adev->dev, " CP_RB0_CNTL=0x%08X\n",
  3921. RREG32(mmCP_RB0_CNTL));
  3922. dev_info(adev->dev, " CP_RB0_WPTR=0x%08X\n",
  3923. RREG32(mmCP_RB0_WPTR));
  3924. dev_info(adev->dev, " CP_RB0_RPTR_ADDR=0x%08X\n",
  3925. RREG32(mmCP_RB0_RPTR_ADDR));
  3926. dev_info(adev->dev, " CP_RB0_RPTR_ADDR_HI=0x%08X\n",
  3927. RREG32(mmCP_RB0_RPTR_ADDR_HI));
  3928. dev_info(adev->dev, " CP_RB0_CNTL=0x%08X\n",
  3929. RREG32(mmCP_RB0_CNTL));
  3930. dev_info(adev->dev, " CP_RB0_BASE=0x%08X\n",
  3931. RREG32(mmCP_RB0_BASE));
  3932. dev_info(adev->dev, " CP_RB0_BASE_HI=0x%08X\n",
  3933. RREG32(mmCP_RB0_BASE_HI));
  3934. dev_info(adev->dev, " CP_MEC_CNTL=0x%08X\n",
  3935. RREG32(mmCP_MEC_CNTL));
  3936. dev_info(adev->dev, " CP_CPF_DEBUG=0x%08X\n",
  3937. RREG32(mmCP_CPF_DEBUG));
  3938. dev_info(adev->dev, " SCRATCH_ADDR=0x%08X\n",
  3939. RREG32(mmSCRATCH_ADDR));
  3940. dev_info(adev->dev, " SCRATCH_UMSK=0x%08X\n",
  3941. RREG32(mmSCRATCH_UMSK));
  3942. dev_info(adev->dev, " CP_INT_CNTL_RING0=0x%08X\n",
  3943. RREG32(mmCP_INT_CNTL_RING0));
  3944. dev_info(adev->dev, " RLC_LB_CNTL=0x%08X\n",
  3945. RREG32(mmRLC_LB_CNTL));
  3946. dev_info(adev->dev, " RLC_CNTL=0x%08X\n",
  3947. RREG32(mmRLC_CNTL));
  3948. dev_info(adev->dev, " RLC_CGCG_CGLS_CTRL=0x%08X\n",
  3949. RREG32(mmRLC_CGCG_CGLS_CTRL));
  3950. dev_info(adev->dev, " RLC_LB_CNTR_INIT=0x%08X\n",
  3951. RREG32(mmRLC_LB_CNTR_INIT));
  3952. dev_info(adev->dev, " RLC_LB_CNTR_MAX=0x%08X\n",
  3953. RREG32(mmRLC_LB_CNTR_MAX));
  3954. dev_info(adev->dev, " RLC_LB_INIT_CU_MASK=0x%08X\n",
  3955. RREG32(mmRLC_LB_INIT_CU_MASK));
  3956. dev_info(adev->dev, " RLC_LB_PARAMS=0x%08X\n",
  3957. RREG32(mmRLC_LB_PARAMS));
  3958. dev_info(adev->dev, " RLC_LB_CNTL=0x%08X\n",
  3959. RREG32(mmRLC_LB_CNTL));
  3960. dev_info(adev->dev, " RLC_MC_CNTL=0x%08X\n",
  3961. RREG32(mmRLC_MC_CNTL));
  3962. dev_info(adev->dev, " RLC_UCODE_CNTL=0x%08X\n",
  3963. RREG32(mmRLC_UCODE_CNTL));
  3964. mutex_lock(&adev->srbm_mutex);
  3965. for (i = 0; i < 16; i++) {
  3966. vi_srbm_select(adev, 0, 0, 0, i);
  3967. dev_info(adev->dev, " VM %d:\n", i);
  3968. dev_info(adev->dev, " SH_MEM_CONFIG=0x%08X\n",
  3969. RREG32(mmSH_MEM_CONFIG));
  3970. dev_info(adev->dev, " SH_MEM_APE1_BASE=0x%08X\n",
  3971. RREG32(mmSH_MEM_APE1_BASE));
  3972. dev_info(adev->dev, " SH_MEM_APE1_LIMIT=0x%08X\n",
  3973. RREG32(mmSH_MEM_APE1_LIMIT));
  3974. dev_info(adev->dev, " SH_MEM_BASES=0x%08X\n",
  3975. RREG32(mmSH_MEM_BASES));
  3976. }
  3977. vi_srbm_select(adev, 0, 0, 0, 0);
  3978. mutex_unlock(&adev->srbm_mutex);
  3979. }
  3980. static int gfx_v8_0_soft_reset(void *handle)
  3981. {
  3982. u32 grbm_soft_reset = 0, srbm_soft_reset = 0;
  3983. u32 tmp;
  3984. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  3985. /* GRBM_STATUS */
  3986. tmp = RREG32(mmGRBM_STATUS);
  3987. if (tmp & (GRBM_STATUS__PA_BUSY_MASK | GRBM_STATUS__SC_BUSY_MASK |
  3988. GRBM_STATUS__BCI_BUSY_MASK | GRBM_STATUS__SX_BUSY_MASK |
  3989. GRBM_STATUS__TA_BUSY_MASK | GRBM_STATUS__VGT_BUSY_MASK |
  3990. GRBM_STATUS__DB_BUSY_MASK | GRBM_STATUS__CB_BUSY_MASK |
  3991. GRBM_STATUS__GDS_BUSY_MASK | GRBM_STATUS__SPI_BUSY_MASK |
  3992. GRBM_STATUS__IA_BUSY_MASK | GRBM_STATUS__IA_BUSY_NO_DMA_MASK)) {
  3993. grbm_soft_reset = REG_SET_FIELD(grbm_soft_reset,
  3994. GRBM_SOFT_RESET, SOFT_RESET_CP, 1);
  3995. grbm_soft_reset = REG_SET_FIELD(grbm_soft_reset,
  3996. GRBM_SOFT_RESET, SOFT_RESET_GFX, 1);
  3997. }
  3998. if (tmp & (GRBM_STATUS__CP_BUSY_MASK | GRBM_STATUS__CP_COHERENCY_BUSY_MASK)) {
  3999. grbm_soft_reset = REG_SET_FIELD(grbm_soft_reset,
  4000. GRBM_SOFT_RESET, SOFT_RESET_CP, 1);
  4001. srbm_soft_reset = REG_SET_FIELD(srbm_soft_reset,
  4002. SRBM_SOFT_RESET, SOFT_RESET_GRBM, 1);
  4003. }
  4004. /* GRBM_STATUS2 */
  4005. tmp = RREG32(mmGRBM_STATUS2);
  4006. if (REG_GET_FIELD(tmp, GRBM_STATUS2, RLC_BUSY))
  4007. grbm_soft_reset = REG_SET_FIELD(grbm_soft_reset,
  4008. GRBM_SOFT_RESET, SOFT_RESET_RLC, 1);
  4009. /* SRBM_STATUS */
  4010. tmp = RREG32(mmSRBM_STATUS);
  4011. if (REG_GET_FIELD(tmp, SRBM_STATUS, GRBM_RQ_PENDING))
  4012. srbm_soft_reset = REG_SET_FIELD(srbm_soft_reset,
  4013. SRBM_SOFT_RESET, SOFT_RESET_GRBM, 1);
  4014. if (grbm_soft_reset || srbm_soft_reset) {
  4015. gfx_v8_0_print_status((void *)adev);
  4016. /* stop the rlc */
  4017. gfx_v8_0_rlc_stop(adev);
  4018. /* Disable GFX parsing/prefetching */
  4019. gfx_v8_0_cp_gfx_enable(adev, false);
  4020. /* Disable MEC parsing/prefetching */
  4021. /* XXX todo */
  4022. if (grbm_soft_reset) {
  4023. tmp = RREG32(mmGRBM_SOFT_RESET);
  4024. tmp |= grbm_soft_reset;
  4025. dev_info(adev->dev, "GRBM_SOFT_RESET=0x%08X\n", tmp);
  4026. WREG32(mmGRBM_SOFT_RESET, tmp);
  4027. tmp = RREG32(mmGRBM_SOFT_RESET);
  4028. udelay(50);
  4029. tmp &= ~grbm_soft_reset;
  4030. WREG32(mmGRBM_SOFT_RESET, tmp);
  4031. tmp = RREG32(mmGRBM_SOFT_RESET);
  4032. }
  4033. if (srbm_soft_reset) {
  4034. tmp = RREG32(mmSRBM_SOFT_RESET);
  4035. tmp |= srbm_soft_reset;
  4036. dev_info(adev->dev, "SRBM_SOFT_RESET=0x%08X\n", tmp);
  4037. WREG32(mmSRBM_SOFT_RESET, tmp);
  4038. tmp = RREG32(mmSRBM_SOFT_RESET);
  4039. udelay(50);
  4040. tmp &= ~srbm_soft_reset;
  4041. WREG32(mmSRBM_SOFT_RESET, tmp);
  4042. tmp = RREG32(mmSRBM_SOFT_RESET);
  4043. }
  4044. /* Wait a little for things to settle down */
  4045. udelay(50);
  4046. gfx_v8_0_print_status((void *)adev);
  4047. }
  4048. return 0;
  4049. }
  4050. /**
  4051. * gfx_v8_0_get_gpu_clock_counter - return GPU clock counter snapshot
  4052. *
  4053. * @adev: amdgpu_device pointer
  4054. *
  4055. * Fetches a GPU clock counter snapshot.
  4056. * Returns the 64 bit clock counter snapshot.
  4057. */
  4058. uint64_t gfx_v8_0_get_gpu_clock_counter(struct amdgpu_device *adev)
  4059. {
  4060. uint64_t clock;
  4061. mutex_lock(&adev->gfx.gpu_clock_mutex);
  4062. WREG32(mmRLC_CAPTURE_GPU_CLOCK_COUNT, 1);
  4063. clock = (uint64_t)RREG32(mmRLC_GPU_CLOCK_COUNT_LSB) |
  4064. ((uint64_t)RREG32(mmRLC_GPU_CLOCK_COUNT_MSB) << 32ULL);
  4065. mutex_unlock(&adev->gfx.gpu_clock_mutex);
  4066. return clock;
  4067. }
  4068. static void gfx_v8_0_ring_emit_gds_switch(struct amdgpu_ring *ring,
  4069. uint32_t vmid,
  4070. uint32_t gds_base, uint32_t gds_size,
  4071. uint32_t gws_base, uint32_t gws_size,
  4072. uint32_t oa_base, uint32_t oa_size)
  4073. {
  4074. gds_base = gds_base >> AMDGPU_GDS_SHIFT;
  4075. gds_size = gds_size >> AMDGPU_GDS_SHIFT;
  4076. gws_base = gws_base >> AMDGPU_GWS_SHIFT;
  4077. gws_size = gws_size >> AMDGPU_GWS_SHIFT;
  4078. oa_base = oa_base >> AMDGPU_OA_SHIFT;
  4079. oa_size = oa_size >> AMDGPU_OA_SHIFT;
  4080. /* GDS Base */
  4081. amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));
  4082. amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) |
  4083. WRITE_DATA_DST_SEL(0)));
  4084. amdgpu_ring_write(ring, amdgpu_gds_reg_offset[vmid].mem_base);
  4085. amdgpu_ring_write(ring, 0);
  4086. amdgpu_ring_write(ring, gds_base);
  4087. /* GDS Size */
  4088. amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));
  4089. amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) |
  4090. WRITE_DATA_DST_SEL(0)));
  4091. amdgpu_ring_write(ring, amdgpu_gds_reg_offset[vmid].mem_size);
  4092. amdgpu_ring_write(ring, 0);
  4093. amdgpu_ring_write(ring, gds_size);
  4094. /* GWS */
  4095. amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));
  4096. amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) |
  4097. WRITE_DATA_DST_SEL(0)));
  4098. amdgpu_ring_write(ring, amdgpu_gds_reg_offset[vmid].gws);
  4099. amdgpu_ring_write(ring, 0);
  4100. amdgpu_ring_write(ring, gws_size << GDS_GWS_VMID0__SIZE__SHIFT | gws_base);
  4101. /* OA */
  4102. amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));
  4103. amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) |
  4104. WRITE_DATA_DST_SEL(0)));
  4105. amdgpu_ring_write(ring, amdgpu_gds_reg_offset[vmid].oa);
  4106. amdgpu_ring_write(ring, 0);
  4107. amdgpu_ring_write(ring, (1 << (oa_size + oa_base)) - (1 << oa_base));
  4108. }
  4109. static int gfx_v8_0_early_init(void *handle)
  4110. {
  4111. struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  4112. adev->gfx.num_gfx_rings = GFX8_NUM_GFX_RINGS;
  4113. adev->gfx.num_compute_rings = GFX8_NUM_COMPUTE_RINGS;
  4114. gfx_v8_0_set_ring_funcs(adev);
  4115. gfx_v8_0_set_irq_funcs(adev);
  4116. gfx_v8_0_set_gds_init(adev);
  4117. return 0;
  4118. }
  4119. static int gfx_v8_0_set_powergating_state(void *handle,
  4120. enum amd_powergating_state state)
  4121. {
  4122. return 0;
  4123. }
  4124. static int gfx_v8_0_set_clockgating_state(void *handle,
  4125. enum amd_clockgating_state state)
  4126. {
  4127. return 0;
  4128. }
  4129. static u32 gfx_v8_0_ring_get_rptr_gfx(struct amdgpu_ring *ring)
  4130. {
  4131. u32 rptr;
  4132. rptr = ring->adev->wb.wb[ring->rptr_offs];
  4133. return rptr;
  4134. }
  4135. static u32 gfx_v8_0_ring_get_wptr_gfx(struct amdgpu_ring *ring)
  4136. {
  4137. struct amdgpu_device *adev = ring->adev;
  4138. u32 wptr;
  4139. if (ring->use_doorbell)
  4140. /* XXX check if swapping is necessary on BE */
  4141. wptr = ring->adev->wb.wb[ring->wptr_offs];
  4142. else
  4143. wptr = RREG32(mmCP_RB0_WPTR);
  4144. return wptr;
  4145. }
  4146. static void gfx_v8_0_ring_set_wptr_gfx(struct amdgpu_ring *ring)
  4147. {
  4148. struct amdgpu_device *adev = ring->adev;
  4149. if (ring->use_doorbell) {
  4150. /* XXX check if swapping is necessary on BE */
  4151. adev->wb.wb[ring->wptr_offs] = ring->wptr;
  4152. WDOORBELL32(ring->doorbell_index, ring->wptr);
  4153. } else {
  4154. WREG32(mmCP_RB0_WPTR, ring->wptr);
  4155. (void)RREG32(mmCP_RB0_WPTR);
  4156. }
  4157. }
  4158. static void gfx_v8_0_ring_emit_hdp_flush(struct amdgpu_ring *ring)
  4159. {
  4160. u32 ref_and_mask, reg_mem_engine;
  4161. if (ring->type == AMDGPU_RING_TYPE_COMPUTE) {
  4162. switch (ring->me) {
  4163. case 1:
  4164. ref_and_mask = GPU_HDP_FLUSH_DONE__CP2_MASK << ring->pipe;
  4165. break;
  4166. case 2:
  4167. ref_and_mask = GPU_HDP_FLUSH_DONE__CP6_MASK << ring->pipe;
  4168. break;
  4169. default:
  4170. return;
  4171. }
  4172. reg_mem_engine = 0;
  4173. } else {
  4174. ref_and_mask = GPU_HDP_FLUSH_DONE__CP0_MASK;
  4175. reg_mem_engine = WAIT_REG_MEM_ENGINE(1); /* pfp */
  4176. }
  4177. amdgpu_ring_write(ring, PACKET3(PACKET3_WAIT_REG_MEM, 5));
  4178. amdgpu_ring_write(ring, (WAIT_REG_MEM_OPERATION(1) | /* write, wait, write */
  4179. WAIT_REG_MEM_FUNCTION(3) | /* == */
  4180. reg_mem_engine));
  4181. amdgpu_ring_write(ring, mmGPU_HDP_FLUSH_REQ);
  4182. amdgpu_ring_write(ring, mmGPU_HDP_FLUSH_DONE);
  4183. amdgpu_ring_write(ring, ref_and_mask);
  4184. amdgpu_ring_write(ring, ref_and_mask);
  4185. amdgpu_ring_write(ring, 0x20); /* poll interval */
  4186. }
  4187. static void gfx_v8_0_ring_emit_ib_gfx(struct amdgpu_ring *ring,
  4188. struct amdgpu_ib *ib)
  4189. {
  4190. bool need_ctx_switch = ring->current_ctx != ib->ctx;
  4191. u32 header, control = 0;
  4192. u32 next_rptr = ring->wptr + 5;
  4193. /* drop the CE preamble IB for the same context */
  4194. if ((ib->flags & AMDGPU_IB_FLAG_PREAMBLE) && !need_ctx_switch)
  4195. return;
  4196. if (need_ctx_switch)
  4197. next_rptr += 2;
  4198. next_rptr += 4;
  4199. amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));
  4200. amdgpu_ring_write(ring, WRITE_DATA_DST_SEL(5) | WR_CONFIRM);
  4201. amdgpu_ring_write(ring, ring->next_rptr_gpu_addr & 0xfffffffc);
  4202. amdgpu_ring_write(ring, upper_32_bits(ring->next_rptr_gpu_addr) & 0xffffffff);
  4203. amdgpu_ring_write(ring, next_rptr);
  4204. /* insert SWITCH_BUFFER packet before first IB in the ring frame */
  4205. if (need_ctx_switch) {
  4206. amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0));
  4207. amdgpu_ring_write(ring, 0);
  4208. }
  4209. if (ib->flags & AMDGPU_IB_FLAG_CE)
  4210. header = PACKET3(PACKET3_INDIRECT_BUFFER_CONST, 2);
  4211. else
  4212. header = PACKET3(PACKET3_INDIRECT_BUFFER, 2);
  4213. control |= ib->length_dw |
  4214. (ib->vm ? (ib->vm->ids[ring->idx].id << 24) : 0);
  4215. amdgpu_ring_write(ring, header);
  4216. amdgpu_ring_write(ring,
  4217. #ifdef __BIG_ENDIAN
  4218. (2 << 0) |
  4219. #endif
  4220. (ib->gpu_addr & 0xFFFFFFFC));
  4221. amdgpu_ring_write(ring, upper_32_bits(ib->gpu_addr) & 0xFFFF);
  4222. amdgpu_ring_write(ring, control);
  4223. }
  4224. static void gfx_v8_0_ring_emit_ib_compute(struct amdgpu_ring *ring,
  4225. struct amdgpu_ib *ib)
  4226. {
  4227. u32 header, control = 0;
  4228. u32 next_rptr = ring->wptr + 5;
  4229. control |= INDIRECT_BUFFER_VALID;
  4230. next_rptr += 4;
  4231. amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));
  4232. amdgpu_ring_write(ring, WRITE_DATA_DST_SEL(5) | WR_CONFIRM);
  4233. amdgpu_ring_write(ring, ring->next_rptr_gpu_addr & 0xfffffffc);
  4234. amdgpu_ring_write(ring, upper_32_bits(ring->next_rptr_gpu_addr) & 0xffffffff);
  4235. amdgpu_ring_write(ring, next_rptr);
  4236. header = PACKET3(PACKET3_INDIRECT_BUFFER, 2);
  4237. control |= ib->length_dw |
  4238. (ib->vm ? (ib->vm->ids[ring->idx].id << 24) : 0);
  4239. amdgpu_ring_write(ring, header);
  4240. amdgpu_ring_write(ring,
  4241. #ifdef __BIG_ENDIAN
  4242. (2 << 0) |
  4243. #endif
  4244. (ib->gpu_addr & 0xFFFFFFFC));
  4245. amdgpu_ring_write(ring, upper_32_bits(ib->gpu_addr) & 0xFFFF);
  4246. amdgpu_ring_write(ring, control);
  4247. }
  4248. static void gfx_v8_0_ring_emit_fence_gfx(struct amdgpu_ring *ring, u64 addr,
  4249. u64 seq, unsigned flags)
  4250. {
  4251. bool write64bit = flags & AMDGPU_FENCE_FLAG_64BIT;
  4252. bool int_sel = flags & AMDGPU_FENCE_FLAG_INT;
  4253. /* EVENT_WRITE_EOP - flush caches, send int */
  4254. amdgpu_ring_write(ring, PACKET3(PACKET3_EVENT_WRITE_EOP, 4));
  4255. amdgpu_ring_write(ring, (EOP_TCL1_ACTION_EN |
  4256. EOP_TC_ACTION_EN |
  4257. EVENT_TYPE(CACHE_FLUSH_AND_INV_TS_EVENT) |
  4258. EVENT_INDEX(5)));
  4259. amdgpu_ring_write(ring, addr & 0xfffffffc);
  4260. amdgpu_ring_write(ring, (upper_32_bits(addr) & 0xffff) |
  4261. DATA_SEL(write64bit ? 2 : 1) | INT_SEL(int_sel ? 2 : 0));
  4262. amdgpu_ring_write(ring, lower_32_bits(seq));
  4263. amdgpu_ring_write(ring, upper_32_bits(seq));
  4264. }
  4265. /**
  4266. * gfx_v8_0_ring_emit_semaphore - emit a semaphore on the CP ring
  4267. *
  4268. * @ring: amdgpu ring buffer object
  4269. * @semaphore: amdgpu semaphore object
  4270. * @emit_wait: Is this a sempahore wait?
  4271. *
  4272. * Emits a semaphore signal/wait packet to the CP ring and prevents the PFP
  4273. * from running ahead of semaphore waits.
  4274. */
  4275. static bool gfx_v8_0_ring_emit_semaphore(struct amdgpu_ring *ring,
  4276. struct amdgpu_semaphore *semaphore,
  4277. bool emit_wait)
  4278. {
  4279. uint64_t addr = semaphore->gpu_addr;
  4280. unsigned sel = emit_wait ? PACKET3_SEM_SEL_WAIT : PACKET3_SEM_SEL_SIGNAL;
  4281. if (ring->adev->asic_type == CHIP_TOPAZ ||
  4282. ring->adev->asic_type == CHIP_TONGA ||
  4283. ring->adev->asic_type == CHIP_FIJI)
  4284. /* we got a hw semaphore bug in VI TONGA, return false to switch back to sw fence wait */
  4285. return false;
  4286. else {
  4287. amdgpu_ring_write(ring, PACKET3(PACKET3_MEM_SEMAPHORE, 2));
  4288. amdgpu_ring_write(ring, lower_32_bits(addr));
  4289. amdgpu_ring_write(ring, upper_32_bits(addr));
  4290. amdgpu_ring_write(ring, sel);
  4291. }
  4292. if (emit_wait && (ring->type == AMDGPU_RING_TYPE_GFX)) {
  4293. /* Prevent the PFP from running ahead of the semaphore wait */
  4294. amdgpu_ring_write(ring, PACKET3(PACKET3_PFP_SYNC_ME, 0));
  4295. amdgpu_ring_write(ring, 0x0);
  4296. }
  4297. return true;
  4298. }
  4299. static void gfx_v8_0_ring_emit_vm_flush(struct amdgpu_ring *ring,
  4300. unsigned vm_id, uint64_t pd_addr)
  4301. {
  4302. int usepfp = (ring->type == AMDGPU_RING_TYPE_GFX);
  4303. uint32_t seq = ring->fence_drv.sync_seq[ring->idx];
  4304. uint64_t addr = ring->fence_drv.gpu_addr;
  4305. amdgpu_ring_write(ring, PACKET3(PACKET3_WAIT_REG_MEM, 5));
  4306. amdgpu_ring_write(ring, (WAIT_REG_MEM_MEM_SPACE(1) | /* memory */
  4307. WAIT_REG_MEM_FUNCTION(3) | /* equal */
  4308. WAIT_REG_MEM_ENGINE(usepfp))); /* pfp or me */
  4309. amdgpu_ring_write(ring, addr & 0xfffffffc);
  4310. amdgpu_ring_write(ring, upper_32_bits(addr) & 0xffffffff);
  4311. amdgpu_ring_write(ring, seq);
  4312. amdgpu_ring_write(ring, 0xffffffff);
  4313. amdgpu_ring_write(ring, 4); /* poll interval */
  4314. if (usepfp) {
  4315. /* synce CE with ME to prevent CE fetch CEIB before context switch done */
  4316. amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0));
  4317. amdgpu_ring_write(ring, 0);
  4318. amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0));
  4319. amdgpu_ring_write(ring, 0);
  4320. }
  4321. amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));
  4322. amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(usepfp) |
  4323. WRITE_DATA_DST_SEL(0)) |
  4324. WR_CONFIRM);
  4325. if (vm_id < 8) {
  4326. amdgpu_ring_write(ring,
  4327. (mmVM_CONTEXT0_PAGE_TABLE_BASE_ADDR + vm_id));
  4328. } else {
  4329. amdgpu_ring_write(ring,
  4330. (mmVM_CONTEXT8_PAGE_TABLE_BASE_ADDR + vm_id - 8));
  4331. }
  4332. amdgpu_ring_write(ring, 0);
  4333. amdgpu_ring_write(ring, pd_addr >> 12);
  4334. /* bits 0-15 are the VM contexts0-15 */
  4335. /* invalidate the cache */
  4336. amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));
  4337. amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) |
  4338. WRITE_DATA_DST_SEL(0)));
  4339. amdgpu_ring_write(ring, mmVM_INVALIDATE_REQUEST);
  4340. amdgpu_ring_write(ring, 0);
  4341. amdgpu_ring_write(ring, 1 << vm_id);
  4342. /* wait for the invalidate to complete */
  4343. amdgpu_ring_write(ring, PACKET3(PACKET3_WAIT_REG_MEM, 5));
  4344. amdgpu_ring_write(ring, (WAIT_REG_MEM_OPERATION(0) | /* wait */
  4345. WAIT_REG_MEM_FUNCTION(0) | /* always */
  4346. WAIT_REG_MEM_ENGINE(0))); /* me */
  4347. amdgpu_ring_write(ring, mmVM_INVALIDATE_REQUEST);
  4348. amdgpu_ring_write(ring, 0);
  4349. amdgpu_ring_write(ring, 0); /* ref */
  4350. amdgpu_ring_write(ring, 0); /* mask */
  4351. amdgpu_ring_write(ring, 0x20); /* poll interval */
  4352. /* compute doesn't have PFP */
  4353. if (usepfp) {
  4354. /* sync PFP to ME, otherwise we might get invalid PFP reads */
  4355. amdgpu_ring_write(ring, PACKET3(PACKET3_PFP_SYNC_ME, 0));
  4356. amdgpu_ring_write(ring, 0x0);
  4357. amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0));
  4358. amdgpu_ring_write(ring, 0);
  4359. amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0));
  4360. amdgpu_ring_write(ring, 0);
  4361. }
  4362. }
  4363. static u32 gfx_v8_0_ring_get_rptr_compute(struct amdgpu_ring *ring)
  4364. {
  4365. return ring->adev->wb.wb[ring->rptr_offs];
  4366. }
  4367. static u32 gfx_v8_0_ring_get_wptr_compute(struct amdgpu_ring *ring)
  4368. {
  4369. return ring->adev->wb.wb[ring->wptr_offs];
  4370. }
  4371. static void gfx_v8_0_ring_set_wptr_compute(struct amdgpu_ring *ring)
  4372. {
  4373. struct amdgpu_device *adev = ring->adev;
  4374. /* XXX check if swapping is necessary on BE */
  4375. adev->wb.wb[ring->wptr_offs] = ring->wptr;
  4376. WDOORBELL32(ring->doorbell_index, ring->wptr);
  4377. }
  4378. static void gfx_v8_0_ring_emit_fence_compute(struct amdgpu_ring *ring,
  4379. u64 addr, u64 seq,
  4380. unsigned flags)
  4381. {
  4382. bool write64bit = flags & AMDGPU_FENCE_FLAG_64BIT;
  4383. bool int_sel = flags & AMDGPU_FENCE_FLAG_INT;
  4384. /* RELEASE_MEM - flush caches, send int */
  4385. amdgpu_ring_write(ring, PACKET3(PACKET3_RELEASE_MEM, 5));
  4386. amdgpu_ring_write(ring, (EOP_TCL1_ACTION_EN |
  4387. EOP_TC_ACTION_EN |
  4388. EOP_TC_WB_ACTION_EN |
  4389. EVENT_TYPE(CACHE_FLUSH_AND_INV_TS_EVENT) |
  4390. EVENT_INDEX(5)));
  4391. amdgpu_ring_write(ring, DATA_SEL(write64bit ? 2 : 1) | INT_SEL(int_sel ? 2 : 0));
  4392. amdgpu_ring_write(ring, addr & 0xfffffffc);
  4393. amdgpu_ring_write(ring, upper_32_bits(addr));
  4394. amdgpu_ring_write(ring, lower_32_bits(seq));
  4395. amdgpu_ring_write(ring, upper_32_bits(seq));
  4396. }
  4397. static void gfx_v8_0_set_gfx_eop_interrupt_state(struct amdgpu_device *adev,
  4398. enum amdgpu_interrupt_state state)
  4399. {
  4400. u32 cp_int_cntl;
  4401. switch (state) {
  4402. case AMDGPU_IRQ_STATE_DISABLE:
  4403. cp_int_cntl = RREG32(mmCP_INT_CNTL_RING0);
  4404. cp_int_cntl = REG_SET_FIELD(cp_int_cntl, CP_INT_CNTL_RING0,
  4405. TIME_STAMP_INT_ENABLE, 0);
  4406. WREG32(mmCP_INT_CNTL_RING0, cp_int_cntl);
  4407. break;
  4408. case AMDGPU_IRQ_STATE_ENABLE:
  4409. cp_int_cntl = RREG32(mmCP_INT_CNTL_RING0);
  4410. cp_int_cntl =
  4411. REG_SET_FIELD(cp_int_cntl, CP_INT_CNTL_RING0,
  4412. TIME_STAMP_INT_ENABLE, 1);
  4413. WREG32(mmCP_INT_CNTL_RING0, cp_int_cntl);
  4414. break;
  4415. default:
  4416. break;
  4417. }
  4418. }
  4419. static void gfx_v8_0_set_compute_eop_interrupt_state(struct amdgpu_device *adev,
  4420. int me, int pipe,
  4421. enum amdgpu_interrupt_state state)
  4422. {
  4423. u32 mec_int_cntl, mec_int_cntl_reg;
  4424. /*
  4425. * amdgpu controls only pipe 0 of MEC1. That's why this function only
  4426. * handles the setting of interrupts for this specific pipe. All other
  4427. * pipes' interrupts are set by amdkfd.
  4428. */
  4429. if (me == 1) {
  4430. switch (pipe) {
  4431. case 0:
  4432. mec_int_cntl_reg = mmCP_ME1_PIPE0_INT_CNTL;
  4433. break;
  4434. default:
  4435. DRM_DEBUG("invalid pipe %d\n", pipe);
  4436. return;
  4437. }
  4438. } else {
  4439. DRM_DEBUG("invalid me %d\n", me);
  4440. return;
  4441. }
  4442. switch (state) {
  4443. case AMDGPU_IRQ_STATE_DISABLE:
  4444. mec_int_cntl = RREG32(mec_int_cntl_reg);
  4445. mec_int_cntl = REG_SET_FIELD(mec_int_cntl, CP_ME1_PIPE0_INT_CNTL,
  4446. TIME_STAMP_INT_ENABLE, 0);
  4447. WREG32(mec_int_cntl_reg, mec_int_cntl);
  4448. break;
  4449. case AMDGPU_IRQ_STATE_ENABLE:
  4450. mec_int_cntl = RREG32(mec_int_cntl_reg);
  4451. mec_int_cntl = REG_SET_FIELD(mec_int_cntl, CP_ME1_PIPE0_INT_CNTL,
  4452. TIME_STAMP_INT_ENABLE, 1);
  4453. WREG32(mec_int_cntl_reg, mec_int_cntl);
  4454. break;
  4455. default:
  4456. break;
  4457. }
  4458. }
  4459. static int gfx_v8_0_set_priv_reg_fault_state(struct amdgpu_device *adev,
  4460. struct amdgpu_irq_src *source,
  4461. unsigned type,
  4462. enum amdgpu_interrupt_state state)
  4463. {
  4464. u32 cp_int_cntl;
  4465. switch (state) {
  4466. case AMDGPU_IRQ_STATE_DISABLE:
  4467. cp_int_cntl = RREG32(mmCP_INT_CNTL_RING0);
  4468. cp_int_cntl = REG_SET_FIELD(cp_int_cntl, CP_INT_CNTL_RING0,
  4469. PRIV_REG_INT_ENABLE, 0);
  4470. WREG32(mmCP_INT_CNTL_RING0, cp_int_cntl);
  4471. break;
  4472. case AMDGPU_IRQ_STATE_ENABLE:
  4473. cp_int_cntl = RREG32(mmCP_INT_CNTL_RING0);
  4474. cp_int_cntl = REG_SET_FIELD(cp_int_cntl, CP_INT_CNTL_RING0,
  4475. PRIV_REG_INT_ENABLE, 0);
  4476. WREG32(mmCP_INT_CNTL_RING0, cp_int_cntl);
  4477. break;
  4478. default:
  4479. break;
  4480. }
  4481. return 0;
  4482. }
  4483. static int gfx_v8_0_set_priv_inst_fault_state(struct amdgpu_device *adev,
  4484. struct amdgpu_irq_src *source,
  4485. unsigned type,
  4486. enum amdgpu_interrupt_state state)
  4487. {
  4488. u32 cp_int_cntl;
  4489. switch (state) {
  4490. case AMDGPU_IRQ_STATE_DISABLE:
  4491. cp_int_cntl = RREG32(mmCP_INT_CNTL_RING0);
  4492. cp_int_cntl = REG_SET_FIELD(cp_int_cntl, CP_INT_CNTL_RING0,
  4493. PRIV_INSTR_INT_ENABLE, 0);
  4494. WREG32(mmCP_INT_CNTL_RING0, cp_int_cntl);
  4495. break;
  4496. case AMDGPU_IRQ_STATE_ENABLE:
  4497. cp_int_cntl = RREG32(mmCP_INT_CNTL_RING0);
  4498. cp_int_cntl = REG_SET_FIELD(cp_int_cntl, CP_INT_CNTL_RING0,
  4499. PRIV_INSTR_INT_ENABLE, 1);
  4500. WREG32(mmCP_INT_CNTL_RING0, cp_int_cntl);
  4501. break;
  4502. default:
  4503. break;
  4504. }
  4505. return 0;
  4506. }
  4507. static int gfx_v8_0_set_eop_interrupt_state(struct amdgpu_device *adev,
  4508. struct amdgpu_irq_src *src,
  4509. unsigned type,
  4510. enum amdgpu_interrupt_state state)
  4511. {
  4512. switch (type) {
  4513. case AMDGPU_CP_IRQ_GFX_EOP:
  4514. gfx_v8_0_set_gfx_eop_interrupt_state(adev, state);
  4515. break;
  4516. case AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE0_EOP:
  4517. gfx_v8_0_set_compute_eop_interrupt_state(adev, 1, 0, state);
  4518. break;
  4519. case AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE1_EOP:
  4520. gfx_v8_0_set_compute_eop_interrupt_state(adev, 1, 1, state);
  4521. break;
  4522. case AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE2_EOP:
  4523. gfx_v8_0_set_compute_eop_interrupt_state(adev, 1, 2, state);
  4524. break;
  4525. case AMDGPU_CP_IRQ_COMPUTE_MEC1_PIPE3_EOP:
  4526. gfx_v8_0_set_compute_eop_interrupt_state(adev, 1, 3, state);
  4527. break;
  4528. case AMDGPU_CP_IRQ_COMPUTE_MEC2_PIPE0_EOP:
  4529. gfx_v8_0_set_compute_eop_interrupt_state(adev, 2, 0, state);
  4530. break;
  4531. case AMDGPU_CP_IRQ_COMPUTE_MEC2_PIPE1_EOP:
  4532. gfx_v8_0_set_compute_eop_interrupt_state(adev, 2, 1, state);
  4533. break;
  4534. case AMDGPU_CP_IRQ_COMPUTE_MEC2_PIPE2_EOP:
  4535. gfx_v8_0_set_compute_eop_interrupt_state(adev, 2, 2, state);
  4536. break;
  4537. case AMDGPU_CP_IRQ_COMPUTE_MEC2_PIPE3_EOP:
  4538. gfx_v8_0_set_compute_eop_interrupt_state(adev, 2, 3, state);
  4539. break;
  4540. default:
  4541. break;
  4542. }
  4543. return 0;
  4544. }
  4545. static int gfx_v8_0_eop_irq(struct amdgpu_device *adev,
  4546. struct amdgpu_irq_src *source,
  4547. struct amdgpu_iv_entry *entry)
  4548. {
  4549. int i;
  4550. u8 me_id, pipe_id, queue_id;
  4551. struct amdgpu_ring *ring;
  4552. DRM_DEBUG("IH: CP EOP\n");
  4553. me_id = (entry->ring_id & 0x0c) >> 2;
  4554. pipe_id = (entry->ring_id & 0x03) >> 0;
  4555. queue_id = (entry->ring_id & 0x70) >> 4;
  4556. switch (me_id) {
  4557. case 0:
  4558. amdgpu_fence_process(&adev->gfx.gfx_ring[0]);
  4559. break;
  4560. case 1:
  4561. case 2:
  4562. for (i = 0; i < adev->gfx.num_compute_rings; i++) {
  4563. ring = &adev->gfx.compute_ring[i];
  4564. /* Per-queue interrupt is supported for MEC starting from VI.
  4565. * The interrupt can only be enabled/disabled per pipe instead of per queue.
  4566. */
  4567. if ((ring->me == me_id) && (ring->pipe == pipe_id) && (ring->queue == queue_id))
  4568. amdgpu_fence_process(ring);
  4569. }
  4570. break;
  4571. }
  4572. return 0;
  4573. }
  4574. static int gfx_v8_0_priv_reg_irq(struct amdgpu_device *adev,
  4575. struct amdgpu_irq_src *source,
  4576. struct amdgpu_iv_entry *entry)
  4577. {
  4578. DRM_ERROR("Illegal register access in command stream\n");
  4579. schedule_work(&adev->reset_work);
  4580. return 0;
  4581. }
  4582. static int gfx_v8_0_priv_inst_irq(struct amdgpu_device *adev,
  4583. struct amdgpu_irq_src *source,
  4584. struct amdgpu_iv_entry *entry)
  4585. {
  4586. DRM_ERROR("Illegal instruction in command stream\n");
  4587. schedule_work(&adev->reset_work);
  4588. return 0;
  4589. }
  4590. const struct amd_ip_funcs gfx_v8_0_ip_funcs = {
  4591. .early_init = gfx_v8_0_early_init,
  4592. .late_init = NULL,
  4593. .sw_init = gfx_v8_0_sw_init,
  4594. .sw_fini = gfx_v8_0_sw_fini,
  4595. .hw_init = gfx_v8_0_hw_init,
  4596. .hw_fini = gfx_v8_0_hw_fini,
  4597. .suspend = gfx_v8_0_suspend,
  4598. .resume = gfx_v8_0_resume,
  4599. .is_idle = gfx_v8_0_is_idle,
  4600. .wait_for_idle = gfx_v8_0_wait_for_idle,
  4601. .soft_reset = gfx_v8_0_soft_reset,
  4602. .print_status = gfx_v8_0_print_status,
  4603. .set_clockgating_state = gfx_v8_0_set_clockgating_state,
  4604. .set_powergating_state = gfx_v8_0_set_powergating_state,
  4605. };
  4606. static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_gfx = {
  4607. .get_rptr = gfx_v8_0_ring_get_rptr_gfx,
  4608. .get_wptr = gfx_v8_0_ring_get_wptr_gfx,
  4609. .set_wptr = gfx_v8_0_ring_set_wptr_gfx,
  4610. .parse_cs = NULL,
  4611. .emit_ib = gfx_v8_0_ring_emit_ib_gfx,
  4612. .emit_fence = gfx_v8_0_ring_emit_fence_gfx,
  4613. .emit_semaphore = gfx_v8_0_ring_emit_semaphore,
  4614. .emit_vm_flush = gfx_v8_0_ring_emit_vm_flush,
  4615. .emit_gds_switch = gfx_v8_0_ring_emit_gds_switch,
  4616. .emit_hdp_flush = gfx_v8_0_ring_emit_hdp_flush,
  4617. .test_ring = gfx_v8_0_ring_test_ring,
  4618. .test_ib = gfx_v8_0_ring_test_ib,
  4619. .insert_nop = amdgpu_ring_insert_nop,
  4620. };
  4621. static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_compute = {
  4622. .get_rptr = gfx_v8_0_ring_get_rptr_compute,
  4623. .get_wptr = gfx_v8_0_ring_get_wptr_compute,
  4624. .set_wptr = gfx_v8_0_ring_set_wptr_compute,
  4625. .parse_cs = NULL,
  4626. .emit_ib = gfx_v8_0_ring_emit_ib_compute,
  4627. .emit_fence = gfx_v8_0_ring_emit_fence_compute,
  4628. .emit_semaphore = gfx_v8_0_ring_emit_semaphore,
  4629. .emit_vm_flush = gfx_v8_0_ring_emit_vm_flush,
  4630. .emit_gds_switch = gfx_v8_0_ring_emit_gds_switch,
  4631. .emit_hdp_flush = gfx_v8_0_ring_emit_hdp_flush,
  4632. .test_ring = gfx_v8_0_ring_test_ring,
  4633. .test_ib = gfx_v8_0_ring_test_ib,
  4634. .insert_nop = amdgpu_ring_insert_nop,
  4635. };
  4636. static void gfx_v8_0_set_ring_funcs(struct amdgpu_device *adev)
  4637. {
  4638. int i;
  4639. for (i = 0; i < adev->gfx.num_gfx_rings; i++)
  4640. adev->gfx.gfx_ring[i].funcs = &gfx_v8_0_ring_funcs_gfx;
  4641. for (i = 0; i < adev->gfx.num_compute_rings; i++)
  4642. adev->gfx.compute_ring[i].funcs = &gfx_v8_0_ring_funcs_compute;
  4643. }
  4644. static const struct amdgpu_irq_src_funcs gfx_v8_0_eop_irq_funcs = {
  4645. .set = gfx_v8_0_set_eop_interrupt_state,
  4646. .process = gfx_v8_0_eop_irq,
  4647. };
  4648. static const struct amdgpu_irq_src_funcs gfx_v8_0_priv_reg_irq_funcs = {
  4649. .set = gfx_v8_0_set_priv_reg_fault_state,
  4650. .process = gfx_v8_0_priv_reg_irq,
  4651. };
  4652. static const struct amdgpu_irq_src_funcs gfx_v8_0_priv_inst_irq_funcs = {
  4653. .set = gfx_v8_0_set_priv_inst_fault_state,
  4654. .process = gfx_v8_0_priv_inst_irq,
  4655. };
  4656. static void gfx_v8_0_set_irq_funcs(struct amdgpu_device *adev)
  4657. {
  4658. adev->gfx.eop_irq.num_types = AMDGPU_CP_IRQ_LAST;
  4659. adev->gfx.eop_irq.funcs = &gfx_v8_0_eop_irq_funcs;
  4660. adev->gfx.priv_reg_irq.num_types = 1;
  4661. adev->gfx.priv_reg_irq.funcs = &gfx_v8_0_priv_reg_irq_funcs;
  4662. adev->gfx.priv_inst_irq.num_types = 1;
  4663. adev->gfx.priv_inst_irq.funcs = &gfx_v8_0_priv_inst_irq_funcs;
  4664. }
  4665. static void gfx_v8_0_set_gds_init(struct amdgpu_device *adev)
  4666. {
  4667. /* init asci gds info */
  4668. adev->gds.mem.total_size = RREG32(mmGDS_VMID0_SIZE);
  4669. adev->gds.gws.total_size = 64;
  4670. adev->gds.oa.total_size = 16;
  4671. if (adev->gds.mem.total_size == 64 * 1024) {
  4672. adev->gds.mem.gfx_partition_size = 4096;
  4673. adev->gds.mem.cs_partition_size = 4096;
  4674. adev->gds.gws.gfx_partition_size = 4;
  4675. adev->gds.gws.cs_partition_size = 4;
  4676. adev->gds.oa.gfx_partition_size = 4;
  4677. adev->gds.oa.cs_partition_size = 1;
  4678. } else {
  4679. adev->gds.mem.gfx_partition_size = 1024;
  4680. adev->gds.mem.cs_partition_size = 1024;
  4681. adev->gds.gws.gfx_partition_size = 16;
  4682. adev->gds.gws.cs_partition_size = 16;
  4683. adev->gds.oa.gfx_partition_size = 4;
  4684. adev->gds.oa.cs_partition_size = 4;
  4685. }
  4686. }
  4687. static u32 gfx_v8_0_get_cu_active_bitmap(struct amdgpu_device *adev,
  4688. u32 se, u32 sh)
  4689. {
  4690. u32 mask = 0, tmp, tmp1;
  4691. int i;
  4692. gfx_v8_0_select_se_sh(adev, se, sh);
  4693. tmp = RREG32(mmCC_GC_SHADER_ARRAY_CONFIG);
  4694. tmp1 = RREG32(mmGC_USER_SHADER_ARRAY_CONFIG);
  4695. gfx_v8_0_select_se_sh(adev, 0xffffffff, 0xffffffff);
  4696. tmp &= 0xffff0000;
  4697. tmp |= tmp1;
  4698. tmp >>= 16;
  4699. for (i = 0; i < adev->gfx.config.max_cu_per_sh; i ++) {
  4700. mask <<= 1;
  4701. mask |= 1;
  4702. }
  4703. return (~tmp) & mask;
  4704. }
  4705. int gfx_v8_0_get_cu_info(struct amdgpu_device *adev,
  4706. struct amdgpu_cu_info *cu_info)
  4707. {
  4708. int i, j, k, counter, active_cu_number = 0;
  4709. u32 mask, bitmap, ao_bitmap, ao_cu_mask = 0;
  4710. if (!adev || !cu_info)
  4711. return -EINVAL;
  4712. mutex_lock(&adev->grbm_idx_mutex);
  4713. for (i = 0; i < adev->gfx.config.max_shader_engines; i++) {
  4714. for (j = 0; j < adev->gfx.config.max_sh_per_se; j++) {
  4715. mask = 1;
  4716. ao_bitmap = 0;
  4717. counter = 0;
  4718. bitmap = gfx_v8_0_get_cu_active_bitmap(adev, i, j);
  4719. cu_info->bitmap[i][j] = bitmap;
  4720. for (k = 0; k < adev->gfx.config.max_cu_per_sh; k ++) {
  4721. if (bitmap & mask) {
  4722. if (counter < 2)
  4723. ao_bitmap |= mask;
  4724. counter ++;
  4725. }
  4726. mask <<= 1;
  4727. }
  4728. active_cu_number += counter;
  4729. ao_cu_mask |= (ao_bitmap << (i * 16 + j * 8));
  4730. }
  4731. }
  4732. cu_info->number = active_cu_number;
  4733. cu_info->ao_cu_mask = ao_cu_mask;
  4734. mutex_unlock(&adev->grbm_idx_mutex);
  4735. return 0;
  4736. }