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