In order for interrupt timestamp to be more accurate we should capture it during the interrupt handling rather than in threaded irq context.
Unified · Split
| @@ -1107,6 +1107,7 @@ enum hl_user_interrupt_type { · 1106 unmodified lines | ||
| 1107 | 1107 | * @type: user interrupt type |
| 1108 | 1108 | * @wait_list_head: head to the list of user threads pending on this interrupt |
| 1109 | 1109 | * @wait_list_lock: protects wait_list_head |
| 1110 | + * @timestamp: last timestamp taken upon interrupt | |
| 1110 | 1111 | * @interrupt_id: msix interrupt id |
| 1111 | 1112 | */ |
| 1112 | 1113 | struct hl_user_interrupt { |
| @@ -1114,6 +1115,7 @@ struct hl_user_interrupt { · 1 unmodified line | ||
| 1114 | 1115 | enum hl_user_interrupt_type type; |
| 1115 | 1116 | struct list_head wait_list_head; |
| 1116 | 1117 | spinlock_t wait_list_lock; |
| 1118 | + ktime_t timestamp; | |
| 1117 | 1119 | u32 interrupt_id; |
| 1118 | 1120 | }; |
| 1119 | 1121 | |
| @@ -280,7 +280,6 @@ static void handle_user_interrupt(struct hl_device *hdev, struct hl_user_interru · 279 unmodified lines | ||
| 280 | 280 | struct list_head *ts_reg_free_list_head = NULL; |
| 281 | 281 | struct timestamp_reg_work_obj *job; |
| 282 | 282 | bool reg_node_handle_fail = false; |
| 283 | − ktime_t now = ktime_get(); | |
| 284 | 283 | int rc; |
| 285 | 284 | |
| 286 | 285 | /* For registration nodes: |
| @@ -303,13 +302,13 @@ static void handle_user_interrupt(struct hl_device *hdev, struct hl_user_interru · 16 unmodified lines | ||
| 303 | 302 | if (pend->ts_reg_info.buf) { |
| 304 | 303 | if (!reg_node_handle_fail) { |
| 305 | 304 | rc = handle_registration_node(hdev, pend, |
| 306 | − &ts_reg_free_list_head, now); | |
| 305 | + &ts_reg_free_list_head, intr->timestamp); | |
| 307 | 306 | if (rc) |
| 308 | 307 | reg_node_handle_fail = true; |
| 309 | 308 | } |
| 310 | 309 | } else { |
| 311 | 310 | /* Handle wait target value node */ |
| 312 | − pend->fence.timestamp = now; | |
| 311 | + pend->fence.timestamp = intr->timestamp; | |
| 313 | 312 | complete_all(&pend->fence.completion); |
| 314 | 313 | } |
| 315 | 314 | } |
| @@ -335,6 +334,10 @@ static void handle_user_interrupt(struct hl_device *hdev, struct hl_user_interru · 19 unmodified lines | ||
| 335 | 334 | */ |
| 336 | 335 | irqreturn_t hl_irq_handler_user_interrupt(int irq, void *arg) |
| 337 | 336 | { |
| 337 | + struct hl_user_interrupt *user_int = arg; | |
| 338 | + | |
| 339 | + user_int->timestamp = ktime_get(); | |
| 340 | + | |
| 338 | 341 | return IRQ_WAKE_THREAD; |
| 339 | 342 | } |
| 340 | 343 | |