File Index
Files and directories
Sign in
FILE

intel_guc_log.h

File preview with syntax highlighting.

linux-6.19.14/drivers/gpu/drm/i915/gt/uc/intel_guc_log.h C
  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/*
 19 * While we're using plain log level in i915, GuC controls are much more...
 20 * "elaborate"? We have a couple of bits for verbosity, separate bit for actual
 21 * log enabling, and separate bit for default logging - which "conveniently"
 22 * ignores the enable bit.
 23 */
 24#define GUC_LOG_LEVEL_DISABLED		0
 25#define GUC_LOG_LEVEL_NON_VERBOSE	1
 26#define GUC_LOG_LEVEL_IS_ENABLED(x)	((x) > GUC_LOG_LEVEL_DISABLED)
 27#define GUC_LOG_LEVEL_IS_VERBOSE(x)	((x) > GUC_LOG_LEVEL_NON_VERBOSE)
 28#define GUC_LOG_LEVEL_TO_VERBOSITY(x) ({		\
 29	typeof(x) _x = (x);				\
 30	GUC_LOG_LEVEL_IS_VERBOSE(_x) ? _x - 2 : 0;	\
 31})
 32#define GUC_VERBOSITY_TO_LOG_LEVEL(x)	((x) + 2)
 33#define GUC_LOG_LEVEL_MAX GUC_VERBOSITY_TO_LOG_LEVEL(GUC_LOG_VERBOSITY_MAX)
 34
 35enum {
 36	GUC_LOG_SECTIONS_CRASH,
 37	GUC_LOG_SECTIONS_DEBUG,
 38	GUC_LOG_SECTIONS_CAPTURE,
 39	GUC_LOG_SECTIONS_LIMIT
 40};
 41
 42struct intel_guc_log {
 43	u32 level;
 44
 45	/*
 46	 * Protects concurrent access and modification of intel_guc_log->level.
 47	 *
 48	 * This lock replaces the legacy struct_mutex usage in
 49	 * intel_guc_log system.
 50	 */
 51	struct mutex guc_lock;
 52
 53	/* Allocation settings */
 54	struct {
 55		s32 bytes;	/* Size in bytes */
 56		s32 units;	/* GuC API units - 1MB or 4KB */
 57		s32 count;	/* Number of API units */
 58		u32 flag;	/* GuC API units flag */
 59	} sizes[GUC_LOG_SECTIONS_LIMIT];
 60	bool sizes_initialised;
 61
 62	/* Combined buffer allocation */
 63	struct i915_vma *vma;
 64	void *buf_addr;
 65
 66	/* RelayFS support */
 67	struct {
 68		bool buf_in_use;
 69		bool started;
 70		struct work_struct flush_work;
 71		struct rchan *channel;
 72		struct mutex lock;
 73		u32 full_count;
 74	} relay;
 75
 76	/* logging related stats */
 77	struct {
 78		u32 sampled_overflow;
 79		u32 overflow;
 80		u32 flush;
 81	} stats[GUC_MAX_LOG_BUFFER];
 82};
 83
 84void intel_guc_log_init_early(struct intel_guc_log *log);
 85bool intel_guc_check_log_buf_overflow(struct intel_guc_log *log, enum guc_log_buffer_type type,
 86				      unsigned int full_cnt);
 87unsigned int intel_guc_get_log_buffer_size(struct intel_guc_log *log,
 88					   enum guc_log_buffer_type type);
 89size_t intel_guc_get_log_buffer_offset(struct intel_guc_log *log, enum guc_log_buffer_type type);
 90int intel_guc_log_create(struct intel_guc_log *log);
 91void intel_guc_log_destroy(struct intel_guc_log *log);
 92
 93int intel_guc_log_set_level(struct intel_guc_log *log, u32 level);
 94bool intel_guc_log_relay_created(const struct intel_guc_log *log);
 95int intel_guc_log_relay_open(struct intel_guc_log *log);
 96int intel_guc_log_relay_start(struct intel_guc_log *log);
 97void intel_guc_log_relay_flush(struct intel_guc_log *log);
 98void intel_guc_log_relay_close(struct intel_guc_log *log);
 99
100void intel_guc_log_handle_flush_event(struct intel_guc_log *log);
101
102static inline u32 intel_guc_log_get_level(struct intel_guc_log *log)
103{
104	return log->level;
105}
106
107void intel_guc_log_info(struct intel_guc_log *log, struct drm_printer *p);
108int intel_guc_log_dump(struct intel_guc_log *log, struct drm_printer *p,
109		       bool dump_load_err);
110
111u32 intel_guc_log_section_size_capture(struct intel_guc_log *log);
112
113#endif
~/ Read-only file preview.