intel_guc_log.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Copyright © 2014-2017 Intel Corporation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice (including the next
  12. * paragraph) shall be included in all copies or substantial portions of the
  13. * Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  21. * IN THE SOFTWARE.
  22. *
  23. */
  24. #ifndef _INTEL_GUC_LOG_H_
  25. #define _INTEL_GUC_LOG_H_
  26. #include <linux/mutex.h>
  27. #include <linux/relay.h>
  28. #include <linux/workqueue.h>
  29. #include "intel_guc_fwif.h"
  30. struct intel_guc;
  31. /*
  32. * The first page is to save log buffer state. Allocate one
  33. * extra page for others in case for overlap
  34. */
  35. #define GUC_LOG_SIZE ((1 + GUC_LOG_DPC_PAGES + 1 + GUC_LOG_ISR_PAGES + \
  36. 1 + GUC_LOG_CRASH_PAGES + 1) << PAGE_SHIFT)
  37. /*
  38. * While we're using plain log level in i915, GuC controls are much more...
  39. * "elaborate"? We have a couple of bits for verbosity, separate bit for actual
  40. * log enabling, and separate bit for default logging - which "conveniently"
  41. * ignores the enable bit.
  42. */
  43. #define GUC_LOG_LEVEL_DISABLED 0
  44. #define GUC_LOG_LEVEL_NON_VERBOSE 1
  45. #define GUC_LOG_LEVEL_IS_ENABLED(x) ((x) > GUC_LOG_LEVEL_DISABLED)
  46. #define GUC_LOG_LEVEL_IS_VERBOSE(x) ((x) > GUC_LOG_LEVEL_NON_VERBOSE)
  47. #define GUC_LOG_LEVEL_TO_VERBOSITY(x) ({ \
  48. typeof(x) _x = (x); \
  49. GUC_LOG_LEVEL_IS_VERBOSE(_x) ? _x - 2 : 0; \
  50. })
  51. #define GUC_VERBOSITY_TO_LOG_LEVEL(x) ((x) + 2)
  52. #define GUC_LOG_LEVEL_MAX GUC_VERBOSITY_TO_LOG_LEVEL(GUC_LOG_VERBOSITY_MAX)
  53. struct intel_guc_log {
  54. u32 flags;
  55. struct i915_vma *vma;
  56. struct {
  57. void *buf_addr;
  58. struct workqueue_struct *flush_wq;
  59. struct work_struct flush_work;
  60. struct rchan *channel;
  61. struct mutex lock;
  62. u32 full_count;
  63. } relay;
  64. /* logging related stats */
  65. struct {
  66. u32 sampled_overflow;
  67. u32 overflow;
  68. u32 flush;
  69. } stats[GUC_MAX_LOG_BUFFER];
  70. };
  71. void intel_guc_log_init_early(struct intel_guc_log *log);
  72. int intel_guc_log_create(struct intel_guc_log *log);
  73. void intel_guc_log_destroy(struct intel_guc_log *log);
  74. int intel_guc_log_level_get(struct intel_guc_log *log);
  75. int intel_guc_log_level_set(struct intel_guc_log *log, u64 control_val);
  76. bool intel_guc_log_relay_enabled(const struct intel_guc_log *log);
  77. int intel_guc_log_relay_open(struct intel_guc_log *log);
  78. void intel_guc_log_relay_flush(struct intel_guc_log *log);
  79. void intel_guc_log_relay_close(struct intel_guc_log *log);
  80. void intel_guc_log_handle_flush_event(struct intel_guc_log *log);
  81. #endif