1 /* 2 * Copyright © 2022 Imagination Technologies Ltd. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a copy 5 * of this software and associated documentation files (the "Software"), to deal 6 * in the Software without restriction, including without limitation the rights 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 * copies of the Software, and to permit persons to whom the Software is 9 * furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 * SOFTWARE. 22 */ 23 24 #ifndef PVR_SRV_BRIDGE_H 25 #define PVR_SRV_BRIDGE_H 26 27 #include <stdbool.h> 28 #include <stdint.h> 29 30 #include "pvr_private.h" 31 #include "pvr_srv.h" 32 #include "pvr_types.h" 33 #include "util/macros.h" 34 35 /****************************************************************************** 36 Services bridges 37 ******************************************************************************/ 38 39 #define PVR_SRV_BRIDGE_SRVCORE 1UL 40 41 #define PVR_SRV_BRIDGE_SRVCORE_CONNECT 0UL 42 #define PVR_SRV_BRIDGE_SRVCORE_DISCONNECT 1UL 43 #define PVR_SRV_BRIDGE_SRVCORE_GETMULTICOREINFO 12U 44 45 #define PVR_SRV_BRIDGE_SYNC 2UL 46 47 #define PVR_SRV_BRIDGE_SYNC_ALLOCSYNCPRIMITIVEBLOCK 0UL 48 #define PVR_SRV_BRIDGE_SYNC_FREESYNCPRIMITIVEBLOCK 1UL 49 50 #define PVR_SRV_BRIDGE_MM 6UL 51 52 #define PVR_SRV_BRIDGE_MM_PMRUNREFUNLOCKPMR 8UL 53 #define PVR_SRV_BRIDGE_MM_PHYSMEMNEWRAMBACKEDLOCKEDPMR 10UL 54 #define PVR_SRV_BRIDGE_MM_DEVMEMINTCTXCREATE 15UL 55 #define PVR_SRV_BRIDGE_MM_DEVMEMINTCTXDESTROY 16UL 56 #define PVR_SRV_BRIDGE_MM_DEVMEMINTHEAPCREATE 17UL 57 #define PVR_SRV_BRIDGE_MM_DEVMEMINTHEAPDESTROY 18UL 58 #define PVR_SRV_BRIDGE_MM_DEVMEMINTMAPPMR 19UL 59 #define PVR_SRV_BRIDGE_MM_DEVMEMINTUNMAPPMR 20UL 60 #define PVR_SRV_BRIDGE_MM_DEVMEMINTRESERVERANGE 21UL 61 #define PVR_SRV_BRIDGE_MM_DEVMEMINTUNRESERVERANGE 22UL 62 #define PVR_SRV_BRIDGE_MM_DEVMEMINTMAPPAGES 24UL 63 #define PVR_SRV_BRIDGE_MM_DEVMEMINTUNMAPPAGES 25UL 64 #define PVR_SRV_BRIDGE_MM_HEAPCFGHEAPCOUNT 30UL 65 #define PVR_SRV_BRIDGE_MM_HEAPCFGHEAPDETAILS 32UL 66 67 #define PVR_SRV_BRIDGE_DMABUF 11UL 68 69 #define PVR_SRV_BRIDGE_DMABUF_PHYSMEMIMPORTDMABUF 0UL 70 #define PVR_SRV_BRIDGE_DMABUF_PHYSMEMEXPORTDMABUF 2UL 71 72 #define PVR_SRV_BRIDGE_RGXTQ 128UL 73 74 #define PVR_SRV_BRIDGE_RGXTQ_RGXCREATETRANSFERCONTEXT 0UL 75 #define PVR_SRV_BRIDGE_RGXTQ_RGXDESTROYTRANSFERCONTEXT 1UL 76 #define PVR_SRV_BRIDGE_RGXTQ_RGXSUBMITTRANSFER2 3UL 77 78 #define PVR_SRV_BRIDGE_RGXCMP 129UL 79 80 #define PVR_SRV_BRIDGE_RGXCMP_RGXCREATECOMPUTECONTEXT 0UL 81 #define PVR_SRV_BRIDGE_RGXCMP_RGXDESTROYCOMPUTECONTEXT 1UL 82 #define PVR_SRV_BRIDGE_RGXCMP_RGXKICKCDM2 5UL 83 84 #define PVR_SRV_BRIDGE_RGXTA3D 130UL 85 86 #define PVR_SRV_BRIDGE_RGXTA3D_RGXCREATEHWRTDATASET 0UL 87 #define PVR_SRV_BRIDGE_RGXTA3D_RGXDESTROYHWRTDATASET 1UL 88 #define PVR_SRV_BRIDGE_RGXTA3D_RGXCREATEFREELIST 6UL 89 #define PVR_SRV_BRIDGE_RGXTA3D_RGXDESTROYFREELIST 7UL 90 #define PVR_SRV_BRIDGE_RGXTA3D_RGXCREATERENDERCONTEXT 8UL 91 #define PVR_SRV_BRIDGE_RGXTA3D_RGXDESTROYRENDERCONTEXT 9UL 92 #define PVR_SRV_BRIDGE_RGXTA3D_RGXKICKTA3D2 12UL 93 94 /****************************************************************************** 95 DRM Services specific defines 96 ******************************************************************************/ 97 /* DRM command numbers, relative to DRM_COMMAND_BASE. 98 * These defines must be prefixed with "DRM_". 99 */ 100 #define DRM_SRVKM_CMD 0U /* PVR Services command. */ 101 #define DRM_SRVKM_INIT 5U /* PVR Services Render Device Init command. */ 102 103 /* These defines must be prefixed with "DRM_IOCTL_". */ 104 #define DRM_IOCTL_SRVKM_CMD \ 105 DRM_IOWR(DRM_COMMAND_BASE + DRM_SRVKM_CMD, struct drm_srvkm_cmd) 106 #define DRM_IOCTL_SRVKM_INIT \ 107 DRM_IOWR(DRM_COMMAND_BASE + DRM_SRVKM_INIT, struct drm_srvkm_init_data) 108 109 /****************************************************************************** 110 Bridge call specific defines 111 ******************************************************************************/ 112 113 /* Flags for PVR_SRV_BRIDGE_RGXTQ_RGXSUBMITTRANSFER2 bridge call. */ 114 #define PVR_TRANSFER_PREP_FLAGS_START BITFIELD_BIT(5U) 115 #define PVR_TRANSFER_PREP_FLAGS_END BITFIELD_BIT(6U) 116 117 /****************************************************************************** 118 Misc defines 119 ******************************************************************************/ 120 121 #define SUPPORT_RGX_SET_OFFSET BITFIELD_BIT(4U) 122 #define DEBUG_SET_OFFSET BITFIELD_BIT(10U) 123 #define SUPPORT_BUFFER_SYNC_SET_OFFSET BITFIELD_BIT(11U) 124 #define OPTIONS_BIT31 BITFIELD_BIT(31U) 125 126 #define RGX_BUILD_OPTIONS \ 127 (SUPPORT_RGX_SET_OFFSET | DEBUG_SET_OFFSET | \ 128 SUPPORT_BUFFER_SYNC_SET_OFFSET | OPTIONS_BIT31) 129 130 #define PVR_SRV_VERSION_MAJ 1U 131 #define PVR_SRV_VERSION_MIN 17U 132 133 #define PVR_SRV_VERSION \ 134 (((uint32_t)((uint32_t)(PVR_SRV_VERSION_MAJ)&0xFFFFU) << 16U) | \ 135 (((PVR_SRV_VERSION_MIN)&0xFFFFU) << 0U)) 136 137 #define PVR_SRV_VERSION_BUILD 6256262 138 139 /*! This flags gets set if the client is 64 Bit compatible. */ 140 #define PVR_SRV_FLAGS_CLIENT_64BIT_COMPAT BITFIELD_BIT(5U) 141 142 #define DEVMEM_ANNOTATION_MAX_LEN 64U 143 144 #define PVR_SRV_SYNC_MAX 12U 145 146 #define PVR_BUFFER_FLAG_READ BITFIELD_BIT(0U) 147 #define PVR_BUFFER_FLAG_WRITE BITFIELD_BIT(1U) 148 149 /* clang-format off */ 150 #define PVR_U8888_TO_U32(v1, v2, v3, v4) \ 151 (((v1) & 0xFFU) | (((v2) & 0xFFU) << 8U) | (((v3) & 0xFFU) << 16U) | \ 152 (((v4) & 0xFFU) << 24U)) 153 /* clang-format on */ 154 155 /****************************************************************************** 156 Services Boolean 157 ******************************************************************************/ 158 159 enum pvr_srv_bool { 160 PVR_SRV_FALSE = 0, 161 PVR_SRV_TRUE = 1, 162 PVR_SRV_FORCE_ALIGN = 0x7fffffff 163 }; 164 165 /****************************************************************************** 166 Service Error codes 167 ******************************************************************************/ 168 169 enum pvr_srv_error { 170 PVR_SRV_OK, 171 PVR_SRV_ERROR_RETRY = 25, 172 PVR_SRV_ERROR_BRIDGE_CALL_FAILED = 37, 173 PVR_SRV_ERROR_FORCE_I32 = 0x7fffffff 174 }; 175 176 /****************************************************************************** 177 PVR_SRV_BRIDGE_SRVCORE_CONNECT structs 178 ******************************************************************************/ 179 180 struct pvr_srv_bridge_connect_cmd { 181 uint32_t build_options; 182 uint32_t DDK_build; 183 uint32_t DDK_version; 184 uint32_t flags; 185 } PACKED; 186 187 struct pvr_srv_bridge_connect_ret { 188 uint64_t bvnc; 189 enum pvr_srv_error error; 190 uint32_t capability_flags; 191 uint8_t kernel_arch; 192 } PACKED; 193 194 /****************************************************************************** 195 PVR_SRV_BRIDGE_SRVCORE_DISCONNECT struct 196 ******************************************************************************/ 197 198 struct pvr_srv_bridge_disconnect_ret { 199 enum pvr_srv_error error; 200 } PACKED; 201 202 /****************************************************************************** 203 PVR_SRV_BRIDGE_SRVCORE_GETMULTICOREINFO structs 204 ******************************************************************************/ 205 206 struct pvr_srv_bridge_getmulticoreinfo_cmd { 207 uint64_t *caps; 208 uint32_t caps_size; 209 } PACKED; 210 211 struct pvr_srv_bridge_getmulticoreinfo_ret { 212 uint64_t *caps; 213 enum pvr_srv_error error; 214 uint32_t num_cores; 215 } PACKED; 216 217 /****************************************************************************** 218 PVR_SRV_BRIDGE_SYNC_ALLOCSYNCPRIMITIVEBLOCK struct 219 ******************************************************************************/ 220 221 struct pvr_srv_bridge_alloc_sync_primitive_block_ret { 222 void *handle; 223 void *pmr; 224 enum pvr_srv_error error; 225 uint32_t size; 226 uint32_t addr; 227 } PACKED; 228 229 /****************************************************************************** 230 PVR_SRV_BRIDGE_SYNC_FREESYNCPRIMITIVEBLOCK structs 231 ******************************************************************************/ 232 233 struct pvr_srv_bridge_free_sync_primitive_block_cmd { 234 void *handle; 235 } PACKED; 236 237 struct pvr_srv_bridge_free_sync_primitive_block_ret { 238 enum pvr_srv_error error; 239 } PACKED; 240 241 /****************************************************************************** 242 PVR_SRV_BRIDGE_MM_DEVMEMINTCTXCREATE structs 243 ******************************************************************************/ 244 245 struct pvr_srv_devmem_int_ctx_create_cmd { 246 uint32_t kernel_memory_ctx; 247 } PACKED; 248 249 struct pvr_srv_devmem_int_ctx_create_ret { 250 void *server_memctx; 251 void *server_memctx_data; 252 enum pvr_srv_error error; 253 uint32_t cpu_cache_line_size; 254 } PACKED; 255 256 /****************************************************************************** 257 PVR_SRV_BRIDGE_MM_DEVMEMINTCTXDESTROY structs 258 ******************************************************************************/ 259 260 struct pvr_srv_devmem_int_ctx_destroy_cmd { 261 void *server_memctx; 262 } PACKED; 263 264 struct pvr_srv_devmem_int_ctx_destroy_ret { 265 enum pvr_srv_error error; 266 } PACKED; 267 268 /****************************************************************************** 269 PVR_SRV_BRIDGE_MM_HEAPCFGHEAPCOUNT structs 270 ******************************************************************************/ 271 272 struct pvr_srv_heap_count_cmd { 273 uint32_t heap_config_index; 274 } PACKED; 275 276 struct pvr_srv_heap_count_ret { 277 enum pvr_srv_error error; 278 uint32_t heap_count; 279 } PACKED; 280 281 /****************************************************************************** 282 PVR_SRV_BRIDGE_MM_HEAPCFGHEAPDETAILS structs 283 ******************************************************************************/ 284 285 struct pvr_srv_heap_cfg_details_cmd { 286 char *buffer; 287 uint32_t heap_config_index; 288 uint32_t heap_index; 289 uint32_t buffer_size; 290 } PACKED; 291 292 struct pvr_srv_heap_cfg_details_ret { 293 pvr_dev_addr_t base_addr; 294 uint64_t size; 295 uint64_t reserved_size; 296 char *buffer; 297 enum pvr_srv_error error; 298 uint32_t log2_page_size; 299 uint32_t log2_alignment; 300 } PACKED; 301 302 /****************************************************************************** 303 PVR_SRV_BRIDGE_MM_DEVMEMINTHEAPCREATE structs 304 ******************************************************************************/ 305 306 struct pvr_srv_devmem_int_heap_create_cmd { 307 pvr_dev_addr_t base_addr; 308 uint64_t size; 309 void *server_memctx; 310 uint32_t log2_page_size; 311 } PACKED; 312 313 struct pvr_srv_devmem_int_heap_create_ret { 314 void *server_heap; 315 enum pvr_srv_error error; 316 } PACKED; 317 318 /****************************************************************************** 319 PVR_SRV_BRIDGE_MM_DEVMEMINTHEAPDESTROY structs 320 ******************************************************************************/ 321 322 struct pvr_srv_devmem_int_heap_destroy_cmd { 323 void *server_heap; 324 } PACKED; 325 326 struct pvr_srv_devmem_int_heap_destroy_ret { 327 enum pvr_srv_error error; 328 } PACKED; 329 330 /****************************************************************************** 331 PVR_SRV_BRIDGE_MM_DEVMEMINTRESERVERANGE structs 332 ******************************************************************************/ 333 334 struct pvr_srv_devmem_int_reserve_range_cmd { 335 pvr_dev_addr_t addr; 336 uint64_t size; 337 void *server_heap; 338 } PACKED; 339 340 struct pvr_srv_devmem_int_reserve_range_ret { 341 void *reservation; 342 enum pvr_srv_error error; 343 } PACKED; 344 345 /****************************************************************************** 346 PVR_SRV_BRIDGE_MM_DEVMEMINTUNRESERVERANGE structs 347 ******************************************************************************/ 348 349 struct pvr_srv_bridge_in_devmem_int_unreserve_range_cmd { 350 void *reservation; 351 } PACKED; 352 353 struct pvr_srv_bridge_in_devmem_int_unreserve_range_ret { 354 enum pvr_srv_error error; 355 } PACKED; 356 357 /****************************************************************************** 358 PVR_SRV_BRIDGE_MM_PHYSMEMNEWRAMBACKEDLOCKEDPMR structs 359 ******************************************************************************/ 360 361 struct pvr_srv_physmem_new_ram_backed_locked_pmr_cmd { 362 uint64_t block_size; 363 uint64_t size; 364 uint32_t *mapping_table; 365 const char *annotation; 366 uint32_t annotation_size; 367 uint32_t log2_page_size; 368 uint32_t phy_blocks; 369 uint32_t virt_blocks; 370 uint32_t pdump_flags; 371 uint32_t pid; 372 uint64_t flags; 373 } PACKED; 374 375 struct pvr_srv_physmem_new_ram_backed_locked_pmr_ret { 376 void *pmr; 377 enum pvr_srv_error error; 378 uint64_t out_flags; 379 } PACKED; 380 381 /****************************************************************************** 382 PVR_SRV_BRIDGE_MM_PMRUNREFUNLOCKPMR structs 383 ******************************************************************************/ 384 385 struct pvr_srv_pmr_unref_unlock_pmr_cmd { 386 void *pmr; 387 } PACKED; 388 389 struct pvr_srv_pmr_unref_unlock_pmr_ret { 390 enum pvr_srv_error error; 391 } PACKED; 392 393 /****************************************************************************** 394 PVR_SRV_BRIDGE_MM_DEVMEMINTMAPPAGES structs 395 ******************************************************************************/ 396 397 struct pvr_srv_devmem_int_map_pages_cmd { 398 pvr_dev_addr_t addr; 399 void *pmr; 400 void *reservation; 401 uint32_t page_count; 402 uint32_t page_offset; 403 uint64_t flags; 404 } PACKED; 405 406 struct pvr_srv_devmem_int_map_pages_ret { 407 enum pvr_srv_error error; 408 } PACKED; 409 410 /****************************************************************************** 411 PVR_SRV_BRIDGE_MM_DEVMEMINTUNMAPPAGES structs 412 ******************************************************************************/ 413 414 struct pvr_srv_devmem_int_unmap_pages_cmd { 415 pvr_dev_addr_t dev_addr; 416 void *reservation; 417 uint32_t page_count; 418 } PACKED; 419 420 struct pvr_srv_devmem_int_unmap_pages_ret { 421 enum pvr_srv_error error; 422 } PACKED; 423 424 /****************************************************************************** 425 PVR_SRV_BRIDGE_MM_DEVMEMINTMAPPMR structs 426 ******************************************************************************/ 427 428 struct pvr_srv_devmem_int_map_pmr_cmd { 429 void *server_heap; 430 void *pmr; 431 void *reservation; 432 uint64_t flags; 433 } PACKED; 434 435 struct pvr_srv_devmem_int_map_pmr_ret { 436 void *mapping; 437 enum pvr_srv_error error; 438 } PACKED; 439 440 /****************************************************************************** 441 PVR_SRV_BRIDGE_MM_DEVMEMINTUNMAPPMR structs 442 ******************************************************************************/ 443 444 struct pvr_srv_devmem_int_unmap_pmr_cmd { 445 void *mapping; 446 } PACKED; 447 448 struct pvr_srv_devmem_int_unmap_pmr_ret { 449 enum pvr_srv_error error; 450 } PACKED; 451 452 /****************************************************************************** 453 PVR_SRV_BRIDGE_DMABUF_PHYSMEMIMPORTDMABUF structs 454 ******************************************************************************/ 455 456 struct pvr_srv_phys_mem_import_dmabuf_cmd { 457 const char *name; 458 int buffer_fd; 459 uint32_t name_size; 460 uint64_t flags; 461 } PACKED; 462 463 struct pvr_srv_phys_mem_import_dmabuf_ret { 464 uint64_t align; 465 uint64_t size; 466 void *pmr; 467 enum pvr_srv_error error; 468 } PACKED; 469 470 /****************************************************************************** 471 PVR_SRV_BRIDGE_DMABUF_PHYSMEMEXPORTDMABUF structs 472 ******************************************************************************/ 473 474 struct pvr_srv_phys_mem_export_dmabuf_cmd { 475 void *pmr; 476 } PACKED; 477 478 struct pvr_srv_phys_mem_export_dmabuf_ret { 479 enum pvr_srv_error error; 480 int fd; 481 } PACKED; 482 483 /****************************************************************************** 484 PVR_SRV_BRIDGE_RGXTQ_RGXCREATETRANSFERCONTEXT structs 485 ******************************************************************************/ 486 487 struct pvr_srv_rgx_create_transfer_context_cmd { 488 uint64_t robustness_address; 489 void *priv_data; 490 uint8_t *reset_framework_cmd; 491 uint32_t context_flags; 492 uint32_t reset_framework_cmd_size; 493 uint32_t packed_ccb_size_u8888; 494 uint32_t priority; 495 } PACKED; 496 497 struct pvr_srv_rgx_create_transfer_context_ret { 498 void *cli_pmr_mem; 499 void *transfer_context; 500 void *usc_pmr_mem; 501 enum pvr_srv_error error; 502 } PACKED; 503 504 /****************************************************************************** 505 PVR_SRV_BRIDGE_RGXTQ_RGXDESTROYTRANSFERCONTEXT structs 506 ******************************************************************************/ 507 508 struct pvr_srv_rgx_destroy_transfer_context_cmd { 509 void *transfer_context; 510 } PACKED; 511 512 struct pvr_srv_rgx_destroy_transfer_context_ret { 513 enum pvr_srv_error error; 514 } PACKED; 515 516 /****************************************************************************** 517 PVR_SRV_BRIDGE_RGXTQ_RGXSUBMITTRANSFER2 structs 518 ******************************************************************************/ 519 520 struct pvr_srv_rgx_submit_transfer2_cmd { 521 void *transfer_context; 522 uint32_t *client_update_count; 523 uint32_t *cmd_size; 524 uint32_t *sync_pmr_flags; 525 uint32_t *tq_prepare_flags; 526 uint32_t **update_sync_offset; 527 uint32_t **update_value; 528 uint8_t **fw_command; 529 char *update_fence_name; 530 void **sync_pmrs; 531 void ***update_ufo_sync_prim_block; 532 int32_t update_timeline_2d; 533 int32_t update_timeline_3d; 534 int32_t check_fence; 535 uint32_t ext_job_ref; 536 uint32_t prepare_count; 537 uint32_t sync_pmr_count; 538 } PACKED; 539 540 struct pvr_srv_rgx_submit_transfer2_ret { 541 enum pvr_srv_error error; 542 int32_t update_fence_2d; 543 int32_t update_fence_3d; 544 } PACKED; 545 546 /****************************************************************************** 547 PVR_SRV_BRIDGE_RGXCMP_RGXCREATECOMPUTECONTEXT structs 548 ******************************************************************************/ 549 550 struct pvr_srv_rgx_create_compute_context_cmd { 551 uint64_t robustness_address; 552 void *priv_data; 553 uint8_t *reset_framework_cmd; 554 uint8_t *static_compute_context_state; 555 uint32_t context_flags; 556 uint32_t reset_framework_cmd_size; 557 uint32_t max_deadline_ms; 558 uint32_t packed_ccb_size; 559 /* RGX_CONTEXT_PRIORITY_... flags. */ 560 uint32_t priority; 561 uint32_t static_compute_context_state_size; 562 } PACKED; 563 564 struct pvr_srv_rgx_create_compute_context_ret { 565 void *compute_context; 566 enum pvr_srv_error error; 567 } PACKED; 568 569 /****************************************************************************** 570 PVR_SRV_BRIDGE_RGXCMP_RGXDESTROYCOMPUTECONTEXT structs 571 ******************************************************************************/ 572 573 struct pvr_srv_rgx_destroy_compute_context_cmd { 574 void *compute_context; 575 } PACKED; 576 577 struct pvr_srv_rgx_destroy_compute_context_ret { 578 enum pvr_srv_error error; 579 } PACKED; 580 581 /****************************************************************************** 582 PVR_SRV_BRIDGE_RGXCMP_RGXKICKCDM2 structs 583 ******************************************************************************/ 584 585 struct pvr_srv_rgx_kick_cdm2_cmd { 586 uint64_t max_deadline_us; 587 void *compute_context; 588 uint32_t *client_update_offset; 589 uint32_t *client_update_value; 590 uint32_t *sync_pmr_flags; 591 uint8_t *cdm_cmd; 592 char *update_fence_name; 593 void **client_update_ufo_sync_prim_block; 594 void **sync_pmrs; 595 int32_t check_fence; 596 int32_t update_timeline; 597 uint32_t client_update_count; 598 uint32_t cmd_size; 599 uint32_t ext_job_ref; 600 uint32_t num_work_groups; 601 uint32_t num_work_items; 602 uint32_t pdump_flags; 603 uint32_t sync_pmr_count; 604 } PACKED; 605 606 struct pvr_srv_rgx_kick_cdm2_ret { 607 enum pvr_srv_error error; 608 int32_t update_fence; 609 } PACKED; 610 611 /****************************************************************************** 612 PVR_SRV_BRIDGE_RGXTA3D_RGXCREATEHWRTDATASET structs 613 ******************************************************************************/ 614 615 struct pvr_srv_rgx_create_hwrt_dataset_cmd { 616 uint64_t flipped_multi_sample_ctl; 617 uint64_t multi_sample_ctl; 618 /* ROGUE_FWIF_NUM_RTDATAS sized array. */ 619 const pvr_dev_addr_t *macrotile_array_dev_addrs; 620 /* ROGUE_FWIF_NUM_RTDATAS sized array. */ 621 const pvr_dev_addr_t *pm_mlist_dev_addrs; 622 /* ROGUE_FWIF_NUM_GEOMDATAS sized array. */ 623 const pvr_dev_addr_t *rtc_dev_addrs; 624 /* ROGUE_FWIF_NUM_RTDATAS sized array. */ 625 const pvr_dev_addr_t *rgn_header_dev_addrs; 626 /* ROGUE_FWIF_NUM_GEOMDATAS sized array. */ 627 const pvr_dev_addr_t *tail_ptrs_dev_addrs; 628 /* ROGUE_FWIF_NUM_GEOMDATAS sized array. */ 629 const pvr_dev_addr_t *vheap_table_dev_adds; 630 /* ROGUE_FWIF_NUM_RTDATAS sized array of handles. */ 631 void **hwrt_dataset; 632 /* ROGUE_FW_MAX_FREELISTS size array of handles. */ 633 void **free_lists; 634 uint32_t isp_merge_lower_x; 635 uint32_t isp_merge_lower_y; 636 uint32_t isp_merge_scale_x; 637 uint32_t isp_merge_scale_y; 638 uint32_t isp_merge_upper_x; 639 uint32_t isp_merge_upper_y; 640 uint32_t isp_mtile_size; 641 uint32_t mtile_stride; 642 uint32_t ppp_screen; 643 uint32_t rgn_header_size; 644 uint32_t te_aa; 645 uint32_t te_mtile1; 646 uint32_t te_mtile2; 647 uint32_t te_screen; 648 uint32_t tpc_size; 649 uint32_t tpc_stride; 650 uint16_t max_rts; 651 } PACKED; 652 653 struct pvr_srv_rgx_create_hwrt_dataset_ret { 654 /* ROGUE_FWIF_NUM_RTDATAS sized array of handles. */ 655 void **hwrt_dataset; 656 enum pvr_srv_error error; 657 } PACKED; 658 659 /****************************************************************************** 660 PVR_SRV_BRIDGE_RGXTA3D_RGXDESTROYHWRTDATASET structs 661 ******************************************************************************/ 662 663 struct pvr_srv_rgx_destroy_hwrt_dataset_cmd { 664 void *hwrt_dataset; 665 } PACKED; 666 667 struct pvr_srv_rgx_destroy_hwrt_dataset_ret { 668 enum pvr_srv_error error; 669 } PACKED; 670 671 /****************************************************************************** 672 PVR_SRV_BRIDGE_RGXTA3D_RGXCREATEFREELIST structs 673 ******************************************************************************/ 674 675 struct pvr_srv_rgx_create_free_list_cmd { 676 pvr_dev_addr_t free_list_dev_addr; 677 uint64_t pmr_offset; 678 void *mem_ctx_priv_data; 679 void *free_list_pmr; 680 void *global_free_list; 681 enum pvr_srv_bool free_list_check; 682 uint32_t grow_free_list_pages; 683 uint32_t grow_param_threshold; 684 uint32_t init_free_list_pages; 685 uint32_t max_free_list_pages; 686 } PACKED; 687 688 struct pvr_srv_rgx_create_free_list_ret { 689 void *cleanup_cookie; 690 enum pvr_srv_error error; 691 } PACKED; 692 693 /****************************************************************************** 694 PVR_SRV_BRIDGE_RGXTA3D_RGXDESTROYFREELIST structs 695 ******************************************************************************/ 696 697 struct pvr_srv_rgx_destroy_free_list_cmd { 698 void *cleanup_cookie; 699 } PACKED; 700 701 struct pvr_srv_rgx_destroy_free_list_ret { 702 enum pvr_srv_error error; 703 } PACKED; 704 705 /****************************************************************************** 706 PVR_SRV_BRIDGE_RGXTA3D_RGXCREATERENDERCONTEXT structs 707 ******************************************************************************/ 708 709 struct pvr_srv_rgx_create_render_context_cmd { 710 pvr_dev_addr_t vdm_callstack_addr; 711 uint64_t robustness_address; 712 void *priv_data; 713 uint8_t *reset_framework_cmd; 714 uint8_t *static_render_context_state; 715 #define RGX_CONTEXT_FLAG_DISABLESLR BITFIELD_BIT(0U) 716 uint32_t context_flags; 717 uint32_t reset_framework_cmd_size; 718 uint32_t max_3d_deadline_ms; 719 uint32_t max_ta_deadline_ms; 720 uint32_t packed_ccb_size; 721 #define RGX_CONTEXT_PRIORITY_REALTIME UINT32_MAX 722 #define RGX_CONTEXT_PRIORITY_HIGH 2U 723 #define RGX_CONTEXT_PRIORITY_MEDIUM 1U 724 #define RGX_CONTEXT_PRIORITY_LOW 0U 725 uint32_t priority; 726 uint32_t static_render_context_state_size; 727 uint32_t call_stack_depth; 728 } PACKED; 729 730 struct pvr_srv_rgx_create_render_context_ret { 731 void *render_context; 732 enum pvr_srv_error error; 733 } PACKED; 734 735 /****************************************************************************** 736 PVR_SRV_BRIDGE_RGXTA3D_RGXDESTROYRENDERCONTEXT structs 737 ******************************************************************************/ 738 739 struct pvr_srv_rgx_destroy_render_context_cmd { 740 void *render_context; 741 } PACKED; 742 743 struct pvr_srv_rgx_destroy_render_context_ret { 744 enum pvr_srv_error error; 745 } PACKED; 746 747 /****************************************************************************** 748 PVR_SRV_BRIDGE_RGXTA3D_RGXKICKTA3D2 structs 749 ******************************************************************************/ 750 751 struct pvr_srv_rgx_kick_ta3d2_cmd { 752 uint64_t deadline; 753 void *hw_rt_dataset; 754 void *msaa_scratch_buffer; 755 void *pr_fence_ufo_sync_prim_block; 756 void *render_ctx; 757 void *zs_buffer; 758 uint32_t *client_3d_update_sync_offset; 759 uint32_t *client_3d_update_value; 760 uint32_t *client_ta_fence_sync_offset; 761 uint32_t *client_ta_fence_value; 762 uint32_t *client_ta_update_sync_offset; 763 uint32_t *client_ta_update_value; 764 uint32_t *sync_pmr_flags; 765 uint8_t *cmd_3d; 766 uint8_t *cmd_3d_pr; 767 uint8_t *cmd_ta; 768 char *update_fence_name; 769 char *update_fence_name_3d; 770 void **client_3d_update_sync_prim_block; 771 void **client_ta_fence_sync_prim_block; 772 void **client_ta_update_sync_prim_block; 773 void **sync_pmrs; 774 enum pvr_srv_bool abort; 775 enum pvr_srv_bool kick_3d; 776 enum pvr_srv_bool kick_pr; 777 enum pvr_srv_bool kick_ta; 778 int32_t check_fence; 779 int32_t check_fence_3d; 780 int32_t update_timeline; 781 int32_t update_timeline_3d; 782 uint32_t cmd_3d_size; 783 uint32_t cmd_3d_pr_size; 784 uint32_t client_3d_update_count; 785 uint32_t client_ta_fence_count; 786 uint32_t client_ta_update_count; 787 uint32_t ext_job_ref; 788 uint32_t num_draw_calls; 789 uint32_t num_indices; 790 uint32_t num_mrts; 791 uint32_t pdump_flags; 792 uint32_t client_pr_fence_ufo_sync_offset; 793 uint32_t client_pr_fence_value; 794 uint32_t render_target_size; 795 uint32_t sync_pmr_count; 796 uint32_t cmd_ta_size; 797 } PACKED; 798 799 struct pvr_srv_rgx_kick_ta3d2_ret { 800 enum pvr_srv_error error; 801 int32_t update_fence; 802 int32_t update_fence_3d; 803 } PACKED; 804 805 /****************************************************************************** 806 Ioctl structures 807 ******************************************************************************/ 808 809 /* Ioctl to pass cmd and ret structures. */ 810 struct drm_srvkm_cmd { 811 uint32_t bridge_id; 812 uint32_t bridge_func_id; 813 uint64_t in_data_ptr; 814 uint64_t out_data_ptr; 815 uint32_t in_data_size; 816 uint32_t out_data_size; 817 }; 818 819 /* Ioctl to initialize a module. */ 820 struct drm_srvkm_init_data { 821 #define PVR_SRVKM_SERVICES_INIT 1U 822 #define PVR_SRVKM_SYNC_INIT 2U 823 uint32_t init_module; 824 }; 825 826 /****************************************************************************** 827 DRM helper enum 828 ******************************************************************************/ 829 830 enum pvr_srvkm_module_type { 831 PVR_SRVKM_MODULE_TYPE_SERVICES = PVR_SRVKM_SERVICES_INIT, 832 PVR_SRVKM_MODULE_TYPE_SYNC = PVR_SRVKM_SYNC_INIT, 833 }; 834 835 /****************************************************************************** 836 Ioctl function prototypes 837 ******************************************************************************/ 838 839 VkResult pvr_srv_init_module(int fd, enum pvr_srvkm_module_type module); 840 841 /****************************************************************************** 842 Bridge function prototypes 843 ******************************************************************************/ 844 845 VkResult pvr_srv_connection_create(int fd, uint64_t *const bvnc_out); 846 void pvr_srv_connection_destroy(int fd); 847 848 VkResult pvr_srv_get_multicore_info(int fd, 849 uint32_t caps_size, 850 uint64_t *caps, 851 uint32_t *num_cores); 852 853 VkResult pvr_srv_alloc_sync_primitive_block(int fd, 854 void **const handle_out, 855 void **const pmr_out, 856 uint32_t *const size_out, 857 uint32_t *const addr_out); 858 void pvr_srv_free_sync_primitive_block(int fd, void *handle); 859 860 VkResult pvr_srv_get_heap_count(int fd, uint32_t *const heap_count_out); 861 VkResult pvr_srv_get_heap_details(int fd, 862 uint32_t heap_index, 863 uint32_t buffer_size, 864 char *const buffer_out, 865 pvr_dev_addr_t *const base_address_out, 866 uint64_t *const size_out, 867 uint64_t *const reserved_size_out, 868 uint32_t *const log2_page_size_out); 869 870 VkResult pvr_srv_int_heap_create(int fd, 871 pvr_dev_addr_t base_address, 872 uint64_t size, 873 uint32_t log2_page_size, 874 void *server_memctx, 875 void **const server_heap_out); 876 void pvr_srv_int_heap_destroy(int fd, void *server_heap); 877 878 VkResult pvr_srv_int_ctx_create(int fd, 879 void **const server_memctx_out, 880 void **const server_memctx_data_out); 881 void pvr_srv_int_ctx_destroy(int fd, void *server_memctx); 882 883 VkResult pvr_srv_int_reserve_addr(int fd, 884 void *server_heap, 885 pvr_dev_addr_t addr, 886 uint64_t size, 887 void **const reservation_out); 888 void pvr_srv_int_unreserve_addr(int fd, void *reservation); 889 890 VkResult pvr_srv_alloc_pmr(int fd, 891 uint64_t size, 892 uint64_t block_size, 893 uint32_t phy_blocks, 894 uint32_t virt_blocks, 895 uint32_t log2_page_size, 896 uint64_t flags, 897 uint32_t pid, 898 void **const pmr_out); 899 void pvr_srv_free_pmr(int fd, void *pmr); 900 901 VkResult pvr_srv_int_map_pages(int fd, 902 void *reservation, 903 void *pmr, 904 uint32_t page_count, 905 uint32_t page_offset, 906 uint64_t flags, 907 pvr_dev_addr_t addr); 908 void pvr_srv_int_unmap_pages(int fd, 909 void *reservation, 910 pvr_dev_addr_t dev_addr, 911 uint32_t page_count); 912 913 VkResult pvr_srv_int_map_pmr(int fd, 914 void *server_heap, 915 void *reservation, 916 void *pmr, 917 uint64_t flags, 918 void **const mapping_out); 919 void pvr_srv_int_unmap_pmr(int fd, void *mapping); 920 921 VkResult pvr_srv_physmem_import_dmabuf(int fd, 922 int buffer_fd, 923 uint64_t flags, 924 void **const pmr_out, 925 uint64_t *const size_out, 926 uint64_t *const align_out); 927 VkResult pvr_srv_physmem_export_dmabuf(int fd, void *pmr, int *const fd_out); 928 929 VkResult 930 pvr_srv_rgx_create_compute_context(int fd, 931 uint32_t priority, 932 uint32_t reset_framework_cmd_size, 933 uint8_t *reset_framework_cmd, 934 void *priv_data, 935 uint32_t static_compute_context_state_size, 936 uint8_t *static_compute_context_state, 937 uint32_t packed_ccb_size, 938 uint32_t context_flags, 939 uint64_t robustness_address, 940 uint32_t max_deadline_ms, 941 void **const compute_context_out); 942 void pvr_srv_rgx_destroy_compute_context(int fd, void *compute_context); 943 944 VkResult pvr_srv_rgx_kick_compute2(int fd, 945 void *compute_context, 946 uint32_t client_update_count, 947 void **client_update_ufo_sync_prim_block, 948 uint32_t *client_update_offset, 949 uint32_t *client_update_value, 950 int32_t check_fence, 951 int32_t update_timeline, 952 uint32_t cmd_size, 953 uint8_t *cdm_cmd, 954 uint32_t ext_job_ref, 955 uint32_t sync_pmr_count, 956 uint32_t *sync_pmr_flags, 957 void **sync_pmrs, 958 uint32_t num_work_groups, 959 uint32_t num_work_items, 960 uint32_t pdump_flags, 961 uint64_t max_deadline_us, 962 char *update_fence_name, 963 int32_t *const update_fence_out); 964 965 VkResult pvr_srv_rgx_create_transfer_context(int fd, 966 uint32_t priority, 967 uint32_t reset_framework_cmd_size, 968 uint8_t *reset_framework_cmd, 969 void *priv_data, 970 uint32_t packed_ccb_size_u8888, 971 uint32_t context_flags, 972 uint64_t robustness_address, 973 void **const cli_pmr_out, 974 void **const usc_pmr_out, 975 void **const transfer_context_out); 976 void pvr_srv_rgx_destroy_transfer_context(int fd, void *transfer_context); 977 VkResult pvr_srv_rgx_submit_transfer2(int fd, 978 void *transfer_context, 979 uint32_t prepare_count, 980 uint32_t *client_update_count, 981 void ***update_ufo_sync_prim_block, 982 uint32_t **update_sync_offset, 983 uint32_t **update_value, 984 int32_t check_fence, 985 int32_t update_timeline_2d, 986 int32_t update_timeline_3d, 987 char *update_fence_name, 988 uint32_t *cmd_size, 989 uint8_t **fw_command, 990 uint32_t *tq_prepare_flags, 991 uint32_t ext_job_ref, 992 uint32_t sync_pmr_count, 993 uint32_t *sync_pmr_flags, 994 void **sync_pmrs, 995 int32_t *update_fence_2d_out, 996 int32_t *update_fence_3d_out); 997 998 VkResult 999 pvr_srv_rgx_create_hwrt_dataset(int fd, 1000 uint64_t flipped_multi_sample_ctl, 1001 uint64_t multi_sample_ctl, 1002 const pvr_dev_addr_t *macrotile_array_dev_addrs, 1003 const pvr_dev_addr_t *pm_mlist_dev_addrs, 1004 const pvr_dev_addr_t *rtc_dev_addrs, 1005 const pvr_dev_addr_t *rgn_header_dev_addrs, 1006 const pvr_dev_addr_t *tail_ptrs_dev_addrs, 1007 const pvr_dev_addr_t *vheap_table_dev_adds, 1008 void **free_lists, 1009 uint32_t isp_merge_lower_x, 1010 uint32_t isp_merge_lower_y, 1011 uint32_t isp_merge_scale_x, 1012 uint32_t isp_merge_scale_y, 1013 uint32_t isp_merge_upper_x, 1014 uint32_t isp_merge_upper_y, 1015 uint32_t isp_mtile_size, 1016 uint32_t mtile_stride, 1017 uint32_t ppp_screen, 1018 uint32_t rgn_header_size, 1019 uint32_t te_aa, 1020 uint32_t te_mtile1, 1021 uint32_t te_mtile2, 1022 uint32_t te_screen, 1023 uint32_t tpc_size, 1024 uint32_t tpc_stride, 1025 uint16_t max_rts, 1026 void **hwrt_dataset_out); 1027 1028 void pvr_srv_rgx_destroy_hwrt_dataset(int fd, void *hwrt_dataset); 1029 1030 VkResult pvr_srv_rgx_create_free_list(int fd, 1031 void *mem_ctx_priv_data, 1032 uint32_t max_free_list_pages, 1033 uint32_t init_free_list_pages, 1034 uint32_t grow_free_list_pages, 1035 uint32_t grow_param_threshold, 1036 void *global_free_list, 1037 enum pvr_srv_bool free_list_check, 1038 pvr_dev_addr_t free_list_dev_addr, 1039 void *free_list_pmr, 1040 uint64_t pmr_offset, 1041 void **const cleanup_cookie_out); 1042 1043 void pvr_srv_rgx_destroy_free_list(int fd, void *cleanup_cookie); 1044 1045 VkResult 1046 pvr_srv_rgx_create_render_context(int fd, 1047 uint32_t priority, 1048 pvr_dev_addr_t vdm_callstack_addr, 1049 uint32_t call_stack_depth, 1050 uint32_t reset_framework_cmd_size, 1051 uint8_t *reset_framework_cmd, 1052 void *priv_data, 1053 uint32_t static_render_context_state_size, 1054 uint8_t *static_render_context_state, 1055 uint32_t packed_ccb_size, 1056 uint32_t context_flags, 1057 uint64_t robustness_address, 1058 uint32_t max_geom_deadline_ms, 1059 uint32_t max_frag_deadline_ms, 1060 void **const render_context_out); 1061 1062 void pvr_srv_rgx_destroy_render_context(int fd, void *render_context); 1063 1064 VkResult pvr_srv_rgx_kick_render2(int fd, 1065 void *render_ctx, 1066 uint32_t client_geom_fence_count, 1067 void **client_geom_fence_sync_prim_block, 1068 uint32_t *client_geom_fence_sync_offset, 1069 uint32_t *client_geom_fence_value, 1070 uint32_t client_geom_update_count, 1071 void **client_geom_update_sync_prim_block, 1072 uint32_t *client_geom_update_sync_offset, 1073 uint32_t *client_geom_update_value, 1074 uint32_t client_frag_update_count, 1075 void **client_frag_update_sync_prim_block, 1076 uint32_t *client_frag_update_sync_offset, 1077 uint32_t *client_frag_update_value, 1078 void *client_pr_fence_ufo_sync_prim_block, 1079 uint32_t client_pr_fence_ufo_sync_offset, 1080 uint32_t client_pr_fence_value, 1081 int32_t check_fence, 1082 int32_t update_timeline, 1083 int32_t *const update_fence_out, 1084 char *update_fence_name, 1085 int32_t check_fence_frag, 1086 int32_t update_timeline_frag, 1087 int32_t *const update_fence_frag_out, 1088 char *update_fence_name_frag, 1089 uint32_t cmd_geom_size, 1090 uint8_t *cmd_geom, 1091 uint32_t cmd_frag_pr_size, 1092 uint8_t *cmd_frag_pr, 1093 uint32_t cmd_frag_size, 1094 uint8_t *cmd_frag, 1095 uint32_t ext_job_ref, 1096 bool kick_geom, 1097 bool kick_pr, 1098 bool kick_frag, 1099 bool abort, 1100 uint32_t pdump_flags, 1101 void *hw_rt_dataset, 1102 void *zs_buffer, 1103 void *msaa_scratch_buffer, 1104 uint32_t sync_pmr_count, 1105 uint32_t *sync_pmr_flags, 1106 void **sync_pmrs, 1107 uint32_t render_target_size, 1108 uint32_t num_draw_calls, 1109 uint32_t num_indices, 1110 uint32_t num_mrts, 1111 uint64_t deadline); 1112 1113 #endif /* PVR_SRV_BRIDGE_H */ 1114