]> Git Repo - linux.git/blob - drivers/gpu/drm/i915/intel_guc_log.h
Merge tag 'platform-drivers-x86-v4.18-1' of git://git.infradead.org/linux-platform...
[linux.git] / drivers / gpu / drm / i915 / intel_guc_log.h
1 /*
2  * Copyright © 2014-2017 Intel Corporation
3  *
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:
10  *
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
13  * Software.
14  *
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
21  * IN THE SOFTWARE.
22  *
23  */
24
25 #ifndef _INTEL_GUC_LOG_H_
26 #define _INTEL_GUC_LOG_H_
27
28 #include <linux/mutex.h>
29 #include <linux/relay.h>
30 #include <linux/workqueue.h>
31
32 #include "intel_guc_fwif.h"
33
34 struct intel_guc;
35
36 /*
37  * The first page is to save log buffer state. Allocate one
38  * extra page for others in case for overlap
39  */
40 #define GUC_LOG_SIZE    ((1 + GUC_LOG_DPC_PAGES + 1 + GUC_LOG_ISR_PAGES + \
41                           1 + GUC_LOG_CRASH_PAGES + 1) << PAGE_SHIFT)
42
43 /*
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.
48  */
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) ({                \
54         typeof(x) _x = (x);                             \
55         GUC_LOG_LEVEL_IS_VERBOSE(_x) ? _x - 2 : 0;      \
56 })
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)
59
60 struct intel_guc_log {
61         u32 flags;
62         struct i915_vma *vma;
63         struct {
64                 void *buf_addr;
65                 struct workqueue_struct *flush_wq;
66                 struct work_struct flush_work;
67                 struct rchan *channel;
68                 struct mutex lock;
69                 u32 full_count;
70         } relay;
71         /* logging related stats */
72         struct {
73                 u32 sampled_overflow;
74                 u32 overflow;
75                 u32 flush;
76         } stats[GUC_MAX_LOG_BUFFER];
77 };
78
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);
82
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);
89
90 void intel_guc_log_handle_flush_event(struct intel_guc_log *log);
91
92 #endif
This page took 0.040262 seconds and 4 git commands to generate.