osif_driver_sync.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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_DRIVER_SYNC_H
  20. #define __OSIF_DRIVER_SYNC_H
  21. #include "qdf_types.h"
  22. /*
  23. * struct osif_driver_sync - opaque synchronization handle for a driver
  24. */
  25. struct osif_driver_sync;
  26. /**
  27. * osif_driver_sync_create() - create a driver synchronization context
  28. * @out_driver_sync: out parameter for the new synchronization context
  29. *
  30. * Return: Errno
  31. */
  32. qdf_must_check int
  33. osif_driver_sync_create(struct osif_driver_sync **out_driver_sync);
  34. /**
  35. * osif_driver_sync_create_and_trans() - create a driver synchronization context
  36. * @out_driver_sync: out parameter for the new synchronization context
  37. *
  38. * For protecting the driver initialization process.
  39. *
  40. * Return: Errno
  41. */
  42. #define osif_driver_sync_create_and_trans(out_driver_sync) \
  43. __osif_driver_sync_create_and_trans(out_driver_sync, __func__)
  44. qdf_must_check int
  45. __osif_driver_sync_create_and_trans(struct osif_driver_sync **out_driver_sync,
  46. const char *desc);
  47. /**
  48. * osif_driver_sync_destroy() - destroy a driver synchronization context
  49. * @driver_sync: the context to destroy
  50. *
  51. * Return: none
  52. */
  53. void osif_driver_sync_destroy(struct osif_driver_sync *driver_sync);
  54. /**
  55. * osif_driver_sync_register() - register a driver for operations/transitions
  56. * @driver_sync: the driver synchronization context to register
  57. *
  58. * Return: none
  59. */
  60. void osif_driver_sync_register(struct osif_driver_sync *driver_sync);
  61. /**
  62. * osif_driver_sync_unregister() - unregister a driver for
  63. * operations/transitions
  64. *
  65. * Return: the driver synchronization context that was registered for @dev
  66. */
  67. struct osif_driver_sync *osif_driver_sync_unregister(void);
  68. /**
  69. * osif_driver_sync_trans_start() - attempt to start a driver transition
  70. * @out_driver_sync: out parameter for the synchronization context previously
  71. * registered, populated on success
  72. *
  73. * Return: Errno
  74. */
  75. #define osif_driver_sync_trans_start(out_driver_sync) \
  76. __osif_driver_sync_trans_start(out_driver_sync, __func__)
  77. qdf_must_check int
  78. __osif_driver_sync_trans_start(struct osif_driver_sync **out_driver_sync,
  79. const char *desc);
  80. /**
  81. * osif_driver_sync_trans_start_wait() - attempt to start a driver transition,
  82. * blocking if a conflicting transition is in flight
  83. * @out_driver_sync: out parameter for the synchronization context previously
  84. * registered, populated on success
  85. *
  86. * Return: Errno
  87. */
  88. #define osif_driver_sync_trans_start_wait(out_driver_sync) \
  89. __osif_driver_sync_trans_start_wait(out_driver_sync, __func__)
  90. qdf_must_check int
  91. __osif_driver_sync_trans_start_wait(struct osif_driver_sync **out_driver_sync,
  92. const char *desc);
  93. /**
  94. * osif_driver_sync_trans_stop() - stop a transition associated with
  95. * @driver_sync
  96. * @driver_sync: the synchronization context tracking the transition
  97. *
  98. * Return: none
  99. */
  100. void osif_driver_sync_trans_stop(struct osif_driver_sync *driver_sync);
  101. /**
  102. * osif_driver_sync_assert_trans_protected() - assert that the driver is
  103. * currently protected by a transition
  104. *
  105. * Return: none
  106. */
  107. void osif_driver_sync_assert_trans_protected(void);
  108. /**
  109. * osif_driver_sync_op_start() - attempt to start a driver operation
  110. * @out_driver_sync: out parameter for the synchronization context previously
  111. * registered, populated on success
  112. *
  113. * Return: Errno
  114. */
  115. #define osif_driver_sync_op_start(out_driver_sync) \
  116. __osif_driver_sync_op_start(out_driver_sync, __func__)
  117. qdf_must_check int
  118. __osif_driver_sync_op_start(struct osif_driver_sync **out_driver_sync,
  119. const char *func);
  120. /**
  121. * osif_driver_sync_op_stop() - stop an operation associated with @driver_sync
  122. * @driver_sync: the synchronization context tracking the operation
  123. *
  124. * Return: none
  125. */
  126. #define osif_driver_sync_op_stop(driver_sync) \
  127. __osif_driver_sync_op_stop(driver_sync, __func__)
  128. void __osif_driver_sync_op_stop(struct osif_driver_sync *driver_sync,
  129. const char *func);
  130. /**
  131. * osif_driver_sync_wait_for_ops() - wait until all @driver_sync operations
  132. * complete
  133. * @driver_sync: the synchronization context tracking the operations
  134. *
  135. * Return: None
  136. */
  137. void osif_driver_sync_wait_for_ops(struct osif_driver_sync *driver_sync);
  138. #endif /* __OSIF_DRIVER_SYNC_H */