File Index
Files and directories
Sign in
FILE

xe_lrc.h

File preview with syntax highlighting.

linux-6.19.14/drivers/gpu/drm/xe/xe_lrc.h C
  1/* SPDX-License-Identifier: MIT */
  2/*
  3 * Copyright © 2021 Intel Corporation
  4 */
  5#ifndef _XE_LRC_H_
  6#define _XE_LRC_H_
  7
  8#include <linux/types.h>
  9
 10#include "xe_lrc_types.h"
 11
 12struct drm_printer;
 13struct xe_bb;
 14struct xe_device;
 15struct xe_exec_queue;
 16enum xe_engine_class;
 17struct xe_gt;
 18struct xe_hw_engine;
 19struct xe_lrc;
 20struct xe_vm;
 21
 22struct xe_lrc_snapshot {
 23	struct xe_bo *lrc_bo;
 24	void *lrc_snapshot;
 25	unsigned long lrc_size, lrc_offset;
 26
 27	u32 context_desc;
 28	u32 ring_addr;
 29	u32 indirect_context_desc;
 30	u32 head;
 31	u32 start;
 32	struct {
 33		u32 internal;
 34		u32 memory;
 35	} tail;
 36	u32 start_seqno;
 37	u32 seqno;
 38	u32 ctx_timestamp;
 39	u32 ctx_job_timestamp;
 40};
 41
 42#define LRC_PPHWSP_FLUSH_INVAL_SCRATCH_ADDR (0x34 * 4)
 43#define LRC_PPHWSP_PXP_INVAL_SCRATCH_ADDR (0x40 * 4)
 44
 45#define LRC_WA_BB_SIZE SZ_4K
 46
 47#define XE_LRC_CREATE_RUNALONE		BIT(0)
 48#define XE_LRC_CREATE_PXP		BIT(1)
 49#define XE_LRC_CREATE_USER_CTX		BIT(2)
 50
 51struct xe_lrc *xe_lrc_create(struct xe_hw_engine *hwe, struct xe_vm *vm,
 52			     u32 ring_size, u16 msix_vec, u32 flags);
 53void xe_lrc_destroy(struct kref *ref);
 54
 55/**
 56 * xe_lrc_get - Get reference to the LRC
 57 * @lrc: Logical Ring Context
 58 *
 59 * Increment reference count of @lrc
 60 */
 61static inline struct xe_lrc *xe_lrc_get(struct xe_lrc *lrc)
 62{
 63	kref_get(&lrc->refcount);
 64	return lrc;
 65}
 66
 67/**
 68 * xe_lrc_put - Put reference of the LRC
 69 * @lrc: Logical Ring Context
 70 *
 71 * Decrement reference count of @lrc, call xe_lrc_destroy when
 72 * reference count reaches 0.
 73 */
 74static inline void xe_lrc_put(struct xe_lrc *lrc)
 75{
 76	if (lrc)
 77		kref_put(&lrc->refcount, xe_lrc_destroy);
 78}
 79
 80/**
 81 * xe_lrc_ring_size() - Xe LRC ring size
 82 *
 83 * Return: Size of LRC ring buffer
 84 */
 85static inline size_t xe_lrc_ring_size(void)
 86{
 87	return SZ_16K;
 88}
 89
 90size_t xe_gt_lrc_size(struct xe_gt *gt, enum xe_engine_class class);
 91u32 xe_lrc_pphwsp_offset(struct xe_lrc *lrc);
 92u32 xe_lrc_regs_offset(struct xe_lrc *lrc);
 93
 94void xe_lrc_set_ring_tail(struct xe_lrc *lrc, u32 tail);
 95u32 xe_lrc_ring_tail(struct xe_lrc *lrc);
 96void xe_lrc_set_ring_head(struct xe_lrc *lrc, u32 head);
 97u32 xe_lrc_ring_head(struct xe_lrc *lrc);
 98u32 xe_lrc_ring_space(struct xe_lrc *lrc);
 99void xe_lrc_write_ring(struct xe_lrc *lrc, const void *data, size_t size);
100
101bool xe_lrc_ring_is_idle(struct xe_lrc *lrc);
102
103u32 xe_lrc_indirect_ring_ggtt_addr(struct xe_lrc *lrc);
104u32 xe_lrc_ggtt_addr(struct xe_lrc *lrc);
105u32 *xe_lrc_regs(struct xe_lrc *lrc);
106void xe_lrc_update_hwctx_regs_with_address(struct xe_lrc *lrc);
107void xe_default_lrc_update_memirq_regs_with_address(struct xe_hw_engine *hwe);
108void xe_lrc_update_memirq_regs_with_address(struct xe_lrc *lrc, struct xe_hw_engine *hwe,
109					    u32 *regs);
110
111u32 xe_lrc_read_ctx_reg(struct xe_lrc *lrc, int reg_nr);
112void xe_lrc_write_ctx_reg(struct xe_lrc *lrc, int reg_nr, u32 val);
113
114u64 xe_lrc_descriptor(struct xe_lrc *lrc);
115
116u32 xe_lrc_seqno_ggtt_addr(struct xe_lrc *lrc);
117struct dma_fence *xe_lrc_alloc_seqno_fence(void);
118void xe_lrc_free_seqno_fence(struct dma_fence *fence);
119void xe_lrc_init_seqno_fence(struct xe_lrc *lrc, struct dma_fence *fence);
120s32 xe_lrc_seqno(struct xe_lrc *lrc);
121
122u32 xe_lrc_start_seqno_ggtt_addr(struct xe_lrc *lrc);
123s32 xe_lrc_start_seqno(struct xe_lrc *lrc);
124
125u32 xe_lrc_parallel_ggtt_addr(struct xe_lrc *lrc);
126struct iosys_map xe_lrc_parallel_map(struct xe_lrc *lrc);
127
128size_t xe_lrc_reg_size(struct xe_device *xe);
129size_t xe_lrc_skip_size(struct xe_device *xe);
130
131void xe_lrc_dump_default(struct drm_printer *p,
132			 struct xe_gt *gt,
133			 enum xe_engine_class);
134
135u32 *xe_lrc_emit_hwe_state_instructions(struct xe_exec_queue *q, u32 *cs);
136
137struct xe_lrc_snapshot *xe_lrc_snapshot_capture(struct xe_lrc *lrc);
138void xe_lrc_snapshot_capture_delayed(struct xe_lrc_snapshot *snapshot);
139void xe_lrc_snapshot_print(struct xe_lrc_snapshot *snapshot, struct drm_printer *p);
140void xe_lrc_snapshot_free(struct xe_lrc_snapshot *snapshot);
141
142u32 xe_lrc_ctx_timestamp_ggtt_addr(struct xe_lrc *lrc);
143u32 xe_lrc_ctx_timestamp_udw_ggtt_addr(struct xe_lrc *lrc);
144u64 xe_lrc_ctx_timestamp(struct xe_lrc *lrc);
145u32 xe_lrc_ctx_job_timestamp_ggtt_addr(struct xe_lrc *lrc);
146u32 xe_lrc_ctx_job_timestamp(struct xe_lrc *lrc);
147int xe_lrc_setup_wa_bb_with_scratch(struct xe_lrc *lrc, struct xe_hw_engine *hwe,
148				    u32 *scratch);
149
150/**
151 * xe_lrc_update_timestamp - readout LRC timestamp and update cached value
152 * @lrc: logical ring context for this exec queue
153 * @old_ts: pointer where to save the previous timestamp
154 *
155 * Read the current timestamp for this LRC and update the cached value. The
156 * previous cached value is also returned in @old_ts so the caller can calculate
157 * the delta between 2 updates. Note that this is not intended to be called from
158 * any place, but just by the paths updating the drm client utilization.
159 *
160 * Returns the current LRC timestamp
161 */
162u64 xe_lrc_update_timestamp(struct xe_lrc *lrc, u64 *old_ts);
163
164#endif
~/ Read-only file preview.