1 /* $NetBSD: intel_guc_log.h,v 1.2 2021/12/18 23:45:31 riastradh Exp $ */ 2 3 /* SPDX-License-Identifier: MIT */ 4 /* 5 * Copyright © 2014-2019 Intel Corporation 6 */ 7 8 #ifndef _INTEL_GUC_LOG_H_ 9 #define _INTEL_GUC_LOG_H_ 10 11 #include <linux/mutex.h> 12 #include <linux/relay.h> 13 #include <linux/workqueue.h> 14 15 #include "intel_guc_fwif.h" 16 #include "i915_gem.h" 17 18 struct intel_guc; 19 20 #ifdef CONFIG_DRM_I915_DEBUG_GUC 21 #define CRASH_BUFFER_SIZE SZ_2M 22 #define DPC_BUFFER_SIZE SZ_8M 23 #define ISR_BUFFER_SIZE SZ_8M 24 #else 25 #define CRASH_BUFFER_SIZE SZ_8K 26 #define DPC_BUFFER_SIZE SZ_32K 27 #define ISR_BUFFER_SIZE SZ_32K 28 #endif 29 30 /* 31 * While we're using plain log level in i915, GuC controls are much more... 32 * "elaborate"? We have a couple of bits for verbosity, separate bit for actual 33 * log enabling, and separate bit for default logging - which "conveniently" 34 * ignores the enable bit. 35 */ 36 #define GUC_LOG_LEVEL_DISABLED 0 37 #define GUC_LOG_LEVEL_NON_VERBOSE 1 38 #define GUC_LOG_LEVEL_IS_ENABLED(x) ((x) > GUC_LOG_LEVEL_DISABLED) 39 #define GUC_LOG_LEVEL_IS_VERBOSE(x) ((x) > GUC_LOG_LEVEL_NON_VERBOSE) 40 #define GUC_LOG_LEVEL_TO_VERBOSITY(x) ({ \ 41 typeof(x) _x = (x); \ 42 GUC_LOG_LEVEL_IS_VERBOSE(_x) ? _x - 2 : 0; \ 43 }) 44 #define GUC_VERBOSITY_TO_LOG_LEVEL(x) ((x) + 2) 45 #define GUC_LOG_LEVEL_MAX GUC_VERBOSITY_TO_LOG_LEVEL(GUC_LOG_VERBOSITY_MAX) 46 47 struct intel_guc_log { 48 u32 level; 49 struct i915_vma *vma; 50 struct { 51 void *buf_addr; 52 bool started; 53 struct work_struct flush_work; 54 struct rchan *channel; 55 struct mutex lock; 56 u32 full_count; 57 } relay; 58 /* logging related stats */ 59 struct { 60 u32 sampled_overflow; 61 u32 overflow; 62 u32 flush; 63 } stats[GUC_MAX_LOG_BUFFER]; 64 }; 65 66 void intel_guc_log_init_early(struct intel_guc_log *log); 67 int intel_guc_log_create(struct intel_guc_log *log); 68 void intel_guc_log_destroy(struct intel_guc_log *log); 69 70 int intel_guc_log_set_level(struct intel_guc_log *log, u32 level); 71 bool intel_guc_log_relay_created(const struct intel_guc_log *log); 72 int intel_guc_log_relay_open(struct intel_guc_log *log); 73 int intel_guc_log_relay_start(struct intel_guc_log *log); 74 void intel_guc_log_relay_flush(struct intel_guc_log *log); 75 void intel_guc_log_relay_close(struct intel_guc_log *log); 76 77 void intel_guc_log_handle_flush_event(struct intel_guc_log *log); 78 intel_guc_log_get_level(struct intel_guc_log * log)79static inline u32 intel_guc_log_get_level(struct intel_guc_log *log) 80 { 81 return log->level; 82 } 83 84 #endif 85