summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/xe/xe_hw_fence_types.h
blob: b33c4956e8ea0eba0a9f4438ba72577e7e3b69d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* SPDX-License-Identifier: MIT */
/*
 * Copyright © 2022 Intel Corporation
 */

#ifndef _XE_HW_FENCE_TYPES_H_
#define _XE_HW_FENCE_TYPES_H_

#include <linux/dma-fence.h>
#include <linux/iosys-map.h>
#include <linux/irq_work.h>
#include <linux/list.h>
#include <linux/spinlock.h>

struct xe_gt;

/**
 * struct xe_hw_fence_irq - hardware fence IRQ handler
 *
 * One per engine class, signals completed xe_hw_fences, triggered via hw engine
 * interrupt. On each trigger, search list of pending fences and signal.
 */
struct xe_hw_fence_irq {
	/** @lock: protects all xe_hw_fences + pending list */
	spinlock_t lock;
	/** @work: IRQ worker run to signal the fences */
	struct irq_work work;
	/** @pending: list of pending xe_hw_fences */
	struct list_head pending;
	/** @enabled: fence signaling enabled */
	bool enabled;
};

#define MAX_FENCE_NAME_LEN	16

/**
 * struct xe_hw_fence_ctx - hardware fence context
 *
 * The context for a hardware fence. 1 to 1 relationship with xe_engine. Points
 * to a xe_hw_fence_irq, maintains serial seqno.
 */
struct xe_hw_fence_ctx {
	/** @gt: graphics tile of hardware fence context */
	struct xe_gt *gt;
	/** @irq: fence irq handler */
	struct xe_hw_fence_irq *irq;
	/** @dma_fence_ctx: dma fence context for hardware fence */
	u64 dma_fence_ctx;
	/** @next_seqno: next seqno for hardware fence */
	u32 next_seqno;
	/** @name: name of hardware fence context */
	char name[MAX_FENCE_NAME_LEN];
};

/**
 * struct xe_hw_fence - hardware fence
 *
 * Used to indicate a xe_sched_job is complete via a seqno written to memory.
 * Signals on error or seqno past.
 */
struct xe_hw_fence {
	/** @dma: base dma fence for hardware fence context */
	struct dma_fence dma;
	/** @ctx: hardware fence context */
	struct xe_hw_fence_ctx *ctx;
	/** @seqno_map: I/O map for seqno */
	struct iosys_map seqno_map;
	/** @irq_link: Link in struct xe_hw_fence_irq.pending */
	struct list_head irq_link;
};

#endif