Users and sysadmins usually want to know what is the device utilization as a level 0 indication if they are efficiently using the device. Add a new opcode to the INFO IOCTL that will return the device utilization over the last period of 100-1000ms. The return value is 0-100, representing as percentage the total utilization rate.
Showing the changes to include/uapi (1 of 7 files). Show all
Unified · Split
| @@ -77,22 +77,29 @@ enum hl_device_status { · 76 unmodified lines | |||
| 77 | 77 | ||
| 78 | /* Opcode for management ioctl | 78 | /* Opcode for management ioctl |
| 79 | * | 79 | * |
| 80 | * HW_IP_INFO - Receive information about different IP blocks in the | 80 | * HW_IP_INFO - Receive information about different IP blocks in the |
| 81 | * device. | 81 | * device. |
| 82 | * HL_INFO_HW_EVENTS - Receive an array describing how many times each event | 82 | * HL_INFO_HW_EVENTS - Receive an array describing how many times each event |
| 83 | * occurred since the last hard reset. | 83 | * occurred since the last hard reset. |
| 84 | * HL_INFO_DRAM_USAGE - Retrieve the dram usage inside the device and of the | 84 | * HL_INFO_DRAM_USAGE - Retrieve the dram usage inside the device and of the |
| 85 | * specific context. This is relevant only for GOYA device. | 85 | * specific context. This is relevant only for devices |
| 86 | * HL_INFO_HW_IDLE - Retrieve information about the idle status of each | 86 | * where the dram is managed by the kernel driver |
| 87 | * internal engine. | 87 | * HL_INFO_HW_IDLE - Retrieve information about the idle status of each |
| 88 | * internal engine. | ||
| 88 | * HL_INFO_DEVICE_STATUS - Retrieve the device's status. This opcode doesn't | 89 | * HL_INFO_DEVICE_STATUS - Retrieve the device's status. This opcode doesn't |
| 89 | * require an open context. | 90 | * require an open context. |
| 91 | * HL_INFO_DEVICE_UTILIZATION - Retrieve the total utilization of the device | ||
| 92 | * over the last period specified by the user. | ||
| 93 | * The period can be between 100ms to 1s, in | ||
| 94 | * resolution of 100ms. The return value is a | ||
| 95 | * percentage of the utilization rate. | ||
| 90 | */ | 96 | */ |
| 91 | #define HL_INFO_HW_IP_INFO 0 | 97 | #define HL_INFO_HW_IP_INFO 0 |
| 92 | #define HL_INFO_HW_EVENTS 1 | 98 | #define HL_INFO_HW_EVENTS 1 |
| 93 | #define HL_INFO_DRAM_USAGE 2 | 99 | #define HL_INFO_DRAM_USAGE 2 |
| 94 | #define HL_INFO_HW_IDLE 3 | 100 | #define HL_INFO_HW_IDLE 3 |
| 95 | #define HL_INFO_DEVICE_STATUS 4 | 101 | #define HL_INFO_DEVICE_STATUS 4 |
| 102 | #define HL_INFO_DEVICE_UTILIZATION 6 | ||
| 96 | 103 | ||
| 97 | #define HL_INFO_VERSION_MAX_LEN 128 | 104 | #define HL_INFO_VERSION_MAX_LEN 128 |
| 98 | 105 | ||
| @@ -134,6 +141,11 @@ struct hl_info_device_status { · 35 unmodified lines | |||
| 134 | __u32 pad; | 141 | __u32 pad; |
| 135 | }; | 142 | }; |
| 136 | 143 | ||
| 144 | struct hl_info_device_utilization { | ||
| 145 | __u32 utilization; | ||
| 146 | __u32 pad; | ||
| 147 | }; | ||
| 148 | |||
| 137 | struct hl_info_args { | 149 | struct hl_info_args { |
| 138 | /* Location of relevant struct in userspace */ | 150 | /* Location of relevant struct in userspace */ |
| 139 | __u64 return_pointer; | 151 | __u64 return_pointer; |
| @@ -149,8 +161,15 @@ struct hl_info_args { · 9 unmodified lines | |||
| 149 | /* HL_INFO_* */ | 161 | /* HL_INFO_* */ |
| 150 | __u32 op; | 162 | __u32 op; |
| 151 | 163 | ||
| 152 | /* Context ID - Currently not in use */ | 164 | union { |
| 153 | __u32 ctx_id; | 165 | /* Context ID - Currently not in use */ |
| 166 | __u32 ctx_id; | ||
| 167 | /* Period value for utilization rate (100ms - 1000ms, in 100ms | ||
| 168 | * resolution. | ||
| 169 | */ | ||
| 170 | __u32 period_ms; | ||
| 171 | }; | ||
| 172 | |||
| 154 | __u32 pad; | 173 | __u32 pad; |
| 155 | }; | 174 | }; |
| 156 | 175 | ||