File: gv100_fence.c

package info (click to toggle)
linux 6.17.6-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,734,348 kB
  • sloc: ansic: 26,679,111; asm: 271,215; sh: 147,319; python: 75,916; makefile: 57,295; perl: 36,942; xml: 19,562; cpp: 5,899; yacc: 4,909; lex: 2,943; awk: 1,556; sed: 29; ruby: 25
file content (98 lines) | stat: -rw-r--r-- 2,206 bytes parent folder | download | duplicates (7)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/* SPDX-License-Identifier: MIT
 *
 * Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
 */
#include "nouveau_drv.h"
#include "nouveau_dma.h"
#include "nouveau_fence.h"

#include "nv50_display.h"

#include <nvif/push906f.h>

#include <nvhw/class/clc36f.h>

static int
gv100_fence_emit32(struct nouveau_channel *chan, u64 virtual, u32 sequence)
{
	struct nvif_push *push = &chan->chan.push;
	int ret;

	ret = PUSH_WAIT(push, 13);
	if (ret)
		return ret;

	PUSH_MTHD(push, NVC36F, SEM_ADDR_LO, lower_32_bits(virtual),
				SEM_ADDR_HI, upper_32_bits(virtual),
				SEM_PAYLOAD_LO, sequence);

	PUSH_MTHD(push, NVC36F, SEM_EXECUTE,
		  NVDEF(NVC36F, SEM_EXECUTE, OPERATION, RELEASE) |
		  NVDEF(NVC36F, SEM_EXECUTE, RELEASE_WFI, EN) |
		  NVDEF(NVC36F, SEM_EXECUTE, PAYLOAD_SIZE, 32BIT) |
		  NVDEF(NVC36F, SEM_EXECUTE, RELEASE_TIMESTAMP, DIS));

	PUSH_MTHD(push, NVC36F, MEM_OP_A, 0,
				MEM_OP_B, 0,
				MEM_OP_C, NVDEF(NVC36F, MEM_OP_C, MEMBAR_TYPE, SYS_MEMBAR),
				MEM_OP_D, NVDEF(NVC36F, MEM_OP_D, OPERATION, MEMBAR));

	PUSH_MTHD(push, NVC36F, NON_STALL_INTERRUPT, 0);

	PUSH_KICK(push);
	return 0;
}

static int
gv100_fence_sync32(struct nouveau_channel *chan, u64 virtual, u32 sequence)
{
	struct nvif_push *push = &chan->chan.push;
	int ret;

	ret = PUSH_WAIT(push, 6);
	if (ret)
		return ret;

	PUSH_MTHD(push, NVC36F, SEM_ADDR_LO, lower_32_bits(virtual),
				SEM_ADDR_HI, upper_32_bits(virtual),
				SEM_PAYLOAD_LO, sequence);

	PUSH_MTHD(push, NVC36F, SEM_EXECUTE,
		  NVDEF(NVC36F, SEM_EXECUTE, OPERATION, ACQ_CIRC_GEQ) |
		  NVDEF(NVC36F, SEM_EXECUTE, ACQUIRE_SWITCH_TSG, EN) |
		  NVDEF(NVC36F, SEM_EXECUTE, PAYLOAD_SIZE, 32BIT));

	PUSH_KICK(push);
	return 0;
}

static int
gv100_fence_context_new(struct nouveau_channel *chan)
{
	struct nv84_fence_chan *fctx;
	int ret;

	ret = nv84_fence_context_new(chan);
	if (ret)
		return ret;

	fctx = chan->fence;
	fctx->base.emit32 = gv100_fence_emit32;
	fctx->base.sync32 = gv100_fence_sync32;
	return 0;
}

int
gv100_fence_create(struct nouveau_drm *drm)
{
	struct nv84_fence_priv *priv;
	int ret;

	ret = nv84_fence_create(drm);
	if (ret)
		return ret;

	priv = drm->fence;
	priv->base.context_new = gv100_fence_context_new;
	return 0;
}