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