pvr_rogue_fwif.h 69 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188
  1. /* SPDX-License-Identifier: GPL-2.0-only OR MIT */
  2. /* Copyright (c) 2023 Imagination Technologies Ltd. */
  3. #ifndef PVR_ROGUE_FWIF_H
  4. #define PVR_ROGUE_FWIF_H
  5. #include <linux/bits.h>
  6. #include <linux/build_bug.h>
  7. #include <linux/compiler.h>
  8. #include <linux/kernel.h>
  9. #include <linux/types.h>
  10. #include "pvr_rogue_defs.h"
  11. #include "pvr_rogue_fwif_common.h"
  12. #include "pvr_rogue_fwif_shared.h"
  13. /*
  14. ****************************************************************************
  15. * Logging type
  16. ****************************************************************************
  17. */
  18. #define ROGUE_FWIF_LOG_TYPE_NONE 0x00000000U
  19. #define ROGUE_FWIF_LOG_TYPE_TRACE 0x00000001U
  20. #define ROGUE_FWIF_LOG_TYPE_GROUP_MAIN 0x00000002U
  21. #define ROGUE_FWIF_LOG_TYPE_GROUP_MTS 0x00000004U
  22. #define ROGUE_FWIF_LOG_TYPE_GROUP_CLEANUP 0x00000008U
  23. #define ROGUE_FWIF_LOG_TYPE_GROUP_CSW 0x00000010U
  24. #define ROGUE_FWIF_LOG_TYPE_GROUP_BIF 0x00000020U
  25. #define ROGUE_FWIF_LOG_TYPE_GROUP_PM 0x00000040U
  26. #define ROGUE_FWIF_LOG_TYPE_GROUP_RTD 0x00000080U
  27. #define ROGUE_FWIF_LOG_TYPE_GROUP_SPM 0x00000100U
  28. #define ROGUE_FWIF_LOG_TYPE_GROUP_POW 0x00000200U
  29. #define ROGUE_FWIF_LOG_TYPE_GROUP_HWR 0x00000400U
  30. #define ROGUE_FWIF_LOG_TYPE_GROUP_HWP 0x00000800U
  31. #define ROGUE_FWIF_LOG_TYPE_GROUP_RPM 0x00001000U
  32. #define ROGUE_FWIF_LOG_TYPE_GROUP_DMA 0x00002000U
  33. #define ROGUE_FWIF_LOG_TYPE_GROUP_MISC 0x00004000U
  34. #define ROGUE_FWIF_LOG_TYPE_GROUP_DEBUG 0x80000000U
  35. #define ROGUE_FWIF_LOG_TYPE_GROUP_MASK 0x80007FFEU
  36. #define ROGUE_FWIF_LOG_TYPE_MASK 0x80007FFFU
  37. /* String used in pvrdebug -h output */
  38. #define ROGUE_FWIF_LOG_GROUPS_STRING_LIST \
  39. "main,mts,cleanup,csw,bif,pm,rtd,spm,pow,hwr,hwp,rpm,dma,misc,debug"
  40. /* Table entry to map log group strings to log type value */
  41. struct rogue_fwif_log_group_map_entry {
  42. const char *log_group_name;
  43. u32 log_group_type;
  44. };
  45. /*
  46. ****************************************************************************
  47. * ROGUE FW signature checks
  48. ****************************************************************************
  49. */
  50. #define ROGUE_FW_SIG_BUFFER_SIZE_MIN (8192)
  51. #define ROGUE_FWIF_TIMEDIFF_ID ((0x1UL << 28) | ROGUE_CR_TIMER)
  52. /*
  53. ****************************************************************************
  54. * Trace Buffer
  55. ****************************************************************************
  56. */
  57. /* Default size of ROGUE_FWIF_TRACEBUF_SPACE in DWords */
  58. #define ROGUE_FW_TRACE_BUF_DEFAULT_SIZE_IN_DWORDS 12000U
  59. #define ROGUE_FW_TRACE_BUFFER_ASSERT_SIZE 200U
  60. #define ROGUE_FW_THREAD_NUM 1U
  61. #define ROGUE_FW_THREAD_MAX 2U
  62. #define ROGUE_FW_POLL_TYPE_SET 0x80000000U
  63. struct rogue_fwif_file_info_buf {
  64. char path[ROGUE_FW_TRACE_BUFFER_ASSERT_SIZE];
  65. char info[ROGUE_FW_TRACE_BUFFER_ASSERT_SIZE];
  66. u32 line_num;
  67. u32 padding;
  68. } __aligned(8);
  69. struct rogue_fwif_tracebuf_space {
  70. u32 trace_pointer;
  71. u32 trace_buffer_fw_addr;
  72. /* To be used by host when reading from trace buffer */
  73. u32 *trace_buffer;
  74. struct rogue_fwif_file_info_buf assert_buf;
  75. } __aligned(8);
  76. /* Total number of FW fault logs stored */
  77. #define ROGUE_FWIF_FWFAULTINFO_MAX (8U)
  78. struct rogue_fw_fault_info {
  79. aligned_u64 cr_timer;
  80. aligned_u64 os_timer;
  81. u32 data __aligned(8);
  82. u32 reserved;
  83. struct rogue_fwif_file_info_buf fault_buf;
  84. } __aligned(8);
  85. enum rogue_fwif_pow_state {
  86. ROGUE_FWIF_POW_OFF, /* idle and ready to full power down */
  87. ROGUE_FWIF_POW_ON, /* running HW commands */
  88. ROGUE_FWIF_POW_FORCED_IDLE, /* forced idle */
  89. ROGUE_FWIF_POW_IDLE, /* idle waiting for host handshake */
  90. };
  91. /* Firmware HWR states */
  92. /* The HW state is ok or locked up */
  93. #define ROGUE_FWIF_HWR_HARDWARE_OK BIT(0)
  94. /* Tells if a HWR reset is in progress */
  95. #define ROGUE_FWIF_HWR_RESET_IN_PROGRESS BIT(1)
  96. /* A DM unrelated lockup has been detected */
  97. #define ROGUE_FWIF_HWR_GENERAL_LOCKUP BIT(3)
  98. /* At least one DM is running without being close to a lockup */
  99. #define ROGUE_FWIF_HWR_DM_RUNNING_OK BIT(4)
  100. /* At least one DM is close to lockup */
  101. #define ROGUE_FWIF_HWR_DM_STALLING BIT(5)
  102. /* The FW has faulted and needs to restart */
  103. #define ROGUE_FWIF_HWR_FW_FAULT BIT(6)
  104. /* The FW has requested the host to restart it */
  105. #define ROGUE_FWIF_HWR_RESTART_REQUESTED BIT(7)
  106. #define ROGUE_FWIF_PHR_STATE_SHIFT (8U)
  107. /* The FW has requested the host to restart it, per PHR configuration */
  108. #define ROGUE_FWIF_PHR_RESTART_REQUESTED ((1) << ROGUE_FWIF_PHR_STATE_SHIFT)
  109. /* A PHR triggered GPU reset has just finished */
  110. #define ROGUE_FWIF_PHR_RESTART_FINISHED ((2) << ROGUE_FWIF_PHR_STATE_SHIFT)
  111. #define ROGUE_FWIF_PHR_RESTART_MASK \
  112. (ROGUE_FWIF_PHR_RESTART_REQUESTED | ROGUE_FWIF_PHR_RESTART_FINISHED)
  113. #define ROGUE_FWIF_PHR_MODE_OFF (0UL)
  114. #define ROGUE_FWIF_PHR_MODE_RD_RESET (1UL)
  115. #define ROGUE_FWIF_PHR_MODE_FULL_RESET (2UL)
  116. /* Firmware per-DM HWR states */
  117. /* DM is working if all flags are cleared */
  118. #define ROGUE_FWIF_DM_STATE_WORKING (0)
  119. /* DM is idle and ready for HWR */
  120. #define ROGUE_FWIF_DM_STATE_READY_FOR_HWR BIT(0)
  121. /* DM need to skip to next cmd before resuming processing */
  122. #define ROGUE_FWIF_DM_STATE_NEEDS_SKIP BIT(2)
  123. /* DM need partial render cleanup before resuming processing */
  124. #define ROGUE_FWIF_DM_STATE_NEEDS_PR_CLEANUP BIT(3)
  125. /* DM need to increment Recovery Count once fully recovered */
  126. #define ROGUE_FWIF_DM_STATE_NEEDS_TRACE_CLEAR BIT(4)
  127. /* DM was identified as locking up and causing HWR */
  128. #define ROGUE_FWIF_DM_STATE_GUILTY_LOCKUP BIT(5)
  129. /* DM was innocently affected by another lockup which caused HWR */
  130. #define ROGUE_FWIF_DM_STATE_INNOCENT_LOCKUP BIT(6)
  131. /* DM was identified as over-running and causing HWR */
  132. #define ROGUE_FWIF_DM_STATE_GUILTY_OVERRUNING BIT(7)
  133. /* DM was innocently affected by another DM over-running which caused HWR */
  134. #define ROGUE_FWIF_DM_STATE_INNOCENT_OVERRUNING BIT(8)
  135. /* DM was forced into HWR as it delayed more important workloads */
  136. #define ROGUE_FWIF_DM_STATE_HARD_CONTEXT_SWITCH BIT(9)
  137. /* DM was forced into HWR due to an uncorrected GPU ECC error */
  138. #define ROGUE_FWIF_DM_STATE_GPU_ECC_HWR BIT(10)
  139. /* Firmware's connection state */
  140. enum rogue_fwif_connection_fw_state {
  141. /* Firmware is offline */
  142. ROGUE_FW_CONNECTION_FW_OFFLINE = 0,
  143. /* Firmware is initialised */
  144. ROGUE_FW_CONNECTION_FW_READY,
  145. /* Firmware connection is fully established */
  146. ROGUE_FW_CONNECTION_FW_ACTIVE,
  147. /* Firmware is clearing up connection data*/
  148. ROGUE_FW_CONNECTION_FW_OFFLOADING,
  149. ROGUE_FW_CONNECTION_FW_STATE_COUNT
  150. };
  151. /* OS' connection state */
  152. enum rogue_fwif_connection_os_state {
  153. /* OS is offline */
  154. ROGUE_FW_CONNECTION_OS_OFFLINE = 0,
  155. /* OS's KM driver is setup and waiting */
  156. ROGUE_FW_CONNECTION_OS_READY,
  157. /* OS connection is fully established */
  158. ROGUE_FW_CONNECTION_OS_ACTIVE,
  159. ROGUE_FW_CONNECTION_OS_STATE_COUNT
  160. };
  161. struct rogue_fwif_os_runtime_flags {
  162. unsigned int os_state : 3;
  163. unsigned int fl_ok : 1;
  164. unsigned int fl_grow_pending : 1;
  165. unsigned int isolated_os : 1;
  166. unsigned int reserved : 26;
  167. };
  168. #define PVR_SLR_LOG_ENTRIES 10
  169. /* MAX_CLIENT_CCB_NAME not visible to this header */
  170. #define PVR_SLR_LOG_STRLEN 30
  171. struct rogue_fwif_slr_entry {
  172. aligned_u64 timestamp;
  173. u32 fw_ctx_addr;
  174. u32 num_ufos;
  175. char ccb_name[PVR_SLR_LOG_STRLEN];
  176. char padding[2];
  177. } __aligned(8);
  178. #define MAX_THREAD_NUM 2
  179. /* firmware trace control data */
  180. struct rogue_fwif_tracebuf {
  181. u32 log_type;
  182. struct rogue_fwif_tracebuf_space tracebuf[MAX_THREAD_NUM];
  183. /*
  184. * Member initialised only when sTraceBuf is actually allocated (in
  185. * ROGUETraceBufferInitOnDemandResources)
  186. */
  187. u32 tracebuf_size_in_dwords;
  188. /* Compatibility and other flags */
  189. u32 tracebuf_flags;
  190. } __aligned(8);
  191. /* firmware system data shared with the Host driver */
  192. struct rogue_fwif_sysdata {
  193. /* Configuration flags from host */
  194. u32 config_flags;
  195. /* Extended configuration flags from host */
  196. u32 config_flags_ext;
  197. enum rogue_fwif_pow_state pow_state;
  198. u32 hw_perf_ridx;
  199. u32 hw_perf_widx;
  200. u32 hw_perf_wrap_count;
  201. /* Constant after setup, needed in FW */
  202. u32 hw_perf_size;
  203. /* The number of times the FW drops a packet due to buffer full */
  204. u32 hw_perf_drop_count;
  205. /*
  206. * ui32HWPerfUt, ui32FirstDropOrdinal, ui32LastDropOrdinal only valid
  207. * when FW is built with ROGUE_HWPERF_UTILIZATION &
  208. * ROGUE_HWPERF_DROP_TRACKING defined in rogue_fw_hwperf.c
  209. */
  210. /* Buffer utilisation, high watermark of bytes in use */
  211. u32 hw_perf_ut;
  212. /* The ordinal of the first packet the FW dropped */
  213. u32 first_drop_ordinal;
  214. /* The ordinal of the last packet the FW dropped */
  215. u32 last_drop_ordinal;
  216. /* State flags for each Operating System mirrored from Fw coremem */
  217. struct rogue_fwif_os_runtime_flags
  218. os_runtime_flags_mirror[ROGUE_FW_MAX_NUM_OS];
  219. struct rogue_fw_fault_info fault_info[ROGUE_FWIF_FWFAULTINFO_MAX];
  220. u32 fw_faults;
  221. u32 cr_poll_addr[MAX_THREAD_NUM];
  222. u32 cr_poll_mask[MAX_THREAD_NUM];
  223. u32 cr_poll_count[MAX_THREAD_NUM];
  224. aligned_u64 start_idle_time;
  225. #if defined(SUPPORT_ROGUE_FW_STATS_FRAMEWORK)
  226. # define ROGUE_FWIF_STATS_FRAMEWORK_LINESIZE (8)
  227. # define ROGUE_FWIF_STATS_FRAMEWORK_MAX \
  228. (2048 * ROGUE_FWIF_STATS_FRAMEWORK_LINESIZE)
  229. u32 fw_stats_buf[ROGUE_FWIF_STATS_FRAMEWORK_MAX] __aligned(8);
  230. #endif
  231. u32 hwr_state_flags;
  232. u32 hwr_recovery_flags[PVR_FWIF_DM_MAX];
  233. /* Compatibility and other flags */
  234. u32 fw_sys_data_flags;
  235. /* Identify whether MC config is P-P or P-S */
  236. u32 mc_config;
  237. } __aligned(8);
  238. /* per-os firmware shared data */
  239. struct rogue_fwif_osdata {
  240. /* Configuration flags from an OS */
  241. u32 fw_os_config_flags;
  242. /* Markers to signal that the host should perform a full sync check */
  243. u32 fw_sync_check_mark;
  244. u32 host_sync_check_mark;
  245. u32 forced_updates_requested;
  246. u8 slr_log_wp;
  247. struct rogue_fwif_slr_entry slr_log_first;
  248. struct rogue_fwif_slr_entry slr_log[PVR_SLR_LOG_ENTRIES];
  249. aligned_u64 last_forced_update_time;
  250. /* Interrupt count from Threads > */
  251. u32 interrupt_count[MAX_THREAD_NUM];
  252. u32 kccb_cmds_executed;
  253. u32 power_sync_fw_addr;
  254. /* Compatibility and other flags */
  255. u32 fw_os_data_flags;
  256. u32 padding;
  257. } __aligned(8);
  258. /* Firmware trace time-stamp field breakup */
  259. /* ROGUE_CR_TIMER register read (48 bits) value*/
  260. #define ROGUE_FWT_TIMESTAMP_TIME_SHIFT (0U)
  261. #define ROGUE_FWT_TIMESTAMP_TIME_CLRMSK (0xFFFF000000000000ull)
  262. /* Extra debug-info (16 bits) */
  263. #define ROGUE_FWT_TIMESTAMP_DEBUG_INFO_SHIFT (48U)
  264. #define ROGUE_FWT_TIMESTAMP_DEBUG_INFO_CLRMSK ~ROGUE_FWT_TIMESTAMP_TIME_CLRMSK
  265. /* Debug-info sub-fields */
  266. /*
  267. * Bit 0: ROGUE_CR_EVENT_STATUS_MMU_PAGE_FAULT bit from ROGUE_CR_EVENT_STATUS
  268. * register
  269. */
  270. #define ROGUE_FWT_DEBUG_INFO_MMU_PAGE_FAULT_SHIFT (0U)
  271. #define ROGUE_FWT_DEBUG_INFO_MMU_PAGE_FAULT_SET \
  272. BIT(ROGUE_FWT_DEBUG_INFO_MMU_PAGE_FAULT_SHIFT)
  273. /* Bit 1: ROGUE_CR_BIF_MMU_ENTRY_PENDING bit from ROGUE_CR_BIF_MMU_ENTRY register */
  274. #define ROGUE_FWT_DEBUG_INFO_MMU_ENTRY_PENDING_SHIFT (1U)
  275. #define ROGUE_FWT_DEBUG_INFO_MMU_ENTRY_PENDING_SET \
  276. BIT(ROGUE_FWT_DEBUG_INFO_MMU_ENTRY_PENDING_SHIFT)
  277. /* Bit 2: ROGUE_CR_SLAVE_EVENT register is non-zero */
  278. #define ROGUE_FWT_DEBUG_INFO_SLAVE_EVENTS_SHIFT (2U)
  279. #define ROGUE_FWT_DEBUG_INFO_SLAVE_EVENTS_SET \
  280. BIT(ROGUE_FWT_DEBUG_INFO_SLAVE_EVENTS_SHIFT)
  281. /* Bit 3-15: Unused bits */
  282. #define ROGUE_FWT_DEBUG_INFO_STR_MAXLEN 64
  283. #define ROGUE_FWT_DEBUG_INFO_STR_PREPEND " (debug info: "
  284. #define ROGUE_FWT_DEBUG_INFO_STR_APPEND ")"
  285. /*
  286. ******************************************************************************
  287. * HWR Data
  288. ******************************************************************************
  289. */
  290. enum rogue_hwrtype {
  291. ROGUE_HWRTYPE_UNKNOWNFAILURE = 0,
  292. ROGUE_HWRTYPE_OVERRUN = 1,
  293. ROGUE_HWRTYPE_POLLFAILURE = 2,
  294. ROGUE_HWRTYPE_BIF0FAULT = 3,
  295. ROGUE_HWRTYPE_BIF1FAULT = 4,
  296. ROGUE_HWRTYPE_TEXASBIF0FAULT = 5,
  297. ROGUE_HWRTYPE_MMUFAULT = 6,
  298. ROGUE_HWRTYPE_MMUMETAFAULT = 7,
  299. ROGUE_HWRTYPE_MIPSTLBFAULT = 8,
  300. ROGUE_HWRTYPE_ECCFAULT = 9,
  301. ROGUE_HWRTYPE_MMURISCVFAULT = 10,
  302. };
  303. #define ROGUE_FWIF_HWRTYPE_BIF_BANK_GET(hwr_type) \
  304. (((hwr_type) == ROGUE_HWRTYPE_BIF0FAULT) ? 0 : 1)
  305. #define ROGUE_FWIF_HWRTYPE_PAGE_FAULT_GET(hwr_type) \
  306. ((((hwr_type) == ROGUE_HWRTYPE_BIF0FAULT) || \
  307. ((hwr_type) == ROGUE_HWRTYPE_BIF1FAULT) || \
  308. ((hwr_type) == ROGUE_HWRTYPE_TEXASBIF0FAULT) || \
  309. ((hwr_type) == ROGUE_HWRTYPE_MMUFAULT) || \
  310. ((hwr_type) == ROGUE_HWRTYPE_MMUMETAFAULT) || \
  311. ((hwr_type) == ROGUE_HWRTYPE_MIPSTLBFAULT) || \
  312. ((hwr_type) == ROGUE_HWRTYPE_MMURISCVFAULT)) \
  313. ? true \
  314. : false)
  315. struct rogue_bifinfo {
  316. aligned_u64 bif_req_status;
  317. aligned_u64 bif_mmu_status;
  318. aligned_u64 pc_address; /* phys address of the page catalogue */
  319. aligned_u64 reserved;
  320. };
  321. struct rogue_eccinfo {
  322. u32 fault_gpu;
  323. };
  324. struct rogue_mmuinfo {
  325. aligned_u64 mmu_status[2];
  326. aligned_u64 pc_address; /* phys address of the page catalogue */
  327. aligned_u64 reserved;
  328. };
  329. struct rogue_pollinfo {
  330. u32 thread_num;
  331. u32 cr_poll_addr;
  332. u32 cr_poll_mask;
  333. u32 cr_poll_last_value;
  334. aligned_u64 reserved;
  335. } __aligned(8);
  336. struct rogue_tlbinfo {
  337. u32 bad_addr;
  338. u32 entry_lo;
  339. };
  340. struct rogue_hwrinfo {
  341. union {
  342. struct rogue_bifinfo bif_info;
  343. struct rogue_mmuinfo mmu_info;
  344. struct rogue_pollinfo poll_info;
  345. struct rogue_tlbinfo tlb_info;
  346. struct rogue_eccinfo ecc_info;
  347. } hwr_data;
  348. aligned_u64 cr_timer;
  349. aligned_u64 os_timer;
  350. u32 frame_num;
  351. u32 pid;
  352. u32 active_hwrt_data;
  353. u32 hwr_number;
  354. u32 event_status;
  355. u32 hwr_recovery_flags;
  356. enum rogue_hwrtype hwr_type;
  357. u32 dm;
  358. u32 core_id;
  359. aligned_u64 cr_time_of_kick;
  360. aligned_u64 cr_time_hw_reset_start;
  361. aligned_u64 cr_time_hw_reset_finish;
  362. aligned_u64 cr_time_freelist_ready;
  363. aligned_u64 reserved[2];
  364. } __aligned(8);
  365. /* Number of first HWR logs recorded (never overwritten by newer logs) */
  366. #define ROGUE_FWIF_HWINFO_MAX_FIRST 8U
  367. /* Number of latest HWR logs (older logs are overwritten by newer logs) */
  368. #define ROGUE_FWIF_HWINFO_MAX_LAST 8U
  369. /* Total number of HWR logs stored in a buffer */
  370. #define ROGUE_FWIF_HWINFO_MAX \
  371. (ROGUE_FWIF_HWINFO_MAX_FIRST + ROGUE_FWIF_HWINFO_MAX_LAST)
  372. /* Index of the last log in the HWR log buffer */
  373. #define ROGUE_FWIF_HWINFO_LAST_INDEX (ROGUE_FWIF_HWINFO_MAX - 1U)
  374. struct rogue_fwif_hwrinfobuf {
  375. struct rogue_hwrinfo hwr_info[ROGUE_FWIF_HWINFO_MAX];
  376. u32 hwr_counter;
  377. u32 write_index;
  378. u32 dd_req_count;
  379. u32 hwr_info_buf_flags; /* Compatibility and other flags */
  380. u32 hwr_dm_locked_up_count[PVR_FWIF_DM_MAX];
  381. u32 hwr_dm_overran_count[PVR_FWIF_DM_MAX];
  382. u32 hwr_dm_recovered_count[PVR_FWIF_DM_MAX];
  383. u32 hwr_dm_false_detect_count[PVR_FWIF_DM_MAX];
  384. } __aligned(8);
  385. #define ROGUE_FWIF_CTXSWITCH_PROFILE_FAST_EN (1)
  386. #define ROGUE_FWIF_CTXSWITCH_PROFILE_MEDIUM_EN (2)
  387. #define ROGUE_FWIF_CTXSWITCH_PROFILE_SLOW_EN (3)
  388. #define ROGUE_FWIF_CTXSWITCH_PROFILE_NODELAY_EN (4)
  389. #define ROGUE_FWIF_CDM_ARBITRATION_TASK_DEMAND_EN (1)
  390. #define ROGUE_FWIF_CDM_ARBITRATION_ROUND_ROBIN_EN (2)
  391. #define ROGUE_FWIF_ISP_SCHEDMODE_VER1_IPP (1)
  392. #define ROGUE_FWIF_ISP_SCHEDMODE_VER2_ISP (2)
  393. /*
  394. ******************************************************************************
  395. * ROGUE firmware Init Config Data
  396. ******************************************************************************
  397. */
  398. /* Flag definitions affecting the firmware globally */
  399. #define ROGUE_FWIF_INICFG_CTXSWITCH_MODE_RAND BIT(0)
  400. #define ROGUE_FWIF_INICFG_CTXSWITCH_SRESET_EN BIT(1)
  401. #define ROGUE_FWIF_INICFG_HWPERF_EN BIT(2)
  402. #define ROGUE_FWIF_INICFG_DM_KILL_MODE_RAND_EN BIT(3)
  403. #define ROGUE_FWIF_INICFG_POW_RASCALDUST BIT(4)
  404. /* Bit 5 is reserved. */
  405. #define ROGUE_FWIF_INICFG_FBCDC_V3_1_EN BIT(6)
  406. #define ROGUE_FWIF_INICFG_CHECK_MLIST_EN BIT(7)
  407. #define ROGUE_FWIF_INICFG_DISABLE_CLKGATING_EN BIT(8)
  408. /* Bit 9 is reserved. */
  409. /* Bit 10 is reserved. */
  410. /* Bit 11 is reserved. */
  411. #define ROGUE_FWIF_INICFG_REGCONFIG_EN BIT(12)
  412. #define ROGUE_FWIF_INICFG_ASSERT_ON_OUTOFMEMORY BIT(13)
  413. #define ROGUE_FWIF_INICFG_HWP_DISABLE_FILTER BIT(14)
  414. /* Bit 15 is reserved. */
  415. #define ROGUE_FWIF_INICFG_CTXSWITCH_PROFILE_SHIFT (16)
  416. #define ROGUE_FWIF_INICFG_CTXSWITCH_PROFILE_FAST \
  417. (ROGUE_FWIF_CTXSWITCH_PROFILE_FAST_EN \
  418. << ROGUE_FWIF_INICFG_CTXSWITCH_PROFILE_SHIFT)
  419. #define ROGUE_FWIF_INICFG_CTXSWITCH_PROFILE_MEDIUM \
  420. (ROGUE_FWIF_CTXSWITCH_PROFILE_MEDIUM_EN \
  421. << ROGUE_FWIF_INICFG_CTXSWITCH_PROFILE_SHIFT)
  422. #define ROGUE_FWIF_INICFG_CTXSWITCH_PROFILE_SLOW \
  423. (ROGUE_FWIF_CTXSWITCH_PROFILE_SLOW_EN \
  424. << ROGUE_FWIF_INICFG_CTXSWITCH_PROFILE_SHIFT)
  425. #define ROGUE_FWIF_INICFG_CTXSWITCH_PROFILE_NODELAY \
  426. (ROGUE_FWIF_CTXSWITCH_PROFILE_NODELAY_EN \
  427. << ROGUE_FWIF_INICFG_CTXSWITCH_PROFILE_SHIFT)
  428. #define ROGUE_FWIF_INICFG_CTXSWITCH_PROFILE_MASK \
  429. (7 << ROGUE_FWIF_INICFG_CTXSWITCH_PROFILE_SHIFT)
  430. #define ROGUE_FWIF_INICFG_DISABLE_DM_OVERLAP BIT(19)
  431. #define ROGUE_FWIF_INICFG_ASSERT_ON_HWR_TRIGGER BIT(20)
  432. #define ROGUE_FWIF_INICFG_FABRIC_COHERENCY_ENABLED BIT(21)
  433. #define ROGUE_FWIF_INICFG_VALIDATE_IRQ BIT(22)
  434. #define ROGUE_FWIF_INICFG_DISABLE_PDP_EN BIT(23)
  435. #define ROGUE_FWIF_INICFG_SPU_POWER_STATE_MASK_CHANGE_EN BIT(24)
  436. #define ROGUE_FWIF_INICFG_WORKEST BIT(25)
  437. #define ROGUE_FWIF_INICFG_PDVFS BIT(26)
  438. #define ROGUE_FWIF_INICFG_CDM_ARBITRATION_SHIFT (27)
  439. #define ROGUE_FWIF_INICFG_CDM_ARBITRATION_TASK_DEMAND \
  440. (ROGUE_FWIF_CDM_ARBITRATION_TASK_DEMAND_EN \
  441. << ROGUE_FWIF_INICFG_CDM_ARBITRATION_SHIFT)
  442. #define ROGUE_FWIF_INICFG_CDM_ARBITRATION_ROUND_ROBIN \
  443. (ROGUE_FWIF_CDM_ARBITRATION_ROUND_ROBIN_EN \
  444. << ROGUE_FWIF_INICFG_CDM_ARBITRATION_SHIFT)
  445. #define ROGUE_FWIF_INICFG_CDM_ARBITRATION_MASK \
  446. (3 << ROGUE_FWIF_INICFG_CDM_ARBITRATION_SHIFT)
  447. #define ROGUE_FWIF_INICFG_ISPSCHEDMODE_SHIFT (29)
  448. #define ROGUE_FWIF_INICFG_ISPSCHEDMODE_NONE (0)
  449. #define ROGUE_FWIF_INICFG_ISPSCHEDMODE_VER1_IPP \
  450. (ROGUE_FWIF_ISP_SCHEDMODE_VER1_IPP \
  451. << ROGUE_FWIF_INICFG_ISPSCHEDMODE_SHIFT)
  452. #define ROGUE_FWIF_INICFG_ISPSCHEDMODE_VER2_ISP \
  453. (ROGUE_FWIF_ISP_SCHEDMODE_VER2_ISP \
  454. << ROGUE_FWIF_INICFG_ISPSCHEDMODE_SHIFT)
  455. #define ROGUE_FWIF_INICFG_ISPSCHEDMODE_MASK \
  456. (ROGUE_FWIF_INICFG_ISPSCHEDMODE_VER1_IPP | \
  457. ROGUE_FWIF_INICFG_ISPSCHEDMODE_VER2_ISP)
  458. #define ROGUE_FWIF_INICFG_VALIDATE_SOCUSC_TIMER BIT(31)
  459. #define ROGUE_FWIF_INICFG_ALL (0xFFFFFFFFU)
  460. /* Extended Flag definitions affecting the firmware globally */
  461. #define ROGUE_FWIF_INICFG_EXT_TFBC_CONTROL_SHIFT (0)
  462. /* [7] YUV10 override
  463. * [6:4] Quality
  464. * [3] Quality enable
  465. * [2:1] Compression scheme
  466. * [0] Lossy group
  467. */
  468. #define ROGUE_FWIF_INICFG_EXT_TFBC_CONTROL_MASK (0xFF)
  469. #define ROGUE_FWIF_INICFG_EXT_ALL (ROGUE_FWIF_INICFG_EXT_TFBC_CONTROL_MASK)
  470. /* Flag definitions affecting only workloads submitted by a particular OS */
  471. #define ROGUE_FWIF_INICFG_OS_CTXSWITCH_TDM_EN BIT(0)
  472. #define ROGUE_FWIF_INICFG_OS_CTXSWITCH_GEOM_EN BIT(1)
  473. #define ROGUE_FWIF_INICFG_OS_CTXSWITCH_FRAG_EN BIT(2)
  474. #define ROGUE_FWIF_INICFG_OS_CTXSWITCH_CDM_EN BIT(3)
  475. #define ROGUE_FWIF_INICFG_OS_LOW_PRIO_CS_TDM BIT(4)
  476. #define ROGUE_FWIF_INICFG_OS_LOW_PRIO_CS_GEOM BIT(5)
  477. #define ROGUE_FWIF_INICFG_OS_LOW_PRIO_CS_FRAG BIT(6)
  478. #define ROGUE_FWIF_INICFG_OS_LOW_PRIO_CS_CDM BIT(7)
  479. #define ROGUE_FWIF_INICFG_OS_ALL (0xFF)
  480. #define ROGUE_FWIF_INICFG_OS_CTXSWITCH_DM_ALL \
  481. (ROGUE_FWIF_INICFG_OS_CTXSWITCH_TDM_EN | \
  482. ROGUE_FWIF_INICFG_OS_CTXSWITCH_GEOM_EN | \
  483. ROGUE_FWIF_INICFG_OS_CTXSWITCH_FRAG_EN | \
  484. ROGUE_FWIF_INICFG_OS_CTXSWITCH_CDM_EN)
  485. #define ROGUE_FWIF_INICFG_OS_CTXSWITCH_CLRMSK \
  486. ~(ROGUE_FWIF_INICFG_OS_CTXSWITCH_DM_ALL)
  487. #define ROGUE_FWIF_FILTCFG_TRUNCATE_HALF BIT(3)
  488. #define ROGUE_FWIF_FILTCFG_TRUNCATE_INT BIT(2)
  489. #define ROGUE_FWIF_FILTCFG_NEW_FILTER_MODE BIT(1)
  490. enum rogue_activepm_conf {
  491. ROGUE_ACTIVEPM_FORCE_OFF = 0,
  492. ROGUE_ACTIVEPM_FORCE_ON = 1,
  493. ROGUE_ACTIVEPM_DEFAULT = 2
  494. };
  495. enum rogue_rd_power_island_conf {
  496. ROGUE_RD_POWER_ISLAND_FORCE_OFF = 0,
  497. ROGUE_RD_POWER_ISLAND_FORCE_ON = 1,
  498. ROGUE_RD_POWER_ISLAND_DEFAULT = 2
  499. };
  500. struct rogue_fw_register_list {
  501. /* Register number */
  502. u16 reg_num;
  503. /* Indirect register number (or 0 if not used) */
  504. u16 indirect_reg_num;
  505. /* Start value for indirect register */
  506. u16 indirect_start_val;
  507. /* End value for indirect register */
  508. u16 indirect_end_val;
  509. };
  510. struct rogue_fwif_dllist_node {
  511. u32 p;
  512. u32 n;
  513. };
  514. /*
  515. * This number is used to represent an invalid page catalogue physical address
  516. */
  517. #define ROGUE_FWIF_INVALID_PC_PHYADDR 0xFFFFFFFFFFFFFFFFLLU
  518. /* This number is used to represent unallocated page catalog base register */
  519. #define ROGUE_FW_BIF_INVALID_PCSET 0xFFFFFFFFU
  520. /* Firmware memory context. */
  521. struct rogue_fwif_fwmemcontext {
  522. /* device physical address of context's page catalogue */
  523. aligned_u64 pc_dev_paddr;
  524. /*
  525. * associated page catalog base register (ROGUE_FW_BIF_INVALID_PCSET ==
  526. * unallocated)
  527. */
  528. u32 page_cat_base_reg_set;
  529. /* breakpoint address */
  530. u32 breakpoint_addr;
  531. /* breakpoint handler address */
  532. u32 bp_handler_addr;
  533. /* DM and enable control for BP */
  534. u32 breakpoint_ctl;
  535. /* Compatibility and other flags */
  536. u32 fw_mem_ctx_flags;
  537. u32 padding;
  538. } __aligned(8);
  539. /*
  540. * FW context state flags
  541. */
  542. #define ROGUE_FWIF_CONTEXT_FLAGS_NEED_RESUME (0x00000001U)
  543. #define ROGUE_FWIF_CONTEXT_FLAGS_MC_NEED_RESUME_MASKFULL (0x000000FFU)
  544. #define ROGUE_FWIF_CONTEXT_FLAGS_TDM_HEADER_STALE (0x00000100U)
  545. #define ROGUE_FWIF_CONTEXT_FLAGS_LAST_KICK_SECURE (0x00000200U)
  546. #define ROGUE_NUM_GEOM_CORES_MAX 4
  547. /*
  548. * FW-accessible TA state which must be written out to memory on context store
  549. */
  550. struct rogue_fwif_geom_ctx_state_per_geom {
  551. /* To store in mid-TA */
  552. aligned_u64 geom_reg_vdm_call_stack_pointer;
  553. /* Initial value (in case is 'lost' due to a lock-up */
  554. aligned_u64 geom_reg_vdm_call_stack_pointer_init;
  555. u32 geom_reg_vbs_so_prim[4];
  556. u16 geom_current_idx;
  557. u16 padding[3];
  558. } __aligned(8);
  559. struct rogue_fwif_geom_ctx_state {
  560. /* FW-accessible TA state which must be written out to memory on context store */
  561. struct rogue_fwif_geom_ctx_state_per_geom geom_core[ROGUE_NUM_GEOM_CORES_MAX];
  562. } __aligned(8);
  563. /*
  564. * FW-accessible ISP state which must be written out to memory on context store
  565. */
  566. struct rogue_fwif_frag_ctx_state {
  567. u32 frag_reg_pm_deallocated_mask_status;
  568. u32 frag_reg_dm_pds_mtilefree_status;
  569. /* Compatibility and other flags */
  570. u32 ctx_state_flags;
  571. /*
  572. * frag_reg_isp_store should be the last element of the structure as this
  573. * is an array whose size is determined at runtime after detecting the
  574. * ROGUE core
  575. */
  576. u32 frag_reg_isp_store[];
  577. } __aligned(8);
  578. #define ROGUE_FWIF_CTX_USING_BUFFER_A (0)
  579. #define ROGUE_FWIF_CTX_USING_BUFFER_B (1U)
  580. struct rogue_fwif_compute_ctx_state {
  581. u32 ctx_state_flags; /* Target buffer and other flags */
  582. };
  583. struct rogue_fwif_fwcommoncontext {
  584. /* CCB details for this firmware context */
  585. u32 ccbctl_fw_addr; /* CCB control */
  586. u32 ccb_fw_addr; /* CCB base */
  587. struct rogue_fwif_dma_addr ccb_meta_dma_addr;
  588. /* Context suspend state */
  589. /* geom/frag context suspend state, read/written by FW */
  590. u32 context_state_addr __aligned(8);
  591. /* Flags e.g. for context switching */
  592. u32 fw_com_ctx_flags;
  593. u32 priority;
  594. u32 priority_seq_num;
  595. /* Framework state */
  596. /* Register updates for Framework */
  597. u32 rf_cmd_addr __aligned(8);
  598. /* Statistic updates waiting to be passed back to the host... */
  599. /* True when some stats are pending */
  600. bool stats_pending __aligned(4);
  601. /* Number of stores on this context since last update */
  602. s32 stats_num_stores;
  603. /* Number of OOMs on this context since last update */
  604. s32 stats_num_out_of_memory;
  605. /* Number of PRs on this context since last update */
  606. s32 stats_num_partial_renders;
  607. /* Data Master type */
  608. u32 dm;
  609. /* Device Virtual Address of the signal the context is waiting on */
  610. aligned_u64 wait_signal_address;
  611. /* List entry for the wait-signal list */
  612. struct rogue_fwif_dllist_node wait_signal_node __aligned(8);
  613. /* List entry for the buffer stalled list */
  614. struct rogue_fwif_dllist_node buf_stalled_node __aligned(8);
  615. /* Address of the circular buffer queue pointers */
  616. aligned_u64 cbuf_queue_ctrl_addr;
  617. aligned_u64 robustness_address;
  618. /* Max HWR deadline limit in ms */
  619. u32 max_deadline_ms;
  620. /* Following HWR circular buffer read-offset needs resetting */
  621. bool read_offset_needs_reset;
  622. /* List entry for the waiting list */
  623. struct rogue_fwif_dllist_node waiting_node __aligned(8);
  624. /* List entry for the run list */
  625. struct rogue_fwif_dllist_node run_node __aligned(8);
  626. /* UFO that last failed (or NULL) */
  627. struct rogue_fwif_ufo last_failed_ufo;
  628. /* Memory context */
  629. u32 fw_mem_context_fw_addr;
  630. /* References to the host side originators */
  631. /* the Server Common Context */
  632. u32 server_common_context_id;
  633. /* associated process ID */
  634. u32 pid;
  635. /* True when Geom DM OOM is not allowed */
  636. bool geom_oom_disabled __aligned(4);
  637. } __aligned(8);
  638. /* Firmware render context. */
  639. struct rogue_fwif_fwrendercontext {
  640. /* Geometry firmware context. */
  641. struct rogue_fwif_fwcommoncontext geom_context;
  642. /* Fragment firmware context. */
  643. struct rogue_fwif_fwcommoncontext frag_context;
  644. struct rogue_fwif_static_rendercontext_state static_render_context_state;
  645. /* Number of commands submitted to the WorkEst FW CCB */
  646. u32 work_est_ccb_submitted;
  647. /* Compatibility and other flags */
  648. u32 fw_render_ctx_flags;
  649. } __aligned(8);
  650. /* Firmware compute context. */
  651. struct rogue_fwif_fwcomputecontext {
  652. /* Firmware context for the CDM */
  653. struct rogue_fwif_fwcommoncontext cdm_context;
  654. struct rogue_fwif_static_computecontext_state
  655. static_compute_context_state;
  656. /* Number of commands submitted to the WorkEst FW CCB */
  657. u32 work_est_ccb_submitted;
  658. /* Compatibility and other flags */
  659. u32 compute_ctx_flags;
  660. u32 wgp_state;
  661. u32 wgp_checksum;
  662. u32 core_mask_a;
  663. u32 core_mask_b;
  664. } __aligned(8);
  665. /* Firmware TDM context. */
  666. struct rogue_fwif_fwtdmcontext {
  667. /* Firmware context for the TDM */
  668. struct rogue_fwif_fwcommoncontext tdm_context;
  669. /* Number of commands submitted to the WorkEst FW CCB */
  670. u32 work_est_ccb_submitted;
  671. } __aligned(8);
  672. /* Firmware TQ3D context. */
  673. struct rogue_fwif_fwtransfercontext {
  674. /* Firmware context for TQ3D. */
  675. struct rogue_fwif_fwcommoncontext tq_context;
  676. } __aligned(8);
  677. /*
  678. ******************************************************************************
  679. * Defines for CMD_TYPE corruption detection and forward compatibility check
  680. ******************************************************************************
  681. */
  682. /*
  683. * CMD_TYPE 32bit contains:
  684. * 31:16 Reserved for magic value to detect corruption (16 bits)
  685. * 15 Reserved for ROGUE_CCB_TYPE_TASK (1 bit)
  686. * 14:0 Bits available for CMD_TYPEs (15 bits)
  687. */
  688. /* Magic value to detect corruption */
  689. #define ROGUE_CMD_MAGIC_DWORD (0x2ABC)
  690. #define ROGUE_CMD_MAGIC_DWORD_MASK (0xFFFF0000U)
  691. #define ROGUE_CMD_MAGIC_DWORD_SHIFT (16U)
  692. #define ROGUE_CMD_MAGIC_DWORD_SHIFTED \
  693. (ROGUE_CMD_MAGIC_DWORD << ROGUE_CMD_MAGIC_DWORD_SHIFT)
  694. /* Kernel CCB control for ROGUE */
  695. struct rogue_fwif_ccb_ctl {
  696. /* write offset into array of commands (MUST be aligned to 16 bytes!) */
  697. u32 write_offset;
  698. /* Padding to ensure read and write offsets are in separate cache lines. */
  699. u8 padding[128 - sizeof(u32)];
  700. /* read offset into array of commands */
  701. u32 read_offset;
  702. /* Offset wrapping mask (Total capacity of the CCB - 1) */
  703. u32 wrap_mask;
  704. /* size of each command in bytes */
  705. u32 cmd_size;
  706. u32 padding2;
  707. } __aligned(8);
  708. /* Kernel CCB command structure for ROGUE */
  709. #define ROGUE_FWIF_MMUCACHEDATA_FLAGS_PT (0x1U) /* MMU_CTRL_INVAL_PT_EN */
  710. #define ROGUE_FWIF_MMUCACHEDATA_FLAGS_PD (0x2U) /* MMU_CTRL_INVAL_PD_EN */
  711. #define ROGUE_FWIF_MMUCACHEDATA_FLAGS_PC (0x4U) /* MMU_CTRL_INVAL_PC_EN */
  712. /*
  713. * can't use PM_TLB0 bit from BIFPM_CTRL reg because it collides with PT
  714. * bit from BIF_CTRL reg
  715. */
  716. #define ROGUE_FWIF_MMUCACHEDATA_FLAGS_PMTLB (0x10)
  717. /* BIF_CTRL_INVAL_TLB1_EN */
  718. #define ROGUE_FWIF_MMUCACHEDATA_FLAGS_TLB \
  719. (ROGUE_FWIF_MMUCACHEDATA_FLAGS_PMTLB | 0x8)
  720. /* MMU_CTRL_INVAL_ALL_CONTEXTS_EN */
  721. #define ROGUE_FWIF_MMUCACHEDATA_FLAGS_CTX_ALL (0x800)
  722. /* indicates FW should interrupt the host */
  723. #define ROGUE_FWIF_MMUCACHEDATA_FLAGS_INTERRUPT (0x4000000U)
  724. struct rogue_fwif_mmucachedata {
  725. u32 cache_flags;
  726. u32 mmu_cache_sync_fw_addr;
  727. u32 mmu_cache_sync_update_value;
  728. };
  729. #define ROGUE_FWIF_BPDATA_FLAGS_ENABLE BIT(0)
  730. #define ROGUE_FWIF_BPDATA_FLAGS_WRITE BIT(1)
  731. #define ROGUE_FWIF_BPDATA_FLAGS_CTL BIT(2)
  732. #define ROGUE_FWIF_BPDATA_FLAGS_REGS BIT(3)
  733. struct rogue_fwif_bpdata {
  734. /* Memory context */
  735. u32 fw_mem_context_fw_addr;
  736. /* Breakpoint address */
  737. u32 bp_addr;
  738. /* Breakpoint handler */
  739. u32 bp_handler_addr;
  740. /* Breakpoint control */
  741. u32 bp_dm;
  742. u32 bp_data_flags;
  743. /* Number of temporary registers to overallocate */
  744. u32 temp_regs;
  745. /* Number of shared registers to overallocate */
  746. u32 shared_regs;
  747. /* DM associated with the breakpoint */
  748. u32 dm;
  749. };
  750. #define ROGUE_FWIF_KCCB_CMD_KICK_DATA_MAX_NUM_CLEANUP_CTLS \
  751. (ROGUE_FWIF_PRBUFFER_MAXSUPPORTED + 1U) /* +1 is RTDATASET cleanup */
  752. struct rogue_fwif_kccb_cmd_kick_data {
  753. /* address of the firmware context */
  754. u32 context_fw_addr;
  755. /* Client CCB woff update */
  756. u32 client_woff_update;
  757. /* Client CCB wrap mask update after CCCB growth */
  758. u32 client_wrap_mask_update;
  759. /* number of CleanupCtl pointers attached */
  760. u32 num_cleanup_ctl;
  761. /* CleanupCtl structures associated with command */
  762. u32 cleanup_ctl_fw_addr
  763. [ROGUE_FWIF_KCCB_CMD_KICK_DATA_MAX_NUM_CLEANUP_CTLS];
  764. /*
  765. * offset to the CmdHeader which houses the workload estimation kick
  766. * data.
  767. */
  768. u32 work_est_cmd_header_offset;
  769. };
  770. struct rogue_fwif_kccb_cmd_combined_geom_frag_kick_data {
  771. struct rogue_fwif_kccb_cmd_kick_data geom_cmd_kick_data;
  772. struct rogue_fwif_kccb_cmd_kick_data frag_cmd_kick_data;
  773. };
  774. struct rogue_fwif_kccb_cmd_force_update_data {
  775. /* address of the firmware context */
  776. u32 context_fw_addr;
  777. /* Client CCB fence offset */
  778. u32 ccb_fence_offset;
  779. };
  780. enum rogue_fwif_cleanup_type {
  781. /* FW common context cleanup */
  782. ROGUE_FWIF_CLEANUP_FWCOMMONCONTEXT,
  783. /* FW HW RT data cleanup */
  784. ROGUE_FWIF_CLEANUP_HWRTDATA,
  785. /* FW freelist cleanup */
  786. ROGUE_FWIF_CLEANUP_FREELIST,
  787. /* FW ZS Buffer cleanup */
  788. ROGUE_FWIF_CLEANUP_ZSBUFFER,
  789. };
  790. struct rogue_fwif_cleanup_request {
  791. /* Cleanup type */
  792. enum rogue_fwif_cleanup_type cleanup_type;
  793. union {
  794. /* FW common context to cleanup */
  795. u32 context_fw_addr;
  796. /* HW RT to cleanup */
  797. u32 hwrt_data_fw_addr;
  798. /* Freelist to cleanup */
  799. u32 freelist_fw_addr;
  800. /* ZS Buffer to cleanup */
  801. u32 zs_buffer_fw_addr;
  802. } cleanup_data;
  803. };
  804. enum rogue_fwif_power_type {
  805. ROGUE_FWIF_POW_OFF_REQ = 1,
  806. ROGUE_FWIF_POW_FORCED_IDLE_REQ,
  807. ROGUE_FWIF_POW_NUM_UNITS_CHANGE,
  808. ROGUE_FWIF_POW_APM_LATENCY_CHANGE
  809. };
  810. enum rogue_fwif_power_force_idle_type {
  811. ROGUE_FWIF_POWER_FORCE_IDLE = 1,
  812. ROGUE_FWIF_POWER_CANCEL_FORCED_IDLE,
  813. ROGUE_FWIF_POWER_HOST_TIMEOUT,
  814. };
  815. struct rogue_fwif_power_request {
  816. /* Type of power request */
  817. enum rogue_fwif_power_type pow_type;
  818. union {
  819. /* Number of active Dusts */
  820. u32 num_of_dusts;
  821. /* If the operation is mandatory */
  822. bool forced __aligned(4);
  823. /*
  824. * Type of Request. Consolidating Force Idle, Cancel Forced
  825. * Idle, Host Timeout
  826. */
  827. enum rogue_fwif_power_force_idle_type pow_request_type;
  828. } power_req_data;
  829. };
  830. struct rogue_fwif_slcflushinvaldata {
  831. /* Context to fence on (only useful when bDMContext == TRUE) */
  832. u32 context_fw_addr;
  833. /* Invalidate the cache as well as flushing */
  834. bool inval __aligned(4);
  835. /* The data to flush/invalidate belongs to a specific DM context */
  836. bool dm_context __aligned(4);
  837. /* Optional address of range (only useful when bDMContext == FALSE) */
  838. aligned_u64 address;
  839. /* Optional size of range (only useful when bDMContext == FALSE) */
  840. aligned_u64 size;
  841. };
  842. enum rogue_fwif_hwperf_update_config {
  843. ROGUE_FWIF_HWPERF_CTRL_TOGGLE = 0,
  844. ROGUE_FWIF_HWPERF_CTRL_SET = 1,
  845. ROGUE_FWIF_HWPERF_CTRL_EMIT_FEATURES_EV = 2
  846. };
  847. struct rogue_fwif_hwperf_ctrl {
  848. enum rogue_fwif_hwperf_update_config opcode; /* Control operation code */
  849. aligned_u64 mask; /* Mask of events to toggle */
  850. };
  851. struct rogue_fwif_hwperf_config_enable_blks {
  852. /* Number of ROGUE_HWPERF_CONFIG_MUX_CNTBLK in the array */
  853. u32 num_blocks;
  854. /* Address of the ROGUE_HWPERF_CONFIG_MUX_CNTBLK array */
  855. u32 block_configs_fw_addr;
  856. };
  857. struct rogue_fwif_hwperf_config_da_blks {
  858. /* Number of ROGUE_HWPERF_CONFIG_CNTBLK in the array */
  859. u32 num_blocks;
  860. /* Address of the ROGUE_HWPERF_CONFIG_CNTBLK array */
  861. u32 block_configs_fw_addr;
  862. };
  863. struct rogue_fwif_coreclkspeedchange_data {
  864. u32 new_clock_speed; /* New clock speed */
  865. };
  866. #define ROGUE_FWIF_HWPERF_CTRL_BLKS_MAX 16
  867. struct rogue_fwif_hwperf_ctrl_blks {
  868. bool enable;
  869. /* Number of block IDs in the array */
  870. u32 num_blocks;
  871. /* Array of ROGUE_HWPERF_CNTBLK_ID values */
  872. u16 block_ids[ROGUE_FWIF_HWPERF_CTRL_BLKS_MAX];
  873. };
  874. struct rogue_fwif_hwperf_select_custom_cntrs {
  875. u16 custom_block;
  876. u16 num_counters;
  877. u32 custom_counter_ids_fw_addr;
  878. };
  879. struct rogue_fwif_zsbuffer_backing_data {
  880. u32 zs_buffer_fw_addr; /* ZS-Buffer FW address */
  881. bool done __aligned(4); /* action backing/unbacking succeeded */
  882. };
  883. struct rogue_fwif_freelist_gs_data {
  884. /* Freelist FW address */
  885. u32 freelist_fw_addr;
  886. /* Amount of the Freelist change */
  887. u32 delta_pages;
  888. /* New amount of pages on the freelist (including ready pages) */
  889. u32 new_pages;
  890. /* Number of ready pages to be held in reserve until OOM */
  891. u32 ready_pages;
  892. };
  893. #define MAX_FREELISTS_SIZE 3
  894. #define MAX_HW_GEOM_FRAG_CONTEXTS_SIZE 3
  895. #define ROGUE_FWIF_MAX_FREELISTS_TO_RECONSTRUCT \
  896. (MAX_HW_GEOM_FRAG_CONTEXTS_SIZE * MAX_FREELISTS_SIZE * 2U)
  897. #define ROGUE_FWIF_FREELISTS_RECONSTRUCTION_FAILED_FLAG 0x80000000U
  898. struct rogue_fwif_freelists_reconstruction_data {
  899. u32 freelist_count;
  900. u32 freelist_ids[ROGUE_FWIF_MAX_FREELISTS_TO_RECONSTRUCT];
  901. };
  902. struct rogue_fwif_write_offset_update_data {
  903. /*
  904. * Context to that may need to be resumed following write offset update
  905. */
  906. u32 context_fw_addr;
  907. } __aligned(8);
  908. /*
  909. ******************************************************************************
  910. * Proactive DVFS Structures
  911. ******************************************************************************
  912. */
  913. #define NUM_OPP_VALUES 16
  914. struct pdvfs_opp {
  915. u32 volt; /* V */
  916. u32 freq; /* Hz */
  917. } __aligned(8);
  918. struct rogue_fwif_pdvfs_opp {
  919. struct pdvfs_opp opp_values[NUM_OPP_VALUES];
  920. u32 min_opp_point;
  921. u32 max_opp_point;
  922. } __aligned(8);
  923. struct rogue_fwif_pdvfs_max_freq_data {
  924. u32 max_opp_point;
  925. } __aligned(8);
  926. struct rogue_fwif_pdvfs_min_freq_data {
  927. u32 min_opp_point;
  928. } __aligned(8);
  929. /*
  930. ******************************************************************************
  931. * Register configuration structures
  932. ******************************************************************************
  933. */
  934. #define ROGUE_FWIF_REG_CFG_MAX_SIZE 512
  935. enum rogue_fwif_regdata_cmd_type {
  936. ROGUE_FWIF_REGCFG_CMD_ADD = 101,
  937. ROGUE_FWIF_REGCFG_CMD_CLEAR = 102,
  938. ROGUE_FWIF_REGCFG_CMD_ENABLE = 103,
  939. ROGUE_FWIF_REGCFG_CMD_DISABLE = 104
  940. };
  941. enum rogue_fwif_reg_cfg_type {
  942. /* Sidekick power event */
  943. ROGUE_FWIF_REG_CFG_TYPE_PWR_ON = 0,
  944. /* Rascal / dust power event */
  945. ROGUE_FWIF_REG_CFG_TYPE_DUST_CHANGE,
  946. /* Geometry kick */
  947. ROGUE_FWIF_REG_CFG_TYPE_GEOM,
  948. /* Fragment kick */
  949. ROGUE_FWIF_REG_CFG_TYPE_FRAG,
  950. /* Compute kick */
  951. ROGUE_FWIF_REG_CFG_TYPE_CDM,
  952. /* TLA kick */
  953. ROGUE_FWIF_REG_CFG_TYPE_TLA,
  954. /* TDM kick */
  955. ROGUE_FWIF_REG_CFG_TYPE_TDM,
  956. /* Applies to all types. Keep as last element */
  957. ROGUE_FWIF_REG_CFG_TYPE_ALL
  958. };
  959. struct rogue_fwif_reg_cfg_rec {
  960. u64 sddr;
  961. u64 mask;
  962. u64 value;
  963. };
  964. struct rogue_fwif_regconfig_data {
  965. enum rogue_fwif_regdata_cmd_type cmd_type;
  966. enum rogue_fwif_reg_cfg_type reg_config_type;
  967. struct rogue_fwif_reg_cfg_rec reg_config __aligned(8);
  968. };
  969. struct rogue_fwif_reg_cfg {
  970. /*
  971. * PDump WRW command write granularity is 32 bits.
  972. * Add padding to ensure array size is 32 bit granular.
  973. */
  974. u8 num_regs_type[ALIGN((u32)ROGUE_FWIF_REG_CFG_TYPE_ALL,
  975. sizeof(u32))] __aligned(8);
  976. struct rogue_fwif_reg_cfg_rec
  977. reg_configs[ROGUE_FWIF_REG_CFG_MAX_SIZE] __aligned(8);
  978. } __aligned(8);
  979. enum rogue_fwif_os_state_change {
  980. ROGUE_FWIF_OS_ONLINE = 1,
  981. ROGUE_FWIF_OS_OFFLINE
  982. };
  983. struct rogue_fwif_os_state_change_data {
  984. u32 osid;
  985. enum rogue_fwif_os_state_change new_os_state;
  986. } __aligned(8);
  987. enum rogue_fwif_counter_dump_request {
  988. ROGUE_FWIF_PWR_COUNTER_DUMP_START = 1,
  989. ROGUE_FWIF_PWR_COUNTER_DUMP_STOP,
  990. ROGUE_FWIF_PWR_COUNTER_DUMP_SAMPLE,
  991. };
  992. struct rogue_fwif_counter_dump_data {
  993. enum rogue_fwif_counter_dump_request counter_dump_request;
  994. } __aligned(8);
  995. enum rogue_fwif_kccb_cmd_type {
  996. /* Common commands */
  997. ROGUE_FWIF_KCCB_CMD_KICK = 101U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  998. ROGUE_FWIF_KCCB_CMD_MMUCACHE = 102U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  999. ROGUE_FWIF_KCCB_CMD_BP = 103U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1000. /* SLC flush and invalidation request */
  1001. ROGUE_FWIF_KCCB_CMD_SLCFLUSHINVAL = 105U |
  1002. ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1003. /*
  1004. * Requests cleanup of a FW resource (type specified in the command
  1005. * data)
  1006. */
  1007. ROGUE_FWIF_KCCB_CMD_CLEANUP = 106U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1008. /* Power request */
  1009. ROGUE_FWIF_KCCB_CMD_POW = 107U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1010. /* Backing for on-demand ZS-Buffer done */
  1011. ROGUE_FWIF_KCCB_CMD_ZSBUFFER_BACKING_UPDATE =
  1012. 108U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1013. /* Unbacking for on-demand ZS-Buffer done */
  1014. ROGUE_FWIF_KCCB_CMD_ZSBUFFER_UNBACKING_UPDATE =
  1015. 109U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1016. /* Freelist Grow done */
  1017. ROGUE_FWIF_KCCB_CMD_FREELIST_GROW_UPDATE =
  1018. 110U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1019. /* Freelists Reconstruction done */
  1020. ROGUE_FWIF_KCCB_CMD_FREELISTS_RECONSTRUCTION_UPDATE =
  1021. 112U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1022. /*
  1023. * Informs the firmware that the host has added more data to a CDM2
  1024. * Circular Buffer
  1025. */
  1026. ROGUE_FWIF_KCCB_CMD_NOTIFY_WRITE_OFFSET_UPDATE =
  1027. 114U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1028. /* Health check request */
  1029. ROGUE_FWIF_KCCB_CMD_HEALTH_CHECK = 115U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1030. /* Forcing signalling of all unmet UFOs for a given CCB offset */
  1031. ROGUE_FWIF_KCCB_CMD_FORCE_UPDATE = 116U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1032. /* There is a geometry and a fragment command in this single kick */
  1033. ROGUE_FWIF_KCCB_CMD_COMBINED_GEOM_FRAG_KICK = 117U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1034. /* Informs the FW that a Guest OS has come online / offline. */
  1035. ROGUE_FWIF_KCCB_CMD_OS_ONLINE_STATE_CONFIGURE = 118U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1036. /* Commands only permitted to the native or host OS */
  1037. ROGUE_FWIF_KCCB_CMD_REGCONFIG = 200U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1038. /* Configure HWPerf events (to be generated) and HWPerf buffer address (if required) */
  1039. ROGUE_FWIF_KCCB_CMD_HWPERF_UPDATE_CONFIG = 201U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1040. /* Enable or disable multiple HWPerf blocks (reusing existing configuration) */
  1041. ROGUE_FWIF_KCCB_CMD_HWPERF_CTRL_BLKS = 203U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1042. /* Core clock speed change event */
  1043. ROGUE_FWIF_KCCB_CMD_CORECLKSPEEDCHANGE = 204U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1044. /*
  1045. * Ask the firmware to update its cached ui32LogType value from the (shared)
  1046. * tracebuf control structure
  1047. */
  1048. ROGUE_FWIF_KCCB_CMD_LOGTYPE_UPDATE = 206U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1049. /* Set a maximum frequency/OPP point */
  1050. ROGUE_FWIF_KCCB_CMD_PDVFS_LIMIT_MAX_FREQ = 207U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1051. /*
  1052. * Changes the relative scheduling priority for a particular OSid. It can
  1053. * only be serviced for the Host DDK
  1054. */
  1055. ROGUE_FWIF_KCCB_CMD_OSID_PRIORITY_CHANGE = 208U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1056. /* Set or clear firmware state flags */
  1057. ROGUE_FWIF_KCCB_CMD_STATEFLAGS_CTRL = 209U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1058. /* Set a minimum frequency/OPP point */
  1059. ROGUE_FWIF_KCCB_CMD_PDVFS_LIMIT_MIN_FREQ = 212U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1060. /* Configure Periodic Hardware Reset behaviour */
  1061. ROGUE_FWIF_KCCB_CMD_PHR_CFG = 213U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1062. /* Configure Safety Firmware Watchdog */
  1063. ROGUE_FWIF_KCCB_CMD_WDG_CFG = 215U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1064. /* Controls counter dumping in the FW */
  1065. ROGUE_FWIF_KCCB_CMD_COUNTER_DUMP = 216U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1066. /* Configure, clear and enable multiple HWPerf blocks */
  1067. ROGUE_FWIF_KCCB_CMD_HWPERF_CONFIG_ENABLE_BLKS = 217U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1068. /* Configure the custom counters for HWPerf */
  1069. ROGUE_FWIF_KCCB_CMD_HWPERF_SELECT_CUSTOM_CNTRS = 218U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1070. /* Configure directly addressable counters for HWPerf */
  1071. ROGUE_FWIF_KCCB_CMD_HWPERF_CONFIG_BLKS = 220U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1072. };
  1073. #define ROGUE_FWIF_LAST_ALLOWED_GUEST_KCCB_CMD \
  1074. (ROGUE_FWIF_KCCB_CMD_REGCONFIG - 1)
  1075. /* Kernel CCB command packet */
  1076. struct rogue_fwif_kccb_cmd {
  1077. /* Command type */
  1078. enum rogue_fwif_kccb_cmd_type cmd_type;
  1079. /* Compatibility and other flags */
  1080. u32 kccb_flags;
  1081. /*
  1082. * NOTE: Make sure that uCmdData is the last member of this struct
  1083. * This is to calculate actual command size for device mem copy.
  1084. * (Refer ROGUEGetCmdMemCopySize())
  1085. */
  1086. union {
  1087. /* Data for Kick command */
  1088. struct rogue_fwif_kccb_cmd_kick_data cmd_kick_data;
  1089. /* Data for combined geom/frag Kick command */
  1090. struct rogue_fwif_kccb_cmd_combined_geom_frag_kick_data
  1091. combined_geom_frag_cmd_kick_data;
  1092. /* Data for MMU cache command */
  1093. struct rogue_fwif_mmucachedata mmu_cache_data;
  1094. /* Data for Breakpoint Commands */
  1095. struct rogue_fwif_bpdata bp_data;
  1096. /* Data for SLC Flush/Inval commands */
  1097. struct rogue_fwif_slcflushinvaldata slc_flush_inval_data;
  1098. /* Data for cleanup commands */
  1099. struct rogue_fwif_cleanup_request cleanup_data;
  1100. /* Data for power request commands */
  1101. struct rogue_fwif_power_request pow_data;
  1102. /* Data for HWPerf control command */
  1103. struct rogue_fwif_hwperf_ctrl hw_perf_ctrl;
  1104. /*
  1105. * Data for HWPerf configure, clear and enable performance
  1106. * counter block command
  1107. */
  1108. struct rogue_fwif_hwperf_config_enable_blks
  1109. hw_perf_cfg_enable_blks;
  1110. /*
  1111. * Data for HWPerf enable or disable performance counter block
  1112. * commands
  1113. */
  1114. struct rogue_fwif_hwperf_ctrl_blks hw_perf_ctrl_blks;
  1115. /* Data for HWPerf configure the custom counters to read */
  1116. struct rogue_fwif_hwperf_select_custom_cntrs
  1117. hw_perf_select_cstm_cntrs;
  1118. /* Data for HWPerf configure Directly Addressable blocks */
  1119. struct rogue_fwif_hwperf_config_da_blks hw_perf_cfg_da_blks;
  1120. /* Data for core clock speed change */
  1121. struct rogue_fwif_coreclkspeedchange_data
  1122. core_clk_speed_change_data;
  1123. /* Feedback for Z/S Buffer backing/unbacking */
  1124. struct rogue_fwif_zsbuffer_backing_data zs_buffer_backing_data;
  1125. /* Feedback for Freelist grow/shrink */
  1126. struct rogue_fwif_freelist_gs_data free_list_gs_data;
  1127. /* Feedback for Freelists reconstruction*/
  1128. struct rogue_fwif_freelists_reconstruction_data
  1129. free_lists_reconstruction_data;
  1130. /* Data for custom register configuration */
  1131. struct rogue_fwif_regconfig_data reg_config_data;
  1132. /* Data for informing the FW about the write offset update */
  1133. struct rogue_fwif_write_offset_update_data
  1134. write_offset_update_data;
  1135. /* Data for setting the max frequency/OPP */
  1136. struct rogue_fwif_pdvfs_max_freq_data pdvfs_max_freq_data;
  1137. /* Data for setting the min frequency/OPP */
  1138. struct rogue_fwif_pdvfs_min_freq_data pdvfs_min_freq_data;
  1139. /* Data for updating the Guest Online states */
  1140. struct rogue_fwif_os_state_change_data cmd_os_online_state_data;
  1141. /* Dev address for TBI buffer allocated on demand */
  1142. u32 tbi_buffer_fw_addr;
  1143. /* Data for dumping of register ranges */
  1144. struct rogue_fwif_counter_dump_data counter_dump_config_data;
  1145. /* Data for signalling all unmet fences for a given CCB */
  1146. struct rogue_fwif_kccb_cmd_force_update_data force_update_data;
  1147. } cmd_data __aligned(8);
  1148. } __aligned(8);
  1149. PVR_FW_STRUCT_SIZE_ASSERT(struct rogue_fwif_kccb_cmd);
  1150. /*
  1151. ******************************************************************************
  1152. * Firmware CCB command structure for ROGUE
  1153. ******************************************************************************
  1154. */
  1155. struct rogue_fwif_fwccb_cmd_zsbuffer_backing_data {
  1156. u32 zs_buffer_id;
  1157. };
  1158. struct rogue_fwif_fwccb_cmd_freelist_gs_data {
  1159. u32 freelist_id;
  1160. };
  1161. struct rogue_fwif_fwccb_cmd_freelists_reconstruction_data {
  1162. u32 freelist_count;
  1163. u32 hwr_counter;
  1164. u32 freelist_ids[ROGUE_FWIF_MAX_FREELISTS_TO_RECONSTRUCT];
  1165. };
  1166. /* 1 if a page fault happened */
  1167. #define ROGUE_FWIF_FWCCB_CMD_CONTEXT_RESET_FLAG_PF BIT(0)
  1168. /* 1 if applicable to all contexts */
  1169. #define ROGUE_FWIF_FWCCB_CMD_CONTEXT_RESET_FLAG_ALL_CTXS BIT(1)
  1170. struct rogue_fwif_fwccb_cmd_context_reset_data {
  1171. /* Context affected by the reset */
  1172. u32 server_common_context_id;
  1173. /* Reason for reset */
  1174. enum rogue_context_reset_reason reset_reason;
  1175. /* Data Master affected by the reset */
  1176. u32 dm;
  1177. /* Job ref running at the time of reset */
  1178. u32 reset_job_ref;
  1179. /* ROGUE_FWIF_FWCCB_CMD_CONTEXT_RESET_FLAG bitfield */
  1180. u32 flags;
  1181. /* At what page catalog address */
  1182. aligned_u64 pc_address;
  1183. /* Page fault address (only when applicable) */
  1184. aligned_u64 fault_address;
  1185. };
  1186. struct rogue_fwif_fwccb_cmd_fw_pagefault_data {
  1187. /* Page fault address */
  1188. u64 fw_fault_addr;
  1189. };
  1190. enum rogue_fwif_fwccb_cmd_type {
  1191. /* Requests ZSBuffer to be backed with physical pages */
  1192. ROGUE_FWIF_FWCCB_CMD_ZSBUFFER_BACKING = 101U |
  1193. ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1194. /* Requests ZSBuffer to be unbacked */
  1195. ROGUE_FWIF_FWCCB_CMD_ZSBUFFER_UNBACKING = 102U |
  1196. ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1197. /* Requests an on-demand freelist grow/shrink */
  1198. ROGUE_FWIF_FWCCB_CMD_FREELIST_GROW = 103U |
  1199. ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1200. /* Requests freelists reconstruction */
  1201. ROGUE_FWIF_FWCCB_CMD_FREELISTS_RECONSTRUCTION =
  1202. 104U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1203. /* Notifies host of a HWR event on a context */
  1204. ROGUE_FWIF_FWCCB_CMD_CONTEXT_RESET_NOTIFICATION =
  1205. 105U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1206. /* Requests an on-demand debug dump */
  1207. ROGUE_FWIF_FWCCB_CMD_DEBUG_DUMP = 106U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1208. /* Requests an on-demand update on process stats */
  1209. ROGUE_FWIF_FWCCB_CMD_UPDATE_STATS = 107U |
  1210. ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1211. ROGUE_FWIF_FWCCB_CMD_CORE_CLK_RATE_CHANGE =
  1212. 108U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1213. ROGUE_FWIF_FWCCB_CMD_REQUEST_GPU_RESTART =
  1214. 109U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1215. /* Notifies host of a FW pagefault */
  1216. ROGUE_FWIF_FWCCB_CMD_CONTEXT_FW_PF_NOTIFICATION =
  1217. 112U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
  1218. };
  1219. enum rogue_fwif_fwccb_cmd_update_stats_type {
  1220. /*
  1221. * PVRSRVStatsUpdateRenderContextStats should increase the value of the
  1222. * ui32TotalNumPartialRenders stat
  1223. */
  1224. ROGUE_FWIF_FWCCB_CMD_UPDATE_NUM_PARTIAL_RENDERS = 1,
  1225. /*
  1226. * PVRSRVStatsUpdateRenderContextStats should increase the value of the
  1227. * ui32TotalNumOutOfMemory stat
  1228. */
  1229. ROGUE_FWIF_FWCCB_CMD_UPDATE_NUM_OUT_OF_MEMORY,
  1230. /*
  1231. * PVRSRVStatsUpdateRenderContextStats should increase the value of the
  1232. * ui32NumGeomStores stat
  1233. */
  1234. ROGUE_FWIF_FWCCB_CMD_UPDATE_NUM_GEOM_STORES,
  1235. /*
  1236. * PVRSRVStatsUpdateRenderContextStats should increase the value of the
  1237. * ui32NumFragStores stat
  1238. */
  1239. ROGUE_FWIF_FWCCB_CMD_UPDATE_NUM_FRAG_STORES,
  1240. /*
  1241. * PVRSRVStatsUpdateRenderContextStats should increase the value of the
  1242. * ui32NumCDMStores stat
  1243. */
  1244. ROGUE_FWIF_FWCCB_CMD_UPDATE_NUM_CDM_STORES,
  1245. /*
  1246. * PVRSRVStatsUpdateRenderContextStats should increase the value of the
  1247. * ui32NumTDMStores stat
  1248. */
  1249. ROGUE_FWIF_FWCCB_CMD_UPDATE_NUM_TDM_STORES
  1250. };
  1251. struct rogue_fwif_fwccb_cmd_update_stats_data {
  1252. /* Element to update */
  1253. enum rogue_fwif_fwccb_cmd_update_stats_type element_to_update;
  1254. /* The pid of the process whose stats are being updated */
  1255. u32 pid_owner;
  1256. /* Adjustment to be made to the statistic */
  1257. s32 adjustment_value;
  1258. };
  1259. struct rogue_fwif_fwccb_cmd_core_clk_rate_change_data {
  1260. u32 core_clk_rate;
  1261. } __aligned(8);
  1262. struct rogue_fwif_fwccb_cmd {
  1263. /* Command type */
  1264. enum rogue_fwif_fwccb_cmd_type cmd_type;
  1265. /* Compatibility and other flags */
  1266. u32 fwccb_flags;
  1267. union {
  1268. /* Data for Z/S-Buffer on-demand (un)backing*/
  1269. struct rogue_fwif_fwccb_cmd_zsbuffer_backing_data
  1270. cmd_zs_buffer_backing;
  1271. /* Data for on-demand freelist grow/shrink */
  1272. struct rogue_fwif_fwccb_cmd_freelist_gs_data cmd_free_list_gs;
  1273. /* Data for freelists reconstruction */
  1274. struct rogue_fwif_fwccb_cmd_freelists_reconstruction_data
  1275. cmd_freelists_reconstruction;
  1276. /* Data for context reset notification */
  1277. struct rogue_fwif_fwccb_cmd_context_reset_data
  1278. cmd_context_reset_notification;
  1279. /* Data for updating process stats */
  1280. struct rogue_fwif_fwccb_cmd_update_stats_data
  1281. cmd_update_stats_data;
  1282. struct rogue_fwif_fwccb_cmd_core_clk_rate_change_data
  1283. cmd_core_clk_rate_change;
  1284. struct rogue_fwif_fwccb_cmd_fw_pagefault_data cmd_fw_pagefault;
  1285. } cmd_data __aligned(8);
  1286. } __aligned(8);
  1287. PVR_FW_STRUCT_SIZE_ASSERT(struct rogue_fwif_fwccb_cmd);
  1288. /*
  1289. ******************************************************************************
  1290. * Workload estimation Firmware CCB command structure for ROGUE
  1291. ******************************************************************************
  1292. */
  1293. struct rogue_fwif_workest_fwccb_cmd {
  1294. /* Index for return data array */
  1295. u16 return_data_index;
  1296. /* The cycles the workload took on the hardware */
  1297. u32 cycles_taken;
  1298. };
  1299. /*
  1300. ******************************************************************************
  1301. * Client CCB commands for ROGUE
  1302. ******************************************************************************
  1303. */
  1304. /*
  1305. * Required memory alignment for 64-bit variables accessible by Meta
  1306. * (The gcc meta aligns 64-bit variables to 64-bit; therefore, memory shared
  1307. * between the host and meta that contains 64-bit variables has to maintain
  1308. * this alignment)
  1309. */
  1310. #define ROGUE_FWIF_FWALLOC_ALIGN sizeof(u64)
  1311. #define ROGUE_CCB_TYPE_TASK BIT(15)
  1312. #define ROGUE_CCB_FWALLOC_ALIGN(size) \
  1313. (((size) + (ROGUE_FWIF_FWALLOC_ALIGN - 1)) & \
  1314. ~(ROGUE_FWIF_FWALLOC_ALIGN - 1))
  1315. #define ROGUE_FWIF_CCB_CMD_TYPE_GEOM \
  1316. (201U | ROGUE_CMD_MAGIC_DWORD_SHIFTED | ROGUE_CCB_TYPE_TASK)
  1317. #define ROGUE_FWIF_CCB_CMD_TYPE_TQ_3D \
  1318. (202U | ROGUE_CMD_MAGIC_DWORD_SHIFTED | ROGUE_CCB_TYPE_TASK)
  1319. #define ROGUE_FWIF_CCB_CMD_TYPE_FRAG \
  1320. (203U | ROGUE_CMD_MAGIC_DWORD_SHIFTED | ROGUE_CCB_TYPE_TASK)
  1321. #define ROGUE_FWIF_CCB_CMD_TYPE_FRAG_PR \
  1322. (204U | ROGUE_CMD_MAGIC_DWORD_SHIFTED | ROGUE_CCB_TYPE_TASK)
  1323. #define ROGUE_FWIF_CCB_CMD_TYPE_CDM \
  1324. (205U | ROGUE_CMD_MAGIC_DWORD_SHIFTED | ROGUE_CCB_TYPE_TASK)
  1325. #define ROGUE_FWIF_CCB_CMD_TYPE_TQ_TDM \
  1326. (206U | ROGUE_CMD_MAGIC_DWORD_SHIFTED | ROGUE_CCB_TYPE_TASK)
  1327. #define ROGUE_FWIF_CCB_CMD_TYPE_FBSC_INVALIDATE \
  1328. (207U | ROGUE_CMD_MAGIC_DWORD_SHIFTED | ROGUE_CCB_TYPE_TASK)
  1329. #define ROGUE_FWIF_CCB_CMD_TYPE_TQ_2D \
  1330. (208U | ROGUE_CMD_MAGIC_DWORD_SHIFTED | ROGUE_CCB_TYPE_TASK)
  1331. #define ROGUE_FWIF_CCB_CMD_TYPE_PRE_TIMESTAMP \
  1332. (209U | ROGUE_CMD_MAGIC_DWORD_SHIFTED | ROGUE_CCB_TYPE_TASK)
  1333. #define ROGUE_FWIF_CCB_CMD_TYPE_NULL \
  1334. (210U | ROGUE_CMD_MAGIC_DWORD_SHIFTED | ROGUE_CCB_TYPE_TASK)
  1335. #define ROGUE_FWIF_CCB_CMD_TYPE_ABORT \
  1336. (211U | ROGUE_CMD_MAGIC_DWORD_SHIFTED | ROGUE_CCB_TYPE_TASK)
  1337. /* Leave a gap between CCB specific commands and generic commands */
  1338. #define ROGUE_FWIF_CCB_CMD_TYPE_FENCE (212U | ROGUE_CMD_MAGIC_DWORD_SHIFTED)
  1339. #define ROGUE_FWIF_CCB_CMD_TYPE_UPDATE (213U | ROGUE_CMD_MAGIC_DWORD_SHIFTED)
  1340. #define ROGUE_FWIF_CCB_CMD_TYPE_RMW_UPDATE \
  1341. (214U | ROGUE_CMD_MAGIC_DWORD_SHIFTED)
  1342. #define ROGUE_FWIF_CCB_CMD_TYPE_FENCE_PR (215U | ROGUE_CMD_MAGIC_DWORD_SHIFTED)
  1343. #define ROGUE_FWIF_CCB_CMD_TYPE_PRIORITY (216U | ROGUE_CMD_MAGIC_DWORD_SHIFTED)
  1344. /*
  1345. * Pre and Post timestamp commands are supposed to sandwich the DM cmd. The
  1346. * padding code with the CCB wrap upsets the FW if we don't have the task type
  1347. * bit cleared for POST_TIMESTAMPs. That's why we have 2 different cmd types.
  1348. */
  1349. #define ROGUE_FWIF_CCB_CMD_TYPE_POST_TIMESTAMP \
  1350. (217U | ROGUE_CMD_MAGIC_DWORD_SHIFTED)
  1351. #define ROGUE_FWIF_CCB_CMD_TYPE_UNFENCED_UPDATE \
  1352. (218U | ROGUE_CMD_MAGIC_DWORD_SHIFTED)
  1353. #define ROGUE_FWIF_CCB_CMD_TYPE_UNFENCED_RMW_UPDATE \
  1354. (219U | ROGUE_CMD_MAGIC_DWORD_SHIFTED)
  1355. #define ROGUE_FWIF_CCB_CMD_TYPE_PADDING (221U | ROGUE_CMD_MAGIC_DWORD_SHIFTED)
  1356. struct rogue_fwif_workest_kick_data {
  1357. /* Index for the KM Workload estimation return data array */
  1358. u16 return_data_index __aligned(8);
  1359. /* Predicted time taken to do the work in cycles */
  1360. u32 cycles_prediction __aligned(8);
  1361. /* Deadline for the workload */
  1362. aligned_u64 deadline;
  1363. };
  1364. struct rogue_fwif_ccb_cmd_header {
  1365. u32 cmd_type;
  1366. u32 cmd_size;
  1367. /*
  1368. * external job reference - provided by client and used in debug for
  1369. * tracking submitted work
  1370. */
  1371. u32 ext_job_ref;
  1372. /*
  1373. * internal job reference - generated by services and used in debug for
  1374. * tracking submitted work
  1375. */
  1376. u32 int_job_ref;
  1377. /* Workload Estimation - Workload Estimation Data */
  1378. struct rogue_fwif_workest_kick_data work_est_kick_data __aligned(8);
  1379. };
  1380. /*
  1381. ******************************************************************************
  1382. * Client CCB commands which are only required by the kernel
  1383. ******************************************************************************
  1384. */
  1385. struct rogue_fwif_cmd_priority {
  1386. s32 priority;
  1387. };
  1388. /*
  1389. ******************************************************************************
  1390. * Signature and Checksums Buffer
  1391. ******************************************************************************
  1392. */
  1393. struct rogue_fwif_sigbuf_ctl {
  1394. /* Ptr to Signature Buffer memory */
  1395. u32 buffer_fw_addr;
  1396. /* Amount of space left for storing regs in the buffer */
  1397. u32 left_size_in_regs;
  1398. } __aligned(8);
  1399. struct rogue_fwif_counter_dump_ctl {
  1400. /* Ptr to counter dump buffer */
  1401. u32 buffer_fw_addr;
  1402. /* Amount of space for storing in the buffer */
  1403. u32 size_in_dwords;
  1404. } __aligned(8);
  1405. struct rogue_fwif_firmware_gcov_ctl {
  1406. /* Ptr to firmware gcov buffer */
  1407. u32 buffer_fw_addr;
  1408. /* Amount of space for storing in the buffer */
  1409. u32 size;
  1410. } __aligned(8);
  1411. /*
  1412. *****************************************************************************
  1413. * ROGUE Compatibility checks
  1414. *****************************************************************************
  1415. */
  1416. /*
  1417. * WARNING: Whenever the layout of ROGUE_FWIF_COMPCHECKS_BVNC changes, the
  1418. * following define should be increased by 1 to indicate to the compatibility
  1419. * logic that layout has changed.
  1420. */
  1421. #define ROGUE_FWIF_COMPCHECKS_LAYOUT_VERSION 3
  1422. struct rogue_fwif_compchecks_bvnc {
  1423. /* WARNING: This field must be defined as first one in this structure */
  1424. u32 layout_version;
  1425. aligned_u64 bvnc;
  1426. } __aligned(8);
  1427. struct rogue_fwif_init_options {
  1428. u8 os_count_support;
  1429. u8 padding[7];
  1430. } __aligned(8);
  1431. #define ROGUE_FWIF_COMPCHECKS_BVNC_DECLARE_AND_INIT(name) \
  1432. struct rogue_fwif_compchecks_bvnc(name) = { \
  1433. ROGUE_FWIF_COMPCHECKS_LAYOUT_VERSION, \
  1434. 0, \
  1435. }
  1436. static inline void rogue_fwif_compchecks_bvnc_init(struct rogue_fwif_compchecks_bvnc *compchecks)
  1437. {
  1438. compchecks->layout_version = ROGUE_FWIF_COMPCHECKS_LAYOUT_VERSION;
  1439. compchecks->bvnc = 0;
  1440. }
  1441. struct rogue_fwif_compchecks {
  1442. /* hardware BVNC (from the ROGUE registers) */
  1443. struct rogue_fwif_compchecks_bvnc hw_bvnc;
  1444. /* firmware BVNC */
  1445. struct rogue_fwif_compchecks_bvnc fw_bvnc;
  1446. /* identifier of the FW processor version */
  1447. u32 fw_processor_version;
  1448. /* software DDK version */
  1449. u32 ddk_version;
  1450. /* software DDK build no. */
  1451. u32 ddk_build;
  1452. /* build options bit-field */
  1453. u32 build_options;
  1454. /* initialisation options bit-field */
  1455. struct rogue_fwif_init_options init_options;
  1456. /* Information is valid */
  1457. bool updated __aligned(4);
  1458. u32 padding;
  1459. } __aligned(8);
  1460. /*
  1461. ******************************************************************************
  1462. * Updated configuration post FW data init.
  1463. ******************************************************************************
  1464. */
  1465. struct rogue_fwif_runtime_cfg {
  1466. /* APM latency in ms before signalling IDLE to the host */
  1467. u32 active_pm_latency_ms;
  1468. /* Compatibility and other flags */
  1469. u32 runtime_cfg_flags;
  1470. /*
  1471. * If set, APM latency does not reset to system default each GPU power
  1472. * transition
  1473. */
  1474. bool active_pm_latency_persistant __aligned(4);
  1475. /* Core clock speed, currently only used to calculate timer ticks */
  1476. u32 core_clock_speed;
  1477. /* Last number of dusts change requested by the host */
  1478. u32 default_dusts_num_init;
  1479. /* Periodic Hardware Reset configuration values */
  1480. u32 phr_mode;
  1481. /* New number of milliseconds C/S is allowed to last */
  1482. u32 hcs_deadline_ms;
  1483. /* The watchdog period in microseconds */
  1484. u32 wdg_period_us;
  1485. /* Array of priorities per OS */
  1486. u32 osid_priority[ROGUE_FW_MAX_NUM_OS];
  1487. /* On-demand allocated HWPerf buffer address, to be passed to the FW */
  1488. u32 hwperf_buf_fw_addr;
  1489. bool padding __aligned(4);
  1490. };
  1491. /*
  1492. *****************************************************************************
  1493. * Control data for ROGUE
  1494. *****************************************************************************
  1495. */
  1496. #define ROGUE_FWIF_HWR_DEBUG_DUMP_ALL (99999U)
  1497. enum rogue_fwif_tpu_dm {
  1498. ROGUE_FWIF_TPU_DM_PDM = 0,
  1499. ROGUE_FWIF_TPU_DM_VDM = 1,
  1500. ROGUE_FWIF_TPU_DM_CDM = 2,
  1501. ROGUE_FWIF_TPU_DM_TDM = 3,
  1502. ROGUE_FWIF_TPU_DM_LAST
  1503. };
  1504. enum rogue_fwif_gpio_val_mode {
  1505. /* No GPIO validation */
  1506. ROGUE_FWIF_GPIO_VAL_OFF = 0,
  1507. /*
  1508. * Simple test case that initiates by sending data via the GPIO and then
  1509. * sends back any data received over the GPIO
  1510. */
  1511. ROGUE_FWIF_GPIO_VAL_GENERAL = 1,
  1512. /*
  1513. * More complex test case that writes and reads data across the entire
  1514. * GPIO AP address range.
  1515. */
  1516. ROGUE_FWIF_GPIO_VAL_AP = 2,
  1517. /* Validates the GPIO Testbench. */
  1518. ROGUE_FWIF_GPIO_VAL_TESTBENCH = 5,
  1519. /* Send and then receive each byte in the range 0-255. */
  1520. ROGUE_FWIF_GPIO_VAL_LOOPBACK = 6,
  1521. /* Send and then receive each power-of-2 byte in the range 0-255. */
  1522. ROGUE_FWIF_GPIO_VAL_LOOPBACK_LITE = 7,
  1523. ROGUE_FWIF_GPIO_VAL_LAST
  1524. };
  1525. enum fw_perf_conf {
  1526. FW_PERF_CONF_NONE = 0,
  1527. FW_PERF_CONF_ICACHE = 1,
  1528. FW_PERF_CONF_DCACHE = 2,
  1529. FW_PERF_CONF_JTLB_INSTR = 5,
  1530. FW_PERF_CONF_INSTRUCTIONS = 6
  1531. };
  1532. enum fw_boot_stage {
  1533. FW_BOOT_STAGE_TLB_INIT_FAILURE = -2,
  1534. FW_BOOT_STAGE_NOT_AVAILABLE = -1,
  1535. FW_BOOT_NOT_STARTED = 0,
  1536. FW_BOOT_BLDR_STARTED = 1,
  1537. FW_BOOT_CACHE_DONE,
  1538. FW_BOOT_TLB_DONE,
  1539. FW_BOOT_MAIN_STARTED,
  1540. FW_BOOT_ALIGNCHECKS_DONE,
  1541. FW_BOOT_INIT_DONE,
  1542. };
  1543. /*
  1544. * Kernel CCB return slot responses. Usage of bit-fields instead of bare
  1545. * integers allows FW to possibly pack-in several responses for each single kCCB
  1546. * command.
  1547. */
  1548. /* Command executed (return status from FW) */
  1549. #define ROGUE_FWIF_KCCB_RTN_SLOT_CMD_EXECUTED BIT(0)
  1550. /* A cleanup was requested but resource busy */
  1551. #define ROGUE_FWIF_KCCB_RTN_SLOT_CLEANUP_BUSY BIT(1)
  1552. /* Poll failed in FW for a HW operation to complete */
  1553. #define ROGUE_FWIF_KCCB_RTN_SLOT_POLL_FAILURE BIT(2)
  1554. /* Reset value of a kCCB return slot (set by host) */
  1555. #define ROGUE_FWIF_KCCB_RTN_SLOT_NO_RESPONSE 0x0U
  1556. struct rogue_fwif_connection_ctl {
  1557. /* Fw-Os connection states */
  1558. enum rogue_fwif_connection_fw_state connection_fw_state;
  1559. enum rogue_fwif_connection_os_state connection_os_state;
  1560. u32 alive_fw_token;
  1561. u32 alive_os_token;
  1562. } __aligned(8);
  1563. struct rogue_fwif_osinit {
  1564. /* Kernel CCB */
  1565. u32 kernel_ccbctl_fw_addr;
  1566. u32 kernel_ccb_fw_addr;
  1567. u32 kernel_ccb_rtn_slots_fw_addr;
  1568. /* Firmware CCB */
  1569. u32 firmware_ccbctl_fw_addr;
  1570. u32 firmware_ccb_fw_addr;
  1571. /* Workload Estimation Firmware CCB */
  1572. u32 work_est_firmware_ccbctl_fw_addr;
  1573. u32 work_est_firmware_ccb_fw_addr;
  1574. u32 rogue_fwif_hwr_info_buf_ctl_fw_addr;
  1575. u32 hwr_debug_dump_limit;
  1576. u32 fw_os_data_fw_addr;
  1577. /* Compatibility checks to be populated by the Firmware */
  1578. struct rogue_fwif_compchecks rogue_comp_checks;
  1579. } __aligned(8);
  1580. /* BVNC Features */
  1581. struct rogue_hwperf_bvnc_block {
  1582. /* Counter block ID, see ROGUE_HWPERF_CNTBLK_ID */
  1583. u16 block_id;
  1584. /* Number of counters in this block type */
  1585. u16 num_counters;
  1586. /* Number of blocks of this type */
  1587. u16 num_blocks;
  1588. u16 reserved;
  1589. };
  1590. #define ROGUE_HWPERF_MAX_BVNC_LEN (24)
  1591. #define ROGUE_HWPERF_MAX_BVNC_BLOCK_LEN (16U)
  1592. /* BVNC Features */
  1593. struct rogue_hwperf_bvnc {
  1594. /* BVNC string */
  1595. char bvnc_string[ROGUE_HWPERF_MAX_BVNC_LEN];
  1596. /* See ROGUE_HWPERF_FEATURE_FLAGS */
  1597. u32 bvnc_km_feature_flags;
  1598. /* Number of blocks described in aBvncBlocks */
  1599. u16 num_bvnc_blocks;
  1600. /* Number of GPU cores present */
  1601. u16 bvnc_gpu_cores;
  1602. /* Supported Performance Blocks for BVNC */
  1603. struct rogue_hwperf_bvnc_block
  1604. bvnc_blocks[ROGUE_HWPERF_MAX_BVNC_BLOCK_LEN];
  1605. };
  1606. PVR_FW_STRUCT_SIZE_ASSERT(struct rogue_hwperf_bvnc);
  1607. struct rogue_fwif_sysinit {
  1608. /* Fault read address */
  1609. aligned_u64 fault_phys_addr;
  1610. /* PDS execution base */
  1611. aligned_u64 pds_exec_base;
  1612. /* UCS execution base */
  1613. aligned_u64 usc_exec_base;
  1614. /* FBCDC bindless texture state table base */
  1615. aligned_u64 fbcdc_state_table_base;
  1616. aligned_u64 fbcdc_large_state_table_base;
  1617. /* Texture state base */
  1618. aligned_u64 texture_heap_base;
  1619. /* Event filter for Firmware events */
  1620. u64 hw_perf_filter;
  1621. aligned_u64 slc3_fence_dev_addr;
  1622. u32 tpu_trilinear_frac_mask[ROGUE_FWIF_TPU_DM_LAST] __aligned(8);
  1623. /* Signature and Checksum Buffers for DMs */
  1624. struct rogue_fwif_sigbuf_ctl sigbuf_ctl[PVR_FWIF_DM_MAX];
  1625. struct rogue_fwif_pdvfs_opp pdvfs_opp_info;
  1626. struct rogue_fwif_dma_addr coremem_data_store;
  1627. struct rogue_fwif_counter_dump_ctl counter_dump_ctl;
  1628. u32 filter_flags;
  1629. u32 runtime_cfg_fw_addr;
  1630. u32 trace_buf_ctl_fw_addr;
  1631. u32 fw_sys_data_fw_addr;
  1632. u32 gpu_util_fw_cb_ctl_fw_addr;
  1633. u32 reg_cfg_fw_addr;
  1634. u32 hwperf_ctl_fw_addr;
  1635. u32 align_checks;
  1636. /* Core clock speed at FW boot time */
  1637. u32 initial_core_clock_speed;
  1638. /* APM latency in ms before signalling IDLE to the host */
  1639. u32 active_pm_latency_ms;
  1640. /* Flag to be set by the Firmware after successful start */
  1641. bool firmware_started __aligned(4);
  1642. /* Host/FW Trace synchronisation Partition Marker */
  1643. u32 marker_val;
  1644. /* Firmware initialization complete time */
  1645. u32 firmware_started_timestamp;
  1646. u32 jones_disable_mask;
  1647. /* Firmware performance counter config */
  1648. enum fw_perf_conf firmware_perf;
  1649. /*
  1650. * FW Pointer to memory containing core clock rate in Hz.
  1651. * Firmware (PDVFS) updates the memory when running on non primary FW
  1652. * thread to communicate to host driver.
  1653. */
  1654. u32 core_clock_rate_fw_addr;
  1655. enum rogue_fwif_gpio_val_mode gpio_validation_mode;
  1656. /* Used in HWPerf for decoding BVNC Features */
  1657. struct rogue_hwperf_bvnc bvnc_km_feature_flags;
  1658. /* Value to write into ROGUE_CR_TFBC_COMPRESSION_CONTROL */
  1659. u32 tfbc_compression_control;
  1660. } __aligned(8);
  1661. /*
  1662. *****************************************************************************
  1663. * Timer correlation shared data and defines
  1664. *****************************************************************************
  1665. */
  1666. struct rogue_fwif_time_corr {
  1667. aligned_u64 os_timestamp;
  1668. aligned_u64 os_mono_timestamp;
  1669. aligned_u64 cr_timestamp;
  1670. /*
  1671. * Utility variable used to convert CR timer deltas to OS timer deltas
  1672. * (nS), where the deltas are relative to the timestamps above:
  1673. * deltaOS = (deltaCR * K) >> decimal_shift, see full explanation below
  1674. */
  1675. aligned_u64 cr_delta_to_os_delta_kns;
  1676. u32 core_clock_speed;
  1677. u32 reserved;
  1678. } __aligned(8);
  1679. /*
  1680. * The following macros are used to help converting FW timestamps to the Host
  1681. * time domain. On the FW the ROGUE_CR_TIMER counter is used to keep track of
  1682. * time; it increments by 1 every 256 GPU clock ticks, so the general
  1683. * formula to perform the conversion is:
  1684. *
  1685. * [ GPU clock speed in Hz, if (scale == 10^9) then deltaOS is in nS,
  1686. * otherwise if (scale == 10^6) then deltaOS is in uS ]
  1687. *
  1688. * deltaCR * 256 256 * scale
  1689. * deltaOS = --------------- * scale = deltaCR * K [ K = --------------- ]
  1690. * GPUclockspeed GPUclockspeed
  1691. *
  1692. * The actual K is multiplied by 2^20 (and deltaCR * K is divided by 2^20)
  1693. * to get some better accuracy and to avoid returning 0 in the integer
  1694. * division 256000000/GPUfreq if GPUfreq is greater than 256MHz.
  1695. * This is the same as keeping K as a decimal number.
  1696. *
  1697. * The maximum deltaOS is slightly more than 5hrs for all GPU frequencies
  1698. * (deltaCR * K is more or less a constant), and it's relative to the base
  1699. * OS timestamp sampled as a part of the timer correlation data.
  1700. * This base is refreshed on GPU power-on, DVFS transition and periodic
  1701. * frequency calibration (executed every few seconds if the FW is doing
  1702. * some work), so as long as the GPU is doing something and one of these
  1703. * events is triggered then deltaCR * K will not overflow and deltaOS will be
  1704. * correct.
  1705. */
  1706. #define ROGUE_FWIF_CRDELTA_TO_OSDELTA_ACCURACY_SHIFT (20)
  1707. #define ROGUE_FWIF_GET_DELTA_OSTIME_NS(delta_cr, k) \
  1708. (((delta_cr) * (k)) >> ROGUE_FWIF_CRDELTA_TO_OSDELTA_ACCURACY_SHIFT)
  1709. /*
  1710. ******************************************************************************
  1711. * GPU Utilisation
  1712. ******************************************************************************
  1713. */
  1714. /* See rogue_common.h for a list of GPU states */
  1715. #define ROGUE_FWIF_GPU_UTIL_TIME_MASK \
  1716. (0xFFFFFFFFFFFFFFFFull & ~ROGUE_FWIF_GPU_UTIL_STATE_MASK)
  1717. #define ROGUE_FWIF_GPU_UTIL_GET_TIME(word) \
  1718. ((word)(&ROGUE_FWIF_GPU_UTIL_TIME_MASK))
  1719. #define ROGUE_FWIF_GPU_UTIL_GET_STATE(word) \
  1720. ((word)(&ROGUE_FWIF_GPU_UTIL_STATE_MASK))
  1721. /*
  1722. * The OS timestamps computed by the FW are approximations of the real time,
  1723. * which means they could be slightly behind or ahead the real timer on the
  1724. * Host. In some cases we can perform subtractions between FW approximated
  1725. * timestamps and real OS timestamps, so we need a form of protection against
  1726. * negative results if for instance the FW one is a bit ahead of time.
  1727. */
  1728. #define ROGUE_FWIF_GPU_UTIL_GET_PERIOD(newtime, oldtime) \
  1729. (((newtime) > (oldtime)) ? ((newtime) - (oldtime)) : 0U)
  1730. #define ROGUE_FWIF_GPU_UTIL_MAKE_WORD(time, state) \
  1731. (ROGUE_FWIF_GPU_UTIL_GET_TIME(time) | \
  1732. ROGUE_FWIF_GPU_UTIL_GET_STATE(state))
  1733. /*
  1734. * The timer correlation array must be big enough to ensure old entries won't be
  1735. * overwritten before all the HWPerf events linked to those entries are
  1736. * processed by the MISR. The update frequency of this array depends on how fast
  1737. * the system can change state (basically how small the APM latency is) and
  1738. * perform DVFS transitions.
  1739. *
  1740. * The minimum size is 2 (not 1) to avoid race conditions between the FW reading
  1741. * an entry while the Host is updating it. With 2 entries in the worst case the
  1742. * FW will read old data, which is still quite ok if the Host is updating the
  1743. * timer correlation at that time.
  1744. */
  1745. #define ROGUE_FWIF_TIME_CORR_ARRAY_SIZE 256U
  1746. #define ROGUE_FWIF_TIME_CORR_CURR_INDEX(seqcount) \
  1747. ((seqcount) % ROGUE_FWIF_TIME_CORR_ARRAY_SIZE)
  1748. /* Make sure the timer correlation array size is a power of 2 */
  1749. static_assert((ROGUE_FWIF_TIME_CORR_ARRAY_SIZE &
  1750. (ROGUE_FWIF_TIME_CORR_ARRAY_SIZE - 1U)) == 0U,
  1751. "ROGUE_FWIF_TIME_CORR_ARRAY_SIZE must be a power of two");
  1752. struct rogue_fwif_gpu_util_fwcb {
  1753. struct rogue_fwif_time_corr time_corr[ROGUE_FWIF_TIME_CORR_ARRAY_SIZE];
  1754. u32 time_corr_seq_count;
  1755. /* Compatibility and other flags */
  1756. u32 gpu_util_flags;
  1757. /* Last GPU state + OS time of the last state update */
  1758. aligned_u64 last_word;
  1759. /* Counters for the amount of time the GPU was active/idle/blocked */
  1760. aligned_u64 stats_counters[PVR_FWIF_GPU_UTIL_STATE_NUM];
  1761. } __aligned(8);
  1762. struct rogue_fwif_rta_ctl {
  1763. /* Render number */
  1764. u32 render_target_index;
  1765. /* index in RTA */
  1766. u32 current_render_target;
  1767. /* total active RTs */
  1768. u32 active_render_targets;
  1769. /* total active RTs from the first TA kick, for OOM */
  1770. u32 cumul_active_render_targets;
  1771. /* Array of valid RT indices */
  1772. u32 valid_render_targets_fw_addr;
  1773. /* Array of number of occurred partial renders per render target */
  1774. u32 rta_num_partial_renders_fw_addr;
  1775. /* Number of render targets in the array */
  1776. u32 max_rts;
  1777. /* Compatibility and other flags */
  1778. u32 rta_ctl_flags;
  1779. } __aligned(8);
  1780. struct rogue_fwif_freelist {
  1781. aligned_u64 freelist_dev_addr;
  1782. aligned_u64 current_dev_addr;
  1783. u32 current_stack_top;
  1784. u32 max_pages;
  1785. u32 grow_pages;
  1786. /* HW pages */
  1787. u32 current_pages;
  1788. u32 allocated_page_count;
  1789. u32 allocated_mmu_page_count;
  1790. u32 freelist_id;
  1791. bool grow_pending __aligned(4);
  1792. /* Pages that should be used only when OOM is reached */
  1793. u32 ready_pages;
  1794. /* Compatibility and other flags */
  1795. u32 freelist_flags;
  1796. /* PM Global PB on which Freelist is loaded */
  1797. u32 pm_global_pb;
  1798. u32 padding;
  1799. } __aligned(8);
  1800. /*
  1801. ******************************************************************************
  1802. * HWRTData
  1803. ******************************************************************************
  1804. */
  1805. /* HWRTData flags */
  1806. /* Deprecated flags 1:0 */
  1807. #define HWRTDATA_HAS_LAST_GEOM BIT(2)
  1808. #define HWRTDATA_PARTIAL_RENDERED BIT(3)
  1809. #define HWRTDATA_DISABLE_TILE_REORDERING BIT(4)
  1810. #define HWRTDATA_NEED_BRN65101_BLIT BIT(5)
  1811. #define HWRTDATA_FIRST_BRN65101_STRIP BIT(6)
  1812. #define HWRTDATA_NEED_BRN67182_2ND_RENDER BIT(7)
  1813. enum rogue_fwif_rtdata_state {
  1814. ROGUE_FWIF_RTDATA_STATE_NONE = 0,
  1815. ROGUE_FWIF_RTDATA_STATE_KICK_GEOM,
  1816. ROGUE_FWIF_RTDATA_STATE_KICK_GEOM_FIRST,
  1817. ROGUE_FWIF_RTDATA_STATE_GEOM_FINISHED,
  1818. ROGUE_FWIF_RTDATA_STATE_KICK_FRAG,
  1819. ROGUE_FWIF_RTDATA_STATE_FRAG_FINISHED,
  1820. ROGUE_FWIF_RTDATA_STATE_FRAG_CONTEXT_STORED,
  1821. ROGUE_FWIF_RTDATA_STATE_GEOM_OUTOFMEM,
  1822. ROGUE_FWIF_RTDATA_STATE_PARTIALRENDERFINISHED,
  1823. /*
  1824. * In case of HWR, we can't set the RTDATA state to NONE, as this will
  1825. * cause any TA to become a first TA. To ensure all related TA's are
  1826. * skipped, we use the HWR state
  1827. */
  1828. ROGUE_FWIF_RTDATA_STATE_HWR,
  1829. ROGUE_FWIF_RTDATA_STATE_UNKNOWN = 0x7FFFFFFFU
  1830. };
  1831. struct rogue_fwif_hwrtdata_common {
  1832. bool geom_caches_need_zeroing __aligned(4);
  1833. u32 screen_pixel_max;
  1834. aligned_u64 multi_sample_ctl;
  1835. u64 flipped_multi_sample_ctl;
  1836. u32 tpc_stride;
  1837. u32 tpc_size;
  1838. u32 te_screen;
  1839. u32 mtile_stride;
  1840. u32 teaa;
  1841. u32 te_mtile1;
  1842. u32 te_mtile2;
  1843. u32 isp_merge_lower_x;
  1844. u32 isp_merge_lower_y;
  1845. u32 isp_merge_upper_x;
  1846. u32 isp_merge_upper_y;
  1847. u32 isp_merge_scale_x;
  1848. u32 isp_merge_scale_y;
  1849. u32 rgn_header_size;
  1850. u32 isp_mtile_size;
  1851. u32 padding;
  1852. } __aligned(8);
  1853. struct rogue_fwif_hwrtdata {
  1854. /* MList Data Store */
  1855. aligned_u64 pm_mlist_dev_addr;
  1856. aligned_u64 vce_cat_base[4];
  1857. aligned_u64 vce_last_cat_base[4];
  1858. aligned_u64 te_cat_base[4];
  1859. aligned_u64 te_last_cat_base[4];
  1860. aligned_u64 alist_cat_base;
  1861. aligned_u64 alist_last_cat_base;
  1862. aligned_u64 pm_alist_stack_pointer;
  1863. u32 pm_mlist_stack_pointer;
  1864. u32 hwrt_data_common_fw_addr;
  1865. u32 hwrt_data_flags;
  1866. enum rogue_fwif_rtdata_state state;
  1867. u32 freelists_fw_addr[MAX_FREELISTS_SIZE] __aligned(8);
  1868. u32 freelist_hwr_snapshot[MAX_FREELISTS_SIZE];
  1869. aligned_u64 vheap_table_dev_addr;
  1870. struct rogue_fwif_rta_ctl rta_ctl;
  1871. aligned_u64 tail_ptrs_dev_addr;
  1872. aligned_u64 macrotile_array_dev_addr;
  1873. aligned_u64 rgn_header_dev_addr;
  1874. aligned_u64 rtc_dev_addr;
  1875. u32 owner_geom_not_used_by_host __aligned(8);
  1876. bool geom_caches_need_zeroing __aligned(4);
  1877. struct rogue_fwif_cleanup_ctl cleanup_state __aligned(64);
  1878. } __aligned(8);
  1879. /*
  1880. ******************************************************************************
  1881. * Sync checkpoints
  1882. ******************************************************************************
  1883. */
  1884. #define PVR_SYNC_CHECKPOINT_UNDEF 0x000
  1885. #define PVR_SYNC_CHECKPOINT_ACTIVE 0xac1 /* Checkpoint has not signaled. */
  1886. #define PVR_SYNC_CHECKPOINT_SIGNALED 0x519 /* Checkpoint has signaled. */
  1887. #define PVR_SYNC_CHECKPOINT_ERRORED 0xeff /* Checkpoint has been errored. */
  1888. #include "pvr_rogue_fwif_check.h"
  1889. #endif /* PVR_ROGUE_FWIF_H */