2 * Copyright © 2014-2017 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25 #ifndef _INTEL_GUC_LOG_H_
26 #define _INTEL_GUC_LOG_H_
28 #include <linux/mutex.h>
29 #include <linux/relay.h>
30 #include <linux/workqueue.h>
32 #include "intel_guc_fwif.h"
37 * The first page is to save log buffer state. Allocate one
38 * extra page for others in case for overlap
40 #define GUC_LOG_SIZE ((1 + GUC_LOG_DPC_PAGES + 1 + GUC_LOG_ISR_PAGES + \
41 1 + GUC_LOG_CRASH_PAGES + 1) << PAGE_SHIFT)
44 * While we're using plain log level in i915, GuC controls are much more...
45 * "elaborate"? We have a couple of bits for verbosity, separate bit for actual
46 * log enabling, and separate bit for default logging - which "conveniently"
47 * ignores the enable bit.
49 #define GUC_LOG_LEVEL_DISABLED 0
50 #define GUC_LOG_LEVEL_NON_VERBOSE 1
51 #define GUC_LOG_LEVEL_IS_ENABLED(x) ((x) > GUC_LOG_LEVEL_DISABLED)
52 #define GUC_LOG_LEVEL_IS_VERBOSE(x) ((x) > GUC_LOG_LEVEL_NON_VERBOSE)
53 #define GUC_LOG_LEVEL_TO_VERBOSITY(x) ({ \
55 GUC_LOG_LEVEL_IS_VERBOSE(_x) ? _x - 2 : 0; \
57 #define GUC_VERBOSITY_TO_LOG_LEVEL(x) ((x) + 2)
58 #define GUC_LOG_LEVEL_MAX GUC_VERBOSITY_TO_LOG_LEVEL(GUC_LOG_VERBOSITY_MAX)
60 struct intel_guc_log {
65 struct workqueue_struct *flush_wq;
66 struct work_struct flush_work;
67 struct rchan *channel;
71 /* logging related stats */
76 } stats[GUC_MAX_LOG_BUFFER];
79 void intel_guc_log_init_early(struct intel_guc_log *log);
80 int intel_guc_log_create(struct intel_guc_log *log);
81 void intel_guc_log_destroy(struct intel_guc_log *log);
83 int intel_guc_log_level_get(struct intel_guc_log *log);
84 int intel_guc_log_level_set(struct intel_guc_log *log, u64 control_val);
85 bool intel_guc_log_relay_enabled(const struct intel_guc_log *log);
86 int intel_guc_log_relay_open(struct intel_guc_log *log);
87 void intel_guc_log_relay_flush(struct intel_guc_log *log);
88 void intel_guc_log_relay_close(struct intel_guc_log *log);
90 void intel_guc_log_handle_flush_event(struct intel_guc_log *log);