| 1 | /* SPDX-License-Identifier: MIT */ |
| 2 | /* |
| 3 | * Copyright © 2024 Intel Corporation |
| 4 | */ |
| 5 | |
| 6 | #ifndef _ABI_GUC_LOG_ABI_H |
| 7 | #define _ABI_GUC_LOG_ABI_H |
| 8 | |
| 9 | #include <linux/types.h> |
| 10 | |
| 11 | /* GuC logging buffer types */ |
| 12 | enum guc_log_buffer_type { |
| 13 | GUC_LOG_BUFFER_CRASH_DUMP, |
| 14 | GUC_LOG_BUFFER_DEBUG, |
| 15 | GUC_LOG_BUFFER_CAPTURE, |
| 16 | }; |
| 17 | |
| 18 | #define GUC_LOG_BUFFER_TYPE_MAX 3 |
| 19 | |
| 20 | /** |
| 21 | * struct guc_log_buffer_state - GuC log buffer state |
| 22 | * |
| 23 | * Below state structure is used for coordination of retrieval of GuC firmware |
| 24 | * logs. Separate state is maintained for each log buffer type. |
| 25 | * read_ptr points to the location where Xe read last in log buffer and |
| 26 | * is read only for GuC firmware. write_ptr is incremented by GuC with number |
| 27 | * of bytes written for each log entry and is read only for Xe. |
| 28 | * When any type of log buffer becomes half full, GuC sends a flush interrupt. |
| 29 | * GuC firmware expects that while it is writing to 2nd half of the buffer, |
| 30 | * first half would get consumed by Host and then get a flush completed |
| 31 | * acknowledgment from Host, so that it does not end up doing any overwrite |
| 32 | * causing loss of logs. So when buffer gets half filled & Xe has requested |
| 33 | * for interrupt, GuC will set flush_to_file field, set the sampled_write_ptr |
| 34 | * to the value of write_ptr and raise the interrupt. |
| 35 | * On receiving the interrupt Xe should read the buffer, clear flush_to_file |
| 36 | * field and also update read_ptr with the value of sample_write_ptr, before |
| 37 | * sending an acknowledgment to GuC. marker & version fields are for internal |
| 38 | * usage of GuC and opaque to Xe. buffer_full_cnt field is incremented every |
| 39 | * time GuC detects the log buffer overflow. |
| 40 | */ |
| 41 | struct guc_log_buffer_state { |
| 42 | /** @marker: buffer state start marker */ |
| 43 | u32 marker[2]; |
| 44 | /** @read_ptr: the last byte offset that was read by KMD previously */ |
| 45 | u32 read_ptr; |
| 46 | /** |
| 47 | * @write_ptr: the next byte offset location that will be written by |
| 48 | * GuC |
| 49 | */ |
| 50 | u32 write_ptr; |
| 51 | /** @size: Log buffer size */ |
| 52 | u32 size; |
| 53 | /** |
| 54 | * @sampled_write_ptr: Log buffer write pointer |
| 55 | * This is written by GuC to the byte offset of the next free entry in |
| 56 | * the buffer on log buffer half full or state capture notification |
| 57 | */ |
| 58 | u32 sampled_write_ptr; |
| 59 | /** |
| 60 | * @wrap_offset: wraparound offset |
| 61 | * This is the byte offset of location 1 byte after last valid guc log |
| 62 | * event entry written by Guc firmware before there was a wraparound. |
| 63 | * This field is updated by guc firmware and should be used by Host |
| 64 | * when copying buffer contents to file. |
| 65 | */ |
| 66 | u32 wrap_offset; |
| 67 | /** @flags: Flush to file flag and buffer full count */ |
| 68 | u32 flags; |
| 69 | #define GUC_LOG_BUFFER_STATE_FLUSH_TO_FILE GENMASK(0, 0) |
| 70 | #define GUC_LOG_BUFFER_STATE_BUFFER_FULL_CNT GENMASK(4, 1) |
| 71 | /** @version: The Guc-Log-Entry format version */ |
| 72 | u32 version; |
| 73 | } __packed; |
| 74 | |
| 75 | #endif |
| 76 | |