adreno_profile.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2013-2014,2019-2021 The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef __ADRENO_PROFILE_H
  7. #define __ADRENO_PROFILE_H
  8. /**
  9. * struct adreno_profile_assigns_list: linked list for assigned perf counters
  10. * @list: linkage for nodes in list
  11. * @name: group name or GPU name
  12. * @groupid: group id
  13. * @countable: countable assigned to perfcounter
  14. * @offset: perfcounter register address offset
  15. */
  16. struct adreno_profile_assigns_list {
  17. struct list_head list;
  18. char name[25];
  19. unsigned int groupid;
  20. unsigned int countable;
  21. unsigned int offset; /* LO offset */
  22. unsigned int offset_hi; /* HI offset */
  23. };
  24. struct adreno_profile {
  25. struct list_head assignments_list; /* list of all assignments */
  26. unsigned int assignment_count; /* Number of assigned counters */
  27. unsigned int *log_buffer;
  28. unsigned int *log_head;
  29. unsigned int *log_tail;
  30. bool enabled;
  31. /* counter, pre_ib, and post_ib held in one large circular buffer
  32. * shared between kgsl and GPU
  33. * counter entry 0
  34. * pre_ib entry 0
  35. * post_ib entry 0
  36. * ...
  37. * counter entry N
  38. * pre_ib entry N
  39. * post_ib entry N
  40. */
  41. struct kgsl_memdesc *shared_buffer;
  42. unsigned int shared_head;
  43. unsigned int shared_tail;
  44. unsigned int shared_size;
  45. };
  46. #define ADRENO_PROFILE_SHARED_BUF_SIZE_DWORDS (48 * 4096 / sizeof(uint))
  47. /* sized @ 48 pages should allow for over 50 outstanding IBs minimum, 1755 max*/
  48. #define ADRENO_PROFILE_LOG_BUF_SIZE (1024 * 920)
  49. /* sized for 1024 entries of fully assigned 45 cnters in log buffer, 230 pages*/
  50. #define ADRENO_PROFILE_LOG_BUF_SIZE_DWORDS (ADRENO_PROFILE_LOG_BUF_SIZE / \
  51. sizeof(unsigned int))
  52. #ifdef CONFIG_DEBUG_FS
  53. void adreno_profile_init(struct adreno_device *adreno_dev);
  54. void adreno_profile_close(struct adreno_device *adreno_dev);
  55. int adreno_profile_process_results(struct adreno_device *adreno_dev);
  56. u64 adreno_profile_preib_processing(struct adreno_device *adreno_dev,
  57. struct adreno_context *drawctxt, u32 *dwords);
  58. u64 adreno_profile_postib_processing(struct adreno_device *adreno_dev,
  59. struct adreno_context *drawctxt, u32 *dwords);
  60. #else
  61. static inline void adreno_profile_init(struct adreno_device *adreno_dev) { }
  62. static inline void adreno_profile_close(struct adreno_device *adreno_dev) { }
  63. static inline int adreno_profile_process_results(
  64. struct adreno_device *adreno_dev)
  65. {
  66. return 0;
  67. }
  68. static inline u64
  69. adreno_profile_preib_processing(struct adreno_device *adreno_dev,
  70. struct adreno_context *drawctxt, u32 *dwords)
  71. {
  72. return 0;
  73. }
  74. static inline u64
  75. adreno_profile_postib_processing(struct adreno_device *adreno_dev,
  76. struct adreno_context *drawctxt, u32 *dwords)
  77. {
  78. return 0;
  79. }
  80. #endif
  81. static inline bool adreno_profile_enabled(struct adreno_profile *profile)
  82. {
  83. return profile->enabled;
  84. }
  85. static inline bool adreno_profile_has_assignments(
  86. struct adreno_profile *profile)
  87. {
  88. return list_empty(&profile->assignments_list) ? false : true;
  89. }
  90. static inline bool adreno_profile_assignments_ready(
  91. struct adreno_profile *profile)
  92. {
  93. return adreno_profile_enabled(profile) &&
  94. adreno_profile_has_assignments(profile);
  95. }
  96. #endif