adreno_profile.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /* Copyright (c) 2013, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. */
  13. #ifndef __ADRENO_PROFILE_H
  14. #define __ADRENO_PROFILE_H
  15. #include <linux/seq_file.h>
  16. /**
  17. * struct adreno_profile_assigns_list: linked list for assigned perf counters
  18. * @list: linkage for nodes in list
  19. * @name: group name or GPU name name
  20. * @groupid: group id
  21. * @countable: countable assigned to perfcounter
  22. * @offset: perfcounter register address offset
  23. */
  24. struct adreno_profile_assigns_list {
  25. struct list_head list;
  26. char name[25];
  27. unsigned int groupid;
  28. unsigned int countable;
  29. unsigned int offset; /* LO offset */
  30. unsigned int offset_hi; /* HI offset */
  31. };
  32. struct adreno_profile {
  33. struct list_head assignments_list; /* list of all assignments */
  34. unsigned int assignment_count; /* Number of assigned counters */
  35. unsigned int *log_buffer;
  36. unsigned int *log_head;
  37. unsigned int *log_tail;
  38. bool enabled;
  39. /* counter, pre_ib, and post_ib held in one large circular buffer
  40. * shared between kgsl and GPU
  41. * counter entry 0
  42. * pre_ib entry 0
  43. * post_ib entry 0
  44. * ...
  45. * counter entry N
  46. * pre_ib entry N
  47. * post_ib entry N
  48. */
  49. struct kgsl_memdesc shared_buffer;
  50. unsigned int shared_head;
  51. unsigned int shared_tail;
  52. unsigned int shared_size;
  53. };
  54. #define ADRENO_PROFILE_SHARED_BUF_SIZE_DWORDS (48 * 4096 / sizeof(uint))
  55. /* sized @ 48 pages should allow for over 50 outstanding IBs minimum, 1755 max*/
  56. #define ADRENO_PROFILE_LOG_BUF_SIZE (1024 * 920)
  57. /* sized for 1024 entries of fully assigned 45 cnters in log buffer, 230 pages*/
  58. #define ADRENO_PROFILE_LOG_BUF_SIZE_DWORDS (ADRENO_PROFILE_LOG_BUF_SIZE / \
  59. sizeof(unsigned int))
  60. #ifdef CONFIG_DEBUG_FS
  61. void adreno_profile_init(struct kgsl_device *device);
  62. void adreno_profile_close(struct kgsl_device *device);
  63. int adreno_profile_process_results(struct kgsl_device *device);
  64. void adreno_profile_preib_processing(struct kgsl_device *device,
  65. unsigned int context_id, unsigned int *cmd_flags,
  66. unsigned int **rbptr, unsigned int *cmds_gpu);
  67. void adreno_profile_postib_processing(struct kgsl_device *device,
  68. unsigned int *cmd_flags, unsigned int **rbptr,
  69. unsigned int *cmds_gpu);
  70. #else
  71. static inline void adreno_profile_init(struct kgsl_device *device) { }
  72. static inline void adreno_profile_close(struct kgsl_device *device) { }
  73. static inline int adreno_profile_process_results(struct kgsl_device *device)
  74. {
  75. return 0;
  76. }
  77. static inline void adreno_profile_preib_processing(struct kgsl_device *device,
  78. unsigned int context_id, unsigned int *cmd_flags,
  79. unsigned int **rbptr, unsigned int *cmds_gpu) { }
  80. static inline void adreno_profile_postib_processing(struct kgsl_device *device,
  81. unsigned int *cmd_flags, unsigned int **rbptr,
  82. unsigned int *cmds_gpu) { }
  83. #endif
  84. static inline bool adreno_profile_enabled(struct adreno_profile *profile)
  85. {
  86. return profile->enabled;
  87. }
  88. static inline bool adreno_profile_has_assignments(
  89. struct adreno_profile *profile)
  90. {
  91. return list_empty(&profile->assignments_list) ? false : true;
  92. }
  93. static inline bool adreno_profile_assignments_ready(
  94. struct adreno_profile *profile)
  95. {
  96. return adreno_profile_enabled(profile) &&
  97. adreno_profile_has_assignments(profile);
  98. }
  99. #endif