osif_psoc_sync.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. * Copyright (c) 2019 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. #ifndef __OSIF_PSOC_SYNC_H
  20. #define __OSIF_PSOC_SYNC_H
  21. #include "linux/device.h"
  22. #include "wlan_dsc_driver.h"
  23. #include "qdf_types.h"
  24. /*
  25. * struct osif_psoc_sync - opaque synchronization handle for a psoc
  26. */
  27. struct osif_psoc_sync;
  28. /**
  29. * osif_psoc_sync_create() - create a psoc synchronization context
  30. * @out_psoc_sync: out parameter for the new synchronization context
  31. *
  32. * Return: Errno
  33. */
  34. qdf_must_check int
  35. osif_psoc_sync_create(struct osif_psoc_sync **out_psoc_sync);
  36. /**
  37. * osif_psoc_sync_create_and_trans() - create a psoc synchronization context
  38. * @out_psoc_sync: out parameter for the new synchronization context
  39. *
  40. * For protecting the device creation process.
  41. *
  42. * Return: Errno
  43. */
  44. #define osif_psoc_sync_create_and_trans(out_psoc_sync) \
  45. __osif_psoc_sync_create_and_trans(out_psoc_sync, __func__)
  46. qdf_must_check int
  47. __osif_psoc_sync_create_and_trans(struct osif_psoc_sync **out_psoc_sync,
  48. const char *desc);
  49. /**
  50. * osif_psoc_sync_destroy() - destroy a psoc synchronization context
  51. * @psoc_sync: the context to destroy
  52. *
  53. * Return: none
  54. */
  55. void osif_psoc_sync_destroy(struct osif_psoc_sync *psoc_sync);
  56. /**
  57. * osif_psoc_sync_register() - register a psoc for operations/transitions
  58. * @dev: the device to use as the operation/transition lookup key
  59. * @psoc_sync: the psoc synchronization context to register
  60. *
  61. * Return: none
  62. */
  63. void osif_psoc_sync_register(struct device *dev,
  64. struct osif_psoc_sync *psoc_sync);
  65. /**
  66. * osif_psoc_sync_unregister() - unregister a psoc for operations/transitions
  67. * @dev: the device originally used to register the psoc_sync context
  68. *
  69. * Return: the psoc synchronization context that was registered for @dev
  70. */
  71. struct osif_psoc_sync *osif_psoc_sync_unregister(struct device *dev);
  72. /**
  73. * osif_psoc_sync_trans_start() - attempt to start a transition on @dev
  74. * @dev: the device to transition
  75. * @out_psoc_sync: out parameter for the synchronization context registered with
  76. * @dev, populated on success
  77. *
  78. * Return: Errno
  79. */
  80. #define osif_psoc_sync_trans_start(dev, out_psoc_sync) \
  81. __osif_psoc_sync_trans_start(dev, out_psoc_sync, __func__)
  82. qdf_must_check int
  83. __osif_psoc_sync_trans_start(struct device *dev,
  84. struct osif_psoc_sync **out_psoc_sync,
  85. const char *desc);
  86. /**
  87. * osif_psoc_sync_trans_start_wait() - attempt to start a transition on @dev,
  88. * blocking if a conflicting transition is in flight
  89. * @dev: the device to transition
  90. * @out_psoc_sync: out parameter for the synchronization context registered with
  91. * @dev, populated on success
  92. *
  93. * Return: Errno
  94. */
  95. #define osif_psoc_sync_trans_start_wait(dev, out_psoc_sync) \
  96. __osif_psoc_sync_trans_start_wait(dev, out_psoc_sync, __func__)
  97. qdf_must_check int
  98. __osif_psoc_sync_trans_start_wait(struct device *dev,
  99. struct osif_psoc_sync **out_psoc_sync,
  100. const char *desc);
  101. /**
  102. * osif_psoc_sync_trans_resume() - resume a transition on @dev
  103. * @dev: the device under transition
  104. * @out_psoc_sync: out parameter for the synchronization context registered with
  105. * @dev, populated on success
  106. *
  107. * Return: Errno
  108. */
  109. int osif_psoc_sync_trans_resume(struct device *dev,
  110. struct osif_psoc_sync **out_psoc_sync);
  111. /**
  112. * osif_psoc_sync_trans_stop() - stop a transition associated with @psoc_sync
  113. * @psoc_sync: the synchronization context tracking the transition
  114. *
  115. * Return: none
  116. */
  117. void osif_psoc_sync_trans_stop(struct osif_psoc_sync *psoc_sync);
  118. /**
  119. * osif_psoc_sync_assert_trans_protected() - assert that @dev is currently
  120. * protected by a transition
  121. * @dev: the device to check
  122. *
  123. * Return: none
  124. */
  125. void osif_psoc_sync_assert_trans_protected(struct device *dev);
  126. /**
  127. * osif_psoc_sync_op_start() - attempt to start an operation on @dev
  128. * @dev: the device to operate against
  129. * @out_psoc_sync: out parameter for the synchronization context registered with
  130. * @dev, populated on success
  131. *
  132. * Return: Errno
  133. */
  134. #define osif_psoc_sync_op_start(dev, out_psoc_sync) \
  135. __osif_psoc_sync_op_start(dev, out_psoc_sync, __func__)
  136. qdf_must_check int
  137. __osif_psoc_sync_op_start(struct device *dev,
  138. struct osif_psoc_sync **out_psoc_sync,
  139. const char *func);
  140. /**
  141. * osif_psoc_sync_op_stop() - stop an operation associated with @psoc_sync
  142. * @psoc_sync: the synchronization context tracking the operation
  143. *
  144. * Return: none
  145. */
  146. #define osif_psoc_sync_op_stop(psoc_sync) \
  147. __osif_psoc_sync_op_stop(psoc_sync, __func__)
  148. void __osif_psoc_sync_op_stop(struct osif_psoc_sync *psoc_sync,
  149. const char *func);
  150. /**
  151. * osif_psoc_sync_wait_for_ops() - wait until all @psoc_sync operations complete
  152. * @psoc_sync: the synchronization context tracking the operations
  153. *
  154. * Return: None
  155. */
  156. void osif_psoc_sync_wait_for_ops(struct osif_psoc_sync *psoc_sync);
  157. #endif /* __OSIF_PSOC_SYNC_H */