lima_ctx.h 823 B

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