ipa_rm_i.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _IPA_RM_I_H_
  6. #define _IPA_RM_I_H_
  7. #include <linux/workqueue.h>
  8. #include <linux/ipa.h>
  9. #include "ipa_rm_resource.h"
  10. #include "ipa_common_i.h"
  11. #define IPA_RM_DRV_NAME "ipa_rm"
  12. #define IPA_RM_DBG_LOW(fmt, args...) \
  13. do { \
  14. pr_debug(IPA_RM_DRV_NAME " %s:%d " fmt, __func__, __LINE__, \
  15. ## args); \
  16. IPA_IPC_LOGGING(ipa_get_ipc_logbuf_low(), \
  17. IPA_RM_DRV_NAME " %s:%d " fmt, ## args); \
  18. } while (0)
  19. #define IPA_RM_DBG(fmt, args...) \
  20. do { \
  21. pr_debug(IPA_RM_DRV_NAME " %s:%d " fmt, __func__, __LINE__, \
  22. ## args); \
  23. IPA_IPC_LOGGING(ipa_get_ipc_logbuf(), \
  24. IPA_RM_DRV_NAME " %s:%d " fmt, ## args); \
  25. IPA_IPC_LOGGING(ipa_get_ipc_logbuf_low(), \
  26. IPA_RM_DRV_NAME " %s:%d " fmt, ## args); \
  27. } while (0)
  28. #define IPA_RM_ERR(fmt, args...) \
  29. do { \
  30. pr_err(IPA_RM_DRV_NAME " %s:%d " fmt, __func__, __LINE__, \
  31. ## args); \
  32. IPA_IPC_LOGGING(ipa_get_ipc_logbuf(), \
  33. IPA_RM_DRV_NAME " %s:%d " fmt, ## args); \
  34. IPA_IPC_LOGGING(ipa_get_ipc_logbuf_low(), \
  35. IPA_RM_DRV_NAME " %s:%d " fmt, ## args); \
  36. } while (0)
  37. #define IPA_RM_RESORCE_IS_PROD(x) \
  38. (x < IPA_RM_RESOURCE_MAX && (x & 0x1) == 0)
  39. #define IPA_RM_RESORCE_IS_CONS(x) \
  40. (x < IPA_RM_RESOURCE_MAX && (x & 0x1) == 1)
  41. #define IPA_RM_INDEX_INVALID (-1)
  42. #define IPA_RM_RELEASE_DELAY_IN_MSEC 1000
  43. int ipa_rm_prod_index(enum ipa_rm_resource_name resource_name);
  44. int ipa_rm_cons_index(enum ipa_rm_resource_name resource_name);
  45. /**
  46. * struct ipa_rm_delayed_release_work_type - IPA RM delayed resource release
  47. * work type
  48. * @delayed_work: work struct
  49. * @ipa_rm_resource_name: name of the resource on which this work should be done
  50. * @needed_bw: bandwidth required for resource in Mbps
  51. * @dec_usage_count: decrease usage count on release ?
  52. */
  53. struct ipa_rm_delayed_release_work_type {
  54. struct delayed_work work;
  55. enum ipa_rm_resource_name resource_name;
  56. u32 needed_bw;
  57. bool dec_usage_count;
  58. };
  59. /**
  60. * enum ipa_rm_wq_cmd - workqueue commands
  61. */
  62. enum ipa_rm_wq_cmd {
  63. IPA_RM_WQ_NOTIFY_PROD,
  64. IPA_RM_WQ_NOTIFY_CONS,
  65. IPA_RM_WQ_RESOURCE_CB
  66. };
  67. /**
  68. * struct ipa_rm_wq_work_type - IPA RM worqueue specific
  69. * work type
  70. * @work: work struct
  71. * @wq_cmd: command that should be processed in workqueue context
  72. * @resource_name: name of the resource on which this work
  73. * should be done
  74. * @dep_graph: data structure to search for resource if exists
  75. * @event: event to notify
  76. * @notify_registered_only: notify only clients registered by
  77. * ipa_rm_register()
  78. */
  79. struct ipa_rm_wq_work_type {
  80. struct work_struct work;
  81. enum ipa_rm_wq_cmd wq_cmd;
  82. enum ipa_rm_resource_name resource_name;
  83. enum ipa_rm_event event;
  84. bool notify_registered_only;
  85. };
  86. /**
  87. * struct ipa_rm_wq_suspend_resume_work_type - IPA RM worqueue resume or
  88. * suspend work type
  89. * @work: work struct
  90. * @resource_name: name of the resource on which this work
  91. * should be done
  92. * @prev_state:
  93. * @needed_bw:
  94. */
  95. struct ipa_rm_wq_suspend_resume_work_type {
  96. struct work_struct work;
  97. enum ipa_rm_resource_name resource_name;
  98. enum ipa_rm_resource_state prev_state;
  99. u32 needed_bw;
  100. bool inc_usage_count;
  101. };
  102. int ipa_rm_wq_send_cmd(enum ipa_rm_wq_cmd wq_cmd,
  103. enum ipa_rm_resource_name resource_name,
  104. enum ipa_rm_event event,
  105. bool notify_registered_only);
  106. int ipa_rm_wq_send_resume_cmd(enum ipa_rm_resource_name resource_name,
  107. enum ipa_rm_resource_state prev_state,
  108. u32 needed_bw,
  109. bool inc_usage_count);
  110. int ipa_rm_wq_send_suspend_cmd(enum ipa_rm_resource_name resource_name,
  111. enum ipa_rm_resource_state prev_state,
  112. u32 needed_bw);
  113. int ipa_rm_initialize(void);
  114. int ipa_rm_stat(char *buf, int size);
  115. const char *ipa_rm_resource_str(enum ipa_rm_resource_name resource_name);
  116. void ipa_rm_perf_profile_change(enum ipa_rm_resource_name resource_name);
  117. int ipa_rm_request_resource_with_timer(enum ipa_rm_resource_name resource_name);
  118. void delayed_release_work_func(struct work_struct *work);
  119. int ipa_rm_add_dependency_from_ioctl(enum ipa_rm_resource_name resource_name,
  120. enum ipa_rm_resource_name depends_on_name);
  121. int ipa_rm_delete_dependency_from_ioctl(enum ipa_rm_resource_name resource_name,
  122. enum ipa_rm_resource_name depends_on_name);
  123. void ipa_rm_exit(void);
  124. #endif /* _IPA_RM_I_H_ */