i915_drm.h 122 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724
  1. /*
  2. * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
  3. * All Rights Reserved.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a
  6. * copy of this software and associated documentation files (the
  7. * "Software"), to deal in the Software without restriction, including
  8. * without limitation the rights to use, copy, modify, merge, publish,
  9. * distribute, sub license, and/or sell copies of the Software, and to
  10. * permit persons to whom the Software is furnished to do so, subject to
  11. * the following conditions:
  12. *
  13. * The above copyright notice and this permission notice (including the
  14. * next paragraph) shall be included in all copies or substantial portions
  15. * of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  18. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  20. * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
  21. * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  22. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  23. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24. *
  25. */
  26. #ifndef _UAPI_I915_DRM_H_
  27. #define _UAPI_I915_DRM_H_
  28. #include "drm.h"
  29. #if defined(__cplusplus)
  30. extern "C" {
  31. #endif
  32. /* Please note that modifications to all structs defined here are
  33. * subject to backwards-compatibility constraints.
  34. */
  35. /**
  36. * DOC: uevents generated by i915 on it's device node
  37. *
  38. * I915_L3_PARITY_UEVENT - Generated when the driver receives a parity mismatch
  39. * event from the gpu l3 cache. Additional information supplied is ROW,
  40. * BANK, SUBBANK, SLICE of the affected cacheline. Userspace should keep
  41. * track of these events and if a specific cache-line seems to have a
  42. * persistent error remap it with the l3 remapping tool supplied in
  43. * intel-gpu-tools. The value supplied with the event is always 1.
  44. *
  45. * I915_ERROR_UEVENT - Generated upon error detection, currently only via
  46. * hangcheck. The error detection event is a good indicator of when things
  47. * began to go badly. The value supplied with the event is a 1 upon error
  48. * detection, and a 0 upon reset completion, signifying no more error
  49. * exists. NOTE: Disabling hangcheck or reset via module parameter will
  50. * cause the related events to not be seen.
  51. *
  52. * I915_RESET_UEVENT - Event is generated just before an attempt to reset the
  53. * GPU. The value supplied with the event is always 1. NOTE: Disable
  54. * reset via module parameter will cause this event to not be seen.
  55. */
  56. #define I915_L3_PARITY_UEVENT "L3_PARITY_ERROR"
  57. #define I915_ERROR_UEVENT "ERROR"
  58. #define I915_RESET_UEVENT "RESET"
  59. /**
  60. * struct i915_user_extension - Base class for defining a chain of extensions
  61. *
  62. * Many interfaces need to grow over time. In most cases we can simply
  63. * extend the struct and have userspace pass in more data. Another option,
  64. * as demonstrated by Vulkan's approach to providing extensions for forward
  65. * and backward compatibility, is to use a list of optional structs to
  66. * provide those extra details.
  67. *
  68. * The key advantage to using an extension chain is that it allows us to
  69. * redefine the interface more easily than an ever growing struct of
  70. * increasing complexity, and for large parts of that interface to be
  71. * entirely optional. The downside is more pointer chasing; chasing across
  72. * the __user boundary with pointers encapsulated inside u64.
  73. *
  74. * Example chaining:
  75. *
  76. * .. code-block:: C
  77. *
  78. * struct i915_user_extension ext3 {
  79. * .next_extension = 0, // end
  80. * .name = ...,
  81. * };
  82. * struct i915_user_extension ext2 {
  83. * .next_extension = (uintptr_t)&ext3,
  84. * .name = ...,
  85. * };
  86. * struct i915_user_extension ext1 {
  87. * .next_extension = (uintptr_t)&ext2,
  88. * .name = ...,
  89. * };
  90. *
  91. * Typically the struct i915_user_extension would be embedded in some uAPI
  92. * struct, and in this case we would feed it the head of the chain(i.e ext1),
  93. * which would then apply all of the above extensions.
  94. *
  95. */
  96. struct i915_user_extension {
  97. /**
  98. * @next_extension:
  99. *
  100. * Pointer to the next struct i915_user_extension, or zero if the end.
  101. */
  102. __u64 next_extension;
  103. /**
  104. * @name: Name of the extension.
  105. *
  106. * Note that the name here is just some integer.
  107. *
  108. * Also note that the name space for this is not global for the whole
  109. * driver, but rather its scope/meaning is limited to the specific piece
  110. * of uAPI which has embedded the struct i915_user_extension.
  111. */
  112. __u32 name;
  113. /**
  114. * @flags: MBZ
  115. *
  116. * All undefined bits must be zero.
  117. */
  118. __u32 flags;
  119. /**
  120. * @rsvd: MBZ
  121. *
  122. * Reserved for future use; must be zero.
  123. */
  124. __u32 rsvd[4];
  125. };
  126. /*
  127. * MOCS indexes used for GPU surfaces, defining the cacheability of the
  128. * surface data and the coherency for this data wrt. CPU vs. GPU accesses.
  129. */
  130. enum i915_mocs_table_index {
  131. /*
  132. * Not cached anywhere, coherency between CPU and GPU accesses is
  133. * guaranteed.
  134. */
  135. I915_MOCS_UNCACHED,
  136. /*
  137. * Cacheability and coherency controlled by the kernel automatically
  138. * based on the DRM_I915_GEM_SET_CACHING IOCTL setting and the current
  139. * usage of the surface (used for display scanout or not).
  140. */
  141. I915_MOCS_PTE,
  142. /*
  143. * Cached in all GPU caches available on the platform.
  144. * Coherency between CPU and GPU accesses to the surface is not
  145. * guaranteed without extra synchronization.
  146. */
  147. I915_MOCS_CACHED,
  148. };
  149. /**
  150. * enum drm_i915_gem_engine_class - uapi engine type enumeration
  151. *
  152. * Different engines serve different roles, and there may be more than one
  153. * engine serving each role. This enum provides a classification of the role
  154. * of the engine, which may be used when requesting operations to be performed
  155. * on a certain subset of engines, or for providing information about that
  156. * group.
  157. */
  158. enum drm_i915_gem_engine_class {
  159. /**
  160. * @I915_ENGINE_CLASS_RENDER:
  161. *
  162. * Render engines support instructions used for 3D, Compute (GPGPU),
  163. * and programmable media workloads. These instructions fetch data and
  164. * dispatch individual work items to threads that operate in parallel.
  165. * The threads run small programs (called "kernels" or "shaders") on
  166. * the GPU's execution units (EUs).
  167. */
  168. I915_ENGINE_CLASS_RENDER = 0,
  169. /**
  170. * @I915_ENGINE_CLASS_COPY:
  171. *
  172. * Copy engines (also referred to as "blitters") support instructions
  173. * that move blocks of data from one location in memory to another,
  174. * or that fill a specified location of memory with fixed data.
  175. * Copy engines can perform pre-defined logical or bitwise operations
  176. * on the source, destination, or pattern data.
  177. */
  178. I915_ENGINE_CLASS_COPY = 1,
  179. /**
  180. * @I915_ENGINE_CLASS_VIDEO:
  181. *
  182. * Video engines (also referred to as "bit stream decode" (BSD) or
  183. * "vdbox") support instructions that perform fixed-function media
  184. * decode and encode.
  185. */
  186. I915_ENGINE_CLASS_VIDEO = 2,
  187. /**
  188. * @I915_ENGINE_CLASS_VIDEO_ENHANCE:
  189. *
  190. * Video enhancement engines (also referred to as "vebox") support
  191. * instructions related to image enhancement.
  192. */
  193. I915_ENGINE_CLASS_VIDEO_ENHANCE = 3,
  194. /**
  195. * @I915_ENGINE_CLASS_COMPUTE:
  196. *
  197. * Compute engines support a subset of the instructions available
  198. * on render engines: compute engines support Compute (GPGPU) and
  199. * programmable media workloads, but do not support the 3D pipeline.
  200. */
  201. I915_ENGINE_CLASS_COMPUTE = 4,
  202. /* Values in this enum should be kept compact. */
  203. /**
  204. * @I915_ENGINE_CLASS_INVALID:
  205. *
  206. * Placeholder value to represent an invalid engine class assignment.
  207. */
  208. I915_ENGINE_CLASS_INVALID = -1
  209. };
  210. /**
  211. * struct i915_engine_class_instance - Engine class/instance identifier
  212. *
  213. * There may be more than one engine fulfilling any role within the system.
  214. * Each engine of a class is given a unique instance number and therefore
  215. * any engine can be specified by its class:instance tuplet. APIs that allow
  216. * access to any engine in the system will use struct i915_engine_class_instance
  217. * for this identification.
  218. */
  219. struct i915_engine_class_instance {
  220. /**
  221. * @engine_class:
  222. *
  223. * Engine class from enum drm_i915_gem_engine_class
  224. */
  225. __u16 engine_class;
  226. #define I915_ENGINE_CLASS_INVALID_NONE -1
  227. #define I915_ENGINE_CLASS_INVALID_VIRTUAL -2
  228. /**
  229. * @engine_instance:
  230. *
  231. * Engine instance.
  232. */
  233. __u16 engine_instance;
  234. };
  235. /**
  236. * DOC: perf_events exposed by i915 through /sys/bus/event_sources/drivers/i915
  237. *
  238. */
  239. enum drm_i915_pmu_engine_sample {
  240. I915_SAMPLE_BUSY = 0,
  241. I915_SAMPLE_WAIT = 1,
  242. I915_SAMPLE_SEMA = 2
  243. };
  244. #define I915_PMU_SAMPLE_BITS (4)
  245. #define I915_PMU_SAMPLE_MASK (0xf)
  246. #define I915_PMU_SAMPLE_INSTANCE_BITS (8)
  247. #define I915_PMU_CLASS_SHIFT \
  248. (I915_PMU_SAMPLE_BITS + I915_PMU_SAMPLE_INSTANCE_BITS)
  249. #define __I915_PMU_ENGINE(class, instance, sample) \
  250. ((class) << I915_PMU_CLASS_SHIFT | \
  251. (instance) << I915_PMU_SAMPLE_BITS | \
  252. (sample))
  253. #define I915_PMU_ENGINE_BUSY(class, instance) \
  254. __I915_PMU_ENGINE(class, instance, I915_SAMPLE_BUSY)
  255. #define I915_PMU_ENGINE_WAIT(class, instance) \
  256. __I915_PMU_ENGINE(class, instance, I915_SAMPLE_WAIT)
  257. #define I915_PMU_ENGINE_SEMA(class, instance) \
  258. __I915_PMU_ENGINE(class, instance, I915_SAMPLE_SEMA)
  259. #define __I915_PMU_OTHER(x) (__I915_PMU_ENGINE(0xff, 0xff, 0xf) + 1 + (x))
  260. #define I915_PMU_ACTUAL_FREQUENCY __I915_PMU_OTHER(0)
  261. #define I915_PMU_REQUESTED_FREQUENCY __I915_PMU_OTHER(1)
  262. #define I915_PMU_INTERRUPTS __I915_PMU_OTHER(2)
  263. #define I915_PMU_RC6_RESIDENCY __I915_PMU_OTHER(3)
  264. #define I915_PMU_SOFTWARE_GT_AWAKE_TIME __I915_PMU_OTHER(4)
  265. #define I915_PMU_LAST /* Deprecated - do not use */ I915_PMU_RC6_RESIDENCY
  266. /* Each region is a minimum of 16k, and there are at most 255 of them.
  267. */
  268. #define I915_NR_TEX_REGIONS 255 /* table size 2k - maximum due to use
  269. * of chars for next/prev indices */
  270. #define I915_LOG_MIN_TEX_REGION_SIZE 14
  271. typedef struct _drm_i915_init {
  272. enum {
  273. I915_INIT_DMA = 0x01,
  274. I915_CLEANUP_DMA = 0x02,
  275. I915_RESUME_DMA = 0x03
  276. } func;
  277. unsigned int mmio_offset;
  278. int sarea_priv_offset;
  279. unsigned int ring_start;
  280. unsigned int ring_end;
  281. unsigned int ring_size;
  282. unsigned int front_offset;
  283. unsigned int back_offset;
  284. unsigned int depth_offset;
  285. unsigned int w;
  286. unsigned int h;
  287. unsigned int pitch;
  288. unsigned int pitch_bits;
  289. unsigned int back_pitch;
  290. unsigned int depth_pitch;
  291. unsigned int cpp;
  292. unsigned int chipset;
  293. } drm_i915_init_t;
  294. typedef struct _drm_i915_sarea {
  295. struct drm_tex_region texList[I915_NR_TEX_REGIONS + 1];
  296. int last_upload; /* last time texture was uploaded */
  297. int last_enqueue; /* last time a buffer was enqueued */
  298. int last_dispatch; /* age of the most recently dispatched buffer */
  299. int ctxOwner; /* last context to upload state */
  300. int texAge;
  301. int pf_enabled; /* is pageflipping allowed? */
  302. int pf_active;
  303. int pf_current_page; /* which buffer is being displayed? */
  304. int perf_boxes; /* performance boxes to be displayed */
  305. int width, height; /* screen size in pixels */
  306. drm_handle_t front_handle;
  307. int front_offset;
  308. int front_size;
  309. drm_handle_t back_handle;
  310. int back_offset;
  311. int back_size;
  312. drm_handle_t depth_handle;
  313. int depth_offset;
  314. int depth_size;
  315. drm_handle_t tex_handle;
  316. int tex_offset;
  317. int tex_size;
  318. int log_tex_granularity;
  319. int pitch;
  320. int rotation; /* 0, 90, 180 or 270 */
  321. int rotated_offset;
  322. int rotated_size;
  323. int rotated_pitch;
  324. int virtualX, virtualY;
  325. unsigned int front_tiled;
  326. unsigned int back_tiled;
  327. unsigned int depth_tiled;
  328. unsigned int rotated_tiled;
  329. unsigned int rotated2_tiled;
  330. int pipeA_x;
  331. int pipeA_y;
  332. int pipeA_w;
  333. int pipeA_h;
  334. int pipeB_x;
  335. int pipeB_y;
  336. int pipeB_w;
  337. int pipeB_h;
  338. /* fill out some space for old userspace triple buffer */
  339. drm_handle_t unused_handle;
  340. __u32 unused1, unused2, unused3;
  341. /* buffer object handles for static buffers. May change
  342. * over the lifetime of the client.
  343. */
  344. __u32 front_bo_handle;
  345. __u32 back_bo_handle;
  346. __u32 unused_bo_handle;
  347. __u32 depth_bo_handle;
  348. } drm_i915_sarea_t;
  349. /* due to userspace building against these headers we need some compat here */
  350. #define planeA_x pipeA_x
  351. #define planeA_y pipeA_y
  352. #define planeA_w pipeA_w
  353. #define planeA_h pipeA_h
  354. #define planeB_x pipeB_x
  355. #define planeB_y pipeB_y
  356. #define planeB_w pipeB_w
  357. #define planeB_h pipeB_h
  358. /* Flags for perf_boxes
  359. */
  360. #define I915_BOX_RING_EMPTY 0x1
  361. #define I915_BOX_FLIP 0x2
  362. #define I915_BOX_WAIT 0x4
  363. #define I915_BOX_TEXTURE_LOAD 0x8
  364. #define I915_BOX_LOST_CONTEXT 0x10
  365. /*
  366. * i915 specific ioctls.
  367. *
  368. * The device specific ioctl range is [DRM_COMMAND_BASE, DRM_COMMAND_END) ie
  369. * [0x40, 0xa0) (a0 is excluded). The numbers below are defined as offset
  370. * against DRM_COMMAND_BASE and should be between [0x0, 0x60).
  371. */
  372. #define DRM_I915_INIT 0x00
  373. #define DRM_I915_FLUSH 0x01
  374. #define DRM_I915_FLIP 0x02
  375. #define DRM_I915_BATCHBUFFER 0x03
  376. #define DRM_I915_IRQ_EMIT 0x04
  377. #define DRM_I915_IRQ_WAIT 0x05
  378. #define DRM_I915_GETPARAM 0x06
  379. #define DRM_I915_SETPARAM 0x07
  380. #define DRM_I915_ALLOC 0x08
  381. #define DRM_I915_FREE 0x09
  382. #define DRM_I915_INIT_HEAP 0x0a
  383. #define DRM_I915_CMDBUFFER 0x0b
  384. #define DRM_I915_DESTROY_HEAP 0x0c
  385. #define DRM_I915_SET_VBLANK_PIPE 0x0d
  386. #define DRM_I915_GET_VBLANK_PIPE 0x0e
  387. #define DRM_I915_VBLANK_SWAP 0x0f
  388. #define DRM_I915_HWS_ADDR 0x11
  389. #define DRM_I915_GEM_INIT 0x13
  390. #define DRM_I915_GEM_EXECBUFFER 0x14
  391. #define DRM_I915_GEM_PIN 0x15
  392. #define DRM_I915_GEM_UNPIN 0x16
  393. #define DRM_I915_GEM_BUSY 0x17
  394. #define DRM_I915_GEM_THROTTLE 0x18
  395. #define DRM_I915_GEM_ENTERVT 0x19
  396. #define DRM_I915_GEM_LEAVEVT 0x1a
  397. #define DRM_I915_GEM_CREATE 0x1b
  398. #define DRM_I915_GEM_PREAD 0x1c
  399. #define DRM_I915_GEM_PWRITE 0x1d
  400. #define DRM_I915_GEM_MMAP 0x1e
  401. #define DRM_I915_GEM_SET_DOMAIN 0x1f
  402. #define DRM_I915_GEM_SW_FINISH 0x20
  403. #define DRM_I915_GEM_SET_TILING 0x21
  404. #define DRM_I915_GEM_GET_TILING 0x22
  405. #define DRM_I915_GEM_GET_APERTURE 0x23
  406. #define DRM_I915_GEM_MMAP_GTT 0x24
  407. #define DRM_I915_GET_PIPE_FROM_CRTC_ID 0x25
  408. #define DRM_I915_GEM_MADVISE 0x26
  409. #define DRM_I915_OVERLAY_PUT_IMAGE 0x27
  410. #define DRM_I915_OVERLAY_ATTRS 0x28
  411. #define DRM_I915_GEM_EXECBUFFER2 0x29
  412. #define DRM_I915_GEM_EXECBUFFER2_WR DRM_I915_GEM_EXECBUFFER2
  413. #define DRM_I915_GET_SPRITE_COLORKEY 0x2a
  414. #define DRM_I915_SET_SPRITE_COLORKEY 0x2b
  415. #define DRM_I915_GEM_WAIT 0x2c
  416. #define DRM_I915_GEM_CONTEXT_CREATE 0x2d
  417. #define DRM_I915_GEM_CONTEXT_DESTROY 0x2e
  418. #define DRM_I915_GEM_SET_CACHING 0x2f
  419. #define DRM_I915_GEM_GET_CACHING 0x30
  420. #define DRM_I915_REG_READ 0x31
  421. #define DRM_I915_GET_RESET_STATS 0x32
  422. #define DRM_I915_GEM_USERPTR 0x33
  423. #define DRM_I915_GEM_CONTEXT_GETPARAM 0x34
  424. #define DRM_I915_GEM_CONTEXT_SETPARAM 0x35
  425. #define DRM_I915_PERF_OPEN 0x36
  426. #define DRM_I915_PERF_ADD_CONFIG 0x37
  427. #define DRM_I915_PERF_REMOVE_CONFIG 0x38
  428. #define DRM_I915_QUERY 0x39
  429. #define DRM_I915_GEM_VM_CREATE 0x3a
  430. #define DRM_I915_GEM_VM_DESTROY 0x3b
  431. #define DRM_I915_GEM_CREATE_EXT 0x3c
  432. /* Must be kept compact -- no holes */
  433. #define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t)
  434. #define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH)
  435. #define DRM_IOCTL_I915_FLIP DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLIP)
  436. #define DRM_IOCTL_I915_BATCHBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_I915_BATCHBUFFER, drm_i915_batchbuffer_t)
  437. #define DRM_IOCTL_I915_IRQ_EMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_IRQ_EMIT, drm_i915_irq_emit_t)
  438. #define DRM_IOCTL_I915_IRQ_WAIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_IRQ_WAIT, drm_i915_irq_wait_t)
  439. #define DRM_IOCTL_I915_GETPARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GETPARAM, drm_i915_getparam_t)
  440. #define DRM_IOCTL_I915_SETPARAM DRM_IOW( DRM_COMMAND_BASE + DRM_I915_SETPARAM, drm_i915_setparam_t)
  441. #define DRM_IOCTL_I915_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_ALLOC, drm_i915_mem_alloc_t)
  442. #define DRM_IOCTL_I915_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_I915_FREE, drm_i915_mem_free_t)
  443. #define DRM_IOCTL_I915_INIT_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT_HEAP, drm_i915_mem_init_heap_t)
  444. #define DRM_IOCTL_I915_CMDBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_I915_CMDBUFFER, drm_i915_cmdbuffer_t)
  445. #define DRM_IOCTL_I915_DESTROY_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_DESTROY_HEAP, drm_i915_mem_destroy_heap_t)
  446. #define DRM_IOCTL_I915_SET_VBLANK_PIPE DRM_IOW( DRM_COMMAND_BASE + DRM_I915_SET_VBLANK_PIPE, drm_i915_vblank_pipe_t)
  447. #define DRM_IOCTL_I915_GET_VBLANK_PIPE DRM_IOR( DRM_COMMAND_BASE + DRM_I915_GET_VBLANK_PIPE, drm_i915_vblank_pipe_t)
  448. #define DRM_IOCTL_I915_VBLANK_SWAP DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_VBLANK_SWAP, drm_i915_vblank_swap_t)
  449. #define DRM_IOCTL_I915_HWS_ADDR DRM_IOW(DRM_COMMAND_BASE + DRM_I915_HWS_ADDR, struct drm_i915_gem_init)
  450. #define DRM_IOCTL_I915_GEM_INIT DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_INIT, struct drm_i915_gem_init)
  451. #define DRM_IOCTL_I915_GEM_EXECBUFFER DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER, struct drm_i915_gem_execbuffer)
  452. #define DRM_IOCTL_I915_GEM_EXECBUFFER2 DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2, struct drm_i915_gem_execbuffer2)
  453. #define DRM_IOCTL_I915_GEM_EXECBUFFER2_WR DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2_WR, struct drm_i915_gem_execbuffer2)
  454. #define DRM_IOCTL_I915_GEM_PIN DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_PIN, struct drm_i915_gem_pin)
  455. #define DRM_IOCTL_I915_GEM_UNPIN DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_UNPIN, struct drm_i915_gem_unpin)
  456. #define DRM_IOCTL_I915_GEM_BUSY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_BUSY, struct drm_i915_gem_busy)
  457. #define DRM_IOCTL_I915_GEM_SET_CACHING DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_SET_CACHING, struct drm_i915_gem_caching)
  458. #define DRM_IOCTL_I915_GEM_GET_CACHING DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_GET_CACHING, struct drm_i915_gem_caching)
  459. #define DRM_IOCTL_I915_GEM_THROTTLE DRM_IO ( DRM_COMMAND_BASE + DRM_I915_GEM_THROTTLE)
  460. #define DRM_IOCTL_I915_GEM_ENTERVT DRM_IO(DRM_COMMAND_BASE + DRM_I915_GEM_ENTERVT)
  461. #define DRM_IOCTL_I915_GEM_LEAVEVT DRM_IO(DRM_COMMAND_BASE + DRM_I915_GEM_LEAVEVT)
  462. #define DRM_IOCTL_I915_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_CREATE, struct drm_i915_gem_create)
  463. #define DRM_IOCTL_I915_GEM_CREATE_EXT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_CREATE_EXT, struct drm_i915_gem_create_ext)
  464. #define DRM_IOCTL_I915_GEM_PREAD DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_PREAD, struct drm_i915_gem_pread)
  465. #define DRM_IOCTL_I915_GEM_PWRITE DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_PWRITE, struct drm_i915_gem_pwrite)
  466. #define DRM_IOCTL_I915_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MMAP, struct drm_i915_gem_mmap)
  467. #define DRM_IOCTL_I915_GEM_MMAP_GTT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MMAP_GTT, struct drm_i915_gem_mmap_gtt)
  468. #define DRM_IOCTL_I915_GEM_MMAP_OFFSET DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MMAP_GTT, struct drm_i915_gem_mmap_offset)
  469. #define DRM_IOCTL_I915_GEM_SET_DOMAIN DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_SET_DOMAIN, struct drm_i915_gem_set_domain)
  470. #define DRM_IOCTL_I915_GEM_SW_FINISH DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_SW_FINISH, struct drm_i915_gem_sw_finish)
  471. #define DRM_IOCTL_I915_GEM_SET_TILING DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_SET_TILING, struct drm_i915_gem_set_tiling)
  472. #define DRM_IOCTL_I915_GEM_GET_TILING DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_GET_TILING, struct drm_i915_gem_get_tiling)
  473. #define DRM_IOCTL_I915_GEM_GET_APERTURE DRM_IOR (DRM_COMMAND_BASE + DRM_I915_GEM_GET_APERTURE, struct drm_i915_gem_get_aperture)
  474. #define DRM_IOCTL_I915_GET_PIPE_FROM_CRTC_ID DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GET_PIPE_FROM_CRTC_ID, struct drm_i915_get_pipe_from_crtc_id)
  475. #define DRM_IOCTL_I915_GEM_MADVISE DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MADVISE, struct drm_i915_gem_madvise)
  476. #define DRM_IOCTL_I915_OVERLAY_PUT_IMAGE DRM_IOW(DRM_COMMAND_BASE + DRM_I915_OVERLAY_PUT_IMAGE, struct drm_intel_overlay_put_image)
  477. #define DRM_IOCTL_I915_OVERLAY_ATTRS DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_OVERLAY_ATTRS, struct drm_intel_overlay_attrs)
  478. #define DRM_IOCTL_I915_SET_SPRITE_COLORKEY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_SET_SPRITE_COLORKEY, struct drm_intel_sprite_colorkey)
  479. #define DRM_IOCTL_I915_GET_SPRITE_COLORKEY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GET_SPRITE_COLORKEY, struct drm_intel_sprite_colorkey)
  480. #define DRM_IOCTL_I915_GEM_WAIT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_WAIT, struct drm_i915_gem_wait)
  481. #define DRM_IOCTL_I915_GEM_CONTEXT_CREATE DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_CREATE, struct drm_i915_gem_context_create)
  482. #define DRM_IOCTL_I915_GEM_CONTEXT_CREATE_EXT DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_CREATE, struct drm_i915_gem_context_create_ext)
  483. #define DRM_IOCTL_I915_GEM_CONTEXT_DESTROY DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_DESTROY, struct drm_i915_gem_context_destroy)
  484. #define DRM_IOCTL_I915_REG_READ DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_REG_READ, struct drm_i915_reg_read)
  485. #define DRM_IOCTL_I915_GET_RESET_STATS DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GET_RESET_STATS, struct drm_i915_reset_stats)
  486. #define DRM_IOCTL_I915_GEM_USERPTR DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_USERPTR, struct drm_i915_gem_userptr)
  487. #define DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_GETPARAM, struct drm_i915_gem_context_param)
  488. #define DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_SETPARAM, struct drm_i915_gem_context_param)
  489. #define DRM_IOCTL_I915_PERF_OPEN DRM_IOW(DRM_COMMAND_BASE + DRM_I915_PERF_OPEN, struct drm_i915_perf_open_param)
  490. #define DRM_IOCTL_I915_PERF_ADD_CONFIG DRM_IOW(DRM_COMMAND_BASE + DRM_I915_PERF_ADD_CONFIG, struct drm_i915_perf_oa_config)
  491. #define DRM_IOCTL_I915_PERF_REMOVE_CONFIG DRM_IOW(DRM_COMMAND_BASE + DRM_I915_PERF_REMOVE_CONFIG, __u64)
  492. #define DRM_IOCTL_I915_QUERY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_QUERY, struct drm_i915_query)
  493. #define DRM_IOCTL_I915_GEM_VM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_VM_CREATE, struct drm_i915_gem_vm_control)
  494. #define DRM_IOCTL_I915_GEM_VM_DESTROY DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_VM_DESTROY, struct drm_i915_gem_vm_control)
  495. /* Allow drivers to submit batchbuffers directly to hardware, relying
  496. * on the security mechanisms provided by hardware.
  497. */
  498. typedef struct drm_i915_batchbuffer {
  499. int start; /* agp offset */
  500. int used; /* nr bytes in use */
  501. int DR1; /* hw flags for GFX_OP_DRAWRECT_INFO */
  502. int DR4; /* window origin for GFX_OP_DRAWRECT_INFO */
  503. int num_cliprects; /* mulitpass with multiple cliprects? */
  504. struct drm_clip_rect __user *cliprects; /* pointer to userspace cliprects */
  505. } drm_i915_batchbuffer_t;
  506. /* As above, but pass a pointer to userspace buffer which can be
  507. * validated by the kernel prior to sending to hardware.
  508. */
  509. typedef struct _drm_i915_cmdbuffer {
  510. char __user *buf; /* pointer to userspace command buffer */
  511. int sz; /* nr bytes in buf */
  512. int DR1; /* hw flags for GFX_OP_DRAWRECT_INFO */
  513. int DR4; /* window origin for GFX_OP_DRAWRECT_INFO */
  514. int num_cliprects; /* mulitpass with multiple cliprects? */
  515. struct drm_clip_rect __user *cliprects; /* pointer to userspace cliprects */
  516. } drm_i915_cmdbuffer_t;
  517. /* Userspace can request & wait on irq's:
  518. */
  519. typedef struct drm_i915_irq_emit {
  520. int __user *irq_seq;
  521. } drm_i915_irq_emit_t;
  522. typedef struct drm_i915_irq_wait {
  523. int irq_seq;
  524. } drm_i915_irq_wait_t;
  525. /*
  526. * Different modes of per-process Graphics Translation Table,
  527. * see I915_PARAM_HAS_ALIASING_PPGTT
  528. */
  529. #define I915_GEM_PPGTT_NONE 0
  530. #define I915_GEM_PPGTT_ALIASING 1
  531. #define I915_GEM_PPGTT_FULL 2
  532. /* Ioctl to query kernel params:
  533. */
  534. #define I915_PARAM_IRQ_ACTIVE 1
  535. #define I915_PARAM_ALLOW_BATCHBUFFER 2
  536. #define I915_PARAM_LAST_DISPATCH 3
  537. #define I915_PARAM_CHIPSET_ID 4
  538. #define I915_PARAM_HAS_GEM 5
  539. #define I915_PARAM_NUM_FENCES_AVAIL 6
  540. #define I915_PARAM_HAS_OVERLAY 7
  541. #define I915_PARAM_HAS_PAGEFLIPPING 8
  542. #define I915_PARAM_HAS_EXECBUF2 9
  543. #define I915_PARAM_HAS_BSD 10
  544. #define I915_PARAM_HAS_BLT 11
  545. #define I915_PARAM_HAS_RELAXED_FENCING 12
  546. #define I915_PARAM_HAS_COHERENT_RINGS 13
  547. #define I915_PARAM_HAS_EXEC_CONSTANTS 14
  548. #define I915_PARAM_HAS_RELAXED_DELTA 15
  549. #define I915_PARAM_HAS_GEN7_SOL_RESET 16
  550. #define I915_PARAM_HAS_LLC 17
  551. #define I915_PARAM_HAS_ALIASING_PPGTT 18
  552. #define I915_PARAM_HAS_WAIT_TIMEOUT 19
  553. #define I915_PARAM_HAS_SEMAPHORES 20
  554. #define I915_PARAM_HAS_PRIME_VMAP_FLUSH 21
  555. #define I915_PARAM_HAS_VEBOX 22
  556. #define I915_PARAM_HAS_SECURE_BATCHES 23
  557. #define I915_PARAM_HAS_PINNED_BATCHES 24
  558. #define I915_PARAM_HAS_EXEC_NO_RELOC 25
  559. #define I915_PARAM_HAS_EXEC_HANDLE_LUT 26
  560. #define I915_PARAM_HAS_WT 27
  561. #define I915_PARAM_CMD_PARSER_VERSION 28
  562. #define I915_PARAM_HAS_COHERENT_PHYS_GTT 29
  563. #define I915_PARAM_MMAP_VERSION 30
  564. #define I915_PARAM_HAS_BSD2 31
  565. #define I915_PARAM_REVISION 32
  566. #define I915_PARAM_SUBSLICE_TOTAL 33
  567. #define I915_PARAM_EU_TOTAL 34
  568. #define I915_PARAM_HAS_GPU_RESET 35
  569. #define I915_PARAM_HAS_RESOURCE_STREAMER 36
  570. #define I915_PARAM_HAS_EXEC_SOFTPIN 37
  571. #define I915_PARAM_HAS_POOLED_EU 38
  572. #define I915_PARAM_MIN_EU_IN_POOL 39
  573. #define I915_PARAM_MMAP_GTT_VERSION 40
  574. /*
  575. * Query whether DRM_I915_GEM_EXECBUFFER2 supports user defined execution
  576. * priorities and the driver will attempt to execute batches in priority order.
  577. * The param returns a capability bitmask, nonzero implies that the scheduler
  578. * is enabled, with different features present according to the mask.
  579. *
  580. * The initial priority for each batch is supplied by the context and is
  581. * controlled via I915_CONTEXT_PARAM_PRIORITY.
  582. */
  583. #define I915_PARAM_HAS_SCHEDULER 41
  584. #define I915_SCHEDULER_CAP_ENABLED (1ul << 0)
  585. #define I915_SCHEDULER_CAP_PRIORITY (1ul << 1)
  586. #define I915_SCHEDULER_CAP_PREEMPTION (1ul << 2)
  587. #define I915_SCHEDULER_CAP_SEMAPHORES (1ul << 3)
  588. #define I915_SCHEDULER_CAP_ENGINE_BUSY_STATS (1ul << 4)
  589. /*
  590. * Indicates the 2k user priority levels are statically mapped into 3 buckets as
  591. * follows:
  592. *
  593. * -1k to -1 Low priority
  594. * 0 Normal priority
  595. * 1 to 1k Highest priority
  596. */
  597. #define I915_SCHEDULER_CAP_STATIC_PRIORITY_MAP (1ul << 5)
  598. #define I915_PARAM_HUC_STATUS 42
  599. /* Query whether DRM_I915_GEM_EXECBUFFER2 supports the ability to opt-out of
  600. * synchronisation with implicit fencing on individual objects.
  601. * See EXEC_OBJECT_ASYNC.
  602. */
  603. #define I915_PARAM_HAS_EXEC_ASYNC 43
  604. /* Query whether DRM_I915_GEM_EXECBUFFER2 supports explicit fence support -
  605. * both being able to pass in a sync_file fd to wait upon before executing,
  606. * and being able to return a new sync_file fd that is signaled when the
  607. * current request is complete. See I915_EXEC_FENCE_IN and I915_EXEC_FENCE_OUT.
  608. */
  609. #define I915_PARAM_HAS_EXEC_FENCE 44
  610. /* Query whether DRM_I915_GEM_EXECBUFFER2 supports the ability to capture
  611. * user specified bufffers for post-mortem debugging of GPU hangs. See
  612. * EXEC_OBJECT_CAPTURE.
  613. */
  614. #define I915_PARAM_HAS_EXEC_CAPTURE 45
  615. #define I915_PARAM_SLICE_MASK 46
  616. /* Assuming it's uniform for each slice, this queries the mask of subslices
  617. * per-slice for this system.
  618. */
  619. #define I915_PARAM_SUBSLICE_MASK 47
  620. /*
  621. * Query whether DRM_I915_GEM_EXECBUFFER2 supports supplying the batch buffer
  622. * as the first execobject as opposed to the last. See I915_EXEC_BATCH_FIRST.
  623. */
  624. #define I915_PARAM_HAS_EXEC_BATCH_FIRST 48
  625. /* Query whether DRM_I915_GEM_EXECBUFFER2 supports supplying an array of
  626. * drm_i915_gem_exec_fence structures. See I915_EXEC_FENCE_ARRAY.
  627. */
  628. #define I915_PARAM_HAS_EXEC_FENCE_ARRAY 49
  629. /*
  630. * Query whether every context (both per-file default and user created) is
  631. * isolated (insofar as HW supports). If this parameter is not true, then
  632. * freshly created contexts may inherit values from an existing context,
  633. * rather than default HW values. If true, it also ensures (insofar as HW
  634. * supports) that all state set by this context will not leak to any other
  635. * context.
  636. *
  637. * As not every engine across every gen support contexts, the returned
  638. * value reports the support of context isolation for individual engines by
  639. * returning a bitmask of each engine class set to true if that class supports
  640. * isolation.
  641. */
  642. #define I915_PARAM_HAS_CONTEXT_ISOLATION 50
  643. /* Frequency of the command streamer timestamps given by the *_TIMESTAMP
  644. * registers. This used to be fixed per platform but from CNL onwards, this
  645. * might vary depending on the parts.
  646. */
  647. #define I915_PARAM_CS_TIMESTAMP_FREQUENCY 51
  648. /*
  649. * Once upon a time we supposed that writes through the GGTT would be
  650. * immediately in physical memory (once flushed out of the CPU path). However,
  651. * on a few different processors and chipsets, this is not necessarily the case
  652. * as the writes appear to be buffered internally. Thus a read of the backing
  653. * storage (physical memory) via a different path (with different physical tags
  654. * to the indirect write via the GGTT) will see stale values from before
  655. * the GGTT write. Inside the kernel, we can for the most part keep track of
  656. * the different read/write domains in use (e.g. set-domain), but the assumption
  657. * of coherency is baked into the ABI, hence reporting its true state in this
  658. * parameter.
  659. *
  660. * Reports true when writes via mmap_gtt are immediately visible following an
  661. * lfence to flush the WCB.
  662. *
  663. * Reports false when writes via mmap_gtt are indeterminately delayed in an in
  664. * internal buffer and are _not_ immediately visible to third parties accessing
  665. * directly via mmap_cpu/mmap_wc. Use of mmap_gtt as part of an IPC
  666. * communications channel when reporting false is strongly disadvised.
  667. */
  668. #define I915_PARAM_MMAP_GTT_COHERENT 52
  669. /*
  670. * Query whether DRM_I915_GEM_EXECBUFFER2 supports coordination of parallel
  671. * execution through use of explicit fence support.
  672. * See I915_EXEC_FENCE_OUT and I915_EXEC_FENCE_SUBMIT.
  673. */
  674. #define I915_PARAM_HAS_EXEC_SUBMIT_FENCE 53
  675. /*
  676. * Revision of the i915-perf uAPI. The value returned helps determine what
  677. * i915-perf features are available. See drm_i915_perf_property_id.
  678. */
  679. #define I915_PARAM_PERF_REVISION 54
  680. /* Query whether DRM_I915_GEM_EXECBUFFER2 supports supplying an array of
  681. * timeline syncobj through drm_i915_gem_execbuffer_ext_timeline_fences. See
  682. * I915_EXEC_USE_EXTENSIONS.
  683. */
  684. #define I915_PARAM_HAS_EXEC_TIMELINE_FENCES 55
  685. /* Query if the kernel supports the I915_USERPTR_PROBE flag. */
  686. #define I915_PARAM_HAS_USERPTR_PROBE 56
  687. /* Must be kept compact -- no holes and well documented */
  688. /**
  689. * struct drm_i915_getparam - Driver parameter query structure.
  690. */
  691. struct drm_i915_getparam {
  692. /** @param: Driver parameter to query. */
  693. __s32 param;
  694. /**
  695. * @value: Address of memory where queried value should be put.
  696. *
  697. * WARNING: Using pointers instead of fixed-size u64 means we need to write
  698. * compat32 code. Don't repeat this mistake.
  699. */
  700. int __user *value;
  701. };
  702. /**
  703. * typedef drm_i915_getparam_t - Driver parameter query structure.
  704. * See struct drm_i915_getparam.
  705. */
  706. typedef struct drm_i915_getparam drm_i915_getparam_t;
  707. /* Ioctl to set kernel params:
  708. */
  709. #define I915_SETPARAM_USE_MI_BATCHBUFFER_START 1
  710. #define I915_SETPARAM_TEX_LRU_LOG_GRANULARITY 2
  711. #define I915_SETPARAM_ALLOW_BATCHBUFFER 3
  712. #define I915_SETPARAM_NUM_USED_FENCES 4
  713. /* Must be kept compact -- no holes */
  714. typedef struct drm_i915_setparam {
  715. int param;
  716. int value;
  717. } drm_i915_setparam_t;
  718. /* A memory manager for regions of shared memory:
  719. */
  720. #define I915_MEM_REGION_AGP 1
  721. typedef struct drm_i915_mem_alloc {
  722. int region;
  723. int alignment;
  724. int size;
  725. int __user *region_offset; /* offset from start of fb or agp */
  726. } drm_i915_mem_alloc_t;
  727. typedef struct drm_i915_mem_free {
  728. int region;
  729. int region_offset;
  730. } drm_i915_mem_free_t;
  731. typedef struct drm_i915_mem_init_heap {
  732. int region;
  733. int size;
  734. int start;
  735. } drm_i915_mem_init_heap_t;
  736. /* Allow memory manager to be torn down and re-initialized (eg on
  737. * rotate):
  738. */
  739. typedef struct drm_i915_mem_destroy_heap {
  740. int region;
  741. } drm_i915_mem_destroy_heap_t;
  742. /* Allow X server to configure which pipes to monitor for vblank signals
  743. */
  744. #define DRM_I915_VBLANK_PIPE_A 1
  745. #define DRM_I915_VBLANK_PIPE_B 2
  746. typedef struct drm_i915_vblank_pipe {
  747. int pipe;
  748. } drm_i915_vblank_pipe_t;
  749. /* Schedule buffer swap at given vertical blank:
  750. */
  751. typedef struct drm_i915_vblank_swap {
  752. drm_drawable_t drawable;
  753. enum drm_vblank_seq_type seqtype;
  754. unsigned int sequence;
  755. } drm_i915_vblank_swap_t;
  756. typedef struct drm_i915_hws_addr {
  757. __u64 addr;
  758. } drm_i915_hws_addr_t;
  759. struct drm_i915_gem_init {
  760. /**
  761. * Beginning offset in the GTT to be managed by the DRM memory
  762. * manager.
  763. */
  764. __u64 gtt_start;
  765. /**
  766. * Ending offset in the GTT to be managed by the DRM memory
  767. * manager.
  768. */
  769. __u64 gtt_end;
  770. };
  771. struct drm_i915_gem_create {
  772. /**
  773. * Requested size for the object.
  774. *
  775. * The (page-aligned) allocated size for the object will be returned.
  776. */
  777. __u64 size;
  778. /**
  779. * Returned handle for the object.
  780. *
  781. * Object handles are nonzero.
  782. */
  783. __u32 handle;
  784. __u32 pad;
  785. };
  786. struct drm_i915_gem_pread {
  787. /** Handle for the object being read. */
  788. __u32 handle;
  789. __u32 pad;
  790. /** Offset into the object to read from */
  791. __u64 offset;
  792. /** Length of data to read */
  793. __u64 size;
  794. /**
  795. * Pointer to write the data into.
  796. *
  797. * This is a fixed-size type for 32/64 compatibility.
  798. */
  799. __u64 data_ptr;
  800. };
  801. struct drm_i915_gem_pwrite {
  802. /** Handle for the object being written to. */
  803. __u32 handle;
  804. __u32 pad;
  805. /** Offset into the object to write to */
  806. __u64 offset;
  807. /** Length of data to write */
  808. __u64 size;
  809. /**
  810. * Pointer to read the data from.
  811. *
  812. * This is a fixed-size type for 32/64 compatibility.
  813. */
  814. __u64 data_ptr;
  815. };
  816. struct drm_i915_gem_mmap {
  817. /** Handle for the object being mapped. */
  818. __u32 handle;
  819. __u32 pad;
  820. /** Offset in the object to map. */
  821. __u64 offset;
  822. /**
  823. * Length of data to map.
  824. *
  825. * The value will be page-aligned.
  826. */
  827. __u64 size;
  828. /**
  829. * Returned pointer the data was mapped at.
  830. *
  831. * This is a fixed-size type for 32/64 compatibility.
  832. */
  833. __u64 addr_ptr;
  834. /**
  835. * Flags for extended behaviour.
  836. *
  837. * Added in version 2.
  838. */
  839. __u64 flags;
  840. #define I915_MMAP_WC 0x1
  841. };
  842. struct drm_i915_gem_mmap_gtt {
  843. /** Handle for the object being mapped. */
  844. __u32 handle;
  845. __u32 pad;
  846. /**
  847. * Fake offset to use for subsequent mmap call
  848. *
  849. * This is a fixed-size type for 32/64 compatibility.
  850. */
  851. __u64 offset;
  852. };
  853. /**
  854. * struct drm_i915_gem_mmap_offset - Retrieve an offset so we can mmap this buffer object.
  855. *
  856. * This struct is passed as argument to the `DRM_IOCTL_I915_GEM_MMAP_OFFSET` ioctl,
  857. * and is used to retrieve the fake offset to mmap an object specified by &handle.
  858. *
  859. * The legacy way of using `DRM_IOCTL_I915_GEM_MMAP` is removed on gen12+.
  860. * `DRM_IOCTL_I915_GEM_MMAP_GTT` is an older supported alias to this struct, but will behave
  861. * as setting the &extensions to 0, and &flags to `I915_MMAP_OFFSET_GTT`.
  862. */
  863. struct drm_i915_gem_mmap_offset {
  864. /** @handle: Handle for the object being mapped. */
  865. __u32 handle;
  866. /** @pad: Must be zero */
  867. __u32 pad;
  868. /**
  869. * @offset: The fake offset to use for subsequent mmap call
  870. *
  871. * This is a fixed-size type for 32/64 compatibility.
  872. */
  873. __u64 offset;
  874. /**
  875. * @flags: Flags for extended behaviour.
  876. *
  877. * It is mandatory that one of the `MMAP_OFFSET` types
  878. * should be included:
  879. *
  880. * - `I915_MMAP_OFFSET_GTT`: Use mmap with the object bound to GTT. (Write-Combined)
  881. * - `I915_MMAP_OFFSET_WC`: Use Write-Combined caching.
  882. * - `I915_MMAP_OFFSET_WB`: Use Write-Back caching.
  883. * - `I915_MMAP_OFFSET_FIXED`: Use object placement to determine caching.
  884. *
  885. * On devices with local memory `I915_MMAP_OFFSET_FIXED` is the only valid
  886. * type. On devices without local memory, this caching mode is invalid.
  887. *
  888. * As caching mode when specifying `I915_MMAP_OFFSET_FIXED`, WC or WB will
  889. * be used, depending on the object placement on creation. WB will be used
  890. * when the object can only exist in system memory, WC otherwise.
  891. */
  892. __u64 flags;
  893. #define I915_MMAP_OFFSET_GTT 0
  894. #define I915_MMAP_OFFSET_WC 1
  895. #define I915_MMAP_OFFSET_WB 2
  896. #define I915_MMAP_OFFSET_UC 3
  897. #define I915_MMAP_OFFSET_FIXED 4
  898. /**
  899. * @extensions: Zero-terminated chain of extensions.
  900. *
  901. * No current extensions defined; mbz.
  902. */
  903. __u64 extensions;
  904. };
  905. /**
  906. * struct drm_i915_gem_set_domain - Adjust the objects write or read domain, in
  907. * preparation for accessing the pages via some CPU domain.
  908. *
  909. * Specifying a new write or read domain will flush the object out of the
  910. * previous domain(if required), before then updating the objects domain
  911. * tracking with the new domain.
  912. *
  913. * Note this might involve waiting for the object first if it is still active on
  914. * the GPU.
  915. *
  916. * Supported values for @read_domains and @write_domain:
  917. *
  918. * - I915_GEM_DOMAIN_WC: Uncached write-combined domain
  919. * - I915_GEM_DOMAIN_CPU: CPU cache domain
  920. * - I915_GEM_DOMAIN_GTT: Mappable aperture domain
  921. *
  922. * All other domains are rejected.
  923. *
  924. * Note that for discrete, starting from DG1, this is no longer supported, and
  925. * is instead rejected. On such platforms the CPU domain is effectively static,
  926. * where we also only support a single &drm_i915_gem_mmap_offset cache mode,
  927. * which can't be set explicitly and instead depends on the object placements,
  928. * as per the below.
  929. *
  930. * Implicit caching rules, starting from DG1:
  931. *
  932. * - If any of the object placements (see &drm_i915_gem_create_ext_memory_regions)
  933. * contain I915_MEMORY_CLASS_DEVICE then the object will be allocated and
  934. * mapped as write-combined only.
  935. *
  936. * - Everything else is always allocated and mapped as write-back, with the
  937. * guarantee that everything is also coherent with the GPU.
  938. *
  939. * Note that this is likely to change in the future again, where we might need
  940. * more flexibility on future devices, so making this all explicit as part of a
  941. * new &drm_i915_gem_create_ext extension is probable.
  942. */
  943. struct drm_i915_gem_set_domain {
  944. /** @handle: Handle for the object. */
  945. __u32 handle;
  946. /** @read_domains: New read domains. */
  947. __u32 read_domains;
  948. /**
  949. * @write_domain: New write domain.
  950. *
  951. * Note that having something in the write domain implies it's in the
  952. * read domain, and only that read domain.
  953. */
  954. __u32 write_domain;
  955. };
  956. struct drm_i915_gem_sw_finish {
  957. /** Handle for the object */
  958. __u32 handle;
  959. };
  960. struct drm_i915_gem_relocation_entry {
  961. /**
  962. * Handle of the buffer being pointed to by this relocation entry.
  963. *
  964. * It's appealing to make this be an index into the mm_validate_entry
  965. * list to refer to the buffer, but this allows the driver to create
  966. * a relocation list for state buffers and not re-write it per
  967. * exec using the buffer.
  968. */
  969. __u32 target_handle;
  970. /**
  971. * Value to be added to the offset of the target buffer to make up
  972. * the relocation entry.
  973. */
  974. __u32 delta;
  975. /** Offset in the buffer the relocation entry will be written into */
  976. __u64 offset;
  977. /**
  978. * Offset value of the target buffer that the relocation entry was last
  979. * written as.
  980. *
  981. * If the buffer has the same offset as last time, we can skip syncing
  982. * and writing the relocation. This value is written back out by
  983. * the execbuffer ioctl when the relocation is written.
  984. */
  985. __u64 presumed_offset;
  986. /**
  987. * Target memory domains read by this operation.
  988. */
  989. __u32 read_domains;
  990. /**
  991. * Target memory domains written by this operation.
  992. *
  993. * Note that only one domain may be written by the whole
  994. * execbuffer operation, so that where there are conflicts,
  995. * the application will get -EINVAL back.
  996. */
  997. __u32 write_domain;
  998. };
  999. /** @{
  1000. * Intel memory domains
  1001. *
  1002. * Most of these just align with the various caches in
  1003. * the system and are used to flush and invalidate as
  1004. * objects end up cached in different domains.
  1005. */
  1006. /** CPU cache */
  1007. #define I915_GEM_DOMAIN_CPU 0x00000001
  1008. /** Render cache, used by 2D and 3D drawing */
  1009. #define I915_GEM_DOMAIN_RENDER 0x00000002
  1010. /** Sampler cache, used by texture engine */
  1011. #define I915_GEM_DOMAIN_SAMPLER 0x00000004
  1012. /** Command queue, used to load batch buffers */
  1013. #define I915_GEM_DOMAIN_COMMAND 0x00000008
  1014. /** Instruction cache, used by shader programs */
  1015. #define I915_GEM_DOMAIN_INSTRUCTION 0x00000010
  1016. /** Vertex address cache */
  1017. #define I915_GEM_DOMAIN_VERTEX 0x00000020
  1018. /** GTT domain - aperture and scanout */
  1019. #define I915_GEM_DOMAIN_GTT 0x00000040
  1020. /** WC domain - uncached access */
  1021. #define I915_GEM_DOMAIN_WC 0x00000080
  1022. /** @} */
  1023. struct drm_i915_gem_exec_object {
  1024. /**
  1025. * User's handle for a buffer to be bound into the GTT for this
  1026. * operation.
  1027. */
  1028. __u32 handle;
  1029. /** Number of relocations to be performed on this buffer */
  1030. __u32 relocation_count;
  1031. /**
  1032. * Pointer to array of struct drm_i915_gem_relocation_entry containing
  1033. * the relocations to be performed in this buffer.
  1034. */
  1035. __u64 relocs_ptr;
  1036. /** Required alignment in graphics aperture */
  1037. __u64 alignment;
  1038. /**
  1039. * Returned value of the updated offset of the object, for future
  1040. * presumed_offset writes.
  1041. */
  1042. __u64 offset;
  1043. };
  1044. /* DRM_IOCTL_I915_GEM_EXECBUFFER was removed in Linux 5.13 */
  1045. struct drm_i915_gem_execbuffer {
  1046. /**
  1047. * List of buffers to be validated with their relocations to be
  1048. * performend on them.
  1049. *
  1050. * This is a pointer to an array of struct drm_i915_gem_validate_entry.
  1051. *
  1052. * These buffers must be listed in an order such that all relocations
  1053. * a buffer is performing refer to buffers that have already appeared
  1054. * in the validate list.
  1055. */
  1056. __u64 buffers_ptr;
  1057. __u32 buffer_count;
  1058. /** Offset in the batchbuffer to start execution from. */
  1059. __u32 batch_start_offset;
  1060. /** Bytes used in batchbuffer from batch_start_offset */
  1061. __u32 batch_len;
  1062. __u32 DR1;
  1063. __u32 DR4;
  1064. __u32 num_cliprects;
  1065. /** This is a struct drm_clip_rect *cliprects */
  1066. __u64 cliprects_ptr;
  1067. };
  1068. struct drm_i915_gem_exec_object2 {
  1069. /**
  1070. * User's handle for a buffer to be bound into the GTT for this
  1071. * operation.
  1072. */
  1073. __u32 handle;
  1074. /** Number of relocations to be performed on this buffer */
  1075. __u32 relocation_count;
  1076. /**
  1077. * Pointer to array of struct drm_i915_gem_relocation_entry containing
  1078. * the relocations to be performed in this buffer.
  1079. */
  1080. __u64 relocs_ptr;
  1081. /** Required alignment in graphics aperture */
  1082. __u64 alignment;
  1083. /**
  1084. * When the EXEC_OBJECT_PINNED flag is specified this is populated by
  1085. * the user with the GTT offset at which this object will be pinned.
  1086. *
  1087. * When the I915_EXEC_NO_RELOC flag is specified this must contain the
  1088. * presumed_offset of the object.
  1089. *
  1090. * During execbuffer2 the kernel populates it with the value of the
  1091. * current GTT offset of the object, for future presumed_offset writes.
  1092. *
  1093. * See struct drm_i915_gem_create_ext for the rules when dealing with
  1094. * alignment restrictions with I915_MEMORY_CLASS_DEVICE, on devices with
  1095. * minimum page sizes, like DG2.
  1096. */
  1097. __u64 offset;
  1098. #define EXEC_OBJECT_NEEDS_FENCE (1<<0)
  1099. #define EXEC_OBJECT_NEEDS_GTT (1<<1)
  1100. #define EXEC_OBJECT_WRITE (1<<2)
  1101. #define EXEC_OBJECT_SUPPORTS_48B_ADDRESS (1<<3)
  1102. #define EXEC_OBJECT_PINNED (1<<4)
  1103. #define EXEC_OBJECT_PAD_TO_SIZE (1<<5)
  1104. /* The kernel implicitly tracks GPU activity on all GEM objects, and
  1105. * synchronises operations with outstanding rendering. This includes
  1106. * rendering on other devices if exported via dma-buf. However, sometimes
  1107. * this tracking is too coarse and the user knows better. For example,
  1108. * if the object is split into non-overlapping ranges shared between different
  1109. * clients or engines (i.e. suballocating objects), the implicit tracking
  1110. * by kernel assumes that each operation affects the whole object rather
  1111. * than an individual range, causing needless synchronisation between clients.
  1112. * The kernel will also forgo any CPU cache flushes prior to rendering from
  1113. * the object as the client is expected to be also handling such domain
  1114. * tracking.
  1115. *
  1116. * The kernel maintains the implicit tracking in order to manage resources
  1117. * used by the GPU - this flag only disables the synchronisation prior to
  1118. * rendering with this object in this execbuf.
  1119. *
  1120. * Opting out of implicit synhronisation requires the user to do its own
  1121. * explicit tracking to avoid rendering corruption. See, for example,
  1122. * I915_PARAM_HAS_EXEC_FENCE to order execbufs and execute them asynchronously.
  1123. */
  1124. #define EXEC_OBJECT_ASYNC (1<<6)
  1125. /* Request that the contents of this execobject be copied into the error
  1126. * state upon a GPU hang involving this batch for post-mortem debugging.
  1127. * These buffers are recorded in no particular order as "user" in
  1128. * /sys/class/drm/cardN/error. Query I915_PARAM_HAS_EXEC_CAPTURE to see
  1129. * if the kernel supports this flag.
  1130. */
  1131. #define EXEC_OBJECT_CAPTURE (1<<7)
  1132. /* All remaining bits are MBZ and RESERVED FOR FUTURE USE */
  1133. #define __EXEC_OBJECT_UNKNOWN_FLAGS -(EXEC_OBJECT_CAPTURE<<1)
  1134. __u64 flags;
  1135. union {
  1136. __u64 rsvd1;
  1137. __u64 pad_to_size;
  1138. };
  1139. __u64 rsvd2;
  1140. };
  1141. /**
  1142. * struct drm_i915_gem_exec_fence - An input or output fence for the execbuf
  1143. * ioctl.
  1144. *
  1145. * The request will wait for input fence to signal before submission.
  1146. *
  1147. * The returned output fence will be signaled after the completion of the
  1148. * request.
  1149. */
  1150. struct drm_i915_gem_exec_fence {
  1151. /** @handle: User's handle for a drm_syncobj to wait on or signal. */
  1152. __u32 handle;
  1153. /**
  1154. * @flags: Supported flags are:
  1155. *
  1156. * I915_EXEC_FENCE_WAIT:
  1157. * Wait for the input fence before request submission.
  1158. *
  1159. * I915_EXEC_FENCE_SIGNAL:
  1160. * Return request completion fence as output
  1161. */
  1162. __u32 flags;
  1163. #define I915_EXEC_FENCE_WAIT (1<<0)
  1164. #define I915_EXEC_FENCE_SIGNAL (1<<1)
  1165. #define __I915_EXEC_FENCE_UNKNOWN_FLAGS (-(I915_EXEC_FENCE_SIGNAL << 1))
  1166. };
  1167. /**
  1168. * struct drm_i915_gem_execbuffer_ext_timeline_fences - Timeline fences
  1169. * for execbuf ioctl.
  1170. *
  1171. * This structure describes an array of drm_syncobj and associated points for
  1172. * timeline variants of drm_syncobj. It is invalid to append this structure to
  1173. * the execbuf if I915_EXEC_FENCE_ARRAY is set.
  1174. */
  1175. struct drm_i915_gem_execbuffer_ext_timeline_fences {
  1176. #define DRM_I915_GEM_EXECBUFFER_EXT_TIMELINE_FENCES 0
  1177. /** @base: Extension link. See struct i915_user_extension. */
  1178. struct i915_user_extension base;
  1179. /**
  1180. * @fence_count: Number of elements in the @handles_ptr & @value_ptr
  1181. * arrays.
  1182. */
  1183. __u64 fence_count;
  1184. /**
  1185. * @handles_ptr: Pointer to an array of struct drm_i915_gem_exec_fence
  1186. * of length @fence_count.
  1187. */
  1188. __u64 handles_ptr;
  1189. /**
  1190. * @values_ptr: Pointer to an array of u64 values of length
  1191. * @fence_count.
  1192. * Values must be 0 for a binary drm_syncobj. A Value of 0 for a
  1193. * timeline drm_syncobj is invalid as it turns a drm_syncobj into a
  1194. * binary one.
  1195. */
  1196. __u64 values_ptr;
  1197. };
  1198. /**
  1199. * struct drm_i915_gem_execbuffer2 - Structure for DRM_I915_GEM_EXECBUFFER2
  1200. * ioctl.
  1201. */
  1202. struct drm_i915_gem_execbuffer2 {
  1203. /** @buffers_ptr: Pointer to a list of gem_exec_object2 structs */
  1204. __u64 buffers_ptr;
  1205. /** @buffer_count: Number of elements in @buffers_ptr array */
  1206. __u32 buffer_count;
  1207. /**
  1208. * @batch_start_offset: Offset in the batchbuffer to start execution
  1209. * from.
  1210. */
  1211. __u32 batch_start_offset;
  1212. /**
  1213. * @batch_len: Length in bytes of the batch buffer, starting from the
  1214. * @batch_start_offset. If 0, length is assumed to be the batch buffer
  1215. * object size.
  1216. */
  1217. __u32 batch_len;
  1218. /** @DR1: deprecated */
  1219. __u32 DR1;
  1220. /** @DR4: deprecated */
  1221. __u32 DR4;
  1222. /** @num_cliprects: See @cliprects_ptr */
  1223. __u32 num_cliprects;
  1224. /**
  1225. * @cliprects_ptr: Kernel clipping was a DRI1 misfeature.
  1226. *
  1227. * It is invalid to use this field if I915_EXEC_FENCE_ARRAY or
  1228. * I915_EXEC_USE_EXTENSIONS flags are not set.
  1229. *
  1230. * If I915_EXEC_FENCE_ARRAY is set, then this is a pointer to an array
  1231. * of &drm_i915_gem_exec_fence and @num_cliprects is the length of the
  1232. * array.
  1233. *
  1234. * If I915_EXEC_USE_EXTENSIONS is set, then this is a pointer to a
  1235. * single &i915_user_extension and num_cliprects is 0.
  1236. */
  1237. __u64 cliprects_ptr;
  1238. /** @flags: Execbuf flags */
  1239. __u64 flags;
  1240. #define I915_EXEC_RING_MASK (0x3f)
  1241. #define I915_EXEC_DEFAULT (0<<0)
  1242. #define I915_EXEC_RENDER (1<<0)
  1243. #define I915_EXEC_BSD (2<<0)
  1244. #define I915_EXEC_BLT (3<<0)
  1245. #define I915_EXEC_VEBOX (4<<0)
  1246. /* Used for switching the constants addressing mode on gen4+ RENDER ring.
  1247. * Gen6+ only supports relative addressing to dynamic state (default) and
  1248. * absolute addressing.
  1249. *
  1250. * These flags are ignored for the BSD and BLT rings.
  1251. */
  1252. #define I915_EXEC_CONSTANTS_MASK (3<<6)
  1253. #define I915_EXEC_CONSTANTS_REL_GENERAL (0<<6) /* default */
  1254. #define I915_EXEC_CONSTANTS_ABSOLUTE (1<<6)
  1255. #define I915_EXEC_CONSTANTS_REL_SURFACE (2<<6) /* gen4/5 only */
  1256. /** Resets the SO write offset registers for transform feedback on gen7. */
  1257. #define I915_EXEC_GEN7_SOL_RESET (1<<8)
  1258. /** Request a privileged ("secure") batch buffer. Note only available for
  1259. * DRM_ROOT_ONLY | DRM_MASTER processes.
  1260. */
  1261. #define I915_EXEC_SECURE (1<<9)
  1262. /** Inform the kernel that the batch is and will always be pinned. This
  1263. * negates the requirement for a workaround to be performed to avoid
  1264. * an incoherent CS (such as can be found on 830/845). If this flag is
  1265. * not passed, the kernel will endeavour to make sure the batch is
  1266. * coherent with the CS before execution. If this flag is passed,
  1267. * userspace assumes the responsibility for ensuring the same.
  1268. */
  1269. #define I915_EXEC_IS_PINNED (1<<10)
  1270. /** Provide a hint to the kernel that the command stream and auxiliary
  1271. * state buffers already holds the correct presumed addresses and so the
  1272. * relocation process may be skipped if no buffers need to be moved in
  1273. * preparation for the execbuffer.
  1274. */
  1275. #define I915_EXEC_NO_RELOC (1<<11)
  1276. /** Use the reloc.handle as an index into the exec object array rather
  1277. * than as the per-file handle.
  1278. */
  1279. #define I915_EXEC_HANDLE_LUT (1<<12)
  1280. /** Used for switching BSD rings on the platforms with two BSD rings */
  1281. #define I915_EXEC_BSD_SHIFT (13)
  1282. #define I915_EXEC_BSD_MASK (3 << I915_EXEC_BSD_SHIFT)
  1283. /* default ping-pong mode */
  1284. #define I915_EXEC_BSD_DEFAULT (0 << I915_EXEC_BSD_SHIFT)
  1285. #define I915_EXEC_BSD_RING1 (1 << I915_EXEC_BSD_SHIFT)
  1286. #define I915_EXEC_BSD_RING2 (2 << I915_EXEC_BSD_SHIFT)
  1287. /** Tell the kernel that the batchbuffer is processed by
  1288. * the resource streamer.
  1289. */
  1290. #define I915_EXEC_RESOURCE_STREAMER (1<<15)
  1291. /* Setting I915_EXEC_FENCE_IN implies that lower_32_bits(rsvd2) represent
  1292. * a sync_file fd to wait upon (in a nonblocking manner) prior to executing
  1293. * the batch.
  1294. *
  1295. * Returns -EINVAL if the sync_file fd cannot be found.
  1296. */
  1297. #define I915_EXEC_FENCE_IN (1<<16)
  1298. /* Setting I915_EXEC_FENCE_OUT causes the ioctl to return a sync_file fd
  1299. * in the upper_32_bits(rsvd2) upon success. Ownership of the fd is given
  1300. * to the caller, and it should be close() after use. (The fd is a regular
  1301. * file descriptor and will be cleaned up on process termination. It holds
  1302. * a reference to the request, but nothing else.)
  1303. *
  1304. * The sync_file fd can be combined with other sync_file and passed either
  1305. * to execbuf using I915_EXEC_FENCE_IN, to atomic KMS ioctls (so that a flip
  1306. * will only occur after this request completes), or to other devices.
  1307. *
  1308. * Using I915_EXEC_FENCE_OUT requires use of
  1309. * DRM_IOCTL_I915_GEM_EXECBUFFER2_WR ioctl so that the result is written
  1310. * back to userspace. Failure to do so will cause the out-fence to always
  1311. * be reported as zero, and the real fence fd to be leaked.
  1312. */
  1313. #define I915_EXEC_FENCE_OUT (1<<17)
  1314. /*
  1315. * Traditionally the execbuf ioctl has only considered the final element in
  1316. * the execobject[] to be the executable batch. Often though, the client
  1317. * will known the batch object prior to construction and being able to place
  1318. * it into the execobject[] array first can simplify the relocation tracking.
  1319. * Setting I915_EXEC_BATCH_FIRST tells execbuf to use element 0 of the
  1320. * execobject[] as the * batch instead (the default is to use the last
  1321. * element).
  1322. */
  1323. #define I915_EXEC_BATCH_FIRST (1<<18)
  1324. /* Setting I915_FENCE_ARRAY implies that num_cliprects and cliprects_ptr
  1325. * define an array of i915_gem_exec_fence structures which specify a set of
  1326. * dma fences to wait upon or signal.
  1327. */
  1328. #define I915_EXEC_FENCE_ARRAY (1<<19)
  1329. /*
  1330. * Setting I915_EXEC_FENCE_SUBMIT implies that lower_32_bits(rsvd2) represent
  1331. * a sync_file fd to wait upon (in a nonblocking manner) prior to executing
  1332. * the batch.
  1333. *
  1334. * Returns -EINVAL if the sync_file fd cannot be found.
  1335. */
  1336. #define I915_EXEC_FENCE_SUBMIT (1 << 20)
  1337. /*
  1338. * Setting I915_EXEC_USE_EXTENSIONS implies that
  1339. * drm_i915_gem_execbuffer2.cliprects_ptr is treated as a pointer to an linked
  1340. * list of i915_user_extension. Each i915_user_extension node is the base of a
  1341. * larger structure. The list of supported structures are listed in the
  1342. * drm_i915_gem_execbuffer_ext enum.
  1343. */
  1344. #define I915_EXEC_USE_EXTENSIONS (1 << 21)
  1345. #define __I915_EXEC_UNKNOWN_FLAGS (-(I915_EXEC_USE_EXTENSIONS << 1))
  1346. /** @rsvd1: Context id */
  1347. __u64 rsvd1;
  1348. /**
  1349. * @rsvd2: in and out sync_file file descriptors.
  1350. *
  1351. * When I915_EXEC_FENCE_IN or I915_EXEC_FENCE_SUBMIT flag is set, the
  1352. * lower 32 bits of this field will have the in sync_file fd (input).
  1353. *
  1354. * When I915_EXEC_FENCE_OUT flag is set, the upper 32 bits of this
  1355. * field will have the out sync_file fd (output).
  1356. */
  1357. __u64 rsvd2;
  1358. };
  1359. #define I915_EXEC_CONTEXT_ID_MASK (0xffffffff)
  1360. #define i915_execbuffer2_set_context_id(eb2, context) \
  1361. (eb2).rsvd1 = context & I915_EXEC_CONTEXT_ID_MASK
  1362. #define i915_execbuffer2_get_context_id(eb2) \
  1363. ((eb2).rsvd1 & I915_EXEC_CONTEXT_ID_MASK)
  1364. struct drm_i915_gem_pin {
  1365. /** Handle of the buffer to be pinned. */
  1366. __u32 handle;
  1367. __u32 pad;
  1368. /** alignment required within the aperture */
  1369. __u64 alignment;
  1370. /** Returned GTT offset of the buffer. */
  1371. __u64 offset;
  1372. };
  1373. struct drm_i915_gem_unpin {
  1374. /** Handle of the buffer to be unpinned. */
  1375. __u32 handle;
  1376. __u32 pad;
  1377. };
  1378. struct drm_i915_gem_busy {
  1379. /** Handle of the buffer to check for busy */
  1380. __u32 handle;
  1381. /** Return busy status
  1382. *
  1383. * A return of 0 implies that the object is idle (after
  1384. * having flushed any pending activity), and a non-zero return that
  1385. * the object is still in-flight on the GPU. (The GPU has not yet
  1386. * signaled completion for all pending requests that reference the
  1387. * object.) An object is guaranteed to become idle eventually (so
  1388. * long as no new GPU commands are executed upon it). Due to the
  1389. * asynchronous nature of the hardware, an object reported
  1390. * as busy may become idle before the ioctl is completed.
  1391. *
  1392. * Furthermore, if the object is busy, which engine is busy is only
  1393. * provided as a guide and only indirectly by reporting its class
  1394. * (there may be more than one engine in each class). There are race
  1395. * conditions which prevent the report of which engines are busy from
  1396. * being always accurate. However, the converse is not true. If the
  1397. * object is idle, the result of the ioctl, that all engines are idle,
  1398. * is accurate.
  1399. *
  1400. * The returned dword is split into two fields to indicate both
  1401. * the engine classess on which the object is being read, and the
  1402. * engine class on which it is currently being written (if any).
  1403. *
  1404. * The low word (bits 0:15) indicate if the object is being written
  1405. * to by any engine (there can only be one, as the GEM implicit
  1406. * synchronisation rules force writes to be serialised). Only the
  1407. * engine class (offset by 1, I915_ENGINE_CLASS_RENDER is reported as
  1408. * 1 not 0 etc) for the last write is reported.
  1409. *
  1410. * The high word (bits 16:31) are a bitmask of which engines classes
  1411. * are currently reading from the object. Multiple engines may be
  1412. * reading from the object simultaneously.
  1413. *
  1414. * The value of each engine class is the same as specified in the
  1415. * I915_CONTEXT_PARAM_ENGINES context parameter and via perf, i.e.
  1416. * I915_ENGINE_CLASS_RENDER, I915_ENGINE_CLASS_COPY, etc.
  1417. * Some hardware may have parallel execution engines, e.g. multiple
  1418. * media engines, which are mapped to the same class identifier and so
  1419. * are not separately reported for busyness.
  1420. *
  1421. * Caveat emptor:
  1422. * Only the boolean result of this query is reliable; that is whether
  1423. * the object is idle or busy. The report of which engines are busy
  1424. * should be only used as a heuristic.
  1425. */
  1426. __u32 busy;
  1427. };
  1428. /**
  1429. * struct drm_i915_gem_caching - Set or get the caching for given object
  1430. * handle.
  1431. *
  1432. * Allow userspace to control the GTT caching bits for a given object when the
  1433. * object is later mapped through the ppGTT(or GGTT on older platforms lacking
  1434. * ppGTT support, or if the object is used for scanout). Note that this might
  1435. * require unbinding the object from the GTT first, if its current caching value
  1436. * doesn't match.
  1437. *
  1438. * Note that this all changes on discrete platforms, starting from DG1, the
  1439. * set/get caching is no longer supported, and is now rejected. Instead the CPU
  1440. * caching attributes(WB vs WC) will become an immutable creation time property
  1441. * for the object, along with the GTT caching level. For now we don't expose any
  1442. * new uAPI for this, instead on DG1 this is all implicit, although this largely
  1443. * shouldn't matter since DG1 is coherent by default(without any way of
  1444. * controlling it).
  1445. *
  1446. * Implicit caching rules, starting from DG1:
  1447. *
  1448. * - If any of the object placements (see &drm_i915_gem_create_ext_memory_regions)
  1449. * contain I915_MEMORY_CLASS_DEVICE then the object will be allocated and
  1450. * mapped as write-combined only.
  1451. *
  1452. * - Everything else is always allocated and mapped as write-back, with the
  1453. * guarantee that everything is also coherent with the GPU.
  1454. *
  1455. * Note that this is likely to change in the future again, where we might need
  1456. * more flexibility on future devices, so making this all explicit as part of a
  1457. * new &drm_i915_gem_create_ext extension is probable.
  1458. *
  1459. * Side note: Part of the reason for this is that changing the at-allocation-time CPU
  1460. * caching attributes for the pages might be required(and is expensive) if we
  1461. * need to then CPU map the pages later with different caching attributes. This
  1462. * inconsistent caching behaviour, while supported on x86, is not universally
  1463. * supported on other architectures. So for simplicity we opt for setting
  1464. * everything at creation time, whilst also making it immutable, on discrete
  1465. * platforms.
  1466. */
  1467. struct drm_i915_gem_caching {
  1468. /**
  1469. * @handle: Handle of the buffer to set/get the caching level.
  1470. */
  1471. __u32 handle;
  1472. /**
  1473. * @caching: The GTT caching level to apply or possible return value.
  1474. *
  1475. * The supported @caching values:
  1476. *
  1477. * I915_CACHING_NONE:
  1478. *
  1479. * GPU access is not coherent with CPU caches. Default for machines
  1480. * without an LLC. This means manual flushing might be needed, if we
  1481. * want GPU access to be coherent.
  1482. *
  1483. * I915_CACHING_CACHED:
  1484. *
  1485. * GPU access is coherent with CPU caches and furthermore the data is
  1486. * cached in last-level caches shared between CPU cores and the GPU GT.
  1487. *
  1488. * I915_CACHING_DISPLAY:
  1489. *
  1490. * Special GPU caching mode which is coherent with the scanout engines.
  1491. * Transparently falls back to I915_CACHING_NONE on platforms where no
  1492. * special cache mode (like write-through or gfdt flushing) is
  1493. * available. The kernel automatically sets this mode when using a
  1494. * buffer as a scanout target. Userspace can manually set this mode to
  1495. * avoid a costly stall and clflush in the hotpath of drawing the first
  1496. * frame.
  1497. */
  1498. #define I915_CACHING_NONE 0
  1499. #define I915_CACHING_CACHED 1
  1500. #define I915_CACHING_DISPLAY 2
  1501. __u32 caching;
  1502. };
  1503. #define I915_TILING_NONE 0
  1504. #define I915_TILING_X 1
  1505. #define I915_TILING_Y 2
  1506. /*
  1507. * Do not add new tiling types here. The I915_TILING_* values are for
  1508. * de-tiling fence registers that no longer exist on modern platforms. Although
  1509. * the hardware may support new types of tiling in general (e.g., Tile4), we
  1510. * do not need to add them to the uapi that is specific to now-defunct ioctls.
  1511. */
  1512. #define I915_TILING_LAST I915_TILING_Y
  1513. #define I915_BIT_6_SWIZZLE_NONE 0
  1514. #define I915_BIT_6_SWIZZLE_9 1
  1515. #define I915_BIT_6_SWIZZLE_9_10 2
  1516. #define I915_BIT_6_SWIZZLE_9_11 3
  1517. #define I915_BIT_6_SWIZZLE_9_10_11 4
  1518. /* Not seen by userland */
  1519. #define I915_BIT_6_SWIZZLE_UNKNOWN 5
  1520. /* Seen by userland. */
  1521. #define I915_BIT_6_SWIZZLE_9_17 6
  1522. #define I915_BIT_6_SWIZZLE_9_10_17 7
  1523. struct drm_i915_gem_set_tiling {
  1524. /** Handle of the buffer to have its tiling state updated */
  1525. __u32 handle;
  1526. /**
  1527. * Tiling mode for the object (I915_TILING_NONE, I915_TILING_X,
  1528. * I915_TILING_Y).
  1529. *
  1530. * This value is to be set on request, and will be updated by the
  1531. * kernel on successful return with the actual chosen tiling layout.
  1532. *
  1533. * The tiling mode may be demoted to I915_TILING_NONE when the system
  1534. * has bit 6 swizzling that can't be managed correctly by GEM.
  1535. *
  1536. * Buffer contents become undefined when changing tiling_mode.
  1537. */
  1538. __u32 tiling_mode;
  1539. /**
  1540. * Stride in bytes for the object when in I915_TILING_X or
  1541. * I915_TILING_Y.
  1542. */
  1543. __u32 stride;
  1544. /**
  1545. * Returned address bit 6 swizzling required for CPU access through
  1546. * mmap mapping.
  1547. */
  1548. __u32 swizzle_mode;
  1549. };
  1550. struct drm_i915_gem_get_tiling {
  1551. /** Handle of the buffer to get tiling state for. */
  1552. __u32 handle;
  1553. /**
  1554. * Current tiling mode for the object (I915_TILING_NONE, I915_TILING_X,
  1555. * I915_TILING_Y).
  1556. */
  1557. __u32 tiling_mode;
  1558. /**
  1559. * Returned address bit 6 swizzling required for CPU access through
  1560. * mmap mapping.
  1561. */
  1562. __u32 swizzle_mode;
  1563. /**
  1564. * Returned address bit 6 swizzling required for CPU access through
  1565. * mmap mapping whilst bound.
  1566. */
  1567. __u32 phys_swizzle_mode;
  1568. };
  1569. struct drm_i915_gem_get_aperture {
  1570. /** Total size of the aperture used by i915_gem_execbuffer, in bytes */
  1571. __u64 aper_size;
  1572. /**
  1573. * Available space in the aperture used by i915_gem_execbuffer, in
  1574. * bytes
  1575. */
  1576. __u64 aper_available_size;
  1577. };
  1578. struct drm_i915_get_pipe_from_crtc_id {
  1579. /** ID of CRTC being requested **/
  1580. __u32 crtc_id;
  1581. /** pipe of requested CRTC **/
  1582. __u32 pipe;
  1583. };
  1584. #define I915_MADV_WILLNEED 0
  1585. #define I915_MADV_DONTNEED 1
  1586. #define __I915_MADV_PURGED 2 /* internal state */
  1587. struct drm_i915_gem_madvise {
  1588. /** Handle of the buffer to change the backing store advice */
  1589. __u32 handle;
  1590. /* Advice: either the buffer will be needed again in the near future,
  1591. * or wont be and could be discarded under memory pressure.
  1592. */
  1593. __u32 madv;
  1594. /** Whether the backing store still exists. */
  1595. __u32 retained;
  1596. };
  1597. /* flags */
  1598. #define I915_OVERLAY_TYPE_MASK 0xff
  1599. #define I915_OVERLAY_YUV_PLANAR 0x01
  1600. #define I915_OVERLAY_YUV_PACKED 0x02
  1601. #define I915_OVERLAY_RGB 0x03
  1602. #define I915_OVERLAY_DEPTH_MASK 0xff00
  1603. #define I915_OVERLAY_RGB24 0x1000
  1604. #define I915_OVERLAY_RGB16 0x2000
  1605. #define I915_OVERLAY_RGB15 0x3000
  1606. #define I915_OVERLAY_YUV422 0x0100
  1607. #define I915_OVERLAY_YUV411 0x0200
  1608. #define I915_OVERLAY_YUV420 0x0300
  1609. #define I915_OVERLAY_YUV410 0x0400
  1610. #define I915_OVERLAY_SWAP_MASK 0xff0000
  1611. #define I915_OVERLAY_NO_SWAP 0x000000
  1612. #define I915_OVERLAY_UV_SWAP 0x010000
  1613. #define I915_OVERLAY_Y_SWAP 0x020000
  1614. #define I915_OVERLAY_Y_AND_UV_SWAP 0x030000
  1615. #define I915_OVERLAY_FLAGS_MASK 0xff000000
  1616. #define I915_OVERLAY_ENABLE 0x01000000
  1617. struct drm_intel_overlay_put_image {
  1618. /* various flags and src format description */
  1619. __u32 flags;
  1620. /* source picture description */
  1621. __u32 bo_handle;
  1622. /* stride values and offsets are in bytes, buffer relative */
  1623. __u16 stride_Y; /* stride for packed formats */
  1624. __u16 stride_UV;
  1625. __u32 offset_Y; /* offset for packet formats */
  1626. __u32 offset_U;
  1627. __u32 offset_V;
  1628. /* in pixels */
  1629. __u16 src_width;
  1630. __u16 src_height;
  1631. /* to compensate the scaling factors for partially covered surfaces */
  1632. __u16 src_scan_width;
  1633. __u16 src_scan_height;
  1634. /* output crtc description */
  1635. __u32 crtc_id;
  1636. __u16 dst_x;
  1637. __u16 dst_y;
  1638. __u16 dst_width;
  1639. __u16 dst_height;
  1640. };
  1641. /* flags */
  1642. #define I915_OVERLAY_UPDATE_ATTRS (1<<0)
  1643. #define I915_OVERLAY_UPDATE_GAMMA (1<<1)
  1644. #define I915_OVERLAY_DISABLE_DEST_COLORKEY (1<<2)
  1645. struct drm_intel_overlay_attrs {
  1646. __u32 flags;
  1647. __u32 color_key;
  1648. __s32 brightness;
  1649. __u32 contrast;
  1650. __u32 saturation;
  1651. __u32 gamma0;
  1652. __u32 gamma1;
  1653. __u32 gamma2;
  1654. __u32 gamma3;
  1655. __u32 gamma4;
  1656. __u32 gamma5;
  1657. };
  1658. /*
  1659. * Intel sprite handling
  1660. *
  1661. * Color keying works with a min/mask/max tuple. Both source and destination
  1662. * color keying is allowed.
  1663. *
  1664. * Source keying:
  1665. * Sprite pixels within the min & max values, masked against the color channels
  1666. * specified in the mask field, will be transparent. All other pixels will
  1667. * be displayed on top of the primary plane. For RGB surfaces, only the min
  1668. * and mask fields will be used; ranged compares are not allowed.
  1669. *
  1670. * Destination keying:
  1671. * Primary plane pixels that match the min value, masked against the color
  1672. * channels specified in the mask field, will be replaced by corresponding
  1673. * pixels from the sprite plane.
  1674. *
  1675. * Note that source & destination keying are exclusive; only one can be
  1676. * active on a given plane.
  1677. */
  1678. #define I915_SET_COLORKEY_NONE (1<<0) /* Deprecated. Instead set
  1679. * flags==0 to disable colorkeying.
  1680. */
  1681. #define I915_SET_COLORKEY_DESTINATION (1<<1)
  1682. #define I915_SET_COLORKEY_SOURCE (1<<2)
  1683. struct drm_intel_sprite_colorkey {
  1684. __u32 plane_id;
  1685. __u32 min_value;
  1686. __u32 channel_mask;
  1687. __u32 max_value;
  1688. __u32 flags;
  1689. };
  1690. struct drm_i915_gem_wait {
  1691. /** Handle of BO we shall wait on */
  1692. __u32 bo_handle;
  1693. __u32 flags;
  1694. /** Number of nanoseconds to wait, Returns time remaining. */
  1695. __s64 timeout_ns;
  1696. };
  1697. struct drm_i915_gem_context_create {
  1698. __u32 ctx_id; /* output: id of new context*/
  1699. __u32 pad;
  1700. };
  1701. /**
  1702. * struct drm_i915_gem_context_create_ext - Structure for creating contexts.
  1703. */
  1704. struct drm_i915_gem_context_create_ext {
  1705. /** @ctx_id: Id of the created context (output) */
  1706. __u32 ctx_id;
  1707. /**
  1708. * @flags: Supported flags are:
  1709. *
  1710. * I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS:
  1711. *
  1712. * Extensions may be appended to this structure and driver must check
  1713. * for those. See @extensions.
  1714. *
  1715. * I915_CONTEXT_CREATE_FLAGS_SINGLE_TIMELINE
  1716. *
  1717. * Created context will have single timeline.
  1718. */
  1719. __u32 flags;
  1720. #define I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS (1u << 0)
  1721. #define I915_CONTEXT_CREATE_FLAGS_SINGLE_TIMELINE (1u << 1)
  1722. #define I915_CONTEXT_CREATE_FLAGS_UNKNOWN \
  1723. (-(I915_CONTEXT_CREATE_FLAGS_SINGLE_TIMELINE << 1))
  1724. /**
  1725. * @extensions: Zero-terminated chain of extensions.
  1726. *
  1727. * I915_CONTEXT_CREATE_EXT_SETPARAM:
  1728. * Context parameter to set or query during context creation.
  1729. * See struct drm_i915_gem_context_create_ext_setparam.
  1730. *
  1731. * I915_CONTEXT_CREATE_EXT_CLONE:
  1732. * This extension has been removed. On the off chance someone somewhere
  1733. * has attempted to use it, never re-use this extension number.
  1734. */
  1735. __u64 extensions;
  1736. #define I915_CONTEXT_CREATE_EXT_SETPARAM 0
  1737. #define I915_CONTEXT_CREATE_EXT_CLONE 1
  1738. };
  1739. /**
  1740. * struct drm_i915_gem_context_param - Context parameter to set or query.
  1741. */
  1742. struct drm_i915_gem_context_param {
  1743. /** @ctx_id: Context id */
  1744. __u32 ctx_id;
  1745. /** @size: Size of the parameter @value */
  1746. __u32 size;
  1747. /** @param: Parameter to set or query */
  1748. __u64 param;
  1749. #define I915_CONTEXT_PARAM_BAN_PERIOD 0x1
  1750. /* I915_CONTEXT_PARAM_NO_ZEROMAP has been removed. On the off chance
  1751. * someone somewhere has attempted to use it, never re-use this context
  1752. * param number.
  1753. */
  1754. #define I915_CONTEXT_PARAM_NO_ZEROMAP 0x2
  1755. #define I915_CONTEXT_PARAM_GTT_SIZE 0x3
  1756. #define I915_CONTEXT_PARAM_NO_ERROR_CAPTURE 0x4
  1757. #define I915_CONTEXT_PARAM_BANNABLE 0x5
  1758. #define I915_CONTEXT_PARAM_PRIORITY 0x6
  1759. #define I915_CONTEXT_MAX_USER_PRIORITY 1023 /* inclusive */
  1760. #define I915_CONTEXT_DEFAULT_PRIORITY 0
  1761. #define I915_CONTEXT_MIN_USER_PRIORITY -1023 /* inclusive */
  1762. /*
  1763. * When using the following param, value should be a pointer to
  1764. * drm_i915_gem_context_param_sseu.
  1765. */
  1766. #define I915_CONTEXT_PARAM_SSEU 0x7
  1767. /*
  1768. * Not all clients may want to attempt automatic recover of a context after
  1769. * a hang (for example, some clients may only submit very small incremental
  1770. * batches relying on known logical state of previous batches which will never
  1771. * recover correctly and each attempt will hang), and so would prefer that
  1772. * the context is forever banned instead.
  1773. *
  1774. * If set to false (0), after a reset, subsequent (and in flight) rendering
  1775. * from this context is discarded, and the client will need to create a new
  1776. * context to use instead.
  1777. *
  1778. * If set to true (1), the kernel will automatically attempt to recover the
  1779. * context by skipping the hanging batch and executing the next batch starting
  1780. * from the default context state (discarding the incomplete logical context
  1781. * state lost due to the reset).
  1782. *
  1783. * On creation, all new contexts are marked as recoverable.
  1784. */
  1785. #define I915_CONTEXT_PARAM_RECOVERABLE 0x8
  1786. /*
  1787. * The id of the associated virtual memory address space (ppGTT) of
  1788. * this context. Can be retrieved and passed to another context
  1789. * (on the same fd) for both to use the same ppGTT and so share
  1790. * address layouts, and avoid reloading the page tables on context
  1791. * switches between themselves.
  1792. *
  1793. * See DRM_I915_GEM_VM_CREATE and DRM_I915_GEM_VM_DESTROY.
  1794. */
  1795. #define I915_CONTEXT_PARAM_VM 0x9
  1796. /*
  1797. * I915_CONTEXT_PARAM_ENGINES:
  1798. *
  1799. * Bind this context to operate on this subset of available engines. Henceforth,
  1800. * the I915_EXEC_RING selector for DRM_IOCTL_I915_GEM_EXECBUFFER2 operates as
  1801. * an index into this array of engines; I915_EXEC_DEFAULT selecting engine[0]
  1802. * and upwards. Slots 0...N are filled in using the specified (class, instance).
  1803. * Use
  1804. * engine_class: I915_ENGINE_CLASS_INVALID,
  1805. * engine_instance: I915_ENGINE_CLASS_INVALID_NONE
  1806. * to specify a gap in the array that can be filled in later, e.g. by a
  1807. * virtual engine used for load balancing.
  1808. *
  1809. * Setting the number of engines bound to the context to 0, by passing a zero
  1810. * sized argument, will revert back to default settings.
  1811. *
  1812. * See struct i915_context_param_engines.
  1813. *
  1814. * Extensions:
  1815. * i915_context_engines_load_balance (I915_CONTEXT_ENGINES_EXT_LOAD_BALANCE)
  1816. * i915_context_engines_bond (I915_CONTEXT_ENGINES_EXT_BOND)
  1817. * i915_context_engines_parallel_submit (I915_CONTEXT_ENGINES_EXT_PARALLEL_SUBMIT)
  1818. */
  1819. #define I915_CONTEXT_PARAM_ENGINES 0xa
  1820. /*
  1821. * I915_CONTEXT_PARAM_PERSISTENCE:
  1822. *
  1823. * Allow the context and active rendering to survive the process until
  1824. * completion. Persistence allows fire-and-forget clients to queue up a
  1825. * bunch of work, hand the output over to a display server and then quit.
  1826. * If the context is marked as not persistent, upon closing (either via
  1827. * an explicit DRM_I915_GEM_CONTEXT_DESTROY or implicitly from file closure
  1828. * or process termination), the context and any outstanding requests will be
  1829. * cancelled (and exported fences for cancelled requests marked as -EIO).
  1830. *
  1831. * By default, new contexts allow persistence.
  1832. */
  1833. #define I915_CONTEXT_PARAM_PERSISTENCE 0xb
  1834. /* This API has been removed. On the off chance someone somewhere has
  1835. * attempted to use it, never re-use this context param number.
  1836. */
  1837. #define I915_CONTEXT_PARAM_RINGSIZE 0xc
  1838. /*
  1839. * I915_CONTEXT_PARAM_PROTECTED_CONTENT:
  1840. *
  1841. * Mark that the context makes use of protected content, which will result
  1842. * in the context being invalidated when the protected content session is.
  1843. * Given that the protected content session is killed on suspend, the device
  1844. * is kept awake for the lifetime of a protected context, so the user should
  1845. * make sure to dispose of them once done.
  1846. * This flag can only be set at context creation time and, when set to true,
  1847. * must be preceded by an explicit setting of I915_CONTEXT_PARAM_RECOVERABLE
  1848. * to false. This flag can't be set to true in conjunction with setting the
  1849. * I915_CONTEXT_PARAM_BANNABLE flag to false. Creation example:
  1850. *
  1851. * .. code-block:: C
  1852. *
  1853. * struct drm_i915_gem_context_create_ext_setparam p_protected = {
  1854. * .base = {
  1855. * .name = I915_CONTEXT_CREATE_EXT_SETPARAM,
  1856. * },
  1857. * .param = {
  1858. * .param = I915_CONTEXT_PARAM_PROTECTED_CONTENT,
  1859. * .value = 1,
  1860. * }
  1861. * };
  1862. * struct drm_i915_gem_context_create_ext_setparam p_norecover = {
  1863. * .base = {
  1864. * .name = I915_CONTEXT_CREATE_EXT_SETPARAM,
  1865. * .next_extension = to_user_pointer(&p_protected),
  1866. * },
  1867. * .param = {
  1868. * .param = I915_CONTEXT_PARAM_RECOVERABLE,
  1869. * .value = 0,
  1870. * }
  1871. * };
  1872. * struct drm_i915_gem_context_create_ext create = {
  1873. * .flags = I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS,
  1874. * .extensions = to_user_pointer(&p_norecover);
  1875. * };
  1876. *
  1877. * ctx_id = gem_context_create_ext(drm_fd, &create);
  1878. *
  1879. * In addition to the normal failure cases, setting this flag during context
  1880. * creation can result in the following errors:
  1881. *
  1882. * -ENODEV: feature not available
  1883. * -EPERM: trying to mark a recoverable or not bannable context as protected
  1884. */
  1885. #define I915_CONTEXT_PARAM_PROTECTED_CONTENT 0xd
  1886. /* Must be kept compact -- no holes and well documented */
  1887. /** @value: Context parameter value to be set or queried */
  1888. __u64 value;
  1889. };
  1890. /*
  1891. * Context SSEU programming
  1892. *
  1893. * It may be necessary for either functional or performance reason to configure
  1894. * a context to run with a reduced number of SSEU (where SSEU stands for Slice/
  1895. * Sub-slice/EU).
  1896. *
  1897. * This is done by configuring SSEU configuration using the below
  1898. * @struct drm_i915_gem_context_param_sseu for every supported engine which
  1899. * userspace intends to use.
  1900. *
  1901. * Not all GPUs or engines support this functionality in which case an error
  1902. * code -ENODEV will be returned.
  1903. *
  1904. * Also, flexibility of possible SSEU configuration permutations varies between
  1905. * GPU generations and software imposed limitations. Requesting such a
  1906. * combination will return an error code of -EINVAL.
  1907. *
  1908. * NOTE: When perf/OA is active the context's SSEU configuration is ignored in
  1909. * favour of a single global setting.
  1910. */
  1911. struct drm_i915_gem_context_param_sseu {
  1912. /*
  1913. * Engine class & instance to be configured or queried.
  1914. */
  1915. struct i915_engine_class_instance engine;
  1916. /*
  1917. * Unknown flags must be cleared to zero.
  1918. */
  1919. __u32 flags;
  1920. #define I915_CONTEXT_SSEU_FLAG_ENGINE_INDEX (1u << 0)
  1921. /*
  1922. * Mask of slices to enable for the context. Valid values are a subset
  1923. * of the bitmask value returned for I915_PARAM_SLICE_MASK.
  1924. */
  1925. __u64 slice_mask;
  1926. /*
  1927. * Mask of subslices to enable for the context. Valid values are a
  1928. * subset of the bitmask value return by I915_PARAM_SUBSLICE_MASK.
  1929. */
  1930. __u64 subslice_mask;
  1931. /*
  1932. * Minimum/Maximum number of EUs to enable per subslice for the
  1933. * context. min_eus_per_subslice must be inferior or equal to
  1934. * max_eus_per_subslice.
  1935. */
  1936. __u16 min_eus_per_subslice;
  1937. __u16 max_eus_per_subslice;
  1938. /*
  1939. * Unused for now. Must be cleared to zero.
  1940. */
  1941. __u32 rsvd;
  1942. };
  1943. /**
  1944. * DOC: Virtual Engine uAPI
  1945. *
  1946. * Virtual engine is a concept where userspace is able to configure a set of
  1947. * physical engines, submit a batch buffer, and let the driver execute it on any
  1948. * engine from the set as it sees fit.
  1949. *
  1950. * This is primarily useful on parts which have multiple instances of a same
  1951. * class engine, like for example GT3+ Skylake parts with their two VCS engines.
  1952. *
  1953. * For instance userspace can enumerate all engines of a certain class using the
  1954. * previously described `Engine Discovery uAPI`_. After that userspace can
  1955. * create a GEM context with a placeholder slot for the virtual engine (using
  1956. * `I915_ENGINE_CLASS_INVALID` and `I915_ENGINE_CLASS_INVALID_NONE` for class
  1957. * and instance respectively) and finally using the
  1958. * `I915_CONTEXT_ENGINES_EXT_LOAD_BALANCE` extension place a virtual engine in
  1959. * the same reserved slot.
  1960. *
  1961. * Example of creating a virtual engine and submitting a batch buffer to it:
  1962. *
  1963. * .. code-block:: C
  1964. *
  1965. * I915_DEFINE_CONTEXT_ENGINES_LOAD_BALANCE(virtual, 2) = {
  1966. * .base.name = I915_CONTEXT_ENGINES_EXT_LOAD_BALANCE,
  1967. * .engine_index = 0, // Place this virtual engine into engine map slot 0
  1968. * .num_siblings = 2,
  1969. * .engines = { { I915_ENGINE_CLASS_VIDEO, 0 },
  1970. * { I915_ENGINE_CLASS_VIDEO, 1 }, },
  1971. * };
  1972. * I915_DEFINE_CONTEXT_PARAM_ENGINES(engines, 1) = {
  1973. * .engines = { { I915_ENGINE_CLASS_INVALID,
  1974. * I915_ENGINE_CLASS_INVALID_NONE } },
  1975. * .extensions = to_user_pointer(&virtual), // Chains after load_balance extension
  1976. * };
  1977. * struct drm_i915_gem_context_create_ext_setparam p_engines = {
  1978. * .base = {
  1979. * .name = I915_CONTEXT_CREATE_EXT_SETPARAM,
  1980. * },
  1981. * .param = {
  1982. * .param = I915_CONTEXT_PARAM_ENGINES,
  1983. * .value = to_user_pointer(&engines),
  1984. * .size = sizeof(engines),
  1985. * },
  1986. * };
  1987. * struct drm_i915_gem_context_create_ext create = {
  1988. * .flags = I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS,
  1989. * .extensions = to_user_pointer(&p_engines);
  1990. * };
  1991. *
  1992. * ctx_id = gem_context_create_ext(drm_fd, &create);
  1993. *
  1994. * // Now we have created a GEM context with its engine map containing a
  1995. * // single virtual engine. Submissions to this slot can go either to
  1996. * // vcs0 or vcs1, depending on the load balancing algorithm used inside
  1997. * // the driver. The load balancing is dynamic from one batch buffer to
  1998. * // another and transparent to userspace.
  1999. *
  2000. * ...
  2001. * execbuf.rsvd1 = ctx_id;
  2002. * execbuf.flags = 0; // Submits to index 0 which is the virtual engine
  2003. * gem_execbuf(drm_fd, &execbuf);
  2004. */
  2005. /*
  2006. * i915_context_engines_load_balance:
  2007. *
  2008. * Enable load balancing across this set of engines.
  2009. *
  2010. * Into the I915_EXEC_DEFAULT slot [0], a virtual engine is created that when
  2011. * used will proxy the execbuffer request onto one of the set of engines
  2012. * in such a way as to distribute the load evenly across the set.
  2013. *
  2014. * The set of engines must be compatible (e.g. the same HW class) as they
  2015. * will share the same logical GPU context and ring.
  2016. *
  2017. * To intermix rendering with the virtual engine and direct rendering onto
  2018. * the backing engines (bypassing the load balancing proxy), the context must
  2019. * be defined to use a single timeline for all engines.
  2020. */
  2021. struct i915_context_engines_load_balance {
  2022. struct i915_user_extension base;
  2023. __u16 engine_index;
  2024. __u16 num_siblings;
  2025. __u32 flags; /* all undefined flags must be zero */
  2026. __u64 mbz64; /* reserved for future use; must be zero */
  2027. struct i915_engine_class_instance engines[];
  2028. } __attribute__((packed));
  2029. #define I915_DEFINE_CONTEXT_ENGINES_LOAD_BALANCE(name__, N__) struct { \
  2030. struct i915_user_extension base; \
  2031. __u16 engine_index; \
  2032. __u16 num_siblings; \
  2033. __u32 flags; \
  2034. __u64 mbz64; \
  2035. struct i915_engine_class_instance engines[N__]; \
  2036. } __attribute__((packed)) name__
  2037. /*
  2038. * i915_context_engines_bond:
  2039. *
  2040. * Constructed bonded pairs for execution within a virtual engine.
  2041. *
  2042. * All engines are equal, but some are more equal than others. Given
  2043. * the distribution of resources in the HW, it may be preferable to run
  2044. * a request on a given subset of engines in parallel to a request on a
  2045. * specific engine. We enable this selection of engines within a virtual
  2046. * engine by specifying bonding pairs, for any given master engine we will
  2047. * only execute on one of the corresponding siblings within the virtual engine.
  2048. *
  2049. * To execute a request in parallel on the master engine and a sibling requires
  2050. * coordination with a I915_EXEC_FENCE_SUBMIT.
  2051. */
  2052. struct i915_context_engines_bond {
  2053. struct i915_user_extension base;
  2054. struct i915_engine_class_instance master;
  2055. __u16 virtual_index; /* index of virtual engine in ctx->engines[] */
  2056. __u16 num_bonds;
  2057. __u64 flags; /* all undefined flags must be zero */
  2058. __u64 mbz64[4]; /* reserved for future use; must be zero */
  2059. struct i915_engine_class_instance engines[];
  2060. } __attribute__((packed));
  2061. #define I915_DEFINE_CONTEXT_ENGINES_BOND(name__, N__) struct { \
  2062. struct i915_user_extension base; \
  2063. struct i915_engine_class_instance master; \
  2064. __u16 virtual_index; \
  2065. __u16 num_bonds; \
  2066. __u64 flags; \
  2067. __u64 mbz64[4]; \
  2068. struct i915_engine_class_instance engines[N__]; \
  2069. } __attribute__((packed)) name__
  2070. /**
  2071. * struct i915_context_engines_parallel_submit - Configure engine for
  2072. * parallel submission.
  2073. *
  2074. * Setup a slot in the context engine map to allow multiple BBs to be submitted
  2075. * in a single execbuf IOCTL. Those BBs will then be scheduled to run on the GPU
  2076. * in parallel. Multiple hardware contexts are created internally in the i915 to
  2077. * run these BBs. Once a slot is configured for N BBs only N BBs can be
  2078. * submitted in each execbuf IOCTL and this is implicit behavior e.g. The user
  2079. * doesn't tell the execbuf IOCTL there are N BBs, the execbuf IOCTL knows how
  2080. * many BBs there are based on the slot's configuration. The N BBs are the last
  2081. * N buffer objects or first N if I915_EXEC_BATCH_FIRST is set.
  2082. *
  2083. * The default placement behavior is to create implicit bonds between each
  2084. * context if each context maps to more than 1 physical engine (e.g. context is
  2085. * a virtual engine). Also we only allow contexts of same engine class and these
  2086. * contexts must be in logically contiguous order. Examples of the placement
  2087. * behavior are described below. Lastly, the default is to not allow BBs to be
  2088. * preempted mid-batch. Rather insert coordinated preemption points on all
  2089. * hardware contexts between each set of BBs. Flags could be added in the future
  2090. * to change both of these default behaviors.
  2091. *
  2092. * Returns -EINVAL if hardware context placement configuration is invalid or if
  2093. * the placement configuration isn't supported on the platform / submission
  2094. * interface.
  2095. * Returns -ENODEV if extension isn't supported on the platform / submission
  2096. * interface.
  2097. *
  2098. * .. code-block:: none
  2099. *
  2100. * Examples syntax:
  2101. * CS[X] = generic engine of same class, logical instance X
  2102. * INVALID = I915_ENGINE_CLASS_INVALID, I915_ENGINE_CLASS_INVALID_NONE
  2103. *
  2104. * Example 1 pseudo code:
  2105. * set_engines(INVALID)
  2106. * set_parallel(engine_index=0, width=2, num_siblings=1,
  2107. * engines=CS[0],CS[1])
  2108. *
  2109. * Results in the following valid placement:
  2110. * CS[0], CS[1]
  2111. *
  2112. * Example 2 pseudo code:
  2113. * set_engines(INVALID)
  2114. * set_parallel(engine_index=0, width=2, num_siblings=2,
  2115. * engines=CS[0],CS[2],CS[1],CS[3])
  2116. *
  2117. * Results in the following valid placements:
  2118. * CS[0], CS[1]
  2119. * CS[2], CS[3]
  2120. *
  2121. * This can be thought of as two virtual engines, each containing two
  2122. * engines thereby making a 2D array. However, there are bonds tying the
  2123. * entries together and placing restrictions on how they can be scheduled.
  2124. * Specifically, the scheduler can choose only vertical columns from the 2D
  2125. * array. That is, CS[0] is bonded to CS[1] and CS[2] to CS[3]. So if the
  2126. * scheduler wants to submit to CS[0], it must also choose CS[1] and vice
  2127. * versa. Same for CS[2] requires also using CS[3].
  2128. * VE[0] = CS[0], CS[2]
  2129. * VE[1] = CS[1], CS[3]
  2130. *
  2131. * Example 3 pseudo code:
  2132. * set_engines(INVALID)
  2133. * set_parallel(engine_index=0, width=2, num_siblings=2,
  2134. * engines=CS[0],CS[1],CS[1],CS[3])
  2135. *
  2136. * Results in the following valid and invalid placements:
  2137. * CS[0], CS[1]
  2138. * CS[1], CS[3] - Not logically contiguous, return -EINVAL
  2139. */
  2140. struct i915_context_engines_parallel_submit {
  2141. /**
  2142. * @base: base user extension.
  2143. */
  2144. struct i915_user_extension base;
  2145. /**
  2146. * @engine_index: slot for parallel engine
  2147. */
  2148. __u16 engine_index;
  2149. /**
  2150. * @width: number of contexts per parallel engine or in other words the
  2151. * number of batches in each submission
  2152. */
  2153. __u16 width;
  2154. /**
  2155. * @num_siblings: number of siblings per context or in other words the
  2156. * number of possible placements for each submission
  2157. */
  2158. __u16 num_siblings;
  2159. /**
  2160. * @mbz16: reserved for future use; must be zero
  2161. */
  2162. __u16 mbz16;
  2163. /**
  2164. * @flags: all undefined flags must be zero, currently not defined flags
  2165. */
  2166. __u64 flags;
  2167. /**
  2168. * @mbz64: reserved for future use; must be zero
  2169. */
  2170. __u64 mbz64[3];
  2171. /**
  2172. * @engines: 2-d array of engine instances to configure parallel engine
  2173. *
  2174. * length = width (i) * num_siblings (j)
  2175. * index = j + i * num_siblings
  2176. */
  2177. struct i915_engine_class_instance engines[];
  2178. } __packed;
  2179. #define I915_DEFINE_CONTEXT_ENGINES_PARALLEL_SUBMIT(name__, N__) struct { \
  2180. struct i915_user_extension base; \
  2181. __u16 engine_index; \
  2182. __u16 width; \
  2183. __u16 num_siblings; \
  2184. __u16 mbz16; \
  2185. __u64 flags; \
  2186. __u64 mbz64[3]; \
  2187. struct i915_engine_class_instance engines[N__]; \
  2188. } __attribute__((packed)) name__
  2189. /**
  2190. * DOC: Context Engine Map uAPI
  2191. *
  2192. * Context engine map is a new way of addressing engines when submitting batch-
  2193. * buffers, replacing the existing way of using identifiers like `I915_EXEC_BLT`
  2194. * inside the flags field of `struct drm_i915_gem_execbuffer2`.
  2195. *
  2196. * To use it created GEM contexts need to be configured with a list of engines
  2197. * the user is intending to submit to. This is accomplished using the
  2198. * `I915_CONTEXT_PARAM_ENGINES` parameter and `struct
  2199. * i915_context_param_engines`.
  2200. *
  2201. * For such contexts the `I915_EXEC_RING_MASK` field becomes an index into the
  2202. * configured map.
  2203. *
  2204. * Example of creating such context and submitting against it:
  2205. *
  2206. * .. code-block:: C
  2207. *
  2208. * I915_DEFINE_CONTEXT_PARAM_ENGINES(engines, 2) = {
  2209. * .engines = { { I915_ENGINE_CLASS_RENDER, 0 },
  2210. * { I915_ENGINE_CLASS_COPY, 0 } }
  2211. * };
  2212. * struct drm_i915_gem_context_create_ext_setparam p_engines = {
  2213. * .base = {
  2214. * .name = I915_CONTEXT_CREATE_EXT_SETPARAM,
  2215. * },
  2216. * .param = {
  2217. * .param = I915_CONTEXT_PARAM_ENGINES,
  2218. * .value = to_user_pointer(&engines),
  2219. * .size = sizeof(engines),
  2220. * },
  2221. * };
  2222. * struct drm_i915_gem_context_create_ext create = {
  2223. * .flags = I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS,
  2224. * .extensions = to_user_pointer(&p_engines);
  2225. * };
  2226. *
  2227. * ctx_id = gem_context_create_ext(drm_fd, &create);
  2228. *
  2229. * // We have now created a GEM context with two engines in the map:
  2230. * // Index 0 points to rcs0 while index 1 points to bcs0. Other engines
  2231. * // will not be accessible from this context.
  2232. *
  2233. * ...
  2234. * execbuf.rsvd1 = ctx_id;
  2235. * execbuf.flags = 0; // Submits to index 0, which is rcs0 for this context
  2236. * gem_execbuf(drm_fd, &execbuf);
  2237. *
  2238. * ...
  2239. * execbuf.rsvd1 = ctx_id;
  2240. * execbuf.flags = 1; // Submits to index 0, which is bcs0 for this context
  2241. * gem_execbuf(drm_fd, &execbuf);
  2242. */
  2243. struct i915_context_param_engines {
  2244. __u64 extensions; /* linked chain of extension blocks, 0 terminates */
  2245. #define I915_CONTEXT_ENGINES_EXT_LOAD_BALANCE 0 /* see i915_context_engines_load_balance */
  2246. #define I915_CONTEXT_ENGINES_EXT_BOND 1 /* see i915_context_engines_bond */
  2247. #define I915_CONTEXT_ENGINES_EXT_PARALLEL_SUBMIT 2 /* see i915_context_engines_parallel_submit */
  2248. struct i915_engine_class_instance engines[0];
  2249. } __attribute__((packed));
  2250. #define I915_DEFINE_CONTEXT_PARAM_ENGINES(name__, N__) struct { \
  2251. __u64 extensions; \
  2252. struct i915_engine_class_instance engines[N__]; \
  2253. } __attribute__((packed)) name__
  2254. /**
  2255. * struct drm_i915_gem_context_create_ext_setparam - Context parameter
  2256. * to set or query during context creation.
  2257. */
  2258. struct drm_i915_gem_context_create_ext_setparam {
  2259. /** @base: Extension link. See struct i915_user_extension. */
  2260. struct i915_user_extension base;
  2261. /**
  2262. * @param: Context parameter to set or query.
  2263. * See struct drm_i915_gem_context_param.
  2264. */
  2265. struct drm_i915_gem_context_param param;
  2266. };
  2267. struct drm_i915_gem_context_destroy {
  2268. __u32 ctx_id;
  2269. __u32 pad;
  2270. };
  2271. /**
  2272. * struct drm_i915_gem_vm_control - Structure to create or destroy VM.
  2273. *
  2274. * DRM_I915_GEM_VM_CREATE -
  2275. *
  2276. * Create a new virtual memory address space (ppGTT) for use within a context
  2277. * on the same file. Extensions can be provided to configure exactly how the
  2278. * address space is setup upon creation.
  2279. *
  2280. * The id of new VM (bound to the fd) for use with I915_CONTEXT_PARAM_VM is
  2281. * returned in the outparam @id.
  2282. *
  2283. * An extension chain maybe provided, starting with @extensions, and terminated
  2284. * by the @next_extension being 0. Currently, no extensions are defined.
  2285. *
  2286. * DRM_I915_GEM_VM_DESTROY -
  2287. *
  2288. * Destroys a previously created VM id, specified in @vm_id.
  2289. *
  2290. * No extensions or flags are allowed currently, and so must be zero.
  2291. */
  2292. struct drm_i915_gem_vm_control {
  2293. /** @extensions: Zero-terminated chain of extensions. */
  2294. __u64 extensions;
  2295. /** @flags: reserved for future usage, currently MBZ */
  2296. __u32 flags;
  2297. /** @vm_id: Id of the VM created or to be destroyed */
  2298. __u32 vm_id;
  2299. };
  2300. struct drm_i915_reg_read {
  2301. /*
  2302. * Register offset.
  2303. * For 64bit wide registers where the upper 32bits don't immediately
  2304. * follow the lower 32bits, the offset of the lower 32bits must
  2305. * be specified
  2306. */
  2307. __u64 offset;
  2308. #define I915_REG_READ_8B_WA (1ul << 0)
  2309. __u64 val; /* Return value */
  2310. };
  2311. /* Known registers:
  2312. *
  2313. * Render engine timestamp - 0x2358 + 64bit - gen7+
  2314. * - Note this register returns an invalid value if using the default
  2315. * single instruction 8byte read, in order to workaround that pass
  2316. * flag I915_REG_READ_8B_WA in offset field.
  2317. *
  2318. */
  2319. struct drm_i915_reset_stats {
  2320. __u32 ctx_id;
  2321. __u32 flags;
  2322. /* All resets since boot/module reload, for all contexts */
  2323. __u32 reset_count;
  2324. /* Number of batches lost when active in GPU, for this context */
  2325. __u32 batch_active;
  2326. /* Number of batches lost pending for execution, for this context */
  2327. __u32 batch_pending;
  2328. __u32 pad;
  2329. };
  2330. /**
  2331. * struct drm_i915_gem_userptr - Create GEM object from user allocated memory.
  2332. *
  2333. * Userptr objects have several restrictions on what ioctls can be used with the
  2334. * object handle.
  2335. */
  2336. struct drm_i915_gem_userptr {
  2337. /**
  2338. * @user_ptr: The pointer to the allocated memory.
  2339. *
  2340. * Needs to be aligned to PAGE_SIZE.
  2341. */
  2342. __u64 user_ptr;
  2343. /**
  2344. * @user_size:
  2345. *
  2346. * The size in bytes for the allocated memory. This will also become the
  2347. * object size.
  2348. *
  2349. * Needs to be aligned to PAGE_SIZE, and should be at least PAGE_SIZE,
  2350. * or larger.
  2351. */
  2352. __u64 user_size;
  2353. /**
  2354. * @flags:
  2355. *
  2356. * Supported flags:
  2357. *
  2358. * I915_USERPTR_READ_ONLY:
  2359. *
  2360. * Mark the object as readonly, this also means GPU access can only be
  2361. * readonly. This is only supported on HW which supports readonly access
  2362. * through the GTT. If the HW can't support readonly access, an error is
  2363. * returned.
  2364. *
  2365. * I915_USERPTR_PROBE:
  2366. *
  2367. * Probe the provided @user_ptr range and validate that the @user_ptr is
  2368. * indeed pointing to normal memory and that the range is also valid.
  2369. * For example if some garbage address is given to the kernel, then this
  2370. * should complain.
  2371. *
  2372. * Returns -EFAULT if the probe failed.
  2373. *
  2374. * Note that this doesn't populate the backing pages, and also doesn't
  2375. * guarantee that the object will remain valid when the object is
  2376. * eventually used.
  2377. *
  2378. * The kernel supports this feature if I915_PARAM_HAS_USERPTR_PROBE
  2379. * returns a non-zero value.
  2380. *
  2381. * I915_USERPTR_UNSYNCHRONIZED:
  2382. *
  2383. * NOT USED. Setting this flag will result in an error.
  2384. */
  2385. __u32 flags;
  2386. #define I915_USERPTR_READ_ONLY 0x1
  2387. #define I915_USERPTR_PROBE 0x2
  2388. #define I915_USERPTR_UNSYNCHRONIZED 0x80000000
  2389. /**
  2390. * @handle: Returned handle for the object.
  2391. *
  2392. * Object handles are nonzero.
  2393. */
  2394. __u32 handle;
  2395. };
  2396. enum drm_i915_oa_format {
  2397. I915_OA_FORMAT_A13 = 1, /* HSW only */
  2398. I915_OA_FORMAT_A29, /* HSW only */
  2399. I915_OA_FORMAT_A13_B8_C8, /* HSW only */
  2400. I915_OA_FORMAT_B4_C8, /* HSW only */
  2401. I915_OA_FORMAT_A45_B8_C8, /* HSW only */
  2402. I915_OA_FORMAT_B4_C8_A16, /* HSW only */
  2403. I915_OA_FORMAT_C4_B8, /* HSW+ */
  2404. /* Gen8+ */
  2405. I915_OA_FORMAT_A12,
  2406. I915_OA_FORMAT_A12_B8_C8,
  2407. I915_OA_FORMAT_A32u40_A4u32_B8_C8,
  2408. I915_OA_FORMAT_MAX /* non-ABI */
  2409. };
  2410. enum drm_i915_perf_property_id {
  2411. /**
  2412. * Open the stream for a specific context handle (as used with
  2413. * execbuffer2). A stream opened for a specific context this way
  2414. * won't typically require root privileges.
  2415. *
  2416. * This property is available in perf revision 1.
  2417. */
  2418. DRM_I915_PERF_PROP_CTX_HANDLE = 1,
  2419. /**
  2420. * A value of 1 requests the inclusion of raw OA unit reports as
  2421. * part of stream samples.
  2422. *
  2423. * This property is available in perf revision 1.
  2424. */
  2425. DRM_I915_PERF_PROP_SAMPLE_OA,
  2426. /**
  2427. * The value specifies which set of OA unit metrics should be
  2428. * configured, defining the contents of any OA unit reports.
  2429. *
  2430. * This property is available in perf revision 1.
  2431. */
  2432. DRM_I915_PERF_PROP_OA_METRICS_SET,
  2433. /**
  2434. * The value specifies the size and layout of OA unit reports.
  2435. *
  2436. * This property is available in perf revision 1.
  2437. */
  2438. DRM_I915_PERF_PROP_OA_FORMAT,
  2439. /**
  2440. * Specifying this property implicitly requests periodic OA unit
  2441. * sampling and (at least on Haswell) the sampling frequency is derived
  2442. * from this exponent as follows:
  2443. *
  2444. * 80ns * 2^(period_exponent + 1)
  2445. *
  2446. * This property is available in perf revision 1.
  2447. */
  2448. DRM_I915_PERF_PROP_OA_EXPONENT,
  2449. /**
  2450. * Specifying this property is only valid when specify a context to
  2451. * filter with DRM_I915_PERF_PROP_CTX_HANDLE. Specifying this property
  2452. * will hold preemption of the particular context we want to gather
  2453. * performance data about. The execbuf2 submissions must include a
  2454. * drm_i915_gem_execbuffer_ext_perf parameter for this to apply.
  2455. *
  2456. * This property is available in perf revision 3.
  2457. */
  2458. DRM_I915_PERF_PROP_HOLD_PREEMPTION,
  2459. /**
  2460. * Specifying this pins all contexts to the specified SSEU power
  2461. * configuration for the duration of the recording.
  2462. *
  2463. * This parameter's value is a pointer to a struct
  2464. * drm_i915_gem_context_param_sseu.
  2465. *
  2466. * This property is available in perf revision 4.
  2467. */
  2468. DRM_I915_PERF_PROP_GLOBAL_SSEU,
  2469. /**
  2470. * This optional parameter specifies the timer interval in nanoseconds
  2471. * at which the i915 driver will check the OA buffer for available data.
  2472. * Minimum allowed value is 100 microseconds. A default value is used by
  2473. * the driver if this parameter is not specified. Note that larger timer
  2474. * values will reduce cpu consumption during OA perf captures. However,
  2475. * excessively large values would potentially result in OA buffer
  2476. * overwrites as captures reach end of the OA buffer.
  2477. *
  2478. * This property is available in perf revision 5.
  2479. */
  2480. DRM_I915_PERF_PROP_POLL_OA_PERIOD,
  2481. DRM_I915_PERF_PROP_MAX /* non-ABI */
  2482. };
  2483. struct drm_i915_perf_open_param {
  2484. __u32 flags;
  2485. #define I915_PERF_FLAG_FD_CLOEXEC (1<<0)
  2486. #define I915_PERF_FLAG_FD_NONBLOCK (1<<1)
  2487. #define I915_PERF_FLAG_DISABLED (1<<2)
  2488. /** The number of u64 (id, value) pairs */
  2489. __u32 num_properties;
  2490. /**
  2491. * Pointer to array of u64 (id, value) pairs configuring the stream
  2492. * to open.
  2493. */
  2494. __u64 properties_ptr;
  2495. };
  2496. /*
  2497. * Enable data capture for a stream that was either opened in a disabled state
  2498. * via I915_PERF_FLAG_DISABLED or was later disabled via
  2499. * I915_PERF_IOCTL_DISABLE.
  2500. *
  2501. * It is intended to be cheaper to disable and enable a stream than it may be
  2502. * to close and re-open a stream with the same configuration.
  2503. *
  2504. * It's undefined whether any pending data for the stream will be lost.
  2505. *
  2506. * This ioctl is available in perf revision 1.
  2507. */
  2508. #define I915_PERF_IOCTL_ENABLE _IO('i', 0x0)
  2509. /*
  2510. * Disable data capture for a stream.
  2511. *
  2512. * It is an error to try and read a stream that is disabled.
  2513. *
  2514. * This ioctl is available in perf revision 1.
  2515. */
  2516. #define I915_PERF_IOCTL_DISABLE _IO('i', 0x1)
  2517. /*
  2518. * Change metrics_set captured by a stream.
  2519. *
  2520. * If the stream is bound to a specific context, the configuration change
  2521. * will performed inline with that context such that it takes effect before
  2522. * the next execbuf submission.
  2523. *
  2524. * Returns the previously bound metrics set id, or a negative error code.
  2525. *
  2526. * This ioctl is available in perf revision 2.
  2527. */
  2528. #define I915_PERF_IOCTL_CONFIG _IO('i', 0x2)
  2529. /*
  2530. * Common to all i915 perf records
  2531. */
  2532. struct drm_i915_perf_record_header {
  2533. __u32 type;
  2534. __u16 pad;
  2535. __u16 size;
  2536. };
  2537. enum drm_i915_perf_record_type {
  2538. /**
  2539. * Samples are the work horse record type whose contents are extensible
  2540. * and defined when opening an i915 perf stream based on the given
  2541. * properties.
  2542. *
  2543. * Boolean properties following the naming convention
  2544. * DRM_I915_PERF_SAMPLE_xyz_PROP request the inclusion of 'xyz' data in
  2545. * every sample.
  2546. *
  2547. * The order of these sample properties given by userspace has no
  2548. * affect on the ordering of data within a sample. The order is
  2549. * documented here.
  2550. *
  2551. * struct {
  2552. * struct drm_i915_perf_record_header header;
  2553. *
  2554. * { u32 oa_report[]; } && DRM_I915_PERF_PROP_SAMPLE_OA
  2555. * };
  2556. */
  2557. DRM_I915_PERF_RECORD_SAMPLE = 1,
  2558. /*
  2559. * Indicates that one or more OA reports were not written by the
  2560. * hardware. This can happen for example if an MI_REPORT_PERF_COUNT
  2561. * command collides with periodic sampling - which would be more likely
  2562. * at higher sampling frequencies.
  2563. */
  2564. DRM_I915_PERF_RECORD_OA_REPORT_LOST = 2,
  2565. /**
  2566. * An error occurred that resulted in all pending OA reports being lost.
  2567. */
  2568. DRM_I915_PERF_RECORD_OA_BUFFER_LOST = 3,
  2569. DRM_I915_PERF_RECORD_MAX /* non-ABI */
  2570. };
  2571. /**
  2572. * struct drm_i915_perf_oa_config
  2573. *
  2574. * Structure to upload perf dynamic configuration into the kernel.
  2575. */
  2576. struct drm_i915_perf_oa_config {
  2577. /**
  2578. * @uuid:
  2579. *
  2580. * String formatted like "%\08x-%\04x-%\04x-%\04x-%\012x"
  2581. */
  2582. char uuid[36];
  2583. /**
  2584. * @n_mux_regs:
  2585. *
  2586. * Number of mux regs in &mux_regs_ptr.
  2587. */
  2588. __u32 n_mux_regs;
  2589. /**
  2590. * @n_boolean_regs:
  2591. *
  2592. * Number of boolean regs in &boolean_regs_ptr.
  2593. */
  2594. __u32 n_boolean_regs;
  2595. /**
  2596. * @n_flex_regs:
  2597. *
  2598. * Number of flex regs in &flex_regs_ptr.
  2599. */
  2600. __u32 n_flex_regs;
  2601. /**
  2602. * @mux_regs_ptr:
  2603. *
  2604. * Pointer to tuples of u32 values (register address, value) for mux
  2605. * registers. Expected length of buffer is (2 * sizeof(u32) *
  2606. * &n_mux_regs).
  2607. */
  2608. __u64 mux_regs_ptr;
  2609. /**
  2610. * @boolean_regs_ptr:
  2611. *
  2612. * Pointer to tuples of u32 values (register address, value) for mux
  2613. * registers. Expected length of buffer is (2 * sizeof(u32) *
  2614. * &n_boolean_regs).
  2615. */
  2616. __u64 boolean_regs_ptr;
  2617. /**
  2618. * @flex_regs_ptr:
  2619. *
  2620. * Pointer to tuples of u32 values (register address, value) for mux
  2621. * registers. Expected length of buffer is (2 * sizeof(u32) *
  2622. * &n_flex_regs).
  2623. */
  2624. __u64 flex_regs_ptr;
  2625. };
  2626. /**
  2627. * struct drm_i915_query_item - An individual query for the kernel to process.
  2628. *
  2629. * The behaviour is determined by the @query_id. Note that exactly what
  2630. * @data_ptr is also depends on the specific @query_id.
  2631. */
  2632. struct drm_i915_query_item {
  2633. /**
  2634. * @query_id:
  2635. *
  2636. * The id for this query. Currently accepted query IDs are:
  2637. * - %DRM_I915_QUERY_TOPOLOGY_INFO (see struct drm_i915_query_topology_info)
  2638. * - %DRM_I915_QUERY_ENGINE_INFO (see struct drm_i915_engine_info)
  2639. * - %DRM_I915_QUERY_PERF_CONFIG (see struct drm_i915_query_perf_config)
  2640. * - %DRM_I915_QUERY_MEMORY_REGIONS (see struct drm_i915_query_memory_regions)
  2641. * - %DRM_I915_QUERY_HWCONFIG_BLOB (see `GuC HWCONFIG blob uAPI`)
  2642. * - %DRM_I915_QUERY_GEOMETRY_SUBSLICES (see struct drm_i915_query_topology_info)
  2643. */
  2644. __u64 query_id;
  2645. #define DRM_I915_QUERY_TOPOLOGY_INFO 1
  2646. #define DRM_I915_QUERY_ENGINE_INFO 2
  2647. #define DRM_I915_QUERY_PERF_CONFIG 3
  2648. #define DRM_I915_QUERY_MEMORY_REGIONS 4
  2649. #define DRM_I915_QUERY_HWCONFIG_BLOB 5
  2650. #define DRM_I915_QUERY_GEOMETRY_SUBSLICES 6
  2651. /* Must be kept compact -- no holes and well documented */
  2652. /**
  2653. * @length:
  2654. *
  2655. * When set to zero by userspace, this is filled with the size of the
  2656. * data to be written at the @data_ptr pointer. The kernel sets this
  2657. * value to a negative value to signal an error on a particular query
  2658. * item.
  2659. */
  2660. __s32 length;
  2661. /**
  2662. * @flags:
  2663. *
  2664. * When &query_id == %DRM_I915_QUERY_TOPOLOGY_INFO, must be 0.
  2665. *
  2666. * When &query_id == %DRM_I915_QUERY_PERF_CONFIG, must be one of the
  2667. * following:
  2668. *
  2669. * - %DRM_I915_QUERY_PERF_CONFIG_LIST
  2670. * - %DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_UUID
  2671. * - %DRM_I915_QUERY_PERF_CONFIG_FOR_UUID
  2672. *
  2673. * When &query_id == %DRM_I915_QUERY_GEOMETRY_SUBSLICES must contain
  2674. * a struct i915_engine_class_instance that references a render engine.
  2675. */
  2676. __u32 flags;
  2677. #define DRM_I915_QUERY_PERF_CONFIG_LIST 1
  2678. #define DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_UUID 2
  2679. #define DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_ID 3
  2680. /**
  2681. * @data_ptr:
  2682. *
  2683. * Data will be written at the location pointed by @data_ptr when the
  2684. * value of @length matches the length of the data to be written by the
  2685. * kernel.
  2686. */
  2687. __u64 data_ptr;
  2688. };
  2689. /**
  2690. * struct drm_i915_query - Supply an array of struct drm_i915_query_item for the
  2691. * kernel to fill out.
  2692. *
  2693. * Note that this is generally a two step process for each struct
  2694. * drm_i915_query_item in the array:
  2695. *
  2696. * 1. Call the DRM_IOCTL_I915_QUERY, giving it our array of struct
  2697. * drm_i915_query_item, with &drm_i915_query_item.length set to zero. The
  2698. * kernel will then fill in the size, in bytes, which tells userspace how
  2699. * memory it needs to allocate for the blob(say for an array of properties).
  2700. *
  2701. * 2. Next we call DRM_IOCTL_I915_QUERY again, this time with the
  2702. * &drm_i915_query_item.data_ptr equal to our newly allocated blob. Note that
  2703. * the &drm_i915_query_item.length should still be the same as what the
  2704. * kernel previously set. At this point the kernel can fill in the blob.
  2705. *
  2706. * Note that for some query items it can make sense for userspace to just pass
  2707. * in a buffer/blob equal to or larger than the required size. In this case only
  2708. * a single ioctl call is needed. For some smaller query items this can work
  2709. * quite well.
  2710. *
  2711. */
  2712. struct drm_i915_query {
  2713. /** @num_items: The number of elements in the @items_ptr array */
  2714. __u32 num_items;
  2715. /**
  2716. * @flags: Unused for now. Must be cleared to zero.
  2717. */
  2718. __u32 flags;
  2719. /**
  2720. * @items_ptr:
  2721. *
  2722. * Pointer to an array of struct drm_i915_query_item. The number of
  2723. * array elements is @num_items.
  2724. */
  2725. __u64 items_ptr;
  2726. };
  2727. /**
  2728. * struct drm_i915_query_topology_info
  2729. *
  2730. * Describes slice/subslice/EU information queried by
  2731. * %DRM_I915_QUERY_TOPOLOGY_INFO
  2732. */
  2733. struct drm_i915_query_topology_info {
  2734. /**
  2735. * @flags:
  2736. *
  2737. * Unused for now. Must be cleared to zero.
  2738. */
  2739. __u16 flags;
  2740. /**
  2741. * @max_slices:
  2742. *
  2743. * The number of bits used to express the slice mask.
  2744. */
  2745. __u16 max_slices;
  2746. /**
  2747. * @max_subslices:
  2748. *
  2749. * The number of bits used to express the subslice mask.
  2750. */
  2751. __u16 max_subslices;
  2752. /**
  2753. * @max_eus_per_subslice:
  2754. *
  2755. * The number of bits in the EU mask that correspond to a single
  2756. * subslice's EUs.
  2757. */
  2758. __u16 max_eus_per_subslice;
  2759. /**
  2760. * @subslice_offset:
  2761. *
  2762. * Offset in data[] at which the subslice masks are stored.
  2763. */
  2764. __u16 subslice_offset;
  2765. /**
  2766. * @subslice_stride:
  2767. *
  2768. * Stride at which each of the subslice masks for each slice are
  2769. * stored.
  2770. */
  2771. __u16 subslice_stride;
  2772. /**
  2773. * @eu_offset:
  2774. *
  2775. * Offset in data[] at which the EU masks are stored.
  2776. */
  2777. __u16 eu_offset;
  2778. /**
  2779. * @eu_stride:
  2780. *
  2781. * Stride at which each of the EU masks for each subslice are stored.
  2782. */
  2783. __u16 eu_stride;
  2784. /**
  2785. * @data:
  2786. *
  2787. * Contains 3 pieces of information :
  2788. *
  2789. * - The slice mask with one bit per slice telling whether a slice is
  2790. * available. The availability of slice X can be queried with the
  2791. * following formula :
  2792. *
  2793. * .. code:: c
  2794. *
  2795. * (data[X / 8] >> (X % 8)) & 1
  2796. *
  2797. * Starting with Xe_HP platforms, Intel hardware no longer has
  2798. * traditional slices so i915 will always report a single slice
  2799. * (hardcoded slicemask = 0x1) which contains all of the platform's
  2800. * subslices. I.e., the mask here does not reflect any of the newer
  2801. * hardware concepts such as "gslices" or "cslices" since userspace
  2802. * is capable of inferring those from the subslice mask.
  2803. *
  2804. * - The subslice mask for each slice with one bit per subslice telling
  2805. * whether a subslice is available. Starting with Gen12 we use the
  2806. * term "subslice" to refer to what the hardware documentation
  2807. * describes as a "dual-subslices." The availability of subslice Y
  2808. * in slice X can be queried with the following formula :
  2809. *
  2810. * .. code:: c
  2811. *
  2812. * (data[subslice_offset + X * subslice_stride + Y / 8] >> (Y % 8)) & 1
  2813. *
  2814. * - The EU mask for each subslice in each slice, with one bit per EU
  2815. * telling whether an EU is available. The availability of EU Z in
  2816. * subslice Y in slice X can be queried with the following formula :
  2817. *
  2818. * .. code:: c
  2819. *
  2820. * (data[eu_offset +
  2821. * (X * max_subslices + Y) * eu_stride +
  2822. * Z / 8
  2823. * ] >> (Z % 8)) & 1
  2824. */
  2825. __u8 data[];
  2826. };
  2827. /**
  2828. * DOC: Engine Discovery uAPI
  2829. *
  2830. * Engine discovery uAPI is a way of enumerating physical engines present in a
  2831. * GPU associated with an open i915 DRM file descriptor. This supersedes the old
  2832. * way of using `DRM_IOCTL_I915_GETPARAM` and engine identifiers like
  2833. * `I915_PARAM_HAS_BLT`.
  2834. *
  2835. * The need for this interface came starting with Icelake and newer GPUs, which
  2836. * started to establish a pattern of having multiple engines of a same class,
  2837. * where not all instances were always completely functionally equivalent.
  2838. *
  2839. * Entry point for this uapi is `DRM_IOCTL_I915_QUERY` with the
  2840. * `DRM_I915_QUERY_ENGINE_INFO` as the queried item id.
  2841. *
  2842. * Example for getting the list of engines:
  2843. *
  2844. * .. code-block:: C
  2845. *
  2846. * struct drm_i915_query_engine_info *info;
  2847. * struct drm_i915_query_item item = {
  2848. * .query_id = DRM_I915_QUERY_ENGINE_INFO;
  2849. * };
  2850. * struct drm_i915_query query = {
  2851. * .num_items = 1,
  2852. * .items_ptr = (uintptr_t)&item,
  2853. * };
  2854. * int err, i;
  2855. *
  2856. * // First query the size of the blob we need, this needs to be large
  2857. * // enough to hold our array of engines. The kernel will fill out the
  2858. * // item.length for us, which is the number of bytes we need.
  2859. * //
  2860. * // Alternatively a large buffer can be allocated straight away enabling
  2861. * // querying in one pass, in which case item.length should contain the
  2862. * // length of the provided buffer.
  2863. * err = ioctl(fd, DRM_IOCTL_I915_QUERY, &query);
  2864. * if (err) ...
  2865. *
  2866. * info = calloc(1, item.length);
  2867. * // Now that we allocated the required number of bytes, we call the ioctl
  2868. * // again, this time with the data_ptr pointing to our newly allocated
  2869. * // blob, which the kernel can then populate with info on all engines.
  2870. * item.data_ptr = (uintptr_t)&info,
  2871. *
  2872. * err = ioctl(fd, DRM_IOCTL_I915_QUERY, &query);
  2873. * if (err) ...
  2874. *
  2875. * // We can now access each engine in the array
  2876. * for (i = 0; i < info->num_engines; i++) {
  2877. * struct drm_i915_engine_info einfo = info->engines[i];
  2878. * u16 class = einfo.engine.class;
  2879. * u16 instance = einfo.engine.instance;
  2880. * ....
  2881. * }
  2882. *
  2883. * free(info);
  2884. *
  2885. * Each of the enumerated engines, apart from being defined by its class and
  2886. * instance (see `struct i915_engine_class_instance`), also can have flags and
  2887. * capabilities defined as documented in i915_drm.h.
  2888. *
  2889. * For instance video engines which support HEVC encoding will have the
  2890. * `I915_VIDEO_CLASS_CAPABILITY_HEVC` capability bit set.
  2891. *
  2892. * Engine discovery only fully comes to its own when combined with the new way
  2893. * of addressing engines when submitting batch buffers using contexts with
  2894. * engine maps configured.
  2895. */
  2896. /**
  2897. * struct drm_i915_engine_info
  2898. *
  2899. * Describes one engine and it's capabilities as known to the driver.
  2900. */
  2901. struct drm_i915_engine_info {
  2902. /** @engine: Engine class and instance. */
  2903. struct i915_engine_class_instance engine;
  2904. /** @rsvd0: Reserved field. */
  2905. __u32 rsvd0;
  2906. /** @flags: Engine flags. */
  2907. __u64 flags;
  2908. #define I915_ENGINE_INFO_HAS_LOGICAL_INSTANCE (1 << 0)
  2909. /** @capabilities: Capabilities of this engine. */
  2910. __u64 capabilities;
  2911. #define I915_VIDEO_CLASS_CAPABILITY_HEVC (1 << 0)
  2912. #define I915_VIDEO_AND_ENHANCE_CLASS_CAPABILITY_SFC (1 << 1)
  2913. /** @logical_instance: Logical instance of engine */
  2914. __u16 logical_instance;
  2915. /** @rsvd1: Reserved fields. */
  2916. __u16 rsvd1[3];
  2917. /** @rsvd2: Reserved fields. */
  2918. __u64 rsvd2[3];
  2919. };
  2920. /**
  2921. * struct drm_i915_query_engine_info
  2922. *
  2923. * Engine info query enumerates all engines known to the driver by filling in
  2924. * an array of struct drm_i915_engine_info structures.
  2925. */
  2926. struct drm_i915_query_engine_info {
  2927. /** @num_engines: Number of struct drm_i915_engine_info structs following. */
  2928. __u32 num_engines;
  2929. /** @rsvd: MBZ */
  2930. __u32 rsvd[3];
  2931. /** @engines: Marker for drm_i915_engine_info structures. */
  2932. struct drm_i915_engine_info engines[];
  2933. };
  2934. /**
  2935. * struct drm_i915_query_perf_config
  2936. *
  2937. * Data written by the kernel with query %DRM_I915_QUERY_PERF_CONFIG and
  2938. * %DRM_I915_QUERY_GEOMETRY_SUBSLICES.
  2939. */
  2940. struct drm_i915_query_perf_config {
  2941. union {
  2942. /**
  2943. * @n_configs:
  2944. *
  2945. * When &drm_i915_query_item.flags ==
  2946. * %DRM_I915_QUERY_PERF_CONFIG_LIST, i915 sets this fields to
  2947. * the number of configurations available.
  2948. */
  2949. __u64 n_configs;
  2950. /**
  2951. * @config:
  2952. *
  2953. * When &drm_i915_query_item.flags ==
  2954. * %DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_ID, i915 will use the
  2955. * value in this field as configuration identifier to decide
  2956. * what data to write into config_ptr.
  2957. */
  2958. __u64 config;
  2959. /**
  2960. * @uuid:
  2961. *
  2962. * When &drm_i915_query_item.flags ==
  2963. * %DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_UUID, i915 will use the
  2964. * value in this field as configuration identifier to decide
  2965. * what data to write into config_ptr.
  2966. *
  2967. * String formatted like "%08x-%04x-%04x-%04x-%012x"
  2968. */
  2969. char uuid[36];
  2970. };
  2971. /**
  2972. * @flags:
  2973. *
  2974. * Unused for now. Must be cleared to zero.
  2975. */
  2976. __u32 flags;
  2977. /**
  2978. * @data:
  2979. *
  2980. * When &drm_i915_query_item.flags == %DRM_I915_QUERY_PERF_CONFIG_LIST,
  2981. * i915 will write an array of __u64 of configuration identifiers.
  2982. *
  2983. * When &drm_i915_query_item.flags == %DRM_I915_QUERY_PERF_CONFIG_DATA,
  2984. * i915 will write a struct drm_i915_perf_oa_config. If the following
  2985. * fields of struct drm_i915_perf_oa_config are not set to 0, i915 will
  2986. * write into the associated pointers the values of submitted when the
  2987. * configuration was created :
  2988. *
  2989. * - &drm_i915_perf_oa_config.n_mux_regs
  2990. * - &drm_i915_perf_oa_config.n_boolean_regs
  2991. * - &drm_i915_perf_oa_config.n_flex_regs
  2992. */
  2993. __u8 data[];
  2994. };
  2995. /**
  2996. * enum drm_i915_gem_memory_class - Supported memory classes
  2997. */
  2998. enum drm_i915_gem_memory_class {
  2999. /** @I915_MEMORY_CLASS_SYSTEM: System memory */
  3000. I915_MEMORY_CLASS_SYSTEM = 0,
  3001. /** @I915_MEMORY_CLASS_DEVICE: Device local-memory */
  3002. I915_MEMORY_CLASS_DEVICE,
  3003. };
  3004. /**
  3005. * struct drm_i915_gem_memory_class_instance - Identify particular memory region
  3006. */
  3007. struct drm_i915_gem_memory_class_instance {
  3008. /** @memory_class: See enum drm_i915_gem_memory_class */
  3009. __u16 memory_class;
  3010. /** @memory_instance: Which instance */
  3011. __u16 memory_instance;
  3012. };
  3013. /**
  3014. * struct drm_i915_memory_region_info - Describes one region as known to the
  3015. * driver.
  3016. *
  3017. * Note this is using both struct drm_i915_query_item and struct drm_i915_query.
  3018. * For this new query we are adding the new query id DRM_I915_QUERY_MEMORY_REGIONS
  3019. * at &drm_i915_query_item.query_id.
  3020. */
  3021. struct drm_i915_memory_region_info {
  3022. /** @region: The class:instance pair encoding */
  3023. struct drm_i915_gem_memory_class_instance region;
  3024. /** @rsvd0: MBZ */
  3025. __u32 rsvd0;
  3026. /**
  3027. * @probed_size: Memory probed by the driver
  3028. *
  3029. * Note that it should not be possible to ever encounter a zero value
  3030. * here, also note that no current region type will ever return -1 here.
  3031. * Although for future region types, this might be a possibility. The
  3032. * same applies to the other size fields.
  3033. */
  3034. __u64 probed_size;
  3035. /**
  3036. * @unallocated_size: Estimate of memory remaining
  3037. *
  3038. * Requires CAP_PERFMON or CAP_SYS_ADMIN to get reliable accounting.
  3039. * Without this (or if this is an older kernel) the value here will
  3040. * always equal the @probed_size. Note this is only currently tracked
  3041. * for I915_MEMORY_CLASS_DEVICE regions (for other types the value here
  3042. * will always equal the @probed_size).
  3043. */
  3044. __u64 unallocated_size;
  3045. union {
  3046. /** @rsvd1: MBZ */
  3047. __u64 rsvd1[8];
  3048. struct {
  3049. /**
  3050. * @probed_cpu_visible_size: Memory probed by the driver
  3051. * that is CPU accessible.
  3052. *
  3053. * This will be always be <= @probed_size, and the
  3054. * remainder (if there is any) will not be CPU
  3055. * accessible.
  3056. *
  3057. * On systems without small BAR, the @probed_size will
  3058. * always equal the @probed_cpu_visible_size, since all
  3059. * of it will be CPU accessible.
  3060. *
  3061. * Note this is only tracked for
  3062. * I915_MEMORY_CLASS_DEVICE regions (for other types the
  3063. * value here will always equal the @probed_size).
  3064. *
  3065. * Note that if the value returned here is zero, then
  3066. * this must be an old kernel which lacks the relevant
  3067. * small-bar uAPI support (including
  3068. * I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS), but on
  3069. * such systems we should never actually end up with a
  3070. * small BAR configuration, assuming we are able to load
  3071. * the kernel module. Hence it should be safe to treat
  3072. * this the same as when @probed_cpu_visible_size ==
  3073. * @probed_size.
  3074. */
  3075. __u64 probed_cpu_visible_size;
  3076. /**
  3077. * @unallocated_cpu_visible_size: Estimate of CPU
  3078. * visible memory remaining.
  3079. *
  3080. * Note this is only tracked for
  3081. * I915_MEMORY_CLASS_DEVICE regions (for other types the
  3082. * value here will always equal the
  3083. * @probed_cpu_visible_size).
  3084. *
  3085. * Requires CAP_PERFMON or CAP_SYS_ADMIN to get reliable
  3086. * accounting. Without this the value here will always
  3087. * equal the @probed_cpu_visible_size. Note this is only
  3088. * currently tracked for I915_MEMORY_CLASS_DEVICE
  3089. * regions (for other types the value here will also
  3090. * always equal the @probed_cpu_visible_size).
  3091. *
  3092. * If this is an older kernel the value here will be
  3093. * zero, see also @probed_cpu_visible_size.
  3094. */
  3095. __u64 unallocated_cpu_visible_size;
  3096. };
  3097. };
  3098. };
  3099. /**
  3100. * struct drm_i915_query_memory_regions
  3101. *
  3102. * The region info query enumerates all regions known to the driver by filling
  3103. * in an array of struct drm_i915_memory_region_info structures.
  3104. *
  3105. * Example for getting the list of supported regions:
  3106. *
  3107. * .. code-block:: C
  3108. *
  3109. * struct drm_i915_query_memory_regions *info;
  3110. * struct drm_i915_query_item item = {
  3111. * .query_id = DRM_I915_QUERY_MEMORY_REGIONS;
  3112. * };
  3113. * struct drm_i915_query query = {
  3114. * .num_items = 1,
  3115. * .items_ptr = (uintptr_t)&item,
  3116. * };
  3117. * int err, i;
  3118. *
  3119. * // First query the size of the blob we need, this needs to be large
  3120. * // enough to hold our array of regions. The kernel will fill out the
  3121. * // item.length for us, which is the number of bytes we need.
  3122. * err = ioctl(fd, DRM_IOCTL_I915_QUERY, &query);
  3123. * if (err) ...
  3124. *
  3125. * info = calloc(1, item.length);
  3126. * // Now that we allocated the required number of bytes, we call the ioctl
  3127. * // again, this time with the data_ptr pointing to our newly allocated
  3128. * // blob, which the kernel can then populate with the all the region info.
  3129. * item.data_ptr = (uintptr_t)&info,
  3130. *
  3131. * err = ioctl(fd, DRM_IOCTL_I915_QUERY, &query);
  3132. * if (err) ...
  3133. *
  3134. * // We can now access each region in the array
  3135. * for (i = 0; i < info->num_regions; i++) {
  3136. * struct drm_i915_memory_region_info mr = info->regions[i];
  3137. * u16 class = mr.region.class;
  3138. * u16 instance = mr.region.instance;
  3139. *
  3140. * ....
  3141. * }
  3142. *
  3143. * free(info);
  3144. */
  3145. struct drm_i915_query_memory_regions {
  3146. /** @num_regions: Number of supported regions */
  3147. __u32 num_regions;
  3148. /** @rsvd: MBZ */
  3149. __u32 rsvd[3];
  3150. /** @regions: Info about each supported region */
  3151. struct drm_i915_memory_region_info regions[];
  3152. };
  3153. /**
  3154. * DOC: GuC HWCONFIG blob uAPI
  3155. *
  3156. * The GuC produces a blob with information about the current device.
  3157. * i915 reads this blob from GuC and makes it available via this uAPI.
  3158. *
  3159. * The format and meaning of the blob content are documented in the
  3160. * Programmer's Reference Manual.
  3161. */
  3162. /**
  3163. * struct drm_i915_gem_create_ext - Existing gem_create behaviour, with added
  3164. * extension support using struct i915_user_extension.
  3165. *
  3166. * Note that new buffer flags should be added here, at least for the stuff that
  3167. * is immutable. Previously we would have two ioctls, one to create the object
  3168. * with gem_create, and another to apply various parameters, however this
  3169. * creates some ambiguity for the params which are considered immutable. Also in
  3170. * general we're phasing out the various SET/GET ioctls.
  3171. */
  3172. struct drm_i915_gem_create_ext {
  3173. /**
  3174. * @size: Requested size for the object.
  3175. *
  3176. * The (page-aligned) allocated size for the object will be returned.
  3177. *
  3178. * DG2 64K min page size implications:
  3179. *
  3180. * On discrete platforms, starting from DG2, we have to contend with GTT
  3181. * page size restrictions when dealing with I915_MEMORY_CLASS_DEVICE
  3182. * objects. Specifically the hardware only supports 64K or larger GTT
  3183. * page sizes for such memory. The kernel will already ensure that all
  3184. * I915_MEMORY_CLASS_DEVICE memory is allocated using 64K or larger page
  3185. * sizes underneath.
  3186. *
  3187. * Note that the returned size here will always reflect any required
  3188. * rounding up done by the kernel, i.e 4K will now become 64K on devices
  3189. * such as DG2. The kernel will always select the largest minimum
  3190. * page-size for the set of possible placements as the value to use when
  3191. * rounding up the @size.
  3192. *
  3193. * Special DG2 GTT address alignment requirement:
  3194. *
  3195. * The GTT alignment will also need to be at least 2M for such objects.
  3196. *
  3197. * Note that due to how the hardware implements 64K GTT page support, we
  3198. * have some further complications:
  3199. *
  3200. * 1) The entire PDE (which covers a 2MB virtual address range), must
  3201. * contain only 64K PTEs, i.e mixing 4K and 64K PTEs in the same
  3202. * PDE is forbidden by the hardware.
  3203. *
  3204. * 2) We still need to support 4K PTEs for I915_MEMORY_CLASS_SYSTEM
  3205. * objects.
  3206. *
  3207. * To keep things simple for userland, we mandate that any GTT mappings
  3208. * must be aligned to and rounded up to 2MB. The kernel will internally
  3209. * pad them out to the next 2MB boundary. As this only wastes virtual
  3210. * address space and avoids userland having to copy any needlessly
  3211. * complicated PDE sharing scheme (coloring) and only affects DG2, this
  3212. * is deemed to be a good compromise.
  3213. */
  3214. __u64 size;
  3215. /**
  3216. * @handle: Returned handle for the object.
  3217. *
  3218. * Object handles are nonzero.
  3219. */
  3220. __u32 handle;
  3221. /**
  3222. * @flags: Optional flags.
  3223. *
  3224. * Supported values:
  3225. *
  3226. * I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS - Signal to the kernel that
  3227. * the object will need to be accessed via the CPU.
  3228. *
  3229. * Only valid when placing objects in I915_MEMORY_CLASS_DEVICE, and only
  3230. * strictly required on configurations where some subset of the device
  3231. * memory is directly visible/mappable through the CPU (which we also
  3232. * call small BAR), like on some DG2+ systems. Note that this is quite
  3233. * undesirable, but due to various factors like the client CPU, BIOS etc
  3234. * it's something we can expect to see in the wild. See
  3235. * &drm_i915_memory_region_info.probed_cpu_visible_size for how to
  3236. * determine if this system applies.
  3237. *
  3238. * Note that one of the placements MUST be I915_MEMORY_CLASS_SYSTEM, to
  3239. * ensure the kernel can always spill the allocation to system memory,
  3240. * if the object can't be allocated in the mappable part of
  3241. * I915_MEMORY_CLASS_DEVICE.
  3242. *
  3243. * Also note that since the kernel only supports flat-CCS on objects
  3244. * that can *only* be placed in I915_MEMORY_CLASS_DEVICE, we therefore
  3245. * don't support I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS together with
  3246. * flat-CCS.
  3247. *
  3248. * Without this hint, the kernel will assume that non-mappable
  3249. * I915_MEMORY_CLASS_DEVICE is preferred for this object. Note that the
  3250. * kernel can still migrate the object to the mappable part, as a last
  3251. * resort, if userspace ever CPU faults this object, but this might be
  3252. * expensive, and so ideally should be avoided.
  3253. *
  3254. * On older kernels which lack the relevant small-bar uAPI support (see
  3255. * also &drm_i915_memory_region_info.probed_cpu_visible_size),
  3256. * usage of the flag will result in an error, but it should NEVER be
  3257. * possible to end up with a small BAR configuration, assuming we can
  3258. * also successfully load the i915 kernel module. In such cases the
  3259. * entire I915_MEMORY_CLASS_DEVICE region will be CPU accessible, and as
  3260. * such there are zero restrictions on where the object can be placed.
  3261. */
  3262. #define I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS (1 << 0)
  3263. __u32 flags;
  3264. /**
  3265. * @extensions: The chain of extensions to apply to this object.
  3266. *
  3267. * This will be useful in the future when we need to support several
  3268. * different extensions, and we need to apply more than one when
  3269. * creating the object. See struct i915_user_extension.
  3270. *
  3271. * If we don't supply any extensions then we get the same old gem_create
  3272. * behaviour.
  3273. *
  3274. * For I915_GEM_CREATE_EXT_MEMORY_REGIONS usage see
  3275. * struct drm_i915_gem_create_ext_memory_regions.
  3276. *
  3277. * For I915_GEM_CREATE_EXT_PROTECTED_CONTENT usage see
  3278. * struct drm_i915_gem_create_ext_protected_content.
  3279. */
  3280. #define I915_GEM_CREATE_EXT_MEMORY_REGIONS 0
  3281. #define I915_GEM_CREATE_EXT_PROTECTED_CONTENT 1
  3282. __u64 extensions;
  3283. };
  3284. /**
  3285. * struct drm_i915_gem_create_ext_memory_regions - The
  3286. * I915_GEM_CREATE_EXT_MEMORY_REGIONS extension.
  3287. *
  3288. * Set the object with the desired set of placements/regions in priority
  3289. * order. Each entry must be unique and supported by the device.
  3290. *
  3291. * This is provided as an array of struct drm_i915_gem_memory_class_instance, or
  3292. * an equivalent layout of class:instance pair encodings. See struct
  3293. * drm_i915_query_memory_regions and DRM_I915_QUERY_MEMORY_REGIONS for how to
  3294. * query the supported regions for a device.
  3295. *
  3296. * As an example, on discrete devices, if we wish to set the placement as
  3297. * device local-memory we can do something like:
  3298. *
  3299. * .. code-block:: C
  3300. *
  3301. * struct drm_i915_gem_memory_class_instance region_lmem = {
  3302. * .memory_class = I915_MEMORY_CLASS_DEVICE,
  3303. * .memory_instance = 0,
  3304. * };
  3305. * struct drm_i915_gem_create_ext_memory_regions regions = {
  3306. * .base = { .name = I915_GEM_CREATE_EXT_MEMORY_REGIONS },
  3307. * .regions = (uintptr_t)&region_lmem,
  3308. * .num_regions = 1,
  3309. * };
  3310. * struct drm_i915_gem_create_ext create_ext = {
  3311. * .size = 16 * PAGE_SIZE,
  3312. * .extensions = (uintptr_t)&regions,
  3313. * };
  3314. *
  3315. * int err = ioctl(fd, DRM_IOCTL_I915_GEM_CREATE_EXT, &create_ext);
  3316. * if (err) ...
  3317. *
  3318. * At which point we get the object handle in &drm_i915_gem_create_ext.handle,
  3319. * along with the final object size in &drm_i915_gem_create_ext.size, which
  3320. * should account for any rounding up, if required.
  3321. *
  3322. * Note that userspace has no means of knowing the current backing region
  3323. * for objects where @num_regions is larger than one. The kernel will only
  3324. * ensure that the priority order of the @regions array is honoured, either
  3325. * when initially placing the object, or when moving memory around due to
  3326. * memory pressure
  3327. *
  3328. * On Flat-CCS capable HW, compression is supported for the objects residing
  3329. * in I915_MEMORY_CLASS_DEVICE. When such objects (compressed) have other
  3330. * memory class in @regions and migrated (by i915, due to memory
  3331. * constraints) to the non I915_MEMORY_CLASS_DEVICE region, then i915 needs to
  3332. * decompress the content. But i915 doesn't have the required information to
  3333. * decompress the userspace compressed objects.
  3334. *
  3335. * So i915 supports Flat-CCS, on the objects which can reside only on
  3336. * I915_MEMORY_CLASS_DEVICE regions.
  3337. */
  3338. struct drm_i915_gem_create_ext_memory_regions {
  3339. /** @base: Extension link. See struct i915_user_extension. */
  3340. struct i915_user_extension base;
  3341. /** @pad: MBZ */
  3342. __u32 pad;
  3343. /** @num_regions: Number of elements in the @regions array. */
  3344. __u32 num_regions;
  3345. /**
  3346. * @regions: The regions/placements array.
  3347. *
  3348. * An array of struct drm_i915_gem_memory_class_instance.
  3349. */
  3350. __u64 regions;
  3351. };
  3352. /**
  3353. * struct drm_i915_gem_create_ext_protected_content - The
  3354. * I915_OBJECT_PARAM_PROTECTED_CONTENT extension.
  3355. *
  3356. * If this extension is provided, buffer contents are expected to be protected
  3357. * by PXP encryption and require decryption for scan out and processing. This
  3358. * is only possible on platforms that have PXP enabled, on all other scenarios
  3359. * using this extension will cause the ioctl to fail and return -ENODEV. The
  3360. * flags parameter is reserved for future expansion and must currently be set
  3361. * to zero.
  3362. *
  3363. * The buffer contents are considered invalid after a PXP session teardown.
  3364. *
  3365. * The encryption is guaranteed to be processed correctly only if the object
  3366. * is submitted with a context created using the
  3367. * I915_CONTEXT_PARAM_PROTECTED_CONTENT flag. This will also enable extra checks
  3368. * at submission time on the validity of the objects involved.
  3369. *
  3370. * Below is an example on how to create a protected object:
  3371. *
  3372. * .. code-block:: C
  3373. *
  3374. * struct drm_i915_gem_create_ext_protected_content protected_ext = {
  3375. * .base = { .name = I915_GEM_CREATE_EXT_PROTECTED_CONTENT },
  3376. * .flags = 0,
  3377. * };
  3378. * struct drm_i915_gem_create_ext create_ext = {
  3379. * .size = PAGE_SIZE,
  3380. * .extensions = (uintptr_t)&protected_ext,
  3381. * };
  3382. *
  3383. * int err = ioctl(fd, DRM_IOCTL_I915_GEM_CREATE_EXT, &create_ext);
  3384. * if (err) ...
  3385. */
  3386. struct drm_i915_gem_create_ext_protected_content {
  3387. /** @base: Extension link. See struct i915_user_extension. */
  3388. struct i915_user_extension base;
  3389. /** @flags: reserved for future usage, currently MBZ */
  3390. __u32 flags;
  3391. };
  3392. /* ID of the protected content session managed by i915 when PXP is active */
  3393. #define I915_PROTECTED_CONTENT_DEFAULT_SESSION 0xf
  3394. #if defined(__cplusplus)
  3395. }
  3396. #endif
  3397. #endif /* _UAPI_I915_DRM_H_ */