summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/nouveau/nvkm/engine/fifo/cgrp.h
blob: 1440c72ad7ddbbc9615fd910fb46d683b980b0b2 (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
/* SPDX-License-Identifier: MIT */
#ifndef __NVKM_CGRP_H__
#define __NVKM_CGRP_H__
#include <core/os.h>
struct nvkm_chan;
struct nvkm_client;

struct nvkm_vctx {
	struct nvkm_ectx *ectx;
	struct nvkm_vmm *vmm;
	refcount_t refs;

	struct list_head head;
};

struct nvkm_ectx {
	struct nvkm_engn *engn;
	refcount_t refs;

	struct list_head head;
};

struct nvkm_cgrp {
	const struct nvkm_cgrp_func {
		void (*preempt)(struct nvkm_cgrp *);
	} *func;
	char name[64];
	struct nvkm_runl *runl;
	struct nvkm_vmm *vmm;
	bool hw;
	int id;
	struct kref kref;

	struct nvkm_chan *chans;
	int chan_nr;

	spinlock_t lock; /* protects irq handler channel (group) lookup */

	struct list_head ectxs;
	struct list_head vctxs;
	struct mutex mutex;

	struct list_head head;
	struct list_head chan;
};

int nvkm_cgrp_new(struct nvkm_runl *, const char *name, struct nvkm_vmm *, bool hw,
		  struct nvkm_cgrp **);
struct nvkm_cgrp *nvkm_cgrp_ref(struct nvkm_cgrp *);
void nvkm_cgrp_unref(struct nvkm_cgrp **);
int nvkm_cgrp_vctx_get(struct nvkm_cgrp *, struct nvkm_engn *, struct nvkm_chan *,
		       struct nvkm_vctx **, struct nvkm_client *);
void nvkm_cgrp_vctx_put(struct nvkm_cgrp *, struct nvkm_vctx **);

#define CGRP_PRCLI(c,l,p,f,a...) RUNL_PRINT((c)->runl, l, p, "%04x:[%s]"f, (c)->id, (c)->name, ##a)
#define CGRP_PRINT(c,l,p,f,a...) RUNL_PRINT((c)->runl, l, p, "%04x:"f, (c)->id, ##a)
#define CGRP_ERROR(c,f,a...) CGRP_PRCLI((c), ERROR,    err, " "f"\n", ##a)
#define CGRP_TRACE(c,f,a...) CGRP_PRINT((c), TRACE,   info, " "f"\n", ##a)
#endif