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]; 16*6ebd24b6SQiang Yu 17*6ebd24b6SQiang Yu /* debug info */ 18*6ebd24b6SQiang Yu char pname[TASK_COMM_LEN]; 19*6ebd24b6SQiang Yu pid_t pid; 20a1d2a633SQiang Yu }; 21a1d2a633SQiang Yu 22a1d2a633SQiang Yu struct lima_ctx_mgr { 23a1d2a633SQiang Yu struct mutex lock; 24a1d2a633SQiang Yu struct xarray handles; 25a1d2a633SQiang Yu }; 26a1d2a633SQiang Yu 27a1d2a633SQiang Yu int lima_ctx_create(struct lima_device *dev, struct lima_ctx_mgr *mgr, u32 *id); 28a1d2a633SQiang Yu int lima_ctx_free(struct lima_ctx_mgr *mgr, u32 id); 29a1d2a633SQiang Yu struct lima_ctx *lima_ctx_get(struct lima_ctx_mgr *mgr, u32 id); 30a1d2a633SQiang Yu void lima_ctx_put(struct lima_ctx *ctx); 31a1d2a633SQiang Yu void lima_ctx_mgr_init(struct lima_ctx_mgr *mgr); 32a1d2a633SQiang Yu void lima_ctx_mgr_fini(struct lima_ctx_mgr *mgr); 33a1d2a633SQiang Yu 34a1d2a633SQiang Yu #endif 35