1a85cb24fSFrançois Tigeot /*
2a85cb24fSFrançois Tigeot * Copyright © 2014-2017 Intel Corporation
3a85cb24fSFrançois Tigeot *
4a85cb24fSFrançois Tigeot * Permission is hereby granted, free of charge, to any person obtaining a
5a85cb24fSFrançois Tigeot * copy of this software and associated documentation files (the "Software"),
6a85cb24fSFrançois Tigeot * to deal in the Software without restriction, including without limitation
7a85cb24fSFrançois Tigeot * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8a85cb24fSFrançois Tigeot * and/or sell copies of the Software, and to permit persons to whom the
9a85cb24fSFrançois Tigeot * Software is furnished to do so, subject to the following conditions:
10a85cb24fSFrançois Tigeot *
11a85cb24fSFrançois Tigeot * The above copyright notice and this permission notice (including the next
12a85cb24fSFrançois Tigeot * paragraph) shall be included in all copies or substantial portions of the
13a85cb24fSFrançois Tigeot * Software.
14a85cb24fSFrançois Tigeot *
15a85cb24fSFrançois Tigeot * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16a85cb24fSFrançois Tigeot * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17a85cb24fSFrançois Tigeot * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18a85cb24fSFrançois Tigeot * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19a85cb24fSFrançois Tigeot * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20a85cb24fSFrançois Tigeot * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21a85cb24fSFrançois Tigeot * IN THE SOFTWARE.
22a85cb24fSFrançois Tigeot *
23a85cb24fSFrançois Tigeot */
24*3f2dd94aSFrançois Tigeot
25a85cb24fSFrançois Tigeot #include <linux/debugfs.h>
26a85cb24fSFrançois Tigeot #include <linux/relay.h>
27*3f2dd94aSFrançois Tigeot
28*3f2dd94aSFrançois Tigeot #include "intel_guc_log.h"
29a85cb24fSFrançois Tigeot #include "i915_drv.h"
30a85cb24fSFrançois Tigeot
31a85cb24fSFrançois Tigeot #if 0
32a85cb24fSFrançois Tigeot static void guc_log_capture_logs(struct intel_guc *guc);
33a85cb24fSFrançois Tigeot
34a85cb24fSFrançois Tigeot /**
35a85cb24fSFrançois Tigeot * DOC: GuC firmware log
36a85cb24fSFrançois Tigeot *
37a85cb24fSFrançois Tigeot * Firmware log is enabled by setting i915.guc_log_level to non-negative level.
38a85cb24fSFrançois Tigeot * Log data is printed out via reading debugfs i915_guc_log_dump. Reading from
39a85cb24fSFrançois Tigeot * i915_guc_load_status will print out firmware loading status and scratch
40a85cb24fSFrançois Tigeot * registers value.
41a85cb24fSFrançois Tigeot *
42a85cb24fSFrançois Tigeot */
43a85cb24fSFrançois Tigeot
44a85cb24fSFrançois Tigeot static int guc_log_flush_complete(struct intel_guc *guc)
45a85cb24fSFrançois Tigeot {
46a85cb24fSFrançois Tigeot u32 action[] = {
47a85cb24fSFrançois Tigeot INTEL_GUC_ACTION_LOG_BUFFER_FILE_FLUSH_COMPLETE
48a85cb24fSFrançois Tigeot };
49a85cb24fSFrançois Tigeot
50a85cb24fSFrançois Tigeot return intel_guc_send(guc, action, ARRAY_SIZE(action));
51a85cb24fSFrançois Tigeot }
52a85cb24fSFrançois Tigeot
53a85cb24fSFrançois Tigeot static int guc_log_flush(struct intel_guc *guc)
54a85cb24fSFrançois Tigeot {
55a85cb24fSFrançois Tigeot u32 action[] = {
56a85cb24fSFrançois Tigeot INTEL_GUC_ACTION_FORCE_LOG_BUFFER_FLUSH,
57a85cb24fSFrançois Tigeot 0
58a85cb24fSFrançois Tigeot };
59a85cb24fSFrançois Tigeot
60a85cb24fSFrançois Tigeot return intel_guc_send(guc, action, ARRAY_SIZE(action));
61a85cb24fSFrançois Tigeot }
62a85cb24fSFrançois Tigeot
63a85cb24fSFrançois Tigeot static int guc_log_control(struct intel_guc *guc, u32 control_val)
64a85cb24fSFrançois Tigeot {
65a85cb24fSFrançois Tigeot u32 action[] = {
66a85cb24fSFrançois Tigeot INTEL_GUC_ACTION_UK_LOG_ENABLE_LOGGING,
67a85cb24fSFrançois Tigeot control_val
68a85cb24fSFrançois Tigeot };
69a85cb24fSFrançois Tigeot
70a85cb24fSFrançois Tigeot return intel_guc_send(guc, action, ARRAY_SIZE(action));
71a85cb24fSFrançois Tigeot }
72a85cb24fSFrançois Tigeot
73a85cb24fSFrançois Tigeot /*
74a85cb24fSFrançois Tigeot * Sub buffer switch callback. Called whenever relay has to switch to a new
75a85cb24fSFrançois Tigeot * sub buffer, relay stays on the same sub buffer if 0 is returned.
76a85cb24fSFrançois Tigeot */
77a85cb24fSFrançois Tigeot static int subbuf_start_callback(struct rchan_buf *buf,
78a85cb24fSFrançois Tigeot void *subbuf,
79a85cb24fSFrançois Tigeot void *prev_subbuf,
80a85cb24fSFrançois Tigeot size_t prev_padding)
81a85cb24fSFrançois Tigeot {
82a85cb24fSFrançois Tigeot /* Use no-overwrite mode by default, where relay will stop accepting
83a85cb24fSFrançois Tigeot * new data if there are no empty sub buffers left.
84a85cb24fSFrançois Tigeot * There is no strict synchronization enforced by relay between Consumer
85a85cb24fSFrançois Tigeot * and Producer. In overwrite mode, there is a possibility of getting
86a85cb24fSFrançois Tigeot * inconsistent/garbled data, the producer could be writing on to the
87a85cb24fSFrançois Tigeot * same sub buffer from which Consumer is reading. This can't be avoided
88a85cb24fSFrançois Tigeot * unless Consumer is fast enough and can always run in tandem with
89a85cb24fSFrançois Tigeot * Producer.
90a85cb24fSFrançois Tigeot */
91a85cb24fSFrançois Tigeot if (relay_buf_full(buf))
92a85cb24fSFrançois Tigeot return 0;
93a85cb24fSFrançois Tigeot
94a85cb24fSFrançois Tigeot return 1;
95a85cb24fSFrançois Tigeot }
96a85cb24fSFrançois Tigeot
97a85cb24fSFrançois Tigeot /*
98a85cb24fSFrançois Tigeot * file_create() callback. Creates relay file in debugfs.
99a85cb24fSFrançois Tigeot */
100a85cb24fSFrançois Tigeot static struct dentry *create_buf_file_callback(const char *filename,
101a85cb24fSFrançois Tigeot struct dentry *parent,
102a85cb24fSFrançois Tigeot umode_t mode,
103a85cb24fSFrançois Tigeot struct rchan_buf *buf,
104a85cb24fSFrançois Tigeot int *is_global)
105a85cb24fSFrançois Tigeot {
106a85cb24fSFrançois Tigeot struct dentry *buf_file;
107a85cb24fSFrançois Tigeot
108a85cb24fSFrançois Tigeot /* This to enable the use of a single buffer for the relay channel and
109a85cb24fSFrançois Tigeot * correspondingly have a single file exposed to User, through which
110a85cb24fSFrançois Tigeot * it can collect the logs in order without any post-processing.
111a85cb24fSFrançois Tigeot * Need to set 'is_global' even if parent is NULL for early logging.
112a85cb24fSFrançois Tigeot */
113a85cb24fSFrançois Tigeot *is_global = 1;
114a85cb24fSFrançois Tigeot
115a85cb24fSFrançois Tigeot if (!parent)
116a85cb24fSFrançois Tigeot return NULL;
117a85cb24fSFrançois Tigeot
118a85cb24fSFrançois Tigeot /* Not using the channel filename passed as an argument, since for each
119a85cb24fSFrançois Tigeot * channel relay appends the corresponding CPU number to the filename
120a85cb24fSFrançois Tigeot * passed in relay_open(). This should be fine as relay just needs a
121a85cb24fSFrançois Tigeot * dentry of the file associated with the channel buffer and that file's
122a85cb24fSFrançois Tigeot * name need not be same as the filename passed as an argument.
123a85cb24fSFrançois Tigeot */
124a85cb24fSFrançois Tigeot buf_file = debugfs_create_file("guc_log", mode,
125a85cb24fSFrançois Tigeot parent, buf, &relay_file_operations);
126a85cb24fSFrançois Tigeot return buf_file;
127a85cb24fSFrançois Tigeot }
128a85cb24fSFrançois Tigeot
129a85cb24fSFrançois Tigeot /*
130a85cb24fSFrançois Tigeot * file_remove() default callback. Removes relay file in debugfs.
131a85cb24fSFrançois Tigeot */
132a85cb24fSFrançois Tigeot static int remove_buf_file_callback(struct dentry *dentry)
133a85cb24fSFrançois Tigeot {
134a85cb24fSFrançois Tigeot debugfs_remove(dentry);
135a85cb24fSFrançois Tigeot return 0;
136a85cb24fSFrançois Tigeot }
137a85cb24fSFrançois Tigeot
138a85cb24fSFrançois Tigeot /* relay channel callbacks */
139a85cb24fSFrançois Tigeot static struct rchan_callbacks relay_callbacks = {
140a85cb24fSFrançois Tigeot .subbuf_start = subbuf_start_callback,
141a85cb24fSFrançois Tigeot .create_buf_file = create_buf_file_callback,
142a85cb24fSFrançois Tigeot .remove_buf_file = remove_buf_file_callback,
143a85cb24fSFrançois Tigeot };
144a85cb24fSFrançois Tigeot
145a85cb24fSFrançois Tigeot static int guc_log_relay_file_create(struct intel_guc *guc)
146a85cb24fSFrançois Tigeot {
147a85cb24fSFrançois Tigeot struct drm_i915_private *dev_priv = guc_to_i915(guc);
148a85cb24fSFrançois Tigeot struct dentry *log_dir;
149a85cb24fSFrançois Tigeot int ret;
150a85cb24fSFrançois Tigeot
151*3f2dd94aSFrançois Tigeot if (i915_modparams.guc_log_level < 0)
152a85cb24fSFrançois Tigeot return 0;
153a85cb24fSFrançois Tigeot
154a85cb24fSFrançois Tigeot /* For now create the log file in /sys/kernel/debug/dri/0 dir */
155a85cb24fSFrançois Tigeot log_dir = dev_priv->drm.primary->debugfs_root;
156a85cb24fSFrançois Tigeot
157a85cb24fSFrançois Tigeot /* If /sys/kernel/debug/dri/0 location do not exist, then debugfs is
158a85cb24fSFrançois Tigeot * not mounted and so can't create the relay file.
159a85cb24fSFrançois Tigeot * The relay API seems to fit well with debugfs only, for availing relay
160a85cb24fSFrançois Tigeot * there are 3 requirements which can be met for debugfs file only in a
161a85cb24fSFrançois Tigeot * straightforward/clean manner :-
162a85cb24fSFrançois Tigeot * i) Need the associated dentry pointer of the file, while opening the
163a85cb24fSFrançois Tigeot * relay channel.
164a85cb24fSFrançois Tigeot * ii) Should be able to use 'relay_file_operations' fops for the file.
165a85cb24fSFrançois Tigeot * iii) Set the 'i_private' field of file's inode to the pointer of
166a85cb24fSFrançois Tigeot * relay channel buffer.
167a85cb24fSFrançois Tigeot */
168a85cb24fSFrançois Tigeot if (!log_dir) {
169a85cb24fSFrançois Tigeot DRM_ERROR("Debugfs dir not available yet for GuC log file\n");
170a85cb24fSFrançois Tigeot return -ENODEV;
171a85cb24fSFrançois Tigeot }
172a85cb24fSFrançois Tigeot
173a85cb24fSFrançois Tigeot ret = relay_late_setup_files(guc->log.runtime.relay_chan, "guc_log", log_dir);
174a85cb24fSFrançois Tigeot if (ret < 0 && ret != -EEXIST) {
175a85cb24fSFrançois Tigeot DRM_ERROR("Couldn't associate relay chan with file %d\n", ret);
176a85cb24fSFrançois Tigeot return ret;
177a85cb24fSFrançois Tigeot }
178a85cb24fSFrançois Tigeot
179a85cb24fSFrançois Tigeot return 0;
180a85cb24fSFrançois Tigeot }
181a85cb24fSFrançois Tigeot
182a85cb24fSFrançois Tigeot static void guc_move_to_next_buf(struct intel_guc *guc)
183a85cb24fSFrançois Tigeot {
184a85cb24fSFrançois Tigeot /* Make sure the updates made in the sub buffer are visible when
185a85cb24fSFrançois Tigeot * Consumer sees the following update to offset inside the sub buffer.
186a85cb24fSFrançois Tigeot */
187a85cb24fSFrançois Tigeot smp_wmb();
188a85cb24fSFrançois Tigeot
189a85cb24fSFrançois Tigeot /* All data has been written, so now move the offset of sub buffer. */
190a85cb24fSFrançois Tigeot relay_reserve(guc->log.runtime.relay_chan, guc->log.vma->obj->base.size);
191a85cb24fSFrançois Tigeot
192a85cb24fSFrançois Tigeot /* Switch to the next sub buffer */
193a85cb24fSFrançois Tigeot relay_flush(guc->log.runtime.relay_chan);
194a85cb24fSFrançois Tigeot }
195a85cb24fSFrançois Tigeot
196a85cb24fSFrançois Tigeot static void *guc_get_write_buffer(struct intel_guc *guc)
197a85cb24fSFrançois Tigeot {
198a85cb24fSFrançois Tigeot if (!guc->log.runtime.relay_chan)
199a85cb24fSFrançois Tigeot return NULL;
200a85cb24fSFrançois Tigeot
201a85cb24fSFrançois Tigeot /* Just get the base address of a new sub buffer and copy data into it
202a85cb24fSFrançois Tigeot * ourselves. NULL will be returned in no-overwrite mode, if all sub
203a85cb24fSFrançois Tigeot * buffers are full. Could have used the relay_write() to indirectly
204a85cb24fSFrançois Tigeot * copy the data, but that would have been bit convoluted, as we need to
205a85cb24fSFrançois Tigeot * write to only certain locations inside a sub buffer which cannot be
206a85cb24fSFrançois Tigeot * done without using relay_reserve() along with relay_write(). So its
207a85cb24fSFrançois Tigeot * better to use relay_reserve() alone.
208a85cb24fSFrançois Tigeot */
209a85cb24fSFrançois Tigeot return relay_reserve(guc->log.runtime.relay_chan, 0);
210a85cb24fSFrançois Tigeot }
211a85cb24fSFrançois Tigeot
212a85cb24fSFrançois Tigeot static bool guc_check_log_buf_overflow(struct intel_guc *guc,
213a85cb24fSFrançois Tigeot enum guc_log_buffer_type type,
214a85cb24fSFrançois Tigeot unsigned int full_cnt)
215a85cb24fSFrançois Tigeot {
216a85cb24fSFrançois Tigeot unsigned int prev_full_cnt = guc->log.prev_overflow_count[type];
217a85cb24fSFrançois Tigeot bool overflow = false;
218a85cb24fSFrançois Tigeot
219a85cb24fSFrançois Tigeot if (full_cnt != prev_full_cnt) {
220a85cb24fSFrançois Tigeot overflow = true;
221a85cb24fSFrançois Tigeot
222a85cb24fSFrançois Tigeot guc->log.prev_overflow_count[type] = full_cnt;
223a85cb24fSFrançois Tigeot guc->log.total_overflow_count[type] += full_cnt - prev_full_cnt;
224a85cb24fSFrançois Tigeot
225a85cb24fSFrançois Tigeot if (full_cnt < prev_full_cnt) {
226a85cb24fSFrançois Tigeot /* buffer_full_cnt is a 4 bit counter */
227a85cb24fSFrançois Tigeot guc->log.total_overflow_count[type] += 16;
228a85cb24fSFrançois Tigeot }
229a85cb24fSFrançois Tigeot DRM_ERROR_RATELIMITED("GuC log buffer overflow\n");
230a85cb24fSFrançois Tigeot }
231a85cb24fSFrançois Tigeot
232a85cb24fSFrançois Tigeot return overflow;
233a85cb24fSFrançois Tigeot }
234a85cb24fSFrançois Tigeot
235a85cb24fSFrançois Tigeot static unsigned int guc_get_log_buffer_size(enum guc_log_buffer_type type)
236a85cb24fSFrançois Tigeot {
237a85cb24fSFrançois Tigeot switch (type) {
238a85cb24fSFrançois Tigeot case GUC_ISR_LOG_BUFFER:
239a85cb24fSFrançois Tigeot return (GUC_LOG_ISR_PAGES + 1) * PAGE_SIZE;
240a85cb24fSFrançois Tigeot case GUC_DPC_LOG_BUFFER:
241a85cb24fSFrançois Tigeot return (GUC_LOG_DPC_PAGES + 1) * PAGE_SIZE;
242a85cb24fSFrançois Tigeot case GUC_CRASH_DUMP_LOG_BUFFER:
243a85cb24fSFrançois Tigeot return (GUC_LOG_CRASH_PAGES + 1) * PAGE_SIZE;
244a85cb24fSFrançois Tigeot default:
245a85cb24fSFrançois Tigeot MISSING_CASE(type);
246a85cb24fSFrançois Tigeot }
247a85cb24fSFrançois Tigeot
248a85cb24fSFrançois Tigeot return 0;
249a85cb24fSFrançois Tigeot }
250a85cb24fSFrançois Tigeot
251a85cb24fSFrançois Tigeot static void guc_read_update_log_buffer(struct intel_guc *guc)
252a85cb24fSFrançois Tigeot {
253a85cb24fSFrançois Tigeot unsigned int buffer_size, read_offset, write_offset, bytes_to_copy, full_cnt;
254a85cb24fSFrançois Tigeot struct guc_log_buffer_state *log_buf_state, *log_buf_snapshot_state;
255a85cb24fSFrançois Tigeot struct guc_log_buffer_state log_buf_state_local;
256a85cb24fSFrançois Tigeot enum guc_log_buffer_type type;
257a85cb24fSFrançois Tigeot void *src_data, *dst_data;
258a85cb24fSFrançois Tigeot bool new_overflow;
259a85cb24fSFrançois Tigeot
260a85cb24fSFrançois Tigeot if (WARN_ON(!guc->log.runtime.buf_addr))
261a85cb24fSFrançois Tigeot return;
262a85cb24fSFrançois Tigeot
263a85cb24fSFrançois Tigeot /* Get the pointer to shared GuC log buffer */
264a85cb24fSFrançois Tigeot log_buf_state = src_data = guc->log.runtime.buf_addr;
265a85cb24fSFrançois Tigeot
266a85cb24fSFrançois Tigeot /* Get the pointer to local buffer to store the logs */
267a85cb24fSFrançois Tigeot log_buf_snapshot_state = dst_data = guc_get_write_buffer(guc);
268a85cb24fSFrançois Tigeot
269a85cb24fSFrançois Tigeot /* Actual logs are present from the 2nd page */
270a85cb24fSFrançois Tigeot src_data += PAGE_SIZE;
271a85cb24fSFrançois Tigeot dst_data += PAGE_SIZE;
272a85cb24fSFrançois Tigeot
273a85cb24fSFrançois Tigeot for (type = GUC_ISR_LOG_BUFFER; type < GUC_MAX_LOG_BUFFER; type++) {
274a85cb24fSFrançois Tigeot /* Make a copy of the state structure, inside GuC log buffer
275a85cb24fSFrançois Tigeot * (which is uncached mapped), on the stack to avoid reading
276a85cb24fSFrançois Tigeot * from it multiple times.
277a85cb24fSFrançois Tigeot */
278a85cb24fSFrançois Tigeot memcpy(&log_buf_state_local, log_buf_state,
279a85cb24fSFrançois Tigeot sizeof(struct guc_log_buffer_state));
280a85cb24fSFrançois Tigeot buffer_size = guc_get_log_buffer_size(type);
281a85cb24fSFrançois Tigeot read_offset = log_buf_state_local.read_ptr;
282a85cb24fSFrançois Tigeot write_offset = log_buf_state_local.sampled_write_ptr;
283a85cb24fSFrançois Tigeot full_cnt = log_buf_state_local.buffer_full_cnt;
284a85cb24fSFrançois Tigeot
285a85cb24fSFrançois Tigeot /* Bookkeeping stuff */
286a85cb24fSFrançois Tigeot guc->log.flush_count[type] += log_buf_state_local.flush_to_file;
287a85cb24fSFrançois Tigeot new_overflow = guc_check_log_buf_overflow(guc, type, full_cnt);
288a85cb24fSFrançois Tigeot
289a85cb24fSFrançois Tigeot /* Update the state of shared log buffer */
290a85cb24fSFrançois Tigeot log_buf_state->read_ptr = write_offset;
291a85cb24fSFrançois Tigeot log_buf_state->flush_to_file = 0;
292a85cb24fSFrançois Tigeot log_buf_state++;
293a85cb24fSFrançois Tigeot
294a85cb24fSFrançois Tigeot if (unlikely(!log_buf_snapshot_state))
295a85cb24fSFrançois Tigeot continue;
296a85cb24fSFrançois Tigeot
297a85cb24fSFrançois Tigeot /* First copy the state structure in snapshot buffer */
298a85cb24fSFrançois Tigeot memcpy(log_buf_snapshot_state, &log_buf_state_local,
299a85cb24fSFrançois Tigeot sizeof(struct guc_log_buffer_state));
300a85cb24fSFrançois Tigeot
301a85cb24fSFrançois Tigeot /* The write pointer could have been updated by GuC firmware,
302a85cb24fSFrançois Tigeot * after sending the flush interrupt to Host, for consistency
303a85cb24fSFrançois Tigeot * set write pointer value to same value of sampled_write_ptr
304a85cb24fSFrançois Tigeot * in the snapshot buffer.
305a85cb24fSFrançois Tigeot */
306a85cb24fSFrançois Tigeot log_buf_snapshot_state->write_ptr = write_offset;
307a85cb24fSFrançois Tigeot log_buf_snapshot_state++;
308a85cb24fSFrançois Tigeot
309a85cb24fSFrançois Tigeot /* Now copy the actual logs. */
310a85cb24fSFrançois Tigeot if (unlikely(new_overflow)) {
311a85cb24fSFrançois Tigeot /* copy the whole buffer in case of overflow */
312a85cb24fSFrançois Tigeot read_offset = 0;
313a85cb24fSFrançois Tigeot write_offset = buffer_size;
314a85cb24fSFrançois Tigeot } else if (unlikely((read_offset > buffer_size) ||
315a85cb24fSFrançois Tigeot (write_offset > buffer_size))) {
316a85cb24fSFrançois Tigeot DRM_ERROR("invalid log buffer state\n");
317a85cb24fSFrançois Tigeot /* copy whole buffer as offsets are unreliable */
318a85cb24fSFrançois Tigeot read_offset = 0;
319a85cb24fSFrançois Tigeot write_offset = buffer_size;
320a85cb24fSFrançois Tigeot }
321a85cb24fSFrançois Tigeot
322a85cb24fSFrançois Tigeot /* Just copy the newly written data */
323a85cb24fSFrançois Tigeot if (read_offset > write_offset) {
324a85cb24fSFrançois Tigeot i915_memcpy_from_wc(dst_data, src_data, write_offset);
325a85cb24fSFrançois Tigeot bytes_to_copy = buffer_size - read_offset;
326a85cb24fSFrançois Tigeot } else {
327a85cb24fSFrançois Tigeot bytes_to_copy = write_offset - read_offset;
328a85cb24fSFrançois Tigeot }
329a85cb24fSFrançois Tigeot i915_memcpy_from_wc(dst_data + read_offset,
330a85cb24fSFrançois Tigeot src_data + read_offset, bytes_to_copy);
331a85cb24fSFrançois Tigeot
332a85cb24fSFrançois Tigeot src_data += buffer_size;
333a85cb24fSFrançois Tigeot dst_data += buffer_size;
334a85cb24fSFrançois Tigeot }
335a85cb24fSFrançois Tigeot
336a85cb24fSFrançois Tigeot if (log_buf_snapshot_state)
337a85cb24fSFrançois Tigeot guc_move_to_next_buf(guc);
338a85cb24fSFrançois Tigeot else {
339a85cb24fSFrançois Tigeot /* Used rate limited to avoid deluge of messages, logs might be
340a85cb24fSFrançois Tigeot * getting consumed by User at a slow rate.
341a85cb24fSFrançois Tigeot */
342a85cb24fSFrançois Tigeot DRM_ERROR_RATELIMITED("no sub-buffer to capture logs\n");
343a85cb24fSFrançois Tigeot guc->log.capture_miss_count++;
344a85cb24fSFrançois Tigeot }
345a85cb24fSFrançois Tigeot }
346a85cb24fSFrançois Tigeot
347a85cb24fSFrançois Tigeot static void capture_logs_work(struct work_struct *work)
348a85cb24fSFrançois Tigeot {
349a85cb24fSFrançois Tigeot struct intel_guc *guc =
350a85cb24fSFrançois Tigeot container_of(work, struct intel_guc, log.runtime.flush_work);
351a85cb24fSFrançois Tigeot
352a85cb24fSFrançois Tigeot guc_log_capture_logs(guc);
353a85cb24fSFrançois Tigeot }
354a85cb24fSFrançois Tigeot
355a85cb24fSFrançois Tigeot static bool guc_log_has_runtime(struct intel_guc *guc)
356a85cb24fSFrançois Tigeot {
357a85cb24fSFrançois Tigeot return guc->log.runtime.buf_addr != NULL;
358a85cb24fSFrançois Tigeot }
359a85cb24fSFrançois Tigeot
360a85cb24fSFrançois Tigeot static int guc_log_runtime_create(struct intel_guc *guc)
361a85cb24fSFrançois Tigeot {
362a85cb24fSFrançois Tigeot struct drm_i915_private *dev_priv = guc_to_i915(guc);
363a85cb24fSFrançois Tigeot void *vaddr;
364a85cb24fSFrançois Tigeot struct rchan *guc_log_relay_chan;
365a85cb24fSFrançois Tigeot size_t n_subbufs, subbuf_size;
366*3f2dd94aSFrançois Tigeot int ret;
367a85cb24fSFrançois Tigeot
368a85cb24fSFrançois Tigeot lockdep_assert_held(&dev_priv->drm.struct_mutex);
369a85cb24fSFrançois Tigeot
370a85cb24fSFrançois Tigeot GEM_BUG_ON(guc_log_has_runtime(guc));
371a85cb24fSFrançois Tigeot
372*3f2dd94aSFrançois Tigeot ret = i915_gem_object_set_to_wc_domain(guc->log.vma->obj, true);
373*3f2dd94aSFrançois Tigeot if (ret)
374*3f2dd94aSFrançois Tigeot return ret;
375*3f2dd94aSFrançois Tigeot
376a85cb24fSFrançois Tigeot /* Create a WC (Uncached for read) vmalloc mapping of log
377a85cb24fSFrançois Tigeot * buffer pages, so that we can directly get the data
378a85cb24fSFrançois Tigeot * (up-to-date) from memory.
379a85cb24fSFrançois Tigeot */
380a85cb24fSFrançois Tigeot vaddr = i915_gem_object_pin_map(guc->log.vma->obj, I915_MAP_WC);
381a85cb24fSFrançois Tigeot if (IS_ERR(vaddr)) {
382a85cb24fSFrançois Tigeot DRM_ERROR("Couldn't map log buffer pages %d\n", ret);
383a85cb24fSFrançois Tigeot return PTR_ERR(vaddr);
384a85cb24fSFrançois Tigeot }
385a85cb24fSFrançois Tigeot
386a85cb24fSFrançois Tigeot guc->log.runtime.buf_addr = vaddr;
387a85cb24fSFrançois Tigeot
388a85cb24fSFrançois Tigeot /* Keep the size of sub buffers same as shared log buffer */
389a85cb24fSFrançois Tigeot subbuf_size = guc->log.vma->obj->base.size;
390a85cb24fSFrançois Tigeot
391a85cb24fSFrançois Tigeot /* Store up to 8 snapshots, which is large enough to buffer sufficient
392a85cb24fSFrançois Tigeot * boot time logs and provides enough leeway to User, in terms of
393a85cb24fSFrançois Tigeot * latency, for consuming the logs from relay. Also doesn't take
394a85cb24fSFrançois Tigeot * up too much memory.
395a85cb24fSFrançois Tigeot */
396a85cb24fSFrançois Tigeot n_subbufs = 8;
397a85cb24fSFrançois Tigeot
398a85cb24fSFrançois Tigeot /* Create a relay channel, so that we have buffers for storing
399a85cb24fSFrançois Tigeot * the GuC firmware logs, the channel will be linked with a file
400a85cb24fSFrançois Tigeot * later on when debugfs is registered.
401a85cb24fSFrançois Tigeot */
402a85cb24fSFrançois Tigeot guc_log_relay_chan = relay_open(NULL, NULL, subbuf_size,
403a85cb24fSFrançois Tigeot n_subbufs, &relay_callbacks, dev_priv);
404a85cb24fSFrançois Tigeot if (!guc_log_relay_chan) {
405a85cb24fSFrançois Tigeot DRM_ERROR("Couldn't create relay chan for GuC logging\n");
406a85cb24fSFrançois Tigeot
407a85cb24fSFrançois Tigeot ret = -ENOMEM;
408a85cb24fSFrançois Tigeot goto err_vaddr;
409a85cb24fSFrançois Tigeot }
410a85cb24fSFrançois Tigeot
411a85cb24fSFrançois Tigeot GEM_BUG_ON(guc_log_relay_chan->subbuf_size < subbuf_size);
412a85cb24fSFrançois Tigeot guc->log.runtime.relay_chan = guc_log_relay_chan;
413a85cb24fSFrançois Tigeot
414a85cb24fSFrançois Tigeot INIT_WORK(&guc->log.runtime.flush_work, capture_logs_work);
415a85cb24fSFrançois Tigeot
416a85cb24fSFrançois Tigeot /*
417a85cb24fSFrançois Tigeot * GuC log buffer flush work item has to do register access to
418a85cb24fSFrançois Tigeot * send the ack to GuC and this work item, if not synced before
419a85cb24fSFrançois Tigeot * suspend, can potentially get executed after the GFX device is
420a85cb24fSFrançois Tigeot * suspended.
421a85cb24fSFrançois Tigeot * By marking the WQ as freezable, we don't have to bother about
422a85cb24fSFrançois Tigeot * flushing of this work item from the suspend hooks, the pending
423a85cb24fSFrançois Tigeot * work item if any will be either executed before the suspend
424a85cb24fSFrançois Tigeot * or scheduled later on resume. This way the handling of work
425a85cb24fSFrançois Tigeot * item can be kept same between system suspend & rpm suspend.
426a85cb24fSFrançois Tigeot */
427a85cb24fSFrançois Tigeot guc->log.runtime.flush_wq = alloc_ordered_workqueue("i915-guc_log",
428a85cb24fSFrançois Tigeot WQ_HIGHPRI | WQ_FREEZABLE);
429a85cb24fSFrançois Tigeot if (!guc->log.runtime.flush_wq) {
430a85cb24fSFrançois Tigeot DRM_ERROR("Couldn't allocate the wq for GuC logging\n");
431a85cb24fSFrançois Tigeot ret = -ENOMEM;
432a85cb24fSFrançois Tigeot goto err_relaychan;
433a85cb24fSFrançois Tigeot }
434a85cb24fSFrançois Tigeot
435a85cb24fSFrançois Tigeot return 0;
436a85cb24fSFrançois Tigeot
437a85cb24fSFrançois Tigeot err_relaychan:
438a85cb24fSFrançois Tigeot relay_close(guc->log.runtime.relay_chan);
439a85cb24fSFrançois Tigeot err_vaddr:
440a85cb24fSFrançois Tigeot i915_gem_object_unpin_map(guc->log.vma->obj);
441a85cb24fSFrançois Tigeot guc->log.runtime.buf_addr = NULL;
442a85cb24fSFrançois Tigeot return ret;
443a85cb24fSFrançois Tigeot }
444a85cb24fSFrançois Tigeot
445a85cb24fSFrançois Tigeot static void guc_log_runtime_destroy(struct intel_guc *guc)
446a85cb24fSFrançois Tigeot {
447a85cb24fSFrançois Tigeot /*
448a85cb24fSFrançois Tigeot * It's possible that the runtime stuff was never allocated because
449a85cb24fSFrançois Tigeot * guc_log_level was < 0 at the time
450a85cb24fSFrançois Tigeot **/
451a85cb24fSFrançois Tigeot if (!guc_log_has_runtime(guc))
452a85cb24fSFrançois Tigeot return;
453a85cb24fSFrançois Tigeot
454a85cb24fSFrançois Tigeot destroy_workqueue(guc->log.runtime.flush_wq);
455a85cb24fSFrançois Tigeot relay_close(guc->log.runtime.relay_chan);
456a85cb24fSFrançois Tigeot i915_gem_object_unpin_map(guc->log.vma->obj);
457a85cb24fSFrançois Tigeot guc->log.runtime.buf_addr = NULL;
458a85cb24fSFrançois Tigeot }
459a85cb24fSFrançois Tigeot
460a85cb24fSFrançois Tigeot static int guc_log_late_setup(struct intel_guc *guc)
461a85cb24fSFrançois Tigeot {
462a85cb24fSFrançois Tigeot struct drm_i915_private *dev_priv = guc_to_i915(guc);
463a85cb24fSFrançois Tigeot int ret;
464a85cb24fSFrançois Tigeot
465a85cb24fSFrançois Tigeot lockdep_assert_held(&dev_priv->drm.struct_mutex);
466a85cb24fSFrançois Tigeot
467a85cb24fSFrançois Tigeot if (!guc_log_has_runtime(guc)) {
468a85cb24fSFrançois Tigeot /* If log_level was set as -1 at boot time, then setup needed to
469a85cb24fSFrançois Tigeot * handle log buffer flush interrupts would not have been done yet,
470a85cb24fSFrançois Tigeot * so do that now.
471a85cb24fSFrançois Tigeot */
472a85cb24fSFrançois Tigeot ret = guc_log_runtime_create(guc);
473a85cb24fSFrançois Tigeot if (ret)
474a85cb24fSFrançois Tigeot goto err;
475a85cb24fSFrançois Tigeot }
476a85cb24fSFrançois Tigeot
477a85cb24fSFrançois Tigeot ret = guc_log_relay_file_create(guc);
478a85cb24fSFrançois Tigeot if (ret)
479a85cb24fSFrançois Tigeot goto err_runtime;
480a85cb24fSFrançois Tigeot
481a85cb24fSFrançois Tigeot return 0;
482a85cb24fSFrançois Tigeot
483a85cb24fSFrançois Tigeot err_runtime:
484a85cb24fSFrançois Tigeot guc_log_runtime_destroy(guc);
485a85cb24fSFrançois Tigeot err:
486a85cb24fSFrançois Tigeot /* logging will remain off */
487*3f2dd94aSFrançois Tigeot i915_modparams.guc_log_level = -1;
488a85cb24fSFrançois Tigeot return ret;
489a85cb24fSFrançois Tigeot }
490a85cb24fSFrançois Tigeot
491a85cb24fSFrançois Tigeot static void guc_log_capture_logs(struct intel_guc *guc)
492a85cb24fSFrançois Tigeot {
493a85cb24fSFrançois Tigeot struct drm_i915_private *dev_priv = guc_to_i915(guc);
494a85cb24fSFrançois Tigeot
495a85cb24fSFrançois Tigeot guc_read_update_log_buffer(guc);
496a85cb24fSFrançois Tigeot
497a85cb24fSFrançois Tigeot /* Generally device is expected to be active only at this
498a85cb24fSFrançois Tigeot * time, so get/put should be really quick.
499a85cb24fSFrançois Tigeot */
500a85cb24fSFrançois Tigeot intel_runtime_pm_get(dev_priv);
501a85cb24fSFrançois Tigeot guc_log_flush_complete(guc);
502a85cb24fSFrançois Tigeot intel_runtime_pm_put(dev_priv);
503a85cb24fSFrançois Tigeot }
504a85cb24fSFrançois Tigeot
505a85cb24fSFrançois Tigeot static void guc_flush_logs(struct intel_guc *guc)
506a85cb24fSFrançois Tigeot {
507a85cb24fSFrançois Tigeot struct drm_i915_private *dev_priv = guc_to_i915(guc);
508a85cb24fSFrançois Tigeot
509*3f2dd94aSFrançois Tigeot if (!i915_modparams.enable_guc_submission ||
510*3f2dd94aSFrançois Tigeot (i915_modparams.guc_log_level < 0))
511a85cb24fSFrançois Tigeot return;
512a85cb24fSFrançois Tigeot
513a85cb24fSFrançois Tigeot /* First disable the interrupts, will be renabled afterwards */
514a85cb24fSFrançois Tigeot gen9_disable_guc_interrupts(dev_priv);
515a85cb24fSFrançois Tigeot
516a85cb24fSFrançois Tigeot /* Before initiating the forceful flush, wait for any pending/ongoing
517a85cb24fSFrançois Tigeot * flush to complete otherwise forceful flush may not actually happen.
518a85cb24fSFrançois Tigeot */
519a85cb24fSFrançois Tigeot flush_work(&guc->log.runtime.flush_work);
520a85cb24fSFrançois Tigeot
521a85cb24fSFrançois Tigeot /* Ask GuC to update the log buffer state */
522a85cb24fSFrançois Tigeot guc_log_flush(guc);
523a85cb24fSFrançois Tigeot
524a85cb24fSFrançois Tigeot /* GuC would have updated log buffer by now, so capture it */
525a85cb24fSFrançois Tigeot guc_log_capture_logs(guc);
526a85cb24fSFrançois Tigeot }
527a85cb24fSFrançois Tigeot #endif
528a85cb24fSFrançois Tigeot
intel_guc_log_create(struct intel_guc * guc)529a85cb24fSFrançois Tigeot int intel_guc_log_create(struct intel_guc *guc)
530a85cb24fSFrançois Tigeot {
531a85cb24fSFrançois Tigeot struct i915_vma *vma;
532a85cb24fSFrançois Tigeot unsigned long offset;
533*3f2dd94aSFrançois Tigeot u32 flags;
534*3f2dd94aSFrançois Tigeot u32 size;
535a85cb24fSFrançois Tigeot int ret;
536a85cb24fSFrançois Tigeot
537a85cb24fSFrançois Tigeot GEM_BUG_ON(guc->log.vma);
538a85cb24fSFrançois Tigeot
539*3f2dd94aSFrançois Tigeot if (i915_modparams.guc_log_level > GUC_LOG_VERBOSITY_MAX)
540*3f2dd94aSFrançois Tigeot i915_modparams.guc_log_level = GUC_LOG_VERBOSITY_MAX;
541a85cb24fSFrançois Tigeot
542a85cb24fSFrançois Tigeot /* The first page is to save log buffer state. Allocate one
543a85cb24fSFrançois Tigeot * extra page for others in case for overlap */
544a85cb24fSFrançois Tigeot size = (1 + GUC_LOG_DPC_PAGES + 1 +
545a85cb24fSFrançois Tigeot GUC_LOG_ISR_PAGES + 1 +
546a85cb24fSFrançois Tigeot GUC_LOG_CRASH_PAGES + 1) << PAGE_SHIFT;
547a85cb24fSFrançois Tigeot
548a85cb24fSFrançois Tigeot /* We require SSE 4.1 for fast reads from the GuC log buffer and
549a85cb24fSFrançois Tigeot * it should be present on the chipsets supporting GuC based
550a85cb24fSFrançois Tigeot * submisssions.
551a85cb24fSFrançois Tigeot */
552a85cb24fSFrançois Tigeot if (WARN_ON(!i915_has_memcpy_from_wc())) {
553a85cb24fSFrançois Tigeot ret = -EINVAL;
554a85cb24fSFrançois Tigeot goto err;
555a85cb24fSFrançois Tigeot }
556a85cb24fSFrançois Tigeot
557a85cb24fSFrançois Tigeot vma = intel_guc_allocate_vma(guc, size);
558a85cb24fSFrançois Tigeot if (IS_ERR(vma)) {
559a85cb24fSFrançois Tigeot ret = PTR_ERR(vma);
560a85cb24fSFrançois Tigeot goto err;
561a85cb24fSFrançois Tigeot }
562a85cb24fSFrançois Tigeot
563a85cb24fSFrançois Tigeot guc->log.vma = vma;
564a85cb24fSFrançois Tigeot
565a85cb24fSFrançois Tigeot #if 0
566a85cb24fSFrançois Tigeot if (i915.guc_log_level >= 0) {
567a85cb24fSFrançois Tigeot ret = guc_log_runtime_create(guc);
568a85cb24fSFrançois Tigeot if (ret < 0)
569a85cb24fSFrançois Tigeot goto err_vma;
570a85cb24fSFrançois Tigeot }
571a85cb24fSFrançois Tigeot #endif
572a85cb24fSFrançois Tigeot
573a85cb24fSFrançois Tigeot /* each allocated unit is a page */
574a85cb24fSFrançois Tigeot flags = GUC_LOG_VALID | GUC_LOG_NOTIFY_ON_HALF_FULL |
575a85cb24fSFrançois Tigeot (GUC_LOG_DPC_PAGES << GUC_LOG_DPC_SHIFT) |
576a85cb24fSFrançois Tigeot (GUC_LOG_ISR_PAGES << GUC_LOG_ISR_SHIFT) |
577a85cb24fSFrançois Tigeot (GUC_LOG_CRASH_PAGES << GUC_LOG_CRASH_SHIFT);
578a85cb24fSFrançois Tigeot
579a85cb24fSFrançois Tigeot offset = guc_ggtt_offset(vma) >> PAGE_SHIFT; /* in pages */
580a85cb24fSFrançois Tigeot guc->log.flags = (offset << GUC_LOG_BUF_ADDR_SHIFT) | flags;
581a85cb24fSFrançois Tigeot
582a85cb24fSFrançois Tigeot return 0;
583a85cb24fSFrançois Tigeot
584a85cb24fSFrançois Tigeot #if 0
585a85cb24fSFrançois Tigeot err_vma:
586a85cb24fSFrançois Tigeot i915_vma_unpin_and_release(&guc->log.vma);
587a85cb24fSFrançois Tigeot #endif
588a85cb24fSFrançois Tigeot err:
589a85cb24fSFrançois Tigeot /* logging will be off */
590*3f2dd94aSFrançois Tigeot i915_modparams.guc_log_level = -1;
591a85cb24fSFrançois Tigeot return ret;
592a85cb24fSFrançois Tigeot }
593a85cb24fSFrançois Tigeot
intel_guc_log_destroy(struct intel_guc * guc)594a85cb24fSFrançois Tigeot void intel_guc_log_destroy(struct intel_guc *guc)
595a85cb24fSFrançois Tigeot {
596a85cb24fSFrançois Tigeot #if 0
597a85cb24fSFrançois Tigeot guc_log_runtime_destroy(guc);
598a85cb24fSFrançois Tigeot #endif
599a85cb24fSFrançois Tigeot i915_vma_unpin_and_release(&guc->log.vma);
600a85cb24fSFrançois Tigeot }
601a85cb24fSFrançois Tigeot
602a85cb24fSFrançois Tigeot #if 0
603a85cb24fSFrançois Tigeot int i915_guc_log_control(struct drm_i915_private *dev_priv, u64 control_val)
604a85cb24fSFrançois Tigeot {
605a85cb24fSFrançois Tigeot struct intel_guc *guc = &dev_priv->guc;
606a85cb24fSFrançois Tigeot
607a85cb24fSFrançois Tigeot union guc_log_control log_param;
608a85cb24fSFrançois Tigeot int ret;
609a85cb24fSFrançois Tigeot
610a85cb24fSFrançois Tigeot log_param.value = control_val;
611a85cb24fSFrançois Tigeot
612a85cb24fSFrançois Tigeot if (log_param.verbosity < GUC_LOG_VERBOSITY_MIN ||
613a85cb24fSFrançois Tigeot log_param.verbosity > GUC_LOG_VERBOSITY_MAX)
614a85cb24fSFrançois Tigeot return -EINVAL;
615a85cb24fSFrançois Tigeot
616a85cb24fSFrançois Tigeot /* This combination doesn't make sense & won't have any effect */
617*3f2dd94aSFrançois Tigeot if (!log_param.logging_enabled && (i915_modparams.guc_log_level < 0))
618a85cb24fSFrançois Tigeot return 0;
619a85cb24fSFrançois Tigeot
620a85cb24fSFrançois Tigeot ret = guc_log_control(guc, log_param.value);
621a85cb24fSFrançois Tigeot if (ret < 0) {
622a85cb24fSFrançois Tigeot DRM_DEBUG_DRIVER("guc_logging_control action failed %d\n", ret);
623a85cb24fSFrançois Tigeot return ret;
624a85cb24fSFrançois Tigeot }
625a85cb24fSFrançois Tigeot
626a85cb24fSFrançois Tigeot if (log_param.logging_enabled) {
627*3f2dd94aSFrançois Tigeot i915_modparams.guc_log_level = log_param.verbosity;
628a85cb24fSFrançois Tigeot
629a85cb24fSFrançois Tigeot /* If log_level was set as -1 at boot time, then the relay channel file
630a85cb24fSFrançois Tigeot * wouldn't have been created by now and interrupts also would not have
631a85cb24fSFrançois Tigeot * been enabled. Try again now, just in case.
632a85cb24fSFrançois Tigeot */
633a85cb24fSFrançois Tigeot ret = guc_log_late_setup(guc);
634a85cb24fSFrançois Tigeot if (ret < 0) {
635a85cb24fSFrançois Tigeot DRM_DEBUG_DRIVER("GuC log late setup failed %d\n", ret);
636a85cb24fSFrançois Tigeot return ret;
637a85cb24fSFrançois Tigeot }
638a85cb24fSFrançois Tigeot
639a85cb24fSFrançois Tigeot /* GuC logging is currently the only user of Guc2Host interrupts */
640a85cb24fSFrançois Tigeot gen9_enable_guc_interrupts(dev_priv);
641a85cb24fSFrançois Tigeot } else {
642a85cb24fSFrançois Tigeot /* Once logging is disabled, GuC won't generate logs & send an
643a85cb24fSFrançois Tigeot * interrupt. But there could be some data in the log buffer
644a85cb24fSFrançois Tigeot * which is yet to be captured. So request GuC to update the log
645a85cb24fSFrançois Tigeot * buffer state and then collect the left over logs.
646a85cb24fSFrançois Tigeot */
647a85cb24fSFrançois Tigeot guc_flush_logs(guc);
648a85cb24fSFrançois Tigeot
649a85cb24fSFrançois Tigeot /* As logging is disabled, update log level to reflect that */
650*3f2dd94aSFrançois Tigeot i915_modparams.guc_log_level = -1;
651a85cb24fSFrançois Tigeot }
652a85cb24fSFrançois Tigeot
653a85cb24fSFrançois Tigeot return ret;
654a85cb24fSFrançois Tigeot }
655a85cb24fSFrançois Tigeot #endif
656a85cb24fSFrançois Tigeot
i915_guc_log_register(struct drm_i915_private * dev_priv)657a85cb24fSFrançois Tigeot void i915_guc_log_register(struct drm_i915_private *dev_priv)
658a85cb24fSFrançois Tigeot {
659*3f2dd94aSFrançois Tigeot if (!i915_modparams.enable_guc_submission ||
660*3f2dd94aSFrançois Tigeot (i915_modparams.guc_log_level < 0))
661a85cb24fSFrançois Tigeot return;
662a85cb24fSFrançois Tigeot
663a85cb24fSFrançois Tigeot mutex_lock(&dev_priv->drm.struct_mutex);
664a85cb24fSFrançois Tigeot #if 0
665a85cb24fSFrançois Tigeot guc_log_late_setup(&dev_priv->guc);
666a85cb24fSFrançois Tigeot #endif
667a85cb24fSFrançois Tigeot mutex_unlock(&dev_priv->drm.struct_mutex);
668a85cb24fSFrançois Tigeot }
669a85cb24fSFrançois Tigeot
i915_guc_log_unregister(struct drm_i915_private * dev_priv)670a85cb24fSFrançois Tigeot void i915_guc_log_unregister(struct drm_i915_private *dev_priv)
671a85cb24fSFrançois Tigeot {
672*3f2dd94aSFrançois Tigeot if (!i915_modparams.enable_guc_submission)
673a85cb24fSFrançois Tigeot return;
674a85cb24fSFrançois Tigeot
675a85cb24fSFrançois Tigeot mutex_lock(&dev_priv->drm.struct_mutex);
676a85cb24fSFrançois Tigeot /* GuC logging is currently the only user of Guc2Host interrupts */
677a85cb24fSFrançois Tigeot gen9_disable_guc_interrupts(dev_priv);
678a85cb24fSFrançois Tigeot #if 0
679a85cb24fSFrançois Tigeot guc_log_runtime_destroy(&dev_priv->guc);
680a85cb24fSFrançois Tigeot #endif
681a85cb24fSFrançois Tigeot mutex_unlock(&dev_priv->drm.struct_mutex);
682a85cb24fSFrançois Tigeot }
683