radeon.h 94 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968
  1. /*
  2. * Copyright 2008 Advanced Micro Devices, Inc.
  3. * Copyright 2008 Red Hat Inc.
  4. * Copyright 2009 Jerome Glisse.
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a
  7. * copy of this software and associated documentation files (the "Software"),
  8. * to deal in the Software without restriction, including without limitation
  9. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10. * and/or sell copies of the Software, and to permit persons to whom the
  11. * Software is furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  20. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  21. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  22. * OTHER DEALINGS IN THE SOFTWARE.
  23. *
  24. * Authors: Dave Airlie
  25. * Alex Deucher
  26. * Jerome Glisse
  27. */
  28. #ifndef __RADEON_H__
  29. #define __RADEON_H__
  30. /* TODO: Here are things that needs to be done :
  31. * - surface allocator & initializer : (bit like scratch reg) should
  32. * initialize HDP_ stuff on RS600, R600, R700 hw, well anythings
  33. * related to surface
  34. * - WB : write back stuff (do it bit like scratch reg things)
  35. * - Vblank : look at Jesse's rework and what we should do
  36. * - r600/r700: gart & cp
  37. * - cs : clean cs ioctl use bitmap & things like that.
  38. * - power management stuff
  39. * - Barrier in gart code
  40. * - Unmappabled vram ?
  41. * - TESTING, TESTING, TESTING
  42. */
  43. /* Initialization path:
  44. * We expect that acceleration initialization might fail for various
  45. * reasons even thought we work hard to make it works on most
  46. * configurations. In order to still have a working userspace in such
  47. * situation the init path must succeed up to the memory controller
  48. * initialization point. Failure before this point are considered as
  49. * fatal error. Here is the init callchain :
  50. * radeon_device_init perform common structure, mutex initialization
  51. * asic_init setup the GPU memory layout and perform all
  52. * one time initialization (failure in this
  53. * function are considered fatal)
  54. * asic_startup setup the GPU acceleration, in order to
  55. * follow guideline the first thing this
  56. * function should do is setting the GPU
  57. * memory controller (only MC setup failure
  58. * are considered as fatal)
  59. */
  60. #include <linux/atomic.h>
  61. #include <linux/wait.h>
  62. #include <linux/list.h>
  63. #include <linux/kref.h>
  64. #include <linux/interval_tree.h>
  65. #include <linux/hashtable.h>
  66. #include <linux/fence.h>
  67. #include <ttm/ttm_bo_api.h>
  68. #include <ttm/ttm_bo_driver.h>
  69. #include <ttm/ttm_placement.h>
  70. #include <ttm/ttm_module.h>
  71. #include <ttm/ttm_execbuf_util.h>
  72. #include <drm/drm_gem.h>
  73. #include "radeon_family.h"
  74. #include "radeon_mode.h"
  75. #include "radeon_reg.h"
  76. /*
  77. * Modules parameters.
  78. */
  79. extern int radeon_no_wb;
  80. extern int radeon_modeset;
  81. extern int radeon_dynclks;
  82. extern int radeon_r4xx_atom;
  83. extern int radeon_agpmode;
  84. extern int radeon_vram_limit;
  85. extern int radeon_gart_size;
  86. extern int radeon_benchmarking;
  87. extern int radeon_testing;
  88. extern int radeon_connector_table;
  89. extern int radeon_tv;
  90. extern int radeon_audio;
  91. extern int radeon_disp_priority;
  92. extern int radeon_hw_i2c;
  93. extern int radeon_pcie_gen2;
  94. extern int radeon_msi;
  95. extern int radeon_lockup_timeout;
  96. extern int radeon_fastfb;
  97. extern int radeon_dpm;
  98. extern int radeon_aspm;
  99. extern int radeon_runtime_pm;
  100. extern int radeon_hard_reset;
  101. extern int radeon_vm_size;
  102. extern int radeon_vm_block_size;
  103. extern int radeon_deep_color;
  104. extern int radeon_use_pflipirq;
  105. extern int radeon_bapm;
  106. extern int radeon_backlight;
  107. extern int radeon_auxch;
  108. extern int radeon_mst;
  109. /*
  110. * Copy from radeon_drv.h so we don't have to include both and have conflicting
  111. * symbol;
  112. */
  113. #define RADEON_MAX_USEC_TIMEOUT 100000 /* 100 ms */
  114. #define RADEON_FENCE_JIFFIES_TIMEOUT (HZ / 2)
  115. /* RADEON_IB_POOL_SIZE must be a power of 2 */
  116. #define RADEON_IB_POOL_SIZE 16
  117. #define RADEON_DEBUGFS_MAX_COMPONENTS 32
  118. #define RADEONFB_CONN_LIMIT 4
  119. #define RADEON_BIOS_NUM_SCRATCH 8
  120. /* internal ring indices */
  121. /* r1xx+ has gfx CP ring */
  122. #define RADEON_RING_TYPE_GFX_INDEX 0
  123. /* cayman has 2 compute CP rings */
  124. #define CAYMAN_RING_TYPE_CP1_INDEX 1
  125. #define CAYMAN_RING_TYPE_CP2_INDEX 2
  126. /* R600+ has an async dma ring */
  127. #define R600_RING_TYPE_DMA_INDEX 3
  128. /* cayman add a second async dma ring */
  129. #define CAYMAN_RING_TYPE_DMA1_INDEX 4
  130. /* R600+ */
  131. #define R600_RING_TYPE_UVD_INDEX 5
  132. /* TN+ */
  133. #define TN_RING_TYPE_VCE1_INDEX 6
  134. #define TN_RING_TYPE_VCE2_INDEX 7
  135. /* max number of rings */
  136. #define RADEON_NUM_RINGS 8
  137. /* number of hw syncs before falling back on blocking */
  138. #define RADEON_NUM_SYNCS 4
  139. /* hardcode those limit for now */
  140. #define RADEON_VA_IB_OFFSET (1 << 20)
  141. #define RADEON_VA_RESERVED_SIZE (8 << 20)
  142. #define RADEON_IB_VM_MAX_SIZE (64 << 10)
  143. /* hard reset data */
  144. #define RADEON_ASIC_RESET_DATA 0x39d5e86b
  145. /* reset flags */
  146. #define RADEON_RESET_GFX (1 << 0)
  147. #define RADEON_RESET_COMPUTE (1 << 1)
  148. #define RADEON_RESET_DMA (1 << 2)
  149. #define RADEON_RESET_CP (1 << 3)
  150. #define RADEON_RESET_GRBM (1 << 4)
  151. #define RADEON_RESET_DMA1 (1 << 5)
  152. #define RADEON_RESET_RLC (1 << 6)
  153. #define RADEON_RESET_SEM (1 << 7)
  154. #define RADEON_RESET_IH (1 << 8)
  155. #define RADEON_RESET_VMC (1 << 9)
  156. #define RADEON_RESET_MC (1 << 10)
  157. #define RADEON_RESET_DISPLAY (1 << 11)
  158. /* CG block flags */
  159. #define RADEON_CG_BLOCK_GFX (1 << 0)
  160. #define RADEON_CG_BLOCK_MC (1 << 1)
  161. #define RADEON_CG_BLOCK_SDMA (1 << 2)
  162. #define RADEON_CG_BLOCK_UVD (1 << 3)
  163. #define RADEON_CG_BLOCK_VCE (1 << 4)
  164. #define RADEON_CG_BLOCK_HDP (1 << 5)
  165. #define RADEON_CG_BLOCK_BIF (1 << 6)
  166. /* CG flags */
  167. #define RADEON_CG_SUPPORT_GFX_MGCG (1 << 0)
  168. #define RADEON_CG_SUPPORT_GFX_MGLS (1 << 1)
  169. #define RADEON_CG_SUPPORT_GFX_CGCG (1 << 2)
  170. #define RADEON_CG_SUPPORT_GFX_CGLS (1 << 3)
  171. #define RADEON_CG_SUPPORT_GFX_CGTS (1 << 4)
  172. #define RADEON_CG_SUPPORT_GFX_CGTS_LS (1 << 5)
  173. #define RADEON_CG_SUPPORT_GFX_CP_LS (1 << 6)
  174. #define RADEON_CG_SUPPORT_GFX_RLC_LS (1 << 7)
  175. #define RADEON_CG_SUPPORT_MC_LS (1 << 8)
  176. #define RADEON_CG_SUPPORT_MC_MGCG (1 << 9)
  177. #define RADEON_CG_SUPPORT_SDMA_LS (1 << 10)
  178. #define RADEON_CG_SUPPORT_SDMA_MGCG (1 << 11)
  179. #define RADEON_CG_SUPPORT_BIF_LS (1 << 12)
  180. #define RADEON_CG_SUPPORT_UVD_MGCG (1 << 13)
  181. #define RADEON_CG_SUPPORT_VCE_MGCG (1 << 14)
  182. #define RADEON_CG_SUPPORT_HDP_LS (1 << 15)
  183. #define RADEON_CG_SUPPORT_HDP_MGCG (1 << 16)
  184. /* PG flags */
  185. #define RADEON_PG_SUPPORT_GFX_PG (1 << 0)
  186. #define RADEON_PG_SUPPORT_GFX_SMG (1 << 1)
  187. #define RADEON_PG_SUPPORT_GFX_DMG (1 << 2)
  188. #define RADEON_PG_SUPPORT_UVD (1 << 3)
  189. #define RADEON_PG_SUPPORT_VCE (1 << 4)
  190. #define RADEON_PG_SUPPORT_CP (1 << 5)
  191. #define RADEON_PG_SUPPORT_GDS (1 << 6)
  192. #define RADEON_PG_SUPPORT_RLC_SMU_HS (1 << 7)
  193. #define RADEON_PG_SUPPORT_SDMA (1 << 8)
  194. #define RADEON_PG_SUPPORT_ACP (1 << 9)
  195. #define RADEON_PG_SUPPORT_SAMU (1 << 10)
  196. /* max cursor sizes (in pixels) */
  197. #define CURSOR_WIDTH 64
  198. #define CURSOR_HEIGHT 64
  199. #define CIK_CURSOR_WIDTH 128
  200. #define CIK_CURSOR_HEIGHT 128
  201. /*
  202. * Errata workarounds.
  203. */
  204. enum radeon_pll_errata {
  205. CHIP_ERRATA_R300_CG = 0x00000001,
  206. CHIP_ERRATA_PLL_DUMMYREADS = 0x00000002,
  207. CHIP_ERRATA_PLL_DELAY = 0x00000004
  208. };
  209. struct radeon_device;
  210. /*
  211. * BIOS.
  212. */
  213. bool radeon_get_bios(struct radeon_device *rdev);
  214. /*
  215. * Dummy page
  216. */
  217. struct radeon_dummy_page {
  218. uint64_t entry;
  219. struct page *page;
  220. dma_addr_t addr;
  221. };
  222. int radeon_dummy_page_init(struct radeon_device *rdev);
  223. void radeon_dummy_page_fini(struct radeon_device *rdev);
  224. /*
  225. * Clocks
  226. */
  227. struct radeon_clock {
  228. struct radeon_pll p1pll;
  229. struct radeon_pll p2pll;
  230. struct radeon_pll dcpll;
  231. struct radeon_pll spll;
  232. struct radeon_pll mpll;
  233. /* 10 Khz units */
  234. uint32_t default_mclk;
  235. uint32_t default_sclk;
  236. uint32_t default_dispclk;
  237. uint32_t current_dispclk;
  238. uint32_t dp_extclk;
  239. uint32_t max_pixel_clock;
  240. uint32_t vco_freq;
  241. };
  242. /*
  243. * Power management
  244. */
  245. int radeon_pm_init(struct radeon_device *rdev);
  246. int radeon_pm_late_init(struct radeon_device *rdev);
  247. void radeon_pm_fini(struct radeon_device *rdev);
  248. void radeon_pm_compute_clocks(struct radeon_device *rdev);
  249. void radeon_pm_suspend(struct radeon_device *rdev);
  250. void radeon_pm_resume(struct radeon_device *rdev);
  251. void radeon_combios_get_power_modes(struct radeon_device *rdev);
  252. void radeon_atombios_get_power_modes(struct radeon_device *rdev);
  253. int radeon_atom_get_clock_dividers(struct radeon_device *rdev,
  254. u8 clock_type,
  255. u32 clock,
  256. bool strobe_mode,
  257. struct atom_clock_dividers *dividers);
  258. int radeon_atom_get_memory_pll_dividers(struct radeon_device *rdev,
  259. u32 clock,
  260. bool strobe_mode,
  261. struct atom_mpll_param *mpll_param);
  262. void radeon_atom_set_voltage(struct radeon_device *rdev, u16 voltage_level, u8 voltage_type);
  263. int radeon_atom_get_voltage_gpio_settings(struct radeon_device *rdev,
  264. u16 voltage_level, u8 voltage_type,
  265. u32 *gpio_value, u32 *gpio_mask);
  266. void radeon_atom_set_engine_dram_timings(struct radeon_device *rdev,
  267. u32 eng_clock, u32 mem_clock);
  268. int radeon_atom_get_voltage_step(struct radeon_device *rdev,
  269. u8 voltage_type, u16 *voltage_step);
  270. int radeon_atom_get_max_vddc(struct radeon_device *rdev, u8 voltage_type,
  271. u16 voltage_id, u16 *voltage);
  272. int radeon_atom_get_leakage_vddc_based_on_leakage_idx(struct radeon_device *rdev,
  273. u16 *voltage,
  274. u16 leakage_idx);
  275. int radeon_atom_get_leakage_id_from_vbios(struct radeon_device *rdev,
  276. u16 *leakage_id);
  277. int radeon_atom_get_leakage_vddc_based_on_leakage_params(struct radeon_device *rdev,
  278. u16 *vddc, u16 *vddci,
  279. u16 virtual_voltage_id,
  280. u16 vbios_voltage_id);
  281. int radeon_atom_get_voltage_evv(struct radeon_device *rdev,
  282. u16 virtual_voltage_id,
  283. u16 *voltage);
  284. int radeon_atom_round_to_true_voltage(struct radeon_device *rdev,
  285. u8 voltage_type,
  286. u16 nominal_voltage,
  287. u16 *true_voltage);
  288. int radeon_atom_get_min_voltage(struct radeon_device *rdev,
  289. u8 voltage_type, u16 *min_voltage);
  290. int radeon_atom_get_max_voltage(struct radeon_device *rdev,
  291. u8 voltage_type, u16 *max_voltage);
  292. int radeon_atom_get_voltage_table(struct radeon_device *rdev,
  293. u8 voltage_type, u8 voltage_mode,
  294. struct atom_voltage_table *voltage_table);
  295. bool radeon_atom_is_voltage_gpio(struct radeon_device *rdev,
  296. u8 voltage_type, u8 voltage_mode);
  297. int radeon_atom_get_svi2_info(struct radeon_device *rdev,
  298. u8 voltage_type,
  299. u8 *svd_gpio_id, u8 *svc_gpio_id);
  300. void radeon_atom_update_memory_dll(struct radeon_device *rdev,
  301. u32 mem_clock);
  302. void radeon_atom_set_ac_timing(struct radeon_device *rdev,
  303. u32 mem_clock);
  304. int radeon_atom_init_mc_reg_table(struct radeon_device *rdev,
  305. u8 module_index,
  306. struct atom_mc_reg_table *reg_table);
  307. int radeon_atom_get_memory_info(struct radeon_device *rdev,
  308. u8 module_index, struct atom_memory_info *mem_info);
  309. int radeon_atom_get_mclk_range_table(struct radeon_device *rdev,
  310. bool gddr5, u8 module_index,
  311. struct atom_memory_clock_range_table *mclk_range_table);
  312. int radeon_atom_get_max_vddc(struct radeon_device *rdev, u8 voltage_type,
  313. u16 voltage_id, u16 *voltage);
  314. void rs690_pm_info(struct radeon_device *rdev);
  315. extern void evergreen_tiling_fields(unsigned tiling_flags, unsigned *bankw,
  316. unsigned *bankh, unsigned *mtaspect,
  317. unsigned *tile_split);
  318. /*
  319. * Fences.
  320. */
  321. struct radeon_fence_driver {
  322. struct radeon_device *rdev;
  323. uint32_t scratch_reg;
  324. uint64_t gpu_addr;
  325. volatile uint32_t *cpu_addr;
  326. /* sync_seq is protected by ring emission lock */
  327. uint64_t sync_seq[RADEON_NUM_RINGS];
  328. atomic64_t last_seq;
  329. bool initialized, delayed_irq;
  330. struct delayed_work lockup_work;
  331. };
  332. struct radeon_fence {
  333. struct fence base;
  334. struct radeon_device *rdev;
  335. uint64_t seq;
  336. /* RB, DMA, etc. */
  337. unsigned ring;
  338. bool is_vm_update;
  339. wait_queue_t fence_wake;
  340. };
  341. int radeon_fence_driver_start_ring(struct radeon_device *rdev, int ring);
  342. int radeon_fence_driver_init(struct radeon_device *rdev);
  343. void radeon_fence_driver_fini(struct radeon_device *rdev);
  344. void radeon_fence_driver_force_completion(struct radeon_device *rdev, int ring);
  345. int radeon_fence_emit(struct radeon_device *rdev, struct radeon_fence **fence, int ring);
  346. void radeon_fence_process(struct radeon_device *rdev, int ring);
  347. bool radeon_fence_signaled(struct radeon_fence *fence);
  348. int radeon_fence_wait(struct radeon_fence *fence, bool interruptible);
  349. int radeon_fence_wait_next(struct radeon_device *rdev, int ring);
  350. int radeon_fence_wait_empty(struct radeon_device *rdev, int ring);
  351. int radeon_fence_wait_any(struct radeon_device *rdev,
  352. struct radeon_fence **fences,
  353. bool intr);
  354. struct radeon_fence *radeon_fence_ref(struct radeon_fence *fence);
  355. void radeon_fence_unref(struct radeon_fence **fence);
  356. unsigned radeon_fence_count_emitted(struct radeon_device *rdev, int ring);
  357. bool radeon_fence_need_sync(struct radeon_fence *fence, int ring);
  358. void radeon_fence_note_sync(struct radeon_fence *fence, int ring);
  359. static inline struct radeon_fence *radeon_fence_later(struct radeon_fence *a,
  360. struct radeon_fence *b)
  361. {
  362. if (!a) {
  363. return b;
  364. }
  365. if (!b) {
  366. return a;
  367. }
  368. BUG_ON(a->ring != b->ring);
  369. if (a->seq > b->seq) {
  370. return a;
  371. } else {
  372. return b;
  373. }
  374. }
  375. static inline bool radeon_fence_is_earlier(struct radeon_fence *a,
  376. struct radeon_fence *b)
  377. {
  378. if (!a) {
  379. return false;
  380. }
  381. if (!b) {
  382. return true;
  383. }
  384. BUG_ON(a->ring != b->ring);
  385. return a->seq < b->seq;
  386. }
  387. /*
  388. * Tiling registers
  389. */
  390. struct radeon_surface_reg {
  391. struct radeon_bo *bo;
  392. };
  393. #define RADEON_GEM_MAX_SURFACES 8
  394. /*
  395. * TTM.
  396. */
  397. struct radeon_mman {
  398. struct ttm_bo_global_ref bo_global_ref;
  399. struct drm_global_reference mem_global_ref;
  400. struct ttm_bo_device bdev;
  401. bool mem_global_referenced;
  402. bool initialized;
  403. #if defined(CONFIG_DEBUG_FS)
  404. struct dentry *vram;
  405. struct dentry *gtt;
  406. #endif
  407. };
  408. struct radeon_bo_list {
  409. struct radeon_bo *robj;
  410. struct ttm_validate_buffer tv;
  411. uint64_t gpu_offset;
  412. unsigned prefered_domains;
  413. unsigned allowed_domains;
  414. uint32_t tiling_flags;
  415. };
  416. /* bo virtual address in a specific vm */
  417. struct radeon_bo_va {
  418. /* protected by bo being reserved */
  419. struct list_head bo_list;
  420. uint32_t flags;
  421. struct radeon_fence *last_pt_update;
  422. unsigned ref_count;
  423. /* protected by vm mutex */
  424. struct interval_tree_node it;
  425. struct list_head vm_status;
  426. /* constant after initialization */
  427. struct radeon_vm *vm;
  428. struct radeon_bo *bo;
  429. };
  430. struct radeon_bo {
  431. /* Protected by gem.mutex */
  432. struct list_head list;
  433. /* Protected by tbo.reserved */
  434. u32 initial_domain;
  435. struct ttm_place placements[4];
  436. struct ttm_placement placement;
  437. struct ttm_buffer_object tbo;
  438. struct ttm_bo_kmap_obj kmap;
  439. u32 flags;
  440. unsigned pin_count;
  441. void *kptr;
  442. u32 tiling_flags;
  443. u32 pitch;
  444. int surface_reg;
  445. /* list of all virtual address to which this bo
  446. * is associated to
  447. */
  448. struct list_head va;
  449. /* Constant after initialization */
  450. struct radeon_device *rdev;
  451. struct drm_gem_object gem_base;
  452. struct ttm_bo_kmap_obj dma_buf_vmap;
  453. pid_t pid;
  454. struct radeon_mn *mn;
  455. struct list_head mn_list;
  456. };
  457. #define gem_to_radeon_bo(gobj) container_of((gobj), struct radeon_bo, gem_base)
  458. int radeon_gem_debugfs_init(struct radeon_device *rdev);
  459. /* sub-allocation manager, it has to be protected by another lock.
  460. * By conception this is an helper for other part of the driver
  461. * like the indirect buffer or semaphore, which both have their
  462. * locking.
  463. *
  464. * Principe is simple, we keep a list of sub allocation in offset
  465. * order (first entry has offset == 0, last entry has the highest
  466. * offset).
  467. *
  468. * When allocating new object we first check if there is room at
  469. * the end total_size - (last_object_offset + last_object_size) >=
  470. * alloc_size. If so we allocate new object there.
  471. *
  472. * When there is not enough room at the end, we start waiting for
  473. * each sub object until we reach object_offset+object_size >=
  474. * alloc_size, this object then become the sub object we return.
  475. *
  476. * Alignment can't be bigger than page size.
  477. *
  478. * Hole are not considered for allocation to keep things simple.
  479. * Assumption is that there won't be hole (all object on same
  480. * alignment).
  481. */
  482. struct radeon_sa_manager {
  483. wait_queue_head_t wq;
  484. struct radeon_bo *bo;
  485. struct list_head *hole;
  486. struct list_head flist[RADEON_NUM_RINGS];
  487. struct list_head olist;
  488. unsigned size;
  489. uint64_t gpu_addr;
  490. void *cpu_ptr;
  491. uint32_t domain;
  492. uint32_t align;
  493. };
  494. struct radeon_sa_bo;
  495. /* sub-allocation buffer */
  496. struct radeon_sa_bo {
  497. struct list_head olist;
  498. struct list_head flist;
  499. struct radeon_sa_manager *manager;
  500. unsigned soffset;
  501. unsigned eoffset;
  502. struct radeon_fence *fence;
  503. };
  504. /*
  505. * GEM objects.
  506. */
  507. struct radeon_gem {
  508. struct mutex mutex;
  509. struct list_head objects;
  510. };
  511. int radeon_gem_init(struct radeon_device *rdev);
  512. void radeon_gem_fini(struct radeon_device *rdev);
  513. int radeon_gem_object_create(struct radeon_device *rdev, unsigned long size,
  514. int alignment, int initial_domain,
  515. u32 flags, bool kernel,
  516. struct drm_gem_object **obj);
  517. int radeon_mode_dumb_create(struct drm_file *file_priv,
  518. struct drm_device *dev,
  519. struct drm_mode_create_dumb *args);
  520. int radeon_mode_dumb_mmap(struct drm_file *filp,
  521. struct drm_device *dev,
  522. uint32_t handle, uint64_t *offset_p);
  523. /*
  524. * Semaphores.
  525. */
  526. struct radeon_semaphore {
  527. struct radeon_sa_bo *sa_bo;
  528. signed waiters;
  529. uint64_t gpu_addr;
  530. };
  531. int radeon_semaphore_create(struct radeon_device *rdev,
  532. struct radeon_semaphore **semaphore);
  533. bool radeon_semaphore_emit_signal(struct radeon_device *rdev, int ring,
  534. struct radeon_semaphore *semaphore);
  535. bool radeon_semaphore_emit_wait(struct radeon_device *rdev, int ring,
  536. struct radeon_semaphore *semaphore);
  537. void radeon_semaphore_free(struct radeon_device *rdev,
  538. struct radeon_semaphore **semaphore,
  539. struct radeon_fence *fence);
  540. /*
  541. * Synchronization
  542. */
  543. struct radeon_sync {
  544. struct radeon_semaphore *semaphores[RADEON_NUM_SYNCS];
  545. struct radeon_fence *sync_to[RADEON_NUM_RINGS];
  546. struct radeon_fence *last_vm_update;
  547. };
  548. void radeon_sync_create(struct radeon_sync *sync);
  549. void radeon_sync_fence(struct radeon_sync *sync,
  550. struct radeon_fence *fence);
  551. int radeon_sync_resv(struct radeon_device *rdev,
  552. struct radeon_sync *sync,
  553. struct reservation_object *resv,
  554. bool shared);
  555. int radeon_sync_rings(struct radeon_device *rdev,
  556. struct radeon_sync *sync,
  557. int waiting_ring);
  558. void radeon_sync_free(struct radeon_device *rdev, struct radeon_sync *sync,
  559. struct radeon_fence *fence);
  560. /*
  561. * GART structures, functions & helpers
  562. */
  563. struct radeon_mc;
  564. #define RADEON_GPU_PAGE_SIZE 4096
  565. #define RADEON_GPU_PAGE_MASK (RADEON_GPU_PAGE_SIZE - 1)
  566. #define RADEON_GPU_PAGE_SHIFT 12
  567. #define RADEON_GPU_PAGE_ALIGN(a) (((a) + RADEON_GPU_PAGE_MASK) & ~RADEON_GPU_PAGE_MASK)
  568. #define RADEON_GART_PAGE_DUMMY 0
  569. #define RADEON_GART_PAGE_VALID (1 << 0)
  570. #define RADEON_GART_PAGE_READ (1 << 1)
  571. #define RADEON_GART_PAGE_WRITE (1 << 2)
  572. #define RADEON_GART_PAGE_SNOOP (1 << 3)
  573. struct radeon_gart {
  574. dma_addr_t table_addr;
  575. struct radeon_bo *robj;
  576. void *ptr;
  577. unsigned num_gpu_pages;
  578. unsigned num_cpu_pages;
  579. unsigned table_size;
  580. struct page **pages;
  581. uint64_t *pages_entry;
  582. bool ready;
  583. };
  584. int radeon_gart_table_ram_alloc(struct radeon_device *rdev);
  585. void radeon_gart_table_ram_free(struct radeon_device *rdev);
  586. int radeon_gart_table_vram_alloc(struct radeon_device *rdev);
  587. void radeon_gart_table_vram_free(struct radeon_device *rdev);
  588. int radeon_gart_table_vram_pin(struct radeon_device *rdev);
  589. void radeon_gart_table_vram_unpin(struct radeon_device *rdev);
  590. int radeon_gart_init(struct radeon_device *rdev);
  591. void radeon_gart_fini(struct radeon_device *rdev);
  592. void radeon_gart_unbind(struct radeon_device *rdev, unsigned offset,
  593. int pages);
  594. int radeon_gart_bind(struct radeon_device *rdev, unsigned offset,
  595. int pages, struct page **pagelist,
  596. dma_addr_t *dma_addr, uint32_t flags);
  597. /*
  598. * GPU MC structures, functions & helpers
  599. */
  600. struct radeon_mc {
  601. resource_size_t aper_size;
  602. resource_size_t aper_base;
  603. resource_size_t agp_base;
  604. /* for some chips with <= 32MB we need to lie
  605. * about vram size near mc fb location */
  606. u64 mc_vram_size;
  607. u64 visible_vram_size;
  608. u64 gtt_size;
  609. u64 gtt_start;
  610. u64 gtt_end;
  611. u64 vram_start;
  612. u64 vram_end;
  613. unsigned vram_width;
  614. u64 real_vram_size;
  615. int vram_mtrr;
  616. bool vram_is_ddr;
  617. bool igp_sideport_enabled;
  618. u64 gtt_base_align;
  619. u64 mc_mask;
  620. };
  621. bool radeon_combios_sideport_present(struct radeon_device *rdev);
  622. bool radeon_atombios_sideport_present(struct radeon_device *rdev);
  623. /*
  624. * GPU scratch registers structures, functions & helpers
  625. */
  626. struct radeon_scratch {
  627. unsigned num_reg;
  628. uint32_t reg_base;
  629. bool free[32];
  630. uint32_t reg[32];
  631. };
  632. int radeon_scratch_get(struct radeon_device *rdev, uint32_t *reg);
  633. void radeon_scratch_free(struct radeon_device *rdev, uint32_t reg);
  634. /*
  635. * GPU doorbell structures, functions & helpers
  636. */
  637. #define RADEON_MAX_DOORBELLS 1024 /* Reserve at most 1024 doorbell slots for radeon-owned rings. */
  638. struct radeon_doorbell {
  639. /* doorbell mmio */
  640. resource_size_t base;
  641. resource_size_t size;
  642. u32 __iomem *ptr;
  643. u32 num_doorbells; /* Number of doorbells actually reserved for radeon. */
  644. DECLARE_BITMAP(used, RADEON_MAX_DOORBELLS);
  645. };
  646. int radeon_doorbell_get(struct radeon_device *rdev, u32 *page);
  647. void radeon_doorbell_free(struct radeon_device *rdev, u32 doorbell);
  648. void radeon_doorbell_get_kfd_info(struct radeon_device *rdev,
  649. phys_addr_t *aperture_base,
  650. size_t *aperture_size,
  651. size_t *start_offset);
  652. /*
  653. * IRQS.
  654. */
  655. struct radeon_flip_work {
  656. struct work_struct flip_work;
  657. struct work_struct unpin_work;
  658. struct radeon_device *rdev;
  659. int crtc_id;
  660. uint64_t base;
  661. struct drm_pending_vblank_event *event;
  662. struct radeon_bo *old_rbo;
  663. struct fence *fence;
  664. };
  665. struct r500_irq_stat_regs {
  666. u32 disp_int;
  667. u32 hdmi0_status;
  668. };
  669. struct r600_irq_stat_regs {
  670. u32 disp_int;
  671. u32 disp_int_cont;
  672. u32 disp_int_cont2;
  673. u32 d1grph_int;
  674. u32 d2grph_int;
  675. u32 hdmi0_status;
  676. u32 hdmi1_status;
  677. };
  678. struct evergreen_irq_stat_regs {
  679. u32 disp_int;
  680. u32 disp_int_cont;
  681. u32 disp_int_cont2;
  682. u32 disp_int_cont3;
  683. u32 disp_int_cont4;
  684. u32 disp_int_cont5;
  685. u32 d1grph_int;
  686. u32 d2grph_int;
  687. u32 d3grph_int;
  688. u32 d4grph_int;
  689. u32 d5grph_int;
  690. u32 d6grph_int;
  691. u32 afmt_status1;
  692. u32 afmt_status2;
  693. u32 afmt_status3;
  694. u32 afmt_status4;
  695. u32 afmt_status5;
  696. u32 afmt_status6;
  697. };
  698. struct cik_irq_stat_regs {
  699. u32 disp_int;
  700. u32 disp_int_cont;
  701. u32 disp_int_cont2;
  702. u32 disp_int_cont3;
  703. u32 disp_int_cont4;
  704. u32 disp_int_cont5;
  705. u32 disp_int_cont6;
  706. u32 d1grph_int;
  707. u32 d2grph_int;
  708. u32 d3grph_int;
  709. u32 d4grph_int;
  710. u32 d5grph_int;
  711. u32 d6grph_int;
  712. };
  713. union radeon_irq_stat_regs {
  714. struct r500_irq_stat_regs r500;
  715. struct r600_irq_stat_regs r600;
  716. struct evergreen_irq_stat_regs evergreen;
  717. struct cik_irq_stat_regs cik;
  718. };
  719. struct radeon_irq {
  720. bool installed;
  721. spinlock_t lock;
  722. atomic_t ring_int[RADEON_NUM_RINGS];
  723. bool crtc_vblank_int[RADEON_MAX_CRTCS];
  724. atomic_t pflip[RADEON_MAX_CRTCS];
  725. wait_queue_head_t vblank_queue;
  726. bool hpd[RADEON_MAX_HPD_PINS];
  727. bool afmt[RADEON_MAX_AFMT_BLOCKS];
  728. union radeon_irq_stat_regs stat_regs;
  729. bool dpm_thermal;
  730. };
  731. int radeon_irq_kms_init(struct radeon_device *rdev);
  732. void radeon_irq_kms_fini(struct radeon_device *rdev);
  733. void radeon_irq_kms_sw_irq_get(struct radeon_device *rdev, int ring);
  734. bool radeon_irq_kms_sw_irq_get_delayed(struct radeon_device *rdev, int ring);
  735. void radeon_irq_kms_sw_irq_put(struct radeon_device *rdev, int ring);
  736. void radeon_irq_kms_pflip_irq_get(struct radeon_device *rdev, int crtc);
  737. void radeon_irq_kms_pflip_irq_put(struct radeon_device *rdev, int crtc);
  738. void radeon_irq_kms_enable_afmt(struct radeon_device *rdev, int block);
  739. void radeon_irq_kms_disable_afmt(struct radeon_device *rdev, int block);
  740. void radeon_irq_kms_enable_hpd(struct radeon_device *rdev, unsigned hpd_mask);
  741. void radeon_irq_kms_disable_hpd(struct radeon_device *rdev, unsigned hpd_mask);
  742. /*
  743. * CP & rings.
  744. */
  745. struct radeon_ib {
  746. struct radeon_sa_bo *sa_bo;
  747. uint32_t length_dw;
  748. uint64_t gpu_addr;
  749. uint32_t *ptr;
  750. int ring;
  751. struct radeon_fence *fence;
  752. struct radeon_vm *vm;
  753. bool is_const_ib;
  754. struct radeon_sync sync;
  755. };
  756. struct radeon_ring {
  757. struct radeon_bo *ring_obj;
  758. volatile uint32_t *ring;
  759. unsigned rptr_offs;
  760. unsigned rptr_save_reg;
  761. u64 next_rptr_gpu_addr;
  762. volatile u32 *next_rptr_cpu_addr;
  763. unsigned wptr;
  764. unsigned wptr_old;
  765. unsigned ring_size;
  766. unsigned ring_free_dw;
  767. int count_dw;
  768. atomic_t last_rptr;
  769. atomic64_t last_activity;
  770. uint64_t gpu_addr;
  771. uint32_t align_mask;
  772. uint32_t ptr_mask;
  773. bool ready;
  774. u32 nop;
  775. u32 idx;
  776. u64 last_semaphore_signal_addr;
  777. u64 last_semaphore_wait_addr;
  778. /* for CIK queues */
  779. u32 me;
  780. u32 pipe;
  781. u32 queue;
  782. struct radeon_bo *mqd_obj;
  783. u32 doorbell_index;
  784. unsigned wptr_offs;
  785. };
  786. struct radeon_mec {
  787. struct radeon_bo *hpd_eop_obj;
  788. u64 hpd_eop_gpu_addr;
  789. u32 num_pipe;
  790. u32 num_mec;
  791. u32 num_queue;
  792. };
  793. /*
  794. * VM
  795. */
  796. /* maximum number of VMIDs */
  797. #define RADEON_NUM_VM 16
  798. /* number of entries in page table */
  799. #define RADEON_VM_PTE_COUNT (1 << radeon_vm_block_size)
  800. /* PTBs (Page Table Blocks) need to be aligned to 32K */
  801. #define RADEON_VM_PTB_ALIGN_SIZE 32768
  802. #define RADEON_VM_PTB_ALIGN_MASK (RADEON_VM_PTB_ALIGN_SIZE - 1)
  803. #define RADEON_VM_PTB_ALIGN(a) (((a) + RADEON_VM_PTB_ALIGN_MASK) & ~RADEON_VM_PTB_ALIGN_MASK)
  804. #define R600_PTE_VALID (1 << 0)
  805. #define R600_PTE_SYSTEM (1 << 1)
  806. #define R600_PTE_SNOOPED (1 << 2)
  807. #define R600_PTE_READABLE (1 << 5)
  808. #define R600_PTE_WRITEABLE (1 << 6)
  809. /* PTE (Page Table Entry) fragment field for different page sizes */
  810. #define R600_PTE_FRAG_4KB (0 << 7)
  811. #define R600_PTE_FRAG_64KB (4 << 7)
  812. #define R600_PTE_FRAG_256KB (6 << 7)
  813. /* flags needed to be set so we can copy directly from the GART table */
  814. #define R600_PTE_GART_MASK ( R600_PTE_READABLE | R600_PTE_WRITEABLE | \
  815. R600_PTE_SYSTEM | R600_PTE_VALID )
  816. struct radeon_vm_pt {
  817. struct radeon_bo *bo;
  818. uint64_t addr;
  819. };
  820. struct radeon_vm_id {
  821. unsigned id;
  822. uint64_t pd_gpu_addr;
  823. /* last flushed PD/PT update */
  824. struct radeon_fence *flushed_updates;
  825. /* last use of vmid */
  826. struct radeon_fence *last_id_use;
  827. };
  828. struct radeon_vm {
  829. struct mutex mutex;
  830. struct rb_root va;
  831. /* protecting invalidated and freed */
  832. spinlock_t status_lock;
  833. /* BOs moved, but not yet updated in the PT */
  834. struct list_head invalidated;
  835. /* BOs freed, but not yet updated in the PT */
  836. struct list_head freed;
  837. /* BOs cleared in the PT */
  838. struct list_head cleared;
  839. /* contains the page directory */
  840. struct radeon_bo *page_directory;
  841. unsigned max_pde_used;
  842. /* array of page tables, one for each page directory entry */
  843. struct radeon_vm_pt *page_tables;
  844. struct radeon_bo_va *ib_bo_va;
  845. /* for id and flush management per ring */
  846. struct radeon_vm_id ids[RADEON_NUM_RINGS];
  847. };
  848. struct radeon_vm_manager {
  849. struct radeon_fence *active[RADEON_NUM_VM];
  850. uint32_t max_pfn;
  851. /* number of VMIDs */
  852. unsigned nvm;
  853. /* vram base address for page table entry */
  854. u64 vram_base_offset;
  855. /* is vm enabled? */
  856. bool enabled;
  857. /* for hw to save the PD addr on suspend/resume */
  858. uint32_t saved_table_addr[RADEON_NUM_VM];
  859. };
  860. /*
  861. * file private structure
  862. */
  863. struct radeon_fpriv {
  864. struct radeon_vm vm;
  865. };
  866. /*
  867. * R6xx+ IH ring
  868. */
  869. struct r600_ih {
  870. struct radeon_bo *ring_obj;
  871. volatile uint32_t *ring;
  872. unsigned rptr;
  873. unsigned ring_size;
  874. uint64_t gpu_addr;
  875. uint32_t ptr_mask;
  876. atomic_t lock;
  877. bool enabled;
  878. };
  879. /*
  880. * RLC stuff
  881. */
  882. #include "clearstate_defs.h"
  883. struct radeon_rlc {
  884. /* for power gating */
  885. struct radeon_bo *save_restore_obj;
  886. uint64_t save_restore_gpu_addr;
  887. volatile uint32_t *sr_ptr;
  888. const u32 *reg_list;
  889. u32 reg_list_size;
  890. /* for clear state */
  891. struct radeon_bo *clear_state_obj;
  892. uint64_t clear_state_gpu_addr;
  893. volatile uint32_t *cs_ptr;
  894. const struct cs_section_def *cs_data;
  895. u32 clear_state_size;
  896. /* for cp tables */
  897. struct radeon_bo *cp_table_obj;
  898. uint64_t cp_table_gpu_addr;
  899. volatile uint32_t *cp_table_ptr;
  900. u32 cp_table_size;
  901. };
  902. int radeon_ib_get(struct radeon_device *rdev, int ring,
  903. struct radeon_ib *ib, struct radeon_vm *vm,
  904. unsigned size);
  905. void radeon_ib_free(struct radeon_device *rdev, struct radeon_ib *ib);
  906. int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib,
  907. struct radeon_ib *const_ib, bool hdp_flush);
  908. int radeon_ib_pool_init(struct radeon_device *rdev);
  909. void radeon_ib_pool_fini(struct radeon_device *rdev);
  910. int radeon_ib_ring_tests(struct radeon_device *rdev);
  911. /* Ring access between begin & end cannot sleep */
  912. bool radeon_ring_supports_scratch_reg(struct radeon_device *rdev,
  913. struct radeon_ring *ring);
  914. void radeon_ring_free_size(struct radeon_device *rdev, struct radeon_ring *cp);
  915. int radeon_ring_alloc(struct radeon_device *rdev, struct radeon_ring *cp, unsigned ndw);
  916. int radeon_ring_lock(struct radeon_device *rdev, struct radeon_ring *cp, unsigned ndw);
  917. void radeon_ring_commit(struct radeon_device *rdev, struct radeon_ring *cp,
  918. bool hdp_flush);
  919. void radeon_ring_unlock_commit(struct radeon_device *rdev, struct radeon_ring *cp,
  920. bool hdp_flush);
  921. void radeon_ring_undo(struct radeon_ring *ring);
  922. void radeon_ring_unlock_undo(struct radeon_device *rdev, struct radeon_ring *cp);
  923. int radeon_ring_test(struct radeon_device *rdev, struct radeon_ring *cp);
  924. void radeon_ring_lockup_update(struct radeon_device *rdev,
  925. struct radeon_ring *ring);
  926. bool radeon_ring_test_lockup(struct radeon_device *rdev, struct radeon_ring *ring);
  927. unsigned radeon_ring_backup(struct radeon_device *rdev, struct radeon_ring *ring,
  928. uint32_t **data);
  929. int radeon_ring_restore(struct radeon_device *rdev, struct radeon_ring *ring,
  930. unsigned size, uint32_t *data);
  931. int radeon_ring_init(struct radeon_device *rdev, struct radeon_ring *cp, unsigned ring_size,
  932. unsigned rptr_offs, u32 nop);
  933. void radeon_ring_fini(struct radeon_device *rdev, struct radeon_ring *cp);
  934. /* r600 async dma */
  935. void r600_dma_stop(struct radeon_device *rdev);
  936. int r600_dma_resume(struct radeon_device *rdev);
  937. void r600_dma_fini(struct radeon_device *rdev);
  938. void cayman_dma_stop(struct radeon_device *rdev);
  939. int cayman_dma_resume(struct radeon_device *rdev);
  940. void cayman_dma_fini(struct radeon_device *rdev);
  941. /*
  942. * CS.
  943. */
  944. struct radeon_cs_chunk {
  945. uint32_t length_dw;
  946. uint32_t *kdata;
  947. void __user *user_ptr;
  948. };
  949. struct radeon_cs_parser {
  950. struct device *dev;
  951. struct radeon_device *rdev;
  952. struct drm_file *filp;
  953. /* chunks */
  954. unsigned nchunks;
  955. struct radeon_cs_chunk *chunks;
  956. uint64_t *chunks_array;
  957. /* IB */
  958. unsigned idx;
  959. /* relocations */
  960. unsigned nrelocs;
  961. struct radeon_bo_list *relocs;
  962. struct radeon_bo_list *vm_bos;
  963. struct list_head validated;
  964. unsigned dma_reloc_idx;
  965. /* indices of various chunks */
  966. struct radeon_cs_chunk *chunk_ib;
  967. struct radeon_cs_chunk *chunk_relocs;
  968. struct radeon_cs_chunk *chunk_flags;
  969. struct radeon_cs_chunk *chunk_const_ib;
  970. struct radeon_ib ib;
  971. struct radeon_ib const_ib;
  972. void *track;
  973. unsigned family;
  974. int parser_error;
  975. u32 cs_flags;
  976. u32 ring;
  977. s32 priority;
  978. struct ww_acquire_ctx ticket;
  979. };
  980. static inline u32 radeon_get_ib_value(struct radeon_cs_parser *p, int idx)
  981. {
  982. struct radeon_cs_chunk *ibc = p->chunk_ib;
  983. if (ibc->kdata)
  984. return ibc->kdata[idx];
  985. return p->ib.ptr[idx];
  986. }
  987. struct radeon_cs_packet {
  988. unsigned idx;
  989. unsigned type;
  990. unsigned reg;
  991. unsigned opcode;
  992. int count;
  993. unsigned one_reg_wr;
  994. };
  995. typedef int (*radeon_packet0_check_t)(struct radeon_cs_parser *p,
  996. struct radeon_cs_packet *pkt,
  997. unsigned idx, unsigned reg);
  998. typedef int (*radeon_packet3_check_t)(struct radeon_cs_parser *p,
  999. struct radeon_cs_packet *pkt);
  1000. /*
  1001. * AGP
  1002. */
  1003. int radeon_agp_init(struct radeon_device *rdev);
  1004. void radeon_agp_resume(struct radeon_device *rdev);
  1005. void radeon_agp_suspend(struct radeon_device *rdev);
  1006. void radeon_agp_fini(struct radeon_device *rdev);
  1007. /*
  1008. * Writeback
  1009. */
  1010. struct radeon_wb {
  1011. struct radeon_bo *wb_obj;
  1012. volatile uint32_t *wb;
  1013. uint64_t gpu_addr;
  1014. bool enabled;
  1015. bool use_event;
  1016. };
  1017. #define RADEON_WB_SCRATCH_OFFSET 0
  1018. #define RADEON_WB_RING0_NEXT_RPTR 256
  1019. #define RADEON_WB_CP_RPTR_OFFSET 1024
  1020. #define RADEON_WB_CP1_RPTR_OFFSET 1280
  1021. #define RADEON_WB_CP2_RPTR_OFFSET 1536
  1022. #define R600_WB_DMA_RPTR_OFFSET 1792
  1023. #define R600_WB_IH_WPTR_OFFSET 2048
  1024. #define CAYMAN_WB_DMA1_RPTR_OFFSET 2304
  1025. #define R600_WB_EVENT_OFFSET 3072
  1026. #define CIK_WB_CP1_WPTR_OFFSET 3328
  1027. #define CIK_WB_CP2_WPTR_OFFSET 3584
  1028. #define R600_WB_DMA_RING_TEST_OFFSET 3588
  1029. #define CAYMAN_WB_DMA1_RING_TEST_OFFSET 3592
  1030. /**
  1031. * struct radeon_pm - power management datas
  1032. * @max_bandwidth: maximum bandwidth the gpu has (MByte/s)
  1033. * @igp_sideport_mclk: sideport memory clock Mhz (rs690,rs740,rs780,rs880)
  1034. * @igp_system_mclk: system clock Mhz (rs690,rs740,rs780,rs880)
  1035. * @igp_ht_link_clk: ht link clock Mhz (rs690,rs740,rs780,rs880)
  1036. * @igp_ht_link_width: ht link width in bits (rs690,rs740,rs780,rs880)
  1037. * @k8_bandwidth: k8 bandwidth the gpu has (MByte/s) (IGP)
  1038. * @sideport_bandwidth: sideport bandwidth the gpu has (MByte/s) (IGP)
  1039. * @ht_bandwidth: ht bandwidth the gpu has (MByte/s) (IGP)
  1040. * @core_bandwidth: core GPU bandwidth the gpu has (MByte/s) (IGP)
  1041. * @sclk: GPU clock Mhz (core bandwidth depends of this clock)
  1042. * @needed_bandwidth: current bandwidth needs
  1043. *
  1044. * It keeps track of various data needed to take powermanagement decision.
  1045. * Bandwidth need is used to determine minimun clock of the GPU and memory.
  1046. * Equation between gpu/memory clock and available bandwidth is hw dependent
  1047. * (type of memory, bus size, efficiency, ...)
  1048. */
  1049. enum radeon_pm_method {
  1050. PM_METHOD_PROFILE,
  1051. PM_METHOD_DYNPM,
  1052. PM_METHOD_DPM,
  1053. };
  1054. enum radeon_dynpm_state {
  1055. DYNPM_STATE_DISABLED,
  1056. DYNPM_STATE_MINIMUM,
  1057. DYNPM_STATE_PAUSED,
  1058. DYNPM_STATE_ACTIVE,
  1059. DYNPM_STATE_SUSPENDED,
  1060. };
  1061. enum radeon_dynpm_action {
  1062. DYNPM_ACTION_NONE,
  1063. DYNPM_ACTION_MINIMUM,
  1064. DYNPM_ACTION_DOWNCLOCK,
  1065. DYNPM_ACTION_UPCLOCK,
  1066. DYNPM_ACTION_DEFAULT
  1067. };
  1068. enum radeon_voltage_type {
  1069. VOLTAGE_NONE = 0,
  1070. VOLTAGE_GPIO,
  1071. VOLTAGE_VDDC,
  1072. VOLTAGE_SW
  1073. };
  1074. enum radeon_pm_state_type {
  1075. /* not used for dpm */
  1076. POWER_STATE_TYPE_DEFAULT,
  1077. POWER_STATE_TYPE_POWERSAVE,
  1078. /* user selectable states */
  1079. POWER_STATE_TYPE_BATTERY,
  1080. POWER_STATE_TYPE_BALANCED,
  1081. POWER_STATE_TYPE_PERFORMANCE,
  1082. /* internal states */
  1083. POWER_STATE_TYPE_INTERNAL_UVD,
  1084. POWER_STATE_TYPE_INTERNAL_UVD_SD,
  1085. POWER_STATE_TYPE_INTERNAL_UVD_HD,
  1086. POWER_STATE_TYPE_INTERNAL_UVD_HD2,
  1087. POWER_STATE_TYPE_INTERNAL_UVD_MVC,
  1088. POWER_STATE_TYPE_INTERNAL_BOOT,
  1089. POWER_STATE_TYPE_INTERNAL_THERMAL,
  1090. POWER_STATE_TYPE_INTERNAL_ACPI,
  1091. POWER_STATE_TYPE_INTERNAL_ULV,
  1092. POWER_STATE_TYPE_INTERNAL_3DPERF,
  1093. };
  1094. enum radeon_pm_profile_type {
  1095. PM_PROFILE_DEFAULT,
  1096. PM_PROFILE_AUTO,
  1097. PM_PROFILE_LOW,
  1098. PM_PROFILE_MID,
  1099. PM_PROFILE_HIGH,
  1100. };
  1101. #define PM_PROFILE_DEFAULT_IDX 0
  1102. #define PM_PROFILE_LOW_SH_IDX 1
  1103. #define PM_PROFILE_MID_SH_IDX 2
  1104. #define PM_PROFILE_HIGH_SH_IDX 3
  1105. #define PM_PROFILE_LOW_MH_IDX 4
  1106. #define PM_PROFILE_MID_MH_IDX 5
  1107. #define PM_PROFILE_HIGH_MH_IDX 6
  1108. #define PM_PROFILE_MAX 7
  1109. struct radeon_pm_profile {
  1110. int dpms_off_ps_idx;
  1111. int dpms_on_ps_idx;
  1112. int dpms_off_cm_idx;
  1113. int dpms_on_cm_idx;
  1114. };
  1115. enum radeon_int_thermal_type {
  1116. THERMAL_TYPE_NONE,
  1117. THERMAL_TYPE_EXTERNAL,
  1118. THERMAL_TYPE_EXTERNAL_GPIO,
  1119. THERMAL_TYPE_RV6XX,
  1120. THERMAL_TYPE_RV770,
  1121. THERMAL_TYPE_ADT7473_WITH_INTERNAL,
  1122. THERMAL_TYPE_EVERGREEN,
  1123. THERMAL_TYPE_SUMO,
  1124. THERMAL_TYPE_NI,
  1125. THERMAL_TYPE_SI,
  1126. THERMAL_TYPE_EMC2103_WITH_INTERNAL,
  1127. THERMAL_TYPE_CI,
  1128. THERMAL_TYPE_KV,
  1129. };
  1130. struct radeon_voltage {
  1131. enum radeon_voltage_type type;
  1132. /* gpio voltage */
  1133. struct radeon_gpio_rec gpio;
  1134. u32 delay; /* delay in usec from voltage drop to sclk change */
  1135. bool active_high; /* voltage drop is active when bit is high */
  1136. /* VDDC voltage */
  1137. u8 vddc_id; /* index into vddc voltage table */
  1138. u8 vddci_id; /* index into vddci voltage table */
  1139. bool vddci_enabled;
  1140. /* r6xx+ sw */
  1141. u16 voltage;
  1142. /* evergreen+ vddci */
  1143. u16 vddci;
  1144. };
  1145. /* clock mode flags */
  1146. #define RADEON_PM_MODE_NO_DISPLAY (1 << 0)
  1147. struct radeon_pm_clock_info {
  1148. /* memory clock */
  1149. u32 mclk;
  1150. /* engine clock */
  1151. u32 sclk;
  1152. /* voltage info */
  1153. struct radeon_voltage voltage;
  1154. /* standardized clock flags */
  1155. u32 flags;
  1156. };
  1157. /* state flags */
  1158. #define RADEON_PM_STATE_SINGLE_DISPLAY_ONLY (1 << 0)
  1159. struct radeon_power_state {
  1160. enum radeon_pm_state_type type;
  1161. struct radeon_pm_clock_info *clock_info;
  1162. /* number of valid clock modes in this power state */
  1163. int num_clock_modes;
  1164. struct radeon_pm_clock_info *default_clock_mode;
  1165. /* standardized state flags */
  1166. u32 flags;
  1167. u32 misc; /* vbios specific flags */
  1168. u32 misc2; /* vbios specific flags */
  1169. int pcie_lanes; /* pcie lanes */
  1170. };
  1171. /*
  1172. * Some modes are overclocked by very low value, accept them
  1173. */
  1174. #define RADEON_MODE_OVERCLOCK_MARGIN 500 /* 5 MHz */
  1175. enum radeon_dpm_auto_throttle_src {
  1176. RADEON_DPM_AUTO_THROTTLE_SRC_THERMAL,
  1177. RADEON_DPM_AUTO_THROTTLE_SRC_EXTERNAL
  1178. };
  1179. enum radeon_dpm_event_src {
  1180. RADEON_DPM_EVENT_SRC_ANALOG = 0,
  1181. RADEON_DPM_EVENT_SRC_EXTERNAL = 1,
  1182. RADEON_DPM_EVENT_SRC_DIGITAL = 2,
  1183. RADEON_DPM_EVENT_SRC_ANALOG_OR_EXTERNAL = 3,
  1184. RADEON_DPM_EVENT_SRC_DIGIAL_OR_EXTERNAL = 4
  1185. };
  1186. #define RADEON_MAX_VCE_LEVELS 6
  1187. enum radeon_vce_level {
  1188. RADEON_VCE_LEVEL_AC_ALL = 0, /* AC, All cases */
  1189. RADEON_VCE_LEVEL_DC_EE = 1, /* DC, entropy encoding */
  1190. RADEON_VCE_LEVEL_DC_LL_LOW = 2, /* DC, low latency queue, res <= 720 */
  1191. RADEON_VCE_LEVEL_DC_LL_HIGH = 3, /* DC, low latency queue, 1080 >= res > 720 */
  1192. RADEON_VCE_LEVEL_DC_GP_LOW = 4, /* DC, general purpose queue, res <= 720 */
  1193. RADEON_VCE_LEVEL_DC_GP_HIGH = 5, /* DC, general purpose queue, 1080 >= res > 720 */
  1194. };
  1195. struct radeon_ps {
  1196. u32 caps; /* vbios flags */
  1197. u32 class; /* vbios flags */
  1198. u32 class2; /* vbios flags */
  1199. /* UVD clocks */
  1200. u32 vclk;
  1201. u32 dclk;
  1202. /* VCE clocks */
  1203. u32 evclk;
  1204. u32 ecclk;
  1205. bool vce_active;
  1206. enum radeon_vce_level vce_level;
  1207. /* asic priv */
  1208. void *ps_priv;
  1209. };
  1210. struct radeon_dpm_thermal {
  1211. /* thermal interrupt work */
  1212. struct work_struct work;
  1213. /* low temperature threshold */
  1214. int min_temp;
  1215. /* high temperature threshold */
  1216. int max_temp;
  1217. /* was interrupt low to high or high to low */
  1218. bool high_to_low;
  1219. };
  1220. enum radeon_clk_action
  1221. {
  1222. RADEON_SCLK_UP = 1,
  1223. RADEON_SCLK_DOWN
  1224. };
  1225. struct radeon_blacklist_clocks
  1226. {
  1227. u32 sclk;
  1228. u32 mclk;
  1229. enum radeon_clk_action action;
  1230. };
  1231. struct radeon_clock_and_voltage_limits {
  1232. u32 sclk;
  1233. u32 mclk;
  1234. u16 vddc;
  1235. u16 vddci;
  1236. };
  1237. struct radeon_clock_array {
  1238. u32 count;
  1239. u32 *values;
  1240. };
  1241. struct radeon_clock_voltage_dependency_entry {
  1242. u32 clk;
  1243. u16 v;
  1244. };
  1245. struct radeon_clock_voltage_dependency_table {
  1246. u32 count;
  1247. struct radeon_clock_voltage_dependency_entry *entries;
  1248. };
  1249. union radeon_cac_leakage_entry {
  1250. struct {
  1251. u16 vddc;
  1252. u32 leakage;
  1253. };
  1254. struct {
  1255. u16 vddc1;
  1256. u16 vddc2;
  1257. u16 vddc3;
  1258. };
  1259. };
  1260. struct radeon_cac_leakage_table {
  1261. u32 count;
  1262. union radeon_cac_leakage_entry *entries;
  1263. };
  1264. struct radeon_phase_shedding_limits_entry {
  1265. u16 voltage;
  1266. u32 sclk;
  1267. u32 mclk;
  1268. };
  1269. struct radeon_phase_shedding_limits_table {
  1270. u32 count;
  1271. struct radeon_phase_shedding_limits_entry *entries;
  1272. };
  1273. struct radeon_uvd_clock_voltage_dependency_entry {
  1274. u32 vclk;
  1275. u32 dclk;
  1276. u16 v;
  1277. };
  1278. struct radeon_uvd_clock_voltage_dependency_table {
  1279. u8 count;
  1280. struct radeon_uvd_clock_voltage_dependency_entry *entries;
  1281. };
  1282. struct radeon_vce_clock_voltage_dependency_entry {
  1283. u32 ecclk;
  1284. u32 evclk;
  1285. u16 v;
  1286. };
  1287. struct radeon_vce_clock_voltage_dependency_table {
  1288. u8 count;
  1289. struct radeon_vce_clock_voltage_dependency_entry *entries;
  1290. };
  1291. struct radeon_ppm_table {
  1292. u8 ppm_design;
  1293. u16 cpu_core_number;
  1294. u32 platform_tdp;
  1295. u32 small_ac_platform_tdp;
  1296. u32 platform_tdc;
  1297. u32 small_ac_platform_tdc;
  1298. u32 apu_tdp;
  1299. u32 dgpu_tdp;
  1300. u32 dgpu_ulv_power;
  1301. u32 tj_max;
  1302. };
  1303. struct radeon_cac_tdp_table {
  1304. u16 tdp;
  1305. u16 configurable_tdp;
  1306. u16 tdc;
  1307. u16 battery_power_limit;
  1308. u16 small_power_limit;
  1309. u16 low_cac_leakage;
  1310. u16 high_cac_leakage;
  1311. u16 maximum_power_delivery_limit;
  1312. };
  1313. struct radeon_dpm_dynamic_state {
  1314. struct radeon_clock_voltage_dependency_table vddc_dependency_on_sclk;
  1315. struct radeon_clock_voltage_dependency_table vddci_dependency_on_mclk;
  1316. struct radeon_clock_voltage_dependency_table vddc_dependency_on_mclk;
  1317. struct radeon_clock_voltage_dependency_table mvdd_dependency_on_mclk;
  1318. struct radeon_clock_voltage_dependency_table vddc_dependency_on_dispclk;
  1319. struct radeon_uvd_clock_voltage_dependency_table uvd_clock_voltage_dependency_table;
  1320. struct radeon_vce_clock_voltage_dependency_table vce_clock_voltage_dependency_table;
  1321. struct radeon_clock_voltage_dependency_table samu_clock_voltage_dependency_table;
  1322. struct radeon_clock_voltage_dependency_table acp_clock_voltage_dependency_table;
  1323. struct radeon_clock_array valid_sclk_values;
  1324. struct radeon_clock_array valid_mclk_values;
  1325. struct radeon_clock_and_voltage_limits max_clock_voltage_on_dc;
  1326. struct radeon_clock_and_voltage_limits max_clock_voltage_on_ac;
  1327. u32 mclk_sclk_ratio;
  1328. u32 sclk_mclk_delta;
  1329. u16 vddc_vddci_delta;
  1330. u16 min_vddc_for_pcie_gen2;
  1331. struct radeon_cac_leakage_table cac_leakage_table;
  1332. struct radeon_phase_shedding_limits_table phase_shedding_limits_table;
  1333. struct radeon_ppm_table *ppm_table;
  1334. struct radeon_cac_tdp_table *cac_tdp_table;
  1335. };
  1336. struct radeon_dpm_fan {
  1337. u16 t_min;
  1338. u16 t_med;
  1339. u16 t_high;
  1340. u16 pwm_min;
  1341. u16 pwm_med;
  1342. u16 pwm_high;
  1343. u8 t_hyst;
  1344. u32 cycle_delay;
  1345. u16 t_max;
  1346. u8 control_mode;
  1347. u16 default_max_fan_pwm;
  1348. u16 default_fan_output_sensitivity;
  1349. u16 fan_output_sensitivity;
  1350. bool ucode_fan_control;
  1351. };
  1352. enum radeon_pcie_gen {
  1353. RADEON_PCIE_GEN1 = 0,
  1354. RADEON_PCIE_GEN2 = 1,
  1355. RADEON_PCIE_GEN3 = 2,
  1356. RADEON_PCIE_GEN_INVALID = 0xffff
  1357. };
  1358. enum radeon_dpm_forced_level {
  1359. RADEON_DPM_FORCED_LEVEL_AUTO = 0,
  1360. RADEON_DPM_FORCED_LEVEL_LOW = 1,
  1361. RADEON_DPM_FORCED_LEVEL_HIGH = 2,
  1362. };
  1363. struct radeon_vce_state {
  1364. /* vce clocks */
  1365. u32 evclk;
  1366. u32 ecclk;
  1367. /* gpu clocks */
  1368. u32 sclk;
  1369. u32 mclk;
  1370. u8 clk_idx;
  1371. u8 pstate;
  1372. };
  1373. struct radeon_dpm {
  1374. struct radeon_ps *ps;
  1375. /* number of valid power states */
  1376. int num_ps;
  1377. /* current power state that is active */
  1378. struct radeon_ps *current_ps;
  1379. /* requested power state */
  1380. struct radeon_ps *requested_ps;
  1381. /* boot up power state */
  1382. struct radeon_ps *boot_ps;
  1383. /* default uvd power state */
  1384. struct radeon_ps *uvd_ps;
  1385. /* vce requirements */
  1386. struct radeon_vce_state vce_states[RADEON_MAX_VCE_LEVELS];
  1387. enum radeon_vce_level vce_level;
  1388. enum radeon_pm_state_type state;
  1389. enum radeon_pm_state_type user_state;
  1390. u32 platform_caps;
  1391. u32 voltage_response_time;
  1392. u32 backbias_response_time;
  1393. void *priv;
  1394. u32 new_active_crtcs;
  1395. int new_active_crtc_count;
  1396. u32 current_active_crtcs;
  1397. int current_active_crtc_count;
  1398. bool single_display;
  1399. struct radeon_dpm_dynamic_state dyn_state;
  1400. struct radeon_dpm_fan fan;
  1401. u32 tdp_limit;
  1402. u32 near_tdp_limit;
  1403. u32 near_tdp_limit_adjusted;
  1404. u32 sq_ramping_threshold;
  1405. u32 cac_leakage;
  1406. u16 tdp_od_limit;
  1407. u32 tdp_adjustment;
  1408. u16 load_line_slope;
  1409. bool power_control;
  1410. bool ac_power;
  1411. /* special states active */
  1412. bool thermal_active;
  1413. bool uvd_active;
  1414. bool vce_active;
  1415. /* thermal handling */
  1416. struct radeon_dpm_thermal thermal;
  1417. /* forced levels */
  1418. enum radeon_dpm_forced_level forced_level;
  1419. /* track UVD streams */
  1420. unsigned sd;
  1421. unsigned hd;
  1422. };
  1423. void radeon_dpm_enable_uvd(struct radeon_device *rdev, bool enable);
  1424. void radeon_dpm_enable_vce(struct radeon_device *rdev, bool enable);
  1425. struct radeon_pm {
  1426. struct mutex mutex;
  1427. /* write locked while reprogramming mclk */
  1428. struct rw_semaphore mclk_lock;
  1429. u32 active_crtcs;
  1430. int active_crtc_count;
  1431. int req_vblank;
  1432. bool vblank_sync;
  1433. fixed20_12 max_bandwidth;
  1434. fixed20_12 igp_sideport_mclk;
  1435. fixed20_12 igp_system_mclk;
  1436. fixed20_12 igp_ht_link_clk;
  1437. fixed20_12 igp_ht_link_width;
  1438. fixed20_12 k8_bandwidth;
  1439. fixed20_12 sideport_bandwidth;
  1440. fixed20_12 ht_bandwidth;
  1441. fixed20_12 core_bandwidth;
  1442. fixed20_12 sclk;
  1443. fixed20_12 mclk;
  1444. fixed20_12 needed_bandwidth;
  1445. struct radeon_power_state *power_state;
  1446. /* number of valid power states */
  1447. int num_power_states;
  1448. int current_power_state_index;
  1449. int current_clock_mode_index;
  1450. int requested_power_state_index;
  1451. int requested_clock_mode_index;
  1452. int default_power_state_index;
  1453. u32 current_sclk;
  1454. u32 current_mclk;
  1455. u16 current_vddc;
  1456. u16 current_vddci;
  1457. u32 default_sclk;
  1458. u32 default_mclk;
  1459. u16 default_vddc;
  1460. u16 default_vddci;
  1461. struct radeon_i2c_chan *i2c_bus;
  1462. /* selected pm method */
  1463. enum radeon_pm_method pm_method;
  1464. /* dynpm power management */
  1465. struct delayed_work dynpm_idle_work;
  1466. enum radeon_dynpm_state dynpm_state;
  1467. enum radeon_dynpm_action dynpm_planned_action;
  1468. unsigned long dynpm_action_timeout;
  1469. bool dynpm_can_upclock;
  1470. bool dynpm_can_downclock;
  1471. /* profile-based power management */
  1472. enum radeon_pm_profile_type profile;
  1473. int profile_index;
  1474. struct radeon_pm_profile profiles[PM_PROFILE_MAX];
  1475. /* internal thermal controller on rv6xx+ */
  1476. enum radeon_int_thermal_type int_thermal_type;
  1477. struct device *int_hwmon_dev;
  1478. /* fan control parameters */
  1479. bool no_fan;
  1480. u8 fan_pulses_per_revolution;
  1481. u8 fan_min_rpm;
  1482. u8 fan_max_rpm;
  1483. /* dpm */
  1484. bool dpm_enabled;
  1485. bool sysfs_initialized;
  1486. struct radeon_dpm dpm;
  1487. };
  1488. int radeon_pm_get_type_index(struct radeon_device *rdev,
  1489. enum radeon_pm_state_type ps_type,
  1490. int instance);
  1491. /*
  1492. * UVD
  1493. */
  1494. #define RADEON_MAX_UVD_HANDLES 10
  1495. #define RADEON_UVD_STACK_SIZE (1024*1024)
  1496. #define RADEON_UVD_HEAP_SIZE (1024*1024)
  1497. struct radeon_uvd {
  1498. struct radeon_bo *vcpu_bo;
  1499. void *cpu_addr;
  1500. uint64_t gpu_addr;
  1501. atomic_t handles[RADEON_MAX_UVD_HANDLES];
  1502. struct drm_file *filp[RADEON_MAX_UVD_HANDLES];
  1503. unsigned img_size[RADEON_MAX_UVD_HANDLES];
  1504. struct delayed_work idle_work;
  1505. };
  1506. int radeon_uvd_init(struct radeon_device *rdev);
  1507. void radeon_uvd_fini(struct radeon_device *rdev);
  1508. int radeon_uvd_suspend(struct radeon_device *rdev);
  1509. int radeon_uvd_resume(struct radeon_device *rdev);
  1510. int radeon_uvd_get_create_msg(struct radeon_device *rdev, int ring,
  1511. uint32_t handle, struct radeon_fence **fence);
  1512. int radeon_uvd_get_destroy_msg(struct radeon_device *rdev, int ring,
  1513. uint32_t handle, struct radeon_fence **fence);
  1514. void radeon_uvd_force_into_uvd_segment(struct radeon_bo *rbo,
  1515. uint32_t allowed_domains);
  1516. void radeon_uvd_free_handles(struct radeon_device *rdev,
  1517. struct drm_file *filp);
  1518. int radeon_uvd_cs_parse(struct radeon_cs_parser *parser);
  1519. void radeon_uvd_note_usage(struct radeon_device *rdev);
  1520. int radeon_uvd_calc_upll_dividers(struct radeon_device *rdev,
  1521. unsigned vclk, unsigned dclk,
  1522. unsigned vco_min, unsigned vco_max,
  1523. unsigned fb_factor, unsigned fb_mask,
  1524. unsigned pd_min, unsigned pd_max,
  1525. unsigned pd_even,
  1526. unsigned *optimal_fb_div,
  1527. unsigned *optimal_vclk_div,
  1528. unsigned *optimal_dclk_div);
  1529. int radeon_uvd_send_upll_ctlreq(struct radeon_device *rdev,
  1530. unsigned cg_upll_func_cntl);
  1531. /*
  1532. * VCE
  1533. */
  1534. #define RADEON_MAX_VCE_HANDLES 16
  1535. struct radeon_vce {
  1536. struct radeon_bo *vcpu_bo;
  1537. uint64_t gpu_addr;
  1538. unsigned fw_version;
  1539. unsigned fb_version;
  1540. atomic_t handles[RADEON_MAX_VCE_HANDLES];
  1541. struct drm_file *filp[RADEON_MAX_VCE_HANDLES];
  1542. unsigned img_size[RADEON_MAX_VCE_HANDLES];
  1543. struct delayed_work idle_work;
  1544. uint32_t keyselect;
  1545. };
  1546. int radeon_vce_init(struct radeon_device *rdev);
  1547. void radeon_vce_fini(struct radeon_device *rdev);
  1548. int radeon_vce_suspend(struct radeon_device *rdev);
  1549. int radeon_vce_resume(struct radeon_device *rdev);
  1550. int radeon_vce_get_create_msg(struct radeon_device *rdev, int ring,
  1551. uint32_t handle, struct radeon_fence **fence);
  1552. int radeon_vce_get_destroy_msg(struct radeon_device *rdev, int ring,
  1553. uint32_t handle, struct radeon_fence **fence);
  1554. void radeon_vce_free_handles(struct radeon_device *rdev, struct drm_file *filp);
  1555. void radeon_vce_note_usage(struct radeon_device *rdev);
  1556. int radeon_vce_cs_reloc(struct radeon_cs_parser *p, int lo, int hi, unsigned size);
  1557. int radeon_vce_cs_parse(struct radeon_cs_parser *p);
  1558. bool radeon_vce_semaphore_emit(struct radeon_device *rdev,
  1559. struct radeon_ring *ring,
  1560. struct radeon_semaphore *semaphore,
  1561. bool emit_wait);
  1562. void radeon_vce_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib);
  1563. void radeon_vce_fence_emit(struct radeon_device *rdev,
  1564. struct radeon_fence *fence);
  1565. int radeon_vce_ring_test(struct radeon_device *rdev, struct radeon_ring *ring);
  1566. int radeon_vce_ib_test(struct radeon_device *rdev, struct radeon_ring *ring);
  1567. struct r600_audio_pin {
  1568. int channels;
  1569. int rate;
  1570. int bits_per_sample;
  1571. u8 status_bits;
  1572. u8 category_code;
  1573. u32 offset;
  1574. bool connected;
  1575. u32 id;
  1576. };
  1577. struct r600_audio {
  1578. bool enabled;
  1579. struct r600_audio_pin pin[RADEON_MAX_AFMT_BLOCKS];
  1580. int num_pins;
  1581. struct radeon_audio_funcs *hdmi_funcs;
  1582. struct radeon_audio_funcs *dp_funcs;
  1583. struct radeon_audio_basic_funcs *funcs;
  1584. };
  1585. /*
  1586. * Benchmarking
  1587. */
  1588. void radeon_benchmark(struct radeon_device *rdev, int test_number);
  1589. /*
  1590. * Testing
  1591. */
  1592. void radeon_test_moves(struct radeon_device *rdev);
  1593. void radeon_test_ring_sync(struct radeon_device *rdev,
  1594. struct radeon_ring *cpA,
  1595. struct radeon_ring *cpB);
  1596. void radeon_test_syncing(struct radeon_device *rdev);
  1597. /*
  1598. * MMU Notifier
  1599. */
  1600. #if defined(CONFIG_MMU_NOTIFIER)
  1601. int radeon_mn_register(struct radeon_bo *bo, unsigned long addr);
  1602. void radeon_mn_unregister(struct radeon_bo *bo);
  1603. #else
  1604. static inline int radeon_mn_register(struct radeon_bo *bo, unsigned long addr)
  1605. {
  1606. return -ENODEV;
  1607. }
  1608. static inline void radeon_mn_unregister(struct radeon_bo *bo) {}
  1609. #endif
  1610. /*
  1611. * Debugfs
  1612. */
  1613. struct radeon_debugfs {
  1614. struct drm_info_list *files;
  1615. unsigned num_files;
  1616. };
  1617. int radeon_debugfs_add_files(struct radeon_device *rdev,
  1618. struct drm_info_list *files,
  1619. unsigned nfiles);
  1620. int radeon_debugfs_fence_init(struct radeon_device *rdev);
  1621. /*
  1622. * ASIC ring specific functions.
  1623. */
  1624. struct radeon_asic_ring {
  1625. /* ring read/write ptr handling */
  1626. u32 (*get_rptr)(struct radeon_device *rdev, struct radeon_ring *ring);
  1627. u32 (*get_wptr)(struct radeon_device *rdev, struct radeon_ring *ring);
  1628. void (*set_wptr)(struct radeon_device *rdev, struct radeon_ring *ring);
  1629. /* validating and patching of IBs */
  1630. int (*ib_parse)(struct radeon_device *rdev, struct radeon_ib *ib);
  1631. int (*cs_parse)(struct radeon_cs_parser *p);
  1632. /* command emmit functions */
  1633. void (*ib_execute)(struct radeon_device *rdev, struct radeon_ib *ib);
  1634. void (*emit_fence)(struct radeon_device *rdev, struct radeon_fence *fence);
  1635. void (*hdp_flush)(struct radeon_device *rdev, struct radeon_ring *ring);
  1636. bool (*emit_semaphore)(struct radeon_device *rdev, struct radeon_ring *cp,
  1637. struct radeon_semaphore *semaphore, bool emit_wait);
  1638. void (*vm_flush)(struct radeon_device *rdev, struct radeon_ring *ring,
  1639. unsigned vm_id, uint64_t pd_addr);
  1640. /* testing functions */
  1641. int (*ring_test)(struct radeon_device *rdev, struct radeon_ring *cp);
  1642. int (*ib_test)(struct radeon_device *rdev, struct radeon_ring *cp);
  1643. bool (*is_lockup)(struct radeon_device *rdev, struct radeon_ring *cp);
  1644. /* deprecated */
  1645. void (*ring_start)(struct radeon_device *rdev, struct radeon_ring *cp);
  1646. };
  1647. /*
  1648. * ASIC specific functions.
  1649. */
  1650. struct radeon_asic {
  1651. int (*init)(struct radeon_device *rdev);
  1652. void (*fini)(struct radeon_device *rdev);
  1653. int (*resume)(struct radeon_device *rdev);
  1654. int (*suspend)(struct radeon_device *rdev);
  1655. void (*vga_set_state)(struct radeon_device *rdev, bool state);
  1656. int (*asic_reset)(struct radeon_device *rdev);
  1657. /* Flush the HDP cache via MMIO */
  1658. void (*mmio_hdp_flush)(struct radeon_device *rdev);
  1659. /* check if 3D engine is idle */
  1660. bool (*gui_idle)(struct radeon_device *rdev);
  1661. /* wait for mc_idle */
  1662. int (*mc_wait_for_idle)(struct radeon_device *rdev);
  1663. /* get the reference clock */
  1664. u32 (*get_xclk)(struct radeon_device *rdev);
  1665. /* get the gpu clock counter */
  1666. uint64_t (*get_gpu_clock_counter)(struct radeon_device *rdev);
  1667. /* get register for info ioctl */
  1668. int (*get_allowed_info_register)(struct radeon_device *rdev, u32 reg, u32 *val);
  1669. /* gart */
  1670. struct {
  1671. void (*tlb_flush)(struct radeon_device *rdev);
  1672. uint64_t (*get_page_entry)(uint64_t addr, uint32_t flags);
  1673. void (*set_page)(struct radeon_device *rdev, unsigned i,
  1674. uint64_t entry);
  1675. } gart;
  1676. struct {
  1677. int (*init)(struct radeon_device *rdev);
  1678. void (*fini)(struct radeon_device *rdev);
  1679. void (*copy_pages)(struct radeon_device *rdev,
  1680. struct radeon_ib *ib,
  1681. uint64_t pe, uint64_t src,
  1682. unsigned count);
  1683. void (*write_pages)(struct radeon_device *rdev,
  1684. struct radeon_ib *ib,
  1685. uint64_t pe,
  1686. uint64_t addr, unsigned count,
  1687. uint32_t incr, uint32_t flags);
  1688. void (*set_pages)(struct radeon_device *rdev,
  1689. struct radeon_ib *ib,
  1690. uint64_t pe,
  1691. uint64_t addr, unsigned count,
  1692. uint32_t incr, uint32_t flags);
  1693. void (*pad_ib)(struct radeon_ib *ib);
  1694. } vm;
  1695. /* ring specific callbacks */
  1696. struct radeon_asic_ring *ring[RADEON_NUM_RINGS];
  1697. /* irqs */
  1698. struct {
  1699. int (*set)(struct radeon_device *rdev);
  1700. int (*process)(struct radeon_device *rdev);
  1701. } irq;
  1702. /* displays */
  1703. struct {
  1704. /* display watermarks */
  1705. void (*bandwidth_update)(struct radeon_device *rdev);
  1706. /* get frame count */
  1707. u32 (*get_vblank_counter)(struct radeon_device *rdev, int crtc);
  1708. /* wait for vblank */
  1709. void (*wait_for_vblank)(struct radeon_device *rdev, int crtc);
  1710. /* set backlight level */
  1711. void (*set_backlight_level)(struct radeon_encoder *radeon_encoder, u8 level);
  1712. /* get backlight level */
  1713. u8 (*get_backlight_level)(struct radeon_encoder *radeon_encoder);
  1714. /* audio callbacks */
  1715. void (*hdmi_enable)(struct drm_encoder *encoder, bool enable);
  1716. void (*hdmi_setmode)(struct drm_encoder *encoder, struct drm_display_mode *mode);
  1717. } display;
  1718. /* copy functions for bo handling */
  1719. struct {
  1720. struct radeon_fence *(*blit)(struct radeon_device *rdev,
  1721. uint64_t src_offset,
  1722. uint64_t dst_offset,
  1723. unsigned num_gpu_pages,
  1724. struct reservation_object *resv);
  1725. u32 blit_ring_index;
  1726. struct radeon_fence *(*dma)(struct radeon_device *rdev,
  1727. uint64_t src_offset,
  1728. uint64_t dst_offset,
  1729. unsigned num_gpu_pages,
  1730. struct reservation_object *resv);
  1731. u32 dma_ring_index;
  1732. /* method used for bo copy */
  1733. struct radeon_fence *(*copy)(struct radeon_device *rdev,
  1734. uint64_t src_offset,
  1735. uint64_t dst_offset,
  1736. unsigned num_gpu_pages,
  1737. struct reservation_object *resv);
  1738. /* ring used for bo copies */
  1739. u32 copy_ring_index;
  1740. } copy;
  1741. /* surfaces */
  1742. struct {
  1743. int (*set_reg)(struct radeon_device *rdev, int reg,
  1744. uint32_t tiling_flags, uint32_t pitch,
  1745. uint32_t offset, uint32_t obj_size);
  1746. void (*clear_reg)(struct radeon_device *rdev, int reg);
  1747. } surface;
  1748. /* hotplug detect */
  1749. struct {
  1750. void (*init)(struct radeon_device *rdev);
  1751. void (*fini)(struct radeon_device *rdev);
  1752. bool (*sense)(struct radeon_device *rdev, enum radeon_hpd_id hpd);
  1753. void (*set_polarity)(struct radeon_device *rdev, enum radeon_hpd_id hpd);
  1754. } hpd;
  1755. /* static power management */
  1756. struct {
  1757. void (*misc)(struct radeon_device *rdev);
  1758. void (*prepare)(struct radeon_device *rdev);
  1759. void (*finish)(struct radeon_device *rdev);
  1760. void (*init_profile)(struct radeon_device *rdev);
  1761. void (*get_dynpm_state)(struct radeon_device *rdev);
  1762. uint32_t (*get_engine_clock)(struct radeon_device *rdev);
  1763. void (*set_engine_clock)(struct radeon_device *rdev, uint32_t eng_clock);
  1764. uint32_t (*get_memory_clock)(struct radeon_device *rdev);
  1765. void (*set_memory_clock)(struct radeon_device *rdev, uint32_t mem_clock);
  1766. int (*get_pcie_lanes)(struct radeon_device *rdev);
  1767. void (*set_pcie_lanes)(struct radeon_device *rdev, int lanes);
  1768. void (*set_clock_gating)(struct radeon_device *rdev, int enable);
  1769. int (*set_uvd_clocks)(struct radeon_device *rdev, u32 vclk, u32 dclk);
  1770. int (*set_vce_clocks)(struct radeon_device *rdev, u32 evclk, u32 ecclk);
  1771. int (*get_temperature)(struct radeon_device *rdev);
  1772. } pm;
  1773. /* dynamic power management */
  1774. struct {
  1775. int (*init)(struct radeon_device *rdev);
  1776. void (*setup_asic)(struct radeon_device *rdev);
  1777. int (*enable)(struct radeon_device *rdev);
  1778. int (*late_enable)(struct radeon_device *rdev);
  1779. void (*disable)(struct radeon_device *rdev);
  1780. int (*pre_set_power_state)(struct radeon_device *rdev);
  1781. int (*set_power_state)(struct radeon_device *rdev);
  1782. void (*post_set_power_state)(struct radeon_device *rdev);
  1783. void (*display_configuration_changed)(struct radeon_device *rdev);
  1784. void (*fini)(struct radeon_device *rdev);
  1785. u32 (*get_sclk)(struct radeon_device *rdev, bool low);
  1786. u32 (*get_mclk)(struct radeon_device *rdev, bool low);
  1787. void (*print_power_state)(struct radeon_device *rdev, struct radeon_ps *ps);
  1788. void (*debugfs_print_current_performance_level)(struct radeon_device *rdev, struct seq_file *m);
  1789. int (*force_performance_level)(struct radeon_device *rdev, enum radeon_dpm_forced_level level);
  1790. bool (*vblank_too_short)(struct radeon_device *rdev);
  1791. void (*powergate_uvd)(struct radeon_device *rdev, bool gate);
  1792. void (*enable_bapm)(struct radeon_device *rdev, bool enable);
  1793. void (*fan_ctrl_set_mode)(struct radeon_device *rdev, u32 mode);
  1794. u32 (*fan_ctrl_get_mode)(struct radeon_device *rdev);
  1795. int (*set_fan_speed_percent)(struct radeon_device *rdev, u32 speed);
  1796. int (*get_fan_speed_percent)(struct radeon_device *rdev, u32 *speed);
  1797. u32 (*get_current_sclk)(struct radeon_device *rdev);
  1798. u32 (*get_current_mclk)(struct radeon_device *rdev);
  1799. } dpm;
  1800. /* pageflipping */
  1801. struct {
  1802. void (*page_flip)(struct radeon_device *rdev, int crtc, u64 crtc_base);
  1803. bool (*page_flip_pending)(struct radeon_device *rdev, int crtc);
  1804. } pflip;
  1805. };
  1806. /*
  1807. * Asic structures
  1808. */
  1809. struct r100_asic {
  1810. const unsigned *reg_safe_bm;
  1811. unsigned reg_safe_bm_size;
  1812. u32 hdp_cntl;
  1813. };
  1814. struct r300_asic {
  1815. const unsigned *reg_safe_bm;
  1816. unsigned reg_safe_bm_size;
  1817. u32 resync_scratch;
  1818. u32 hdp_cntl;
  1819. };
  1820. struct r600_asic {
  1821. unsigned max_pipes;
  1822. unsigned max_tile_pipes;
  1823. unsigned max_simds;
  1824. unsigned max_backends;
  1825. unsigned max_gprs;
  1826. unsigned max_threads;
  1827. unsigned max_stack_entries;
  1828. unsigned max_hw_contexts;
  1829. unsigned max_gs_threads;
  1830. unsigned sx_max_export_size;
  1831. unsigned sx_max_export_pos_size;
  1832. unsigned sx_max_export_smx_size;
  1833. unsigned sq_num_cf_insts;
  1834. unsigned tiling_nbanks;
  1835. unsigned tiling_npipes;
  1836. unsigned tiling_group_size;
  1837. unsigned tile_config;
  1838. unsigned backend_map;
  1839. unsigned active_simds;
  1840. };
  1841. struct rv770_asic {
  1842. unsigned max_pipes;
  1843. unsigned max_tile_pipes;
  1844. unsigned max_simds;
  1845. unsigned max_backends;
  1846. unsigned max_gprs;
  1847. unsigned max_threads;
  1848. unsigned max_stack_entries;
  1849. unsigned max_hw_contexts;
  1850. unsigned max_gs_threads;
  1851. unsigned sx_max_export_size;
  1852. unsigned sx_max_export_pos_size;
  1853. unsigned sx_max_export_smx_size;
  1854. unsigned sq_num_cf_insts;
  1855. unsigned sx_num_of_sets;
  1856. unsigned sc_prim_fifo_size;
  1857. unsigned sc_hiz_tile_fifo_size;
  1858. unsigned sc_earlyz_tile_fifo_fize;
  1859. unsigned tiling_nbanks;
  1860. unsigned tiling_npipes;
  1861. unsigned tiling_group_size;
  1862. unsigned tile_config;
  1863. unsigned backend_map;
  1864. unsigned active_simds;
  1865. };
  1866. struct evergreen_asic {
  1867. unsigned num_ses;
  1868. unsigned max_pipes;
  1869. unsigned max_tile_pipes;
  1870. unsigned max_simds;
  1871. unsigned max_backends;
  1872. unsigned max_gprs;
  1873. unsigned max_threads;
  1874. unsigned max_stack_entries;
  1875. unsigned max_hw_contexts;
  1876. unsigned max_gs_threads;
  1877. unsigned sx_max_export_size;
  1878. unsigned sx_max_export_pos_size;
  1879. unsigned sx_max_export_smx_size;
  1880. unsigned sq_num_cf_insts;
  1881. unsigned sx_num_of_sets;
  1882. unsigned sc_prim_fifo_size;
  1883. unsigned sc_hiz_tile_fifo_size;
  1884. unsigned sc_earlyz_tile_fifo_size;
  1885. unsigned tiling_nbanks;
  1886. unsigned tiling_npipes;
  1887. unsigned tiling_group_size;
  1888. unsigned tile_config;
  1889. unsigned backend_map;
  1890. unsigned active_simds;
  1891. };
  1892. struct cayman_asic {
  1893. unsigned max_shader_engines;
  1894. unsigned max_pipes_per_simd;
  1895. unsigned max_tile_pipes;
  1896. unsigned max_simds_per_se;
  1897. unsigned max_backends_per_se;
  1898. unsigned max_texture_channel_caches;
  1899. unsigned max_gprs;
  1900. unsigned max_threads;
  1901. unsigned max_gs_threads;
  1902. unsigned max_stack_entries;
  1903. unsigned sx_num_of_sets;
  1904. unsigned sx_max_export_size;
  1905. unsigned sx_max_export_pos_size;
  1906. unsigned sx_max_export_smx_size;
  1907. unsigned max_hw_contexts;
  1908. unsigned sq_num_cf_insts;
  1909. unsigned sc_prim_fifo_size;
  1910. unsigned sc_hiz_tile_fifo_size;
  1911. unsigned sc_earlyz_tile_fifo_size;
  1912. unsigned num_shader_engines;
  1913. unsigned num_shader_pipes_per_simd;
  1914. unsigned num_tile_pipes;
  1915. unsigned num_simds_per_se;
  1916. unsigned num_backends_per_se;
  1917. unsigned backend_disable_mask_per_asic;
  1918. unsigned backend_map;
  1919. unsigned num_texture_channel_caches;
  1920. unsigned mem_max_burst_length_bytes;
  1921. unsigned mem_row_size_in_kb;
  1922. unsigned shader_engine_tile_size;
  1923. unsigned num_gpus;
  1924. unsigned multi_gpu_tile_size;
  1925. unsigned tile_config;
  1926. unsigned active_simds;
  1927. };
  1928. struct si_asic {
  1929. unsigned max_shader_engines;
  1930. unsigned max_tile_pipes;
  1931. unsigned max_cu_per_sh;
  1932. unsigned max_sh_per_se;
  1933. unsigned max_backends_per_se;
  1934. unsigned max_texture_channel_caches;
  1935. unsigned max_gprs;
  1936. unsigned max_gs_threads;
  1937. unsigned max_hw_contexts;
  1938. unsigned sc_prim_fifo_size_frontend;
  1939. unsigned sc_prim_fifo_size_backend;
  1940. unsigned sc_hiz_tile_fifo_size;
  1941. unsigned sc_earlyz_tile_fifo_size;
  1942. unsigned num_tile_pipes;
  1943. unsigned backend_enable_mask;
  1944. unsigned backend_disable_mask_per_asic;
  1945. unsigned backend_map;
  1946. unsigned num_texture_channel_caches;
  1947. unsigned mem_max_burst_length_bytes;
  1948. unsigned mem_row_size_in_kb;
  1949. unsigned shader_engine_tile_size;
  1950. unsigned num_gpus;
  1951. unsigned multi_gpu_tile_size;
  1952. unsigned tile_config;
  1953. uint32_t tile_mode_array[32];
  1954. uint32_t active_cus;
  1955. };
  1956. struct cik_asic {
  1957. unsigned max_shader_engines;
  1958. unsigned max_tile_pipes;
  1959. unsigned max_cu_per_sh;
  1960. unsigned max_sh_per_se;
  1961. unsigned max_backends_per_se;
  1962. unsigned max_texture_channel_caches;
  1963. unsigned max_gprs;
  1964. unsigned max_gs_threads;
  1965. unsigned max_hw_contexts;
  1966. unsigned sc_prim_fifo_size_frontend;
  1967. unsigned sc_prim_fifo_size_backend;
  1968. unsigned sc_hiz_tile_fifo_size;
  1969. unsigned sc_earlyz_tile_fifo_size;
  1970. unsigned num_tile_pipes;
  1971. unsigned backend_enable_mask;
  1972. unsigned backend_disable_mask_per_asic;
  1973. unsigned backend_map;
  1974. unsigned num_texture_channel_caches;
  1975. unsigned mem_max_burst_length_bytes;
  1976. unsigned mem_row_size_in_kb;
  1977. unsigned shader_engine_tile_size;
  1978. unsigned num_gpus;
  1979. unsigned multi_gpu_tile_size;
  1980. unsigned tile_config;
  1981. uint32_t tile_mode_array[32];
  1982. uint32_t macrotile_mode_array[16];
  1983. uint32_t active_cus;
  1984. };
  1985. union radeon_asic_config {
  1986. struct r300_asic r300;
  1987. struct r100_asic r100;
  1988. struct r600_asic r600;
  1989. struct rv770_asic rv770;
  1990. struct evergreen_asic evergreen;
  1991. struct cayman_asic cayman;
  1992. struct si_asic si;
  1993. struct cik_asic cik;
  1994. };
  1995. /*
  1996. * asic initizalization from radeon_asic.c
  1997. */
  1998. void radeon_agp_disable(struct radeon_device *rdev);
  1999. int radeon_asic_init(struct radeon_device *rdev);
  2000. /*
  2001. * IOCTL.
  2002. */
  2003. int radeon_gem_info_ioctl(struct drm_device *dev, void *data,
  2004. struct drm_file *filp);
  2005. int radeon_gem_create_ioctl(struct drm_device *dev, void *data,
  2006. struct drm_file *filp);
  2007. int radeon_gem_userptr_ioctl(struct drm_device *dev, void *data,
  2008. struct drm_file *filp);
  2009. int radeon_gem_pin_ioctl(struct drm_device *dev, void *data,
  2010. struct drm_file *file_priv);
  2011. int radeon_gem_unpin_ioctl(struct drm_device *dev, void *data,
  2012. struct drm_file *file_priv);
  2013. int radeon_gem_pwrite_ioctl(struct drm_device *dev, void *data,
  2014. struct drm_file *file_priv);
  2015. int radeon_gem_pread_ioctl(struct drm_device *dev, void *data,
  2016. struct drm_file *file_priv);
  2017. int radeon_gem_set_domain_ioctl(struct drm_device *dev, void *data,
  2018. struct drm_file *filp);
  2019. int radeon_gem_mmap_ioctl(struct drm_device *dev, void *data,
  2020. struct drm_file *filp);
  2021. int radeon_gem_busy_ioctl(struct drm_device *dev, void *data,
  2022. struct drm_file *filp);
  2023. int radeon_gem_wait_idle_ioctl(struct drm_device *dev, void *data,
  2024. struct drm_file *filp);
  2025. int radeon_gem_va_ioctl(struct drm_device *dev, void *data,
  2026. struct drm_file *filp);
  2027. int radeon_gem_op_ioctl(struct drm_device *dev, void *data,
  2028. struct drm_file *filp);
  2029. int radeon_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp);
  2030. int radeon_gem_set_tiling_ioctl(struct drm_device *dev, void *data,
  2031. struct drm_file *filp);
  2032. int radeon_gem_get_tiling_ioctl(struct drm_device *dev, void *data,
  2033. struct drm_file *filp);
  2034. /* VRAM scratch page for HDP bug, default vram page */
  2035. struct r600_vram_scratch {
  2036. struct radeon_bo *robj;
  2037. volatile uint32_t *ptr;
  2038. u64 gpu_addr;
  2039. };
  2040. /*
  2041. * ACPI
  2042. */
  2043. struct radeon_atif_notification_cfg {
  2044. bool enabled;
  2045. int command_code;
  2046. };
  2047. struct radeon_atif_notifications {
  2048. bool display_switch;
  2049. bool expansion_mode_change;
  2050. bool thermal_state;
  2051. bool forced_power_state;
  2052. bool system_power_state;
  2053. bool display_conf_change;
  2054. bool px_gfx_switch;
  2055. bool brightness_change;
  2056. bool dgpu_display_event;
  2057. };
  2058. struct radeon_atif_functions {
  2059. bool system_params;
  2060. bool sbios_requests;
  2061. bool select_active_disp;
  2062. bool lid_state;
  2063. bool get_tv_standard;
  2064. bool set_tv_standard;
  2065. bool get_panel_expansion_mode;
  2066. bool set_panel_expansion_mode;
  2067. bool temperature_change;
  2068. bool graphics_device_types;
  2069. };
  2070. struct radeon_atif {
  2071. struct radeon_atif_notifications notifications;
  2072. struct radeon_atif_functions functions;
  2073. struct radeon_atif_notification_cfg notification_cfg;
  2074. struct radeon_encoder *encoder_for_bl;
  2075. };
  2076. struct radeon_atcs_functions {
  2077. bool get_ext_state;
  2078. bool pcie_perf_req;
  2079. bool pcie_dev_rdy;
  2080. bool pcie_bus_width;
  2081. };
  2082. struct radeon_atcs {
  2083. struct radeon_atcs_functions functions;
  2084. };
  2085. /*
  2086. * Core structure, functions and helpers.
  2087. */
  2088. typedef uint32_t (*radeon_rreg_t)(struct radeon_device*, uint32_t);
  2089. typedef void (*radeon_wreg_t)(struct radeon_device*, uint32_t, uint32_t);
  2090. struct radeon_device {
  2091. struct device *dev;
  2092. struct drm_device *ddev;
  2093. struct pci_dev *pdev;
  2094. struct rw_semaphore exclusive_lock;
  2095. /* ASIC */
  2096. union radeon_asic_config config;
  2097. enum radeon_family family;
  2098. unsigned long flags;
  2099. int usec_timeout;
  2100. enum radeon_pll_errata pll_errata;
  2101. int num_gb_pipes;
  2102. int num_z_pipes;
  2103. int disp_priority;
  2104. /* BIOS */
  2105. uint8_t *bios;
  2106. bool is_atom_bios;
  2107. uint16_t bios_header_start;
  2108. struct radeon_bo *stollen_vga_memory;
  2109. /* Register mmio */
  2110. resource_size_t rmmio_base;
  2111. resource_size_t rmmio_size;
  2112. /* protects concurrent MM_INDEX/DATA based register access */
  2113. spinlock_t mmio_idx_lock;
  2114. /* protects concurrent SMC based register access */
  2115. spinlock_t smc_idx_lock;
  2116. /* protects concurrent PLL register access */
  2117. spinlock_t pll_idx_lock;
  2118. /* protects concurrent MC register access */
  2119. spinlock_t mc_idx_lock;
  2120. /* protects concurrent PCIE register access */
  2121. spinlock_t pcie_idx_lock;
  2122. /* protects concurrent PCIE_PORT register access */
  2123. spinlock_t pciep_idx_lock;
  2124. /* protects concurrent PIF register access */
  2125. spinlock_t pif_idx_lock;
  2126. /* protects concurrent CG register access */
  2127. spinlock_t cg_idx_lock;
  2128. /* protects concurrent UVD register access */
  2129. spinlock_t uvd_idx_lock;
  2130. /* protects concurrent RCU register access */
  2131. spinlock_t rcu_idx_lock;
  2132. /* protects concurrent DIDT register access */
  2133. spinlock_t didt_idx_lock;
  2134. /* protects concurrent ENDPOINT (audio) register access */
  2135. spinlock_t end_idx_lock;
  2136. void __iomem *rmmio;
  2137. radeon_rreg_t mc_rreg;
  2138. radeon_wreg_t mc_wreg;
  2139. radeon_rreg_t pll_rreg;
  2140. radeon_wreg_t pll_wreg;
  2141. uint32_t pcie_reg_mask;
  2142. radeon_rreg_t pciep_rreg;
  2143. radeon_wreg_t pciep_wreg;
  2144. /* io port */
  2145. void __iomem *rio_mem;
  2146. resource_size_t rio_mem_size;
  2147. struct radeon_clock clock;
  2148. struct radeon_mc mc;
  2149. struct radeon_gart gart;
  2150. struct radeon_mode_info mode_info;
  2151. struct radeon_scratch scratch;
  2152. struct radeon_doorbell doorbell;
  2153. struct radeon_mman mman;
  2154. struct radeon_fence_driver fence_drv[RADEON_NUM_RINGS];
  2155. wait_queue_head_t fence_queue;
  2156. unsigned fence_context;
  2157. struct mutex ring_lock;
  2158. struct radeon_ring ring[RADEON_NUM_RINGS];
  2159. bool ib_pool_ready;
  2160. struct radeon_sa_manager ring_tmp_bo;
  2161. struct radeon_irq irq;
  2162. struct radeon_asic *asic;
  2163. struct radeon_gem gem;
  2164. struct radeon_pm pm;
  2165. struct radeon_uvd uvd;
  2166. struct radeon_vce vce;
  2167. uint32_t bios_scratch[RADEON_BIOS_NUM_SCRATCH];
  2168. struct radeon_wb wb;
  2169. struct radeon_dummy_page dummy_page;
  2170. bool shutdown;
  2171. bool suspend;
  2172. bool need_dma32;
  2173. bool accel_working;
  2174. bool fastfb_working; /* IGP feature*/
  2175. bool needs_reset, in_reset;
  2176. struct radeon_surface_reg surface_regs[RADEON_GEM_MAX_SURFACES];
  2177. const struct firmware *me_fw; /* all family ME firmware */
  2178. const struct firmware *pfp_fw; /* r6/700 PFP firmware */
  2179. const struct firmware *rlc_fw; /* r6/700 RLC firmware */
  2180. const struct firmware *mc_fw; /* NI MC firmware */
  2181. const struct firmware *ce_fw; /* SI CE firmware */
  2182. const struct firmware *mec_fw; /* CIK MEC firmware */
  2183. const struct firmware *mec2_fw; /* KV MEC2 firmware */
  2184. const struct firmware *sdma_fw; /* CIK SDMA firmware */
  2185. const struct firmware *smc_fw; /* SMC firmware */
  2186. const struct firmware *uvd_fw; /* UVD firmware */
  2187. const struct firmware *vce_fw; /* VCE firmware */
  2188. bool new_fw;
  2189. struct r600_vram_scratch vram_scratch;
  2190. int msi_enabled; /* msi enabled */
  2191. struct r600_ih ih; /* r6/700 interrupt ring */
  2192. struct radeon_rlc rlc;
  2193. struct radeon_mec mec;
  2194. struct delayed_work hotplug_work;
  2195. struct work_struct dp_work;
  2196. struct work_struct audio_work;
  2197. int num_crtc; /* number of crtcs */
  2198. struct mutex dc_hw_i2c_mutex; /* display controller hw i2c mutex */
  2199. bool has_uvd;
  2200. struct r600_audio audio; /* audio stuff */
  2201. struct notifier_block acpi_nb;
  2202. /* only one userspace can use Hyperz features or CMASK at a time */
  2203. struct drm_file *hyperz_filp;
  2204. struct drm_file *cmask_filp;
  2205. /* i2c buses */
  2206. struct radeon_i2c_chan *i2c_bus[RADEON_MAX_I2C_BUS];
  2207. /* debugfs */
  2208. struct radeon_debugfs debugfs[RADEON_DEBUGFS_MAX_COMPONENTS];
  2209. unsigned debugfs_count;
  2210. /* virtual memory */
  2211. struct radeon_vm_manager vm_manager;
  2212. struct mutex gpu_clock_mutex;
  2213. /* memory stats */
  2214. atomic64_t vram_usage;
  2215. atomic64_t gtt_usage;
  2216. atomic64_t num_bytes_moved;
  2217. atomic_t gpu_reset_counter;
  2218. /* ACPI interface */
  2219. struct radeon_atif atif;
  2220. struct radeon_atcs atcs;
  2221. /* srbm instance registers */
  2222. struct mutex srbm_mutex;
  2223. /* GRBM index mutex. Protects concurrents access to GRBM index */
  2224. struct mutex grbm_idx_mutex;
  2225. /* clock, powergating flags */
  2226. u32 cg_flags;
  2227. u32 pg_flags;
  2228. struct dev_pm_domain vga_pm_domain;
  2229. bool have_disp_power_ref;
  2230. u32 px_quirk_flags;
  2231. /* tracking pinned memory */
  2232. u64 vram_pin_size;
  2233. u64 gart_pin_size;
  2234. /* amdkfd interface */
  2235. struct kfd_dev *kfd;
  2236. struct mutex mn_lock;
  2237. DECLARE_HASHTABLE(mn_hash, 7);
  2238. };
  2239. bool radeon_is_px(struct drm_device *dev);
  2240. int radeon_device_init(struct radeon_device *rdev,
  2241. struct drm_device *ddev,
  2242. struct pci_dev *pdev,
  2243. uint32_t flags);
  2244. void radeon_device_fini(struct radeon_device *rdev);
  2245. int radeon_gpu_wait_for_idle(struct radeon_device *rdev);
  2246. #define RADEON_MIN_MMIO_SIZE 0x10000
  2247. uint32_t r100_mm_rreg_slow(struct radeon_device *rdev, uint32_t reg);
  2248. void r100_mm_wreg_slow(struct radeon_device *rdev, uint32_t reg, uint32_t v);
  2249. static inline uint32_t r100_mm_rreg(struct radeon_device *rdev, uint32_t reg,
  2250. bool always_indirect)
  2251. {
  2252. /* The mmio size is 64kb at minimum. Allows the if to be optimized out. */
  2253. if ((reg < rdev->rmmio_size || reg < RADEON_MIN_MMIO_SIZE) && !always_indirect)
  2254. return readl(((void __iomem *)rdev->rmmio) + reg);
  2255. else
  2256. return r100_mm_rreg_slow(rdev, reg);
  2257. }
  2258. static inline void r100_mm_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v,
  2259. bool always_indirect)
  2260. {
  2261. if ((reg < rdev->rmmio_size || reg < RADEON_MIN_MMIO_SIZE) && !always_indirect)
  2262. writel(v, ((void __iomem *)rdev->rmmio) + reg);
  2263. else
  2264. r100_mm_wreg_slow(rdev, reg, v);
  2265. }
  2266. u32 r100_io_rreg(struct radeon_device *rdev, u32 reg);
  2267. void r100_io_wreg(struct radeon_device *rdev, u32 reg, u32 v);
  2268. u32 cik_mm_rdoorbell(struct radeon_device *rdev, u32 index);
  2269. void cik_mm_wdoorbell(struct radeon_device *rdev, u32 index, u32 v);
  2270. /*
  2271. * Cast helper
  2272. */
  2273. extern const struct fence_ops radeon_fence_ops;
  2274. static inline struct radeon_fence *to_radeon_fence(struct fence *f)
  2275. {
  2276. struct radeon_fence *__f = container_of(f, struct radeon_fence, base);
  2277. if (__f->base.ops == &radeon_fence_ops)
  2278. return __f;
  2279. return NULL;
  2280. }
  2281. /*
  2282. * Registers read & write functions.
  2283. */
  2284. #define RREG8(reg) readb((rdev->rmmio) + (reg))
  2285. #define WREG8(reg, v) writeb(v, (rdev->rmmio) + (reg))
  2286. #define RREG16(reg) readw((rdev->rmmio) + (reg))
  2287. #define WREG16(reg, v) writew(v, (rdev->rmmio) + (reg))
  2288. #define RREG32(reg) r100_mm_rreg(rdev, (reg), false)
  2289. #define RREG32_IDX(reg) r100_mm_rreg(rdev, (reg), true)
  2290. #define DREG32(reg) printk(KERN_INFO "REGISTER: " #reg " : 0x%08X\n", r100_mm_rreg(rdev, (reg), false))
  2291. #define WREG32(reg, v) r100_mm_wreg(rdev, (reg), (v), false)
  2292. #define WREG32_IDX(reg, v) r100_mm_wreg(rdev, (reg), (v), true)
  2293. #define REG_SET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK)
  2294. #define REG_GET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK)
  2295. #define RREG32_PLL(reg) rdev->pll_rreg(rdev, (reg))
  2296. #define WREG32_PLL(reg, v) rdev->pll_wreg(rdev, (reg), (v))
  2297. #define RREG32_MC(reg) rdev->mc_rreg(rdev, (reg))
  2298. #define WREG32_MC(reg, v) rdev->mc_wreg(rdev, (reg), (v))
  2299. #define RREG32_PCIE(reg) rv370_pcie_rreg(rdev, (reg))
  2300. #define WREG32_PCIE(reg, v) rv370_pcie_wreg(rdev, (reg), (v))
  2301. #define RREG32_PCIE_PORT(reg) rdev->pciep_rreg(rdev, (reg))
  2302. #define WREG32_PCIE_PORT(reg, v) rdev->pciep_wreg(rdev, (reg), (v))
  2303. #define RREG32_SMC(reg) tn_smc_rreg(rdev, (reg))
  2304. #define WREG32_SMC(reg, v) tn_smc_wreg(rdev, (reg), (v))
  2305. #define RREG32_RCU(reg) r600_rcu_rreg(rdev, (reg))
  2306. #define WREG32_RCU(reg, v) r600_rcu_wreg(rdev, (reg), (v))
  2307. #define RREG32_CG(reg) eg_cg_rreg(rdev, (reg))
  2308. #define WREG32_CG(reg, v) eg_cg_wreg(rdev, (reg), (v))
  2309. #define RREG32_PIF_PHY0(reg) eg_pif_phy0_rreg(rdev, (reg))
  2310. #define WREG32_PIF_PHY0(reg, v) eg_pif_phy0_wreg(rdev, (reg), (v))
  2311. #define RREG32_PIF_PHY1(reg) eg_pif_phy1_rreg(rdev, (reg))
  2312. #define WREG32_PIF_PHY1(reg, v) eg_pif_phy1_wreg(rdev, (reg), (v))
  2313. #define RREG32_UVD_CTX(reg) r600_uvd_ctx_rreg(rdev, (reg))
  2314. #define WREG32_UVD_CTX(reg, v) r600_uvd_ctx_wreg(rdev, (reg), (v))
  2315. #define RREG32_DIDT(reg) cik_didt_rreg(rdev, (reg))
  2316. #define WREG32_DIDT(reg, v) cik_didt_wreg(rdev, (reg), (v))
  2317. #define WREG32_P(reg, val, mask) \
  2318. do { \
  2319. uint32_t tmp_ = RREG32(reg); \
  2320. tmp_ &= (mask); \
  2321. tmp_ |= ((val) & ~(mask)); \
  2322. WREG32(reg, tmp_); \
  2323. } while (0)
  2324. #define WREG32_AND(reg, and) WREG32_P(reg, 0, and)
  2325. #define WREG32_OR(reg, or) WREG32_P(reg, or, ~(or))
  2326. #define WREG32_PLL_P(reg, val, mask) \
  2327. do { \
  2328. uint32_t tmp_ = RREG32_PLL(reg); \
  2329. tmp_ &= (mask); \
  2330. tmp_ |= ((val) & ~(mask)); \
  2331. WREG32_PLL(reg, tmp_); \
  2332. } while (0)
  2333. #define WREG32_SMC_P(reg, val, mask) \
  2334. do { \
  2335. uint32_t tmp_ = RREG32_SMC(reg); \
  2336. tmp_ &= (mask); \
  2337. tmp_ |= ((val) & ~(mask)); \
  2338. WREG32_SMC(reg, tmp_); \
  2339. } while (0)
  2340. #define DREG32_SYS(sqf, rdev, reg) seq_printf((sqf), #reg " : 0x%08X\n", r100_mm_rreg((rdev), (reg), false))
  2341. #define RREG32_IO(reg) r100_io_rreg(rdev, (reg))
  2342. #define WREG32_IO(reg, v) r100_io_wreg(rdev, (reg), (v))
  2343. #define RDOORBELL32(index) cik_mm_rdoorbell(rdev, (index))
  2344. #define WDOORBELL32(index, v) cik_mm_wdoorbell(rdev, (index), (v))
  2345. /*
  2346. * Indirect registers accessors.
  2347. * They used to be inlined, but this increases code size by ~65 kbytes.
  2348. * Since each performs a pair of MMIO ops
  2349. * within a spin_lock_irqsave/spin_unlock_irqrestore region,
  2350. * the cost of call+ret is almost negligible. MMIO and locking
  2351. * costs several dozens of cycles each at best, call+ret is ~5 cycles.
  2352. */
  2353. uint32_t rv370_pcie_rreg(struct radeon_device *rdev, uint32_t reg);
  2354. void rv370_pcie_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v);
  2355. u32 tn_smc_rreg(struct radeon_device *rdev, u32 reg);
  2356. void tn_smc_wreg(struct radeon_device *rdev, u32 reg, u32 v);
  2357. u32 r600_rcu_rreg(struct radeon_device *rdev, u32 reg);
  2358. void r600_rcu_wreg(struct radeon_device *rdev, u32 reg, u32 v);
  2359. u32 eg_cg_rreg(struct radeon_device *rdev, u32 reg);
  2360. void eg_cg_wreg(struct radeon_device *rdev, u32 reg, u32 v);
  2361. u32 eg_pif_phy0_rreg(struct radeon_device *rdev, u32 reg);
  2362. void eg_pif_phy0_wreg(struct radeon_device *rdev, u32 reg, u32 v);
  2363. u32 eg_pif_phy1_rreg(struct radeon_device *rdev, u32 reg);
  2364. void eg_pif_phy1_wreg(struct radeon_device *rdev, u32 reg, u32 v);
  2365. u32 r600_uvd_ctx_rreg(struct radeon_device *rdev, u32 reg);
  2366. void r600_uvd_ctx_wreg(struct radeon_device *rdev, u32 reg, u32 v);
  2367. u32 cik_didt_rreg(struct radeon_device *rdev, u32 reg);
  2368. void cik_didt_wreg(struct radeon_device *rdev, u32 reg, u32 v);
  2369. void r100_pll_errata_after_index(struct radeon_device *rdev);
  2370. /*
  2371. * ASICs helpers.
  2372. */
  2373. #define ASIC_IS_RN50(rdev) ((rdev->pdev->device == 0x515e) || \
  2374. (rdev->pdev->device == 0x5969))
  2375. #define ASIC_IS_RV100(rdev) ((rdev->family == CHIP_RV100) || \
  2376. (rdev->family == CHIP_RV200) || \
  2377. (rdev->family == CHIP_RS100) || \
  2378. (rdev->family == CHIP_RS200) || \
  2379. (rdev->family == CHIP_RV250) || \
  2380. (rdev->family == CHIP_RV280) || \
  2381. (rdev->family == CHIP_RS300))
  2382. #define ASIC_IS_R300(rdev) ((rdev->family == CHIP_R300) || \
  2383. (rdev->family == CHIP_RV350) || \
  2384. (rdev->family == CHIP_R350) || \
  2385. (rdev->family == CHIP_RV380) || \
  2386. (rdev->family == CHIP_R420) || \
  2387. (rdev->family == CHIP_R423) || \
  2388. (rdev->family == CHIP_RV410) || \
  2389. (rdev->family == CHIP_RS400) || \
  2390. (rdev->family == CHIP_RS480))
  2391. #define ASIC_IS_X2(rdev) ((rdev->ddev->pdev->device == 0x9441) || \
  2392. (rdev->ddev->pdev->device == 0x9443) || \
  2393. (rdev->ddev->pdev->device == 0x944B) || \
  2394. (rdev->ddev->pdev->device == 0x9506) || \
  2395. (rdev->ddev->pdev->device == 0x9509) || \
  2396. (rdev->ddev->pdev->device == 0x950F) || \
  2397. (rdev->ddev->pdev->device == 0x689C) || \
  2398. (rdev->ddev->pdev->device == 0x689D))
  2399. #define ASIC_IS_AVIVO(rdev) ((rdev->family >= CHIP_RS600))
  2400. #define ASIC_IS_DCE2(rdev) ((rdev->family == CHIP_RS600) || \
  2401. (rdev->family == CHIP_RS690) || \
  2402. (rdev->family == CHIP_RS740) || \
  2403. (rdev->family >= CHIP_R600))
  2404. #define ASIC_IS_DCE3(rdev) ((rdev->family >= CHIP_RV620))
  2405. #define ASIC_IS_DCE32(rdev) ((rdev->family >= CHIP_RV730))
  2406. #define ASIC_IS_DCE4(rdev) ((rdev->family >= CHIP_CEDAR))
  2407. #define ASIC_IS_DCE41(rdev) ((rdev->family >= CHIP_PALM) && \
  2408. (rdev->flags & RADEON_IS_IGP))
  2409. #define ASIC_IS_DCE5(rdev) ((rdev->family >= CHIP_BARTS))
  2410. #define ASIC_IS_DCE6(rdev) ((rdev->family >= CHIP_ARUBA))
  2411. #define ASIC_IS_DCE61(rdev) ((rdev->family >= CHIP_ARUBA) && \
  2412. (rdev->flags & RADEON_IS_IGP))
  2413. #define ASIC_IS_DCE64(rdev) ((rdev->family == CHIP_OLAND))
  2414. #define ASIC_IS_NODCE(rdev) ((rdev->family == CHIP_HAINAN))
  2415. #define ASIC_IS_DCE8(rdev) ((rdev->family >= CHIP_BONAIRE))
  2416. #define ASIC_IS_DCE81(rdev) ((rdev->family == CHIP_KAVERI))
  2417. #define ASIC_IS_DCE82(rdev) ((rdev->family == CHIP_BONAIRE))
  2418. #define ASIC_IS_DCE83(rdev) ((rdev->family == CHIP_KABINI) || \
  2419. (rdev->family == CHIP_MULLINS))
  2420. #define ASIC_IS_LOMBOK(rdev) ((rdev->ddev->pdev->device == 0x6849) || \
  2421. (rdev->ddev->pdev->device == 0x6850) || \
  2422. (rdev->ddev->pdev->device == 0x6858) || \
  2423. (rdev->ddev->pdev->device == 0x6859) || \
  2424. (rdev->ddev->pdev->device == 0x6840) || \
  2425. (rdev->ddev->pdev->device == 0x6841) || \
  2426. (rdev->ddev->pdev->device == 0x6842) || \
  2427. (rdev->ddev->pdev->device == 0x6843))
  2428. /*
  2429. * BIOS helpers.
  2430. */
  2431. #define RBIOS8(i) (rdev->bios[i])
  2432. #define RBIOS16(i) (RBIOS8(i) | (RBIOS8((i)+1) << 8))
  2433. #define RBIOS32(i) ((RBIOS16(i)) | (RBIOS16((i)+2) << 16))
  2434. int radeon_combios_init(struct radeon_device *rdev);
  2435. void radeon_combios_fini(struct radeon_device *rdev);
  2436. int radeon_atombios_init(struct radeon_device *rdev);
  2437. void radeon_atombios_fini(struct radeon_device *rdev);
  2438. /*
  2439. * RING helpers.
  2440. */
  2441. /**
  2442. * radeon_ring_write - write a value to the ring
  2443. *
  2444. * @ring: radeon_ring structure holding ring information
  2445. * @v: dword (dw) value to write
  2446. *
  2447. * Write a value to the requested ring buffer (all asics).
  2448. */
  2449. static inline void radeon_ring_write(struct radeon_ring *ring, uint32_t v)
  2450. {
  2451. if (ring->count_dw <= 0)
  2452. DRM_ERROR("radeon: writing more dwords to the ring than expected!\n");
  2453. ring->ring[ring->wptr++] = v;
  2454. ring->wptr &= ring->ptr_mask;
  2455. ring->count_dw--;
  2456. ring->ring_free_dw--;
  2457. }
  2458. /*
  2459. * ASICs macro.
  2460. */
  2461. #define radeon_init(rdev) (rdev)->asic->init((rdev))
  2462. #define radeon_fini(rdev) (rdev)->asic->fini((rdev))
  2463. #define radeon_resume(rdev) (rdev)->asic->resume((rdev))
  2464. #define radeon_suspend(rdev) (rdev)->asic->suspend((rdev))
  2465. #define radeon_cs_parse(rdev, r, p) (rdev)->asic->ring[(r)]->cs_parse((p))
  2466. #define radeon_vga_set_state(rdev, state) (rdev)->asic->vga_set_state((rdev), (state))
  2467. #define radeon_asic_reset(rdev) (rdev)->asic->asic_reset((rdev))
  2468. #define radeon_gart_tlb_flush(rdev) (rdev)->asic->gart.tlb_flush((rdev))
  2469. #define radeon_gart_get_page_entry(a, f) (rdev)->asic->gart.get_page_entry((a), (f))
  2470. #define radeon_gart_set_page(rdev, i, e) (rdev)->asic->gart.set_page((rdev), (i), (e))
  2471. #define radeon_asic_vm_init(rdev) (rdev)->asic->vm.init((rdev))
  2472. #define radeon_asic_vm_fini(rdev) (rdev)->asic->vm.fini((rdev))
  2473. #define radeon_asic_vm_copy_pages(rdev, ib, pe, src, count) ((rdev)->asic->vm.copy_pages((rdev), (ib), (pe), (src), (count)))
  2474. #define radeon_asic_vm_write_pages(rdev, ib, pe, addr, count, incr, flags) ((rdev)->asic->vm.write_pages((rdev), (ib), (pe), (addr), (count), (incr), (flags)))
  2475. #define radeon_asic_vm_set_pages(rdev, ib, pe, addr, count, incr, flags) ((rdev)->asic->vm.set_pages((rdev), (ib), (pe), (addr), (count), (incr), (flags)))
  2476. #define radeon_asic_vm_pad_ib(rdev, ib) ((rdev)->asic->vm.pad_ib((ib)))
  2477. #define radeon_ring_start(rdev, r, cp) (rdev)->asic->ring[(r)]->ring_start((rdev), (cp))
  2478. #define radeon_ring_test(rdev, r, cp) (rdev)->asic->ring[(r)]->ring_test((rdev), (cp))
  2479. #define radeon_ib_test(rdev, r, cp) (rdev)->asic->ring[(r)]->ib_test((rdev), (cp))
  2480. #define radeon_ring_ib_execute(rdev, r, ib) (rdev)->asic->ring[(r)]->ib_execute((rdev), (ib))
  2481. #define radeon_ring_ib_parse(rdev, r, ib) (rdev)->asic->ring[(r)]->ib_parse((rdev), (ib))
  2482. #define radeon_ring_is_lockup(rdev, r, cp) (rdev)->asic->ring[(r)]->is_lockup((rdev), (cp))
  2483. #define radeon_ring_vm_flush(rdev, r, vm_id, pd_addr) (rdev)->asic->ring[(r)->idx]->vm_flush((rdev), (r), (vm_id), (pd_addr))
  2484. #define radeon_ring_get_rptr(rdev, r) (rdev)->asic->ring[(r)->idx]->get_rptr((rdev), (r))
  2485. #define radeon_ring_get_wptr(rdev, r) (rdev)->asic->ring[(r)->idx]->get_wptr((rdev), (r))
  2486. #define radeon_ring_set_wptr(rdev, r) (rdev)->asic->ring[(r)->idx]->set_wptr((rdev), (r))
  2487. #define radeon_irq_set(rdev) (rdev)->asic->irq.set((rdev))
  2488. #define radeon_irq_process(rdev) (rdev)->asic->irq.process((rdev))
  2489. #define radeon_get_vblank_counter(rdev, crtc) (rdev)->asic->display.get_vblank_counter((rdev), (crtc))
  2490. #define radeon_set_backlight_level(rdev, e, l) (rdev)->asic->display.set_backlight_level((e), (l))
  2491. #define radeon_get_backlight_level(rdev, e) (rdev)->asic->display.get_backlight_level((e))
  2492. #define radeon_hdmi_enable(rdev, e, b) (rdev)->asic->display.hdmi_enable((e), (b))
  2493. #define radeon_hdmi_setmode(rdev, e, m) (rdev)->asic->display.hdmi_setmode((e), (m))
  2494. #define radeon_fence_ring_emit(rdev, r, fence) (rdev)->asic->ring[(r)]->emit_fence((rdev), (fence))
  2495. #define radeon_semaphore_ring_emit(rdev, r, cp, semaphore, emit_wait) (rdev)->asic->ring[(r)]->emit_semaphore((rdev), (cp), (semaphore), (emit_wait))
  2496. #define radeon_copy_blit(rdev, s, d, np, resv) (rdev)->asic->copy.blit((rdev), (s), (d), (np), (resv))
  2497. #define radeon_copy_dma(rdev, s, d, np, resv) (rdev)->asic->copy.dma((rdev), (s), (d), (np), (resv))
  2498. #define radeon_copy(rdev, s, d, np, resv) (rdev)->asic->copy.copy((rdev), (s), (d), (np), (resv))
  2499. #define radeon_copy_blit_ring_index(rdev) (rdev)->asic->copy.blit_ring_index
  2500. #define radeon_copy_dma_ring_index(rdev) (rdev)->asic->copy.dma_ring_index
  2501. #define radeon_copy_ring_index(rdev) (rdev)->asic->copy.copy_ring_index
  2502. #define radeon_get_engine_clock(rdev) (rdev)->asic->pm.get_engine_clock((rdev))
  2503. #define radeon_set_engine_clock(rdev, e) (rdev)->asic->pm.set_engine_clock((rdev), (e))
  2504. #define radeon_get_memory_clock(rdev) (rdev)->asic->pm.get_memory_clock((rdev))
  2505. #define radeon_set_memory_clock(rdev, e) (rdev)->asic->pm.set_memory_clock((rdev), (e))
  2506. #define radeon_get_pcie_lanes(rdev) (rdev)->asic->pm.get_pcie_lanes((rdev))
  2507. #define radeon_set_pcie_lanes(rdev, l) (rdev)->asic->pm.set_pcie_lanes((rdev), (l))
  2508. #define radeon_set_clock_gating(rdev, e) (rdev)->asic->pm.set_clock_gating((rdev), (e))
  2509. #define radeon_set_uvd_clocks(rdev, v, d) (rdev)->asic->pm.set_uvd_clocks((rdev), (v), (d))
  2510. #define radeon_set_vce_clocks(rdev, ev, ec) (rdev)->asic->pm.set_vce_clocks((rdev), (ev), (ec))
  2511. #define radeon_get_temperature(rdev) (rdev)->asic->pm.get_temperature((rdev))
  2512. #define radeon_set_surface_reg(rdev, r, f, p, o, s) ((rdev)->asic->surface.set_reg((rdev), (r), (f), (p), (o), (s)))
  2513. #define radeon_clear_surface_reg(rdev, r) ((rdev)->asic->surface.clear_reg((rdev), (r)))
  2514. #define radeon_bandwidth_update(rdev) (rdev)->asic->display.bandwidth_update((rdev))
  2515. #define radeon_hpd_init(rdev) (rdev)->asic->hpd.init((rdev))
  2516. #define radeon_hpd_fini(rdev) (rdev)->asic->hpd.fini((rdev))
  2517. #define radeon_hpd_sense(rdev, h) (rdev)->asic->hpd.sense((rdev), (h))
  2518. #define radeon_hpd_set_polarity(rdev, h) (rdev)->asic->hpd.set_polarity((rdev), (h))
  2519. #define radeon_gui_idle(rdev) (rdev)->asic->gui_idle((rdev))
  2520. #define radeon_pm_misc(rdev) (rdev)->asic->pm.misc((rdev))
  2521. #define radeon_pm_prepare(rdev) (rdev)->asic->pm.prepare((rdev))
  2522. #define radeon_pm_finish(rdev) (rdev)->asic->pm.finish((rdev))
  2523. #define radeon_pm_init_profile(rdev) (rdev)->asic->pm.init_profile((rdev))
  2524. #define radeon_pm_get_dynpm_state(rdev) (rdev)->asic->pm.get_dynpm_state((rdev))
  2525. #define radeon_page_flip(rdev, crtc, base) (rdev)->asic->pflip.page_flip((rdev), (crtc), (base))
  2526. #define radeon_page_flip_pending(rdev, crtc) (rdev)->asic->pflip.page_flip_pending((rdev), (crtc))
  2527. #define radeon_wait_for_vblank(rdev, crtc) (rdev)->asic->display.wait_for_vblank((rdev), (crtc))
  2528. #define radeon_mc_wait_for_idle(rdev) (rdev)->asic->mc_wait_for_idle((rdev))
  2529. #define radeon_get_xclk(rdev) (rdev)->asic->get_xclk((rdev))
  2530. #define radeon_get_gpu_clock_counter(rdev) (rdev)->asic->get_gpu_clock_counter((rdev))
  2531. #define radeon_get_allowed_info_register(rdev, r, v) (rdev)->asic->get_allowed_info_register((rdev), (r), (v))
  2532. #define radeon_dpm_init(rdev) rdev->asic->dpm.init((rdev))
  2533. #define radeon_dpm_setup_asic(rdev) rdev->asic->dpm.setup_asic((rdev))
  2534. #define radeon_dpm_enable(rdev) rdev->asic->dpm.enable((rdev))
  2535. #define radeon_dpm_late_enable(rdev) rdev->asic->dpm.late_enable((rdev))
  2536. #define radeon_dpm_disable(rdev) rdev->asic->dpm.disable((rdev))
  2537. #define radeon_dpm_pre_set_power_state(rdev) rdev->asic->dpm.pre_set_power_state((rdev))
  2538. #define radeon_dpm_set_power_state(rdev) rdev->asic->dpm.set_power_state((rdev))
  2539. #define radeon_dpm_post_set_power_state(rdev) rdev->asic->dpm.post_set_power_state((rdev))
  2540. #define radeon_dpm_display_configuration_changed(rdev) rdev->asic->dpm.display_configuration_changed((rdev))
  2541. #define radeon_dpm_fini(rdev) rdev->asic->dpm.fini((rdev))
  2542. #define radeon_dpm_get_sclk(rdev, l) rdev->asic->dpm.get_sclk((rdev), (l))
  2543. #define radeon_dpm_get_mclk(rdev, l) rdev->asic->dpm.get_mclk((rdev), (l))
  2544. #define radeon_dpm_print_power_state(rdev, ps) rdev->asic->dpm.print_power_state((rdev), (ps))
  2545. #define radeon_dpm_debugfs_print_current_performance_level(rdev, m) rdev->asic->dpm.debugfs_print_current_performance_level((rdev), (m))
  2546. #define radeon_dpm_force_performance_level(rdev, l) rdev->asic->dpm.force_performance_level((rdev), (l))
  2547. #define radeon_dpm_vblank_too_short(rdev) rdev->asic->dpm.vblank_too_short((rdev))
  2548. #define radeon_dpm_powergate_uvd(rdev, g) rdev->asic->dpm.powergate_uvd((rdev), (g))
  2549. #define radeon_dpm_enable_bapm(rdev, e) rdev->asic->dpm.enable_bapm((rdev), (e))
  2550. #define radeon_dpm_get_current_sclk(rdev) rdev->asic->dpm.get_current_sclk((rdev))
  2551. #define radeon_dpm_get_current_mclk(rdev) rdev->asic->dpm.get_current_mclk((rdev))
  2552. /* Common functions */
  2553. /* AGP */
  2554. extern int radeon_gpu_reset(struct radeon_device *rdev);
  2555. extern void radeon_pci_config_reset(struct radeon_device *rdev);
  2556. extern void r600_set_bios_scratch_engine_hung(struct radeon_device *rdev, bool hung);
  2557. extern void radeon_agp_disable(struct radeon_device *rdev);
  2558. extern int radeon_modeset_init(struct radeon_device *rdev);
  2559. extern void radeon_modeset_fini(struct radeon_device *rdev);
  2560. extern bool radeon_card_posted(struct radeon_device *rdev);
  2561. extern void radeon_update_bandwidth_info(struct radeon_device *rdev);
  2562. extern void radeon_update_display_priority(struct radeon_device *rdev);
  2563. extern bool radeon_boot_test_post_card(struct radeon_device *rdev);
  2564. extern void radeon_scratch_init(struct radeon_device *rdev);
  2565. extern void radeon_wb_fini(struct radeon_device *rdev);
  2566. extern int radeon_wb_init(struct radeon_device *rdev);
  2567. extern void radeon_wb_disable(struct radeon_device *rdev);
  2568. extern void radeon_surface_init(struct radeon_device *rdev);
  2569. extern int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data);
  2570. extern void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enable);
  2571. extern void radeon_atom_set_clock_gating(struct radeon_device *rdev, int enable);
  2572. extern void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain);
  2573. extern bool radeon_ttm_bo_is_radeon_bo(struct ttm_buffer_object *bo);
  2574. extern int radeon_ttm_tt_set_userptr(struct ttm_tt *ttm, uint64_t addr,
  2575. uint32_t flags);
  2576. extern bool radeon_ttm_tt_has_userptr(struct ttm_tt *ttm);
  2577. extern bool radeon_ttm_tt_is_readonly(struct ttm_tt *ttm);
  2578. extern void radeon_vram_location(struct radeon_device *rdev, struct radeon_mc *mc, u64 base);
  2579. extern void radeon_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc);
  2580. extern int radeon_resume_kms(struct drm_device *dev, bool resume, bool fbcon);
  2581. extern int radeon_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon);
  2582. extern void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size);
  2583. extern void radeon_program_register_sequence(struct radeon_device *rdev,
  2584. const u32 *registers,
  2585. const u32 array_size);
  2586. /*
  2587. * vm
  2588. */
  2589. int radeon_vm_manager_init(struct radeon_device *rdev);
  2590. void radeon_vm_manager_fini(struct radeon_device *rdev);
  2591. int radeon_vm_init(struct radeon_device *rdev, struct radeon_vm *vm);
  2592. void radeon_vm_fini(struct radeon_device *rdev, struct radeon_vm *vm);
  2593. struct radeon_bo_list *radeon_vm_get_bos(struct radeon_device *rdev,
  2594. struct radeon_vm *vm,
  2595. struct list_head *head);
  2596. struct radeon_fence *radeon_vm_grab_id(struct radeon_device *rdev,
  2597. struct radeon_vm *vm, int ring);
  2598. void radeon_vm_flush(struct radeon_device *rdev,
  2599. struct radeon_vm *vm,
  2600. int ring, struct radeon_fence *fence);
  2601. void radeon_vm_fence(struct radeon_device *rdev,
  2602. struct radeon_vm *vm,
  2603. struct radeon_fence *fence);
  2604. uint64_t radeon_vm_map_gart(struct radeon_device *rdev, uint64_t addr);
  2605. int radeon_vm_update_page_directory(struct radeon_device *rdev,
  2606. struct radeon_vm *vm);
  2607. int radeon_vm_clear_freed(struct radeon_device *rdev,
  2608. struct radeon_vm *vm);
  2609. int radeon_vm_clear_invalids(struct radeon_device *rdev,
  2610. struct radeon_vm *vm);
  2611. int radeon_vm_bo_update(struct radeon_device *rdev,
  2612. struct radeon_bo_va *bo_va,
  2613. struct ttm_mem_reg *mem);
  2614. void radeon_vm_bo_invalidate(struct radeon_device *rdev,
  2615. struct radeon_bo *bo);
  2616. struct radeon_bo_va *radeon_vm_bo_find(struct radeon_vm *vm,
  2617. struct radeon_bo *bo);
  2618. struct radeon_bo_va *radeon_vm_bo_add(struct radeon_device *rdev,
  2619. struct radeon_vm *vm,
  2620. struct radeon_bo *bo);
  2621. int radeon_vm_bo_set_addr(struct radeon_device *rdev,
  2622. struct radeon_bo_va *bo_va,
  2623. uint64_t offset,
  2624. uint32_t flags);
  2625. void radeon_vm_bo_rmv(struct radeon_device *rdev,
  2626. struct radeon_bo_va *bo_va);
  2627. /* audio */
  2628. void r600_audio_update_hdmi(struct work_struct *work);
  2629. struct r600_audio_pin *r600_audio_get_pin(struct radeon_device *rdev);
  2630. struct r600_audio_pin *dce6_audio_get_pin(struct radeon_device *rdev);
  2631. void r600_audio_enable(struct radeon_device *rdev,
  2632. struct r600_audio_pin *pin,
  2633. u8 enable_mask);
  2634. void dce6_audio_enable(struct radeon_device *rdev,
  2635. struct r600_audio_pin *pin,
  2636. u8 enable_mask);
  2637. /*
  2638. * R600 vram scratch functions
  2639. */
  2640. int r600_vram_scratch_init(struct radeon_device *rdev);
  2641. void r600_vram_scratch_fini(struct radeon_device *rdev);
  2642. /*
  2643. * r600 cs checking helper
  2644. */
  2645. unsigned r600_mip_minify(unsigned size, unsigned level);
  2646. bool r600_fmt_is_valid_color(u32 format);
  2647. bool r600_fmt_is_valid_texture(u32 format, enum radeon_family family);
  2648. int r600_fmt_get_blocksize(u32 format);
  2649. int r600_fmt_get_nblocksx(u32 format, u32 w);
  2650. int r600_fmt_get_nblocksy(u32 format, u32 h);
  2651. /*
  2652. * r600 functions used by radeon_encoder.c
  2653. */
  2654. struct radeon_hdmi_acr {
  2655. u32 clock;
  2656. int n_32khz;
  2657. int cts_32khz;
  2658. int n_44_1khz;
  2659. int cts_44_1khz;
  2660. int n_48khz;
  2661. int cts_48khz;
  2662. };
  2663. extern struct radeon_hdmi_acr r600_hdmi_acr(uint32_t clock);
  2664. extern u32 r6xx_remap_render_backend(struct radeon_device *rdev,
  2665. u32 tiling_pipe_num,
  2666. u32 max_rb_num,
  2667. u32 total_max_rb_num,
  2668. u32 enabled_rb_mask);
  2669. /*
  2670. * evergreen functions used by radeon_encoder.c
  2671. */
  2672. extern int ni_init_microcode(struct radeon_device *rdev);
  2673. extern int ni_mc_load_microcode(struct radeon_device *rdev);
  2674. /* radeon_acpi.c */
  2675. #if defined(CONFIG_ACPI)
  2676. extern int radeon_acpi_init(struct radeon_device *rdev);
  2677. extern void radeon_acpi_fini(struct radeon_device *rdev);
  2678. extern bool radeon_acpi_is_pcie_performance_request_supported(struct radeon_device *rdev);
  2679. extern int radeon_acpi_pcie_performance_request(struct radeon_device *rdev,
  2680. u8 perf_req, bool advertise);
  2681. extern int radeon_acpi_pcie_notify_device_ready(struct radeon_device *rdev);
  2682. #else
  2683. static inline int radeon_acpi_init(struct radeon_device *rdev) { return 0; }
  2684. static inline void radeon_acpi_fini(struct radeon_device *rdev) { }
  2685. #endif
  2686. int radeon_cs_packet_parse(struct radeon_cs_parser *p,
  2687. struct radeon_cs_packet *pkt,
  2688. unsigned idx);
  2689. bool radeon_cs_packet_next_is_pkt3_nop(struct radeon_cs_parser *p);
  2690. void radeon_cs_dump_packet(struct radeon_cs_parser *p,
  2691. struct radeon_cs_packet *pkt);
  2692. int radeon_cs_packet_next_reloc(struct radeon_cs_parser *p,
  2693. struct radeon_bo_list **cs_reloc,
  2694. int nomm);
  2695. int r600_cs_common_vline_parse(struct radeon_cs_parser *p,
  2696. uint32_t *vline_start_end,
  2697. uint32_t *vline_status);
  2698. #include "radeon_object.h"
  2699. #endif