Loading...
1/* SPDX-License-Identifier: GPL-2.0 OR MIT */
2/* Copyright 2018-2019 Qiang Yu <yuq825@gmail.com> */
3
4#ifndef __LIMA_CTX_H__
5#define __LIMA_CTX_H__
6
7#include <linux/xarray.h>
8#include <linux/sched.h>
9
10#include "lima_device.h"
11
12struct lima_ctx {
13 struct kref refcnt;
14 struct lima_device *dev;
15 struct lima_sched_context context[lima_pipe_num];
16 atomic_t guilty;
17
18 /* debug info */
19 char pname[TASK_COMM_LEN];
20 pid_t pid;
21};
22
23struct lima_ctx_mgr {
24 struct mutex lock;
25 struct xarray handles;
26};
27
28int lima_ctx_create(struct lima_device *dev, struct lima_ctx_mgr *mgr, u32 *id);
29int lima_ctx_free(struct lima_ctx_mgr *mgr, u32 id);
30struct lima_ctx *lima_ctx_get(struct lima_ctx_mgr *mgr, u32 id);
31void lima_ctx_put(struct lima_ctx *ctx);
32void lima_ctx_mgr_init(struct lima_ctx_mgr *mgr);
33void lima_ctx_mgr_fini(struct lima_ctx_mgr *mgr);
34
35#endif
1/* SPDX-License-Identifier: GPL-2.0 OR MIT */
2/* Copyright 2018-2019 Qiang Yu <yuq825@gmail.com> */
3
4#ifndef __LIMA_CTX_H__
5#define __LIMA_CTX_H__
6
7#include <linux/xarray.h>
8
9#include "lima_device.h"
10
11struct lima_ctx {
12 struct kref refcnt;
13 struct lima_device *dev;
14 struct lima_sched_context context[lima_pipe_num];
15 atomic_t guilty;
16};
17
18struct lima_ctx_mgr {
19 struct mutex lock;
20 struct xarray handles;
21};
22
23int lima_ctx_create(struct lima_device *dev, struct lima_ctx_mgr *mgr, u32 *id);
24int lima_ctx_free(struct lima_ctx_mgr *mgr, u32 id);
25struct lima_ctx *lima_ctx_get(struct lima_ctx_mgr *mgr, u32 id);
26void lima_ctx_put(struct lima_ctx *ctx);
27void lima_ctx_mgr_init(struct lima_ctx_mgr *mgr);
28void lima_ctx_mgr_fini(struct lima_ctx_mgr *mgr);
29
30#endif