1 /* SPDX-License-Identifier: MIT */ 2 /* 3 * Copyright © 2024 Tomeu Vizoso 4 */ 5 #ifndef __DRM_UAPI_ROCKET_ACCEL_H__ 6 #define __DRM_UAPI_ROCKET_ACCEL_H__ 7 8 #include "drm.h" 9 10 #if defined(__cplusplus) 11 extern "C" { 12 #endif 13 14 #define DRM_ROCKET_CREATE_BO 0x00 15 #define DRM_ROCKET_SUBMIT 0x01 16 17 #define DRM_IOCTL_ROCKET_CREATE_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_ROCKET_CREATE_BO, struct drm_rocket_create_bo) 18 #define DRM_IOCTL_ROCKET_SUBMIT DRM_IOW(DRM_COMMAND_BASE + DRM_ROCKET_SUBMIT, struct drm_rocket_submit) 19 20 /** 21 * struct drm_rocket_create_bo - ioctl argument for creating Rocket BOs. 22 * 23 */ 24 struct drm_rocket_create_bo { 25 /** Input: Size of the requested BO. */ 26 __u32 size; 27 28 /** Output: GEM handle for the BO. */ 29 __u32 handle; 30 31 /** 32 * Output: DMA address for the BO in the NPU address space. This address 33 * is private to the DRM fd and is valid for the lifetime of the GEM 34 * handle. 35 */ 36 __u64 dma_address; 37 38 /** Output: Offset into the drm node to use for subsequent mmap call. */ 39 __u64 offset; 40 }; 41 42 /** 43 * struct drm_rocket_task - A task to be run on the NPU 44 * 45 * A task is the smallest unit of work that can be run on the NPU. 46 */ 47 struct drm_rocket_task { 48 /** Input: DMA address to NPU mapping of register command buffer */ 49 __u32 regcmd; 50 51 /** Input: Number of commands in the register command buffer */ 52 __u32 regcmd_count; 53 }; 54 55 /** 56 * struct drm_rocket_job - A job to be run on the NPU 57 * 58 * The kernel will schedule the execution of this job taking into account its 59 * dependencies with other jobs. All tasks in the same job will be executed 60 * sequentially on the same core, to benefit from memory residency in SRAM. 61 */ 62 struct drm_rocket_job { 63 /** Input: Pointer to an array of struct drm_rocket_task. */ 64 __u64 tasks; 65 66 /** Input: Pointer to a u32 array of the BOs that are read by the job. */ 67 __u64 in_bo_handles; 68 69 /** Input: Pointer to a u32 array of the BOs that are written to by the job. */ 70 __u64 out_bo_handles; 71 72 /** Input: Number of tasks passed in. */ 73 __u32 task_count; 74 75 /** Input: Size in bytes of the structs in the @tasks field. */ 76 __u32 task_struct_size; 77 78 /** Input: Number of input BO handles passed in (size is that times 4). */ 79 __u32 in_bo_handle_count; 80 81 /** Input: Number of output BO handles passed in (size is that times 4). */ 82 __u32 out_bo_handle_count; 83 }; 84 85 /** 86 * struct drm_rocket_submit - ioctl argument for submitting commands to the NPU. 87 * 88 * The kernel will schedule the execution of these jobs in dependency order. 89 */ 90 struct drm_rocket_submit { 91 /** Input: Pointer to an array of struct drm_rocket_job. */ 92 __u64 jobs; 93 94 /** Input: Number of jobs passed in. */ 95 __u32 job_count; 96 97 /** Input: Size in bytes of the structs in the @jobs field. */ 98 __u32 job_struct_size; 99 100 /** Reserved, must be zero. */ 101 __u64 reserved; 102 }; 103 104 #if defined(__cplusplus) 105 } 106 #endif 107 108 #endif /* __DRM_UAPI_ROCKET_ACCEL_H__ */ 109