lima_ctx.h 841 B

1234567891011121314151617181920212223242526272829303132333435
  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. atomic_t guilty;
  13. /* debug info */
  14. char pname[TASK_COMM_LEN];
  15. pid_t pid;
  16. };
  17. struct lima_ctx_mgr {
  18. struct mutex lock;
  19. struct xarray handles;
  20. };
  21. int lima_ctx_create(struct lima_device *dev, struct lima_ctx_mgr *mgr, u32 *id);
  22. int lima_ctx_free(struct lima_ctx_mgr *mgr, u32 id);
  23. struct lima_ctx *lima_ctx_get(struct lima_ctx_mgr *mgr, u32 id);
  24. void lima_ctx_put(struct lima_ctx *ctx);
  25. void lima_ctx_mgr_init(struct lima_ctx_mgr *mgr);
  26. void lima_ctx_mgr_fini(struct lima_ctx_mgr *mgr);
  27. #endif