i915_drm_client.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* SPDX-License-Identifier: MIT */
  2. /*
  3. * Copyright © 2020 Intel Corporation
  4. */
  5. #ifndef __I915_DRM_CLIENT_H__
  6. #define __I915_DRM_CLIENT_H__
  7. #include <linux/kref.h>
  8. #include <linux/list.h>
  9. #include <linux/spinlock.h>
  10. #include <uapi/drm/i915_drm.h>
  11. #include "i915_file_private.h"
  12. #include "gem/i915_gem_object_types.h"
  13. #include "gt/intel_context_types.h"
  14. #define I915_LAST_UABI_ENGINE_CLASS I915_ENGINE_CLASS_COMPUTE
  15. struct drm_file;
  16. struct drm_printer;
  17. struct i915_drm_client {
  18. struct kref kref;
  19. spinlock_t ctx_lock; /* For add/remove from ctx_list. */
  20. struct list_head ctx_list; /* List of contexts belonging to client. */
  21. #ifdef CONFIG_PROC_FS
  22. /**
  23. * @objects_lock: lock protecting @objects_list
  24. */
  25. spinlock_t objects_lock;
  26. /**
  27. * @objects_list: list of objects created by this client
  28. *
  29. * Protected by @objects_lock.
  30. */
  31. struct list_head objects_list;
  32. #endif
  33. /**
  34. * @past_runtime: Accumulation of pphwsp runtimes from closed contexts.
  35. */
  36. atomic64_t past_runtime[I915_LAST_UABI_ENGINE_CLASS + 1];
  37. };
  38. static inline struct i915_drm_client *
  39. i915_drm_client_get(struct i915_drm_client *client)
  40. {
  41. kref_get(&client->kref);
  42. return client;
  43. }
  44. void __i915_drm_client_free(struct kref *kref);
  45. static inline void i915_drm_client_put(struct i915_drm_client *client)
  46. {
  47. kref_put(&client->kref, __i915_drm_client_free);
  48. }
  49. struct i915_drm_client *i915_drm_client_alloc(void);
  50. void i915_drm_client_fdinfo(struct drm_printer *p, struct drm_file *file);
  51. #ifdef CONFIG_PROC_FS
  52. void i915_drm_client_add_object(struct i915_drm_client *client,
  53. struct drm_i915_gem_object *obj);
  54. void i915_drm_client_remove_object(struct drm_i915_gem_object *obj);
  55. void i915_drm_client_add_context_objects(struct i915_drm_client *client,
  56. struct intel_context *ce);
  57. #else
  58. static inline void i915_drm_client_add_object(struct i915_drm_client *client,
  59. struct drm_i915_gem_object *obj)
  60. {
  61. }
  62. static inline void
  63. i915_drm_client_remove_object(struct drm_i915_gem_object *obj)
  64. {
  65. }
  66. static inline void
  67. i915_drm_client_add_context_objects(struct i915_drm_client *client,
  68. struct intel_context *ce)
  69. {
  70. }
  71. #endif
  72. #endif /* !__I915_DRM_CLIENT_H__ */