osif_driver_sync.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*
  2. * Copyright (c) 2019 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #ifndef __OSIF_DRIVER_SYNC_H
  19. #define __OSIF_DRIVER_SYNC_H
  20. #include "qdf_types.h"
  21. /**
  22. * struct osif_driver_sync - opaque synchronization handle for a driver
  23. */
  24. struct osif_driver_sync;
  25. /**
  26. * osif_driver_sync_create() - create a driver synchronization context
  27. * @out_driver_sync: out parameter for the new synchronization context
  28. *
  29. * Return: Errno
  30. */
  31. qdf_must_check int
  32. osif_driver_sync_create(struct osif_driver_sync **out_driver_sync);
  33. /**
  34. * osif_driver_sync_create_and_trans() - create a driver synchronization context
  35. * @out_driver_sync: out parameter for the new synchronization context
  36. *
  37. * For protecting the driver initialization process.
  38. *
  39. * Return: Errno
  40. */
  41. #define osif_driver_sync_create_and_trans(out_driver_sync) \
  42. __osif_driver_sync_create_and_trans(out_driver_sync, __func__)
  43. qdf_must_check int
  44. __osif_driver_sync_create_and_trans(struct osif_driver_sync **out_driver_sync,
  45. const char *desc);
  46. /**
  47. * osif_driver_sync_destroy() - destroy a driver synchronization context
  48. * @driver_sync: the context to destroy
  49. *
  50. * Return: none
  51. */
  52. void osif_driver_sync_destroy(struct osif_driver_sync *driver_sync);
  53. /**
  54. * osif_driver_sync_register() - register a driver for operations/transitions
  55. * @driver_sync: the driver synchronization context to register
  56. *
  57. * Return: none
  58. */
  59. void osif_driver_sync_register(struct osif_driver_sync *driver_sync);
  60. /**
  61. * osif_driver_sync_unregister() - unregister a driver for
  62. * operations/transitions
  63. *
  64. * Return: the driver synchronization context that was registered for @dev
  65. */
  66. struct osif_driver_sync *osif_driver_sync_unregister(void);
  67. /**
  68. * osif_driver_sync_trans_start() - attempt to start a driver transition
  69. * @out_driver_sync: out parameter for the synchronization context previously
  70. * registered, populated on success
  71. *
  72. * Return: Errno
  73. */
  74. #define osif_driver_sync_trans_start(out_driver_sync) \
  75. __osif_driver_sync_trans_start(out_driver_sync, __func__)
  76. qdf_must_check int
  77. __osif_driver_sync_trans_start(struct osif_driver_sync **out_driver_sync,
  78. const char *desc);
  79. /**
  80. * osif_driver_sync_trans_start_wait() - attempt to start a driver transition,
  81. * blocking if a conflicting transition is in flight
  82. * @out_driver_sync: out parameter for the synchronization context previously
  83. * registered, populated on success
  84. *
  85. * Return: Errno
  86. */
  87. #define osif_driver_sync_trans_start_wait(out_driver_sync) \
  88. __osif_driver_sync_trans_start_wait(out_driver_sync, __func__)
  89. qdf_must_check int
  90. __osif_driver_sync_trans_start_wait(struct osif_driver_sync **out_driver_sync,
  91. const char *desc);
  92. /**
  93. * osif_driver_sync_trans_stop() - stop a transition associated with
  94. * @driver_sync
  95. * @driver_sync: the synchonization context tracking the transition
  96. *
  97. * Return: none
  98. */
  99. void osif_driver_sync_trans_stop(struct osif_driver_sync *driver_sync);
  100. /**
  101. * osif_driver_sync_assert_trans_protected() - assert that the driver is
  102. * currently protected by a transition
  103. *
  104. * Return: none
  105. */
  106. void osif_driver_sync_assert_trans_protected(void);
  107. /**
  108. * osif_driver_sync_op_start() - attempt to start a driver operation
  109. * @out_driver_sync: out parameter for the synchronization context previously
  110. * registered, populated on success
  111. *
  112. * Return: Errno
  113. */
  114. #define osif_driver_sync_op_start(out_driver_sync) \
  115. __osif_driver_sync_op_start(out_driver_sync, __func__)
  116. qdf_must_check int
  117. __osif_driver_sync_op_start(struct osif_driver_sync **out_driver_sync,
  118. const char *func);
  119. /**
  120. * osif_driver_sync_op_stop() - stop an operation associated with @driver_sync
  121. * @driver_sync: the synchonization context tracking the operation
  122. *
  123. * Return: none
  124. */
  125. #define osif_driver_sync_op_stop(driver_sync) \
  126. __osif_driver_sync_op_stop(driver_sync, __func__)
  127. void __osif_driver_sync_op_stop(struct osif_driver_sync *driver_sync,
  128. const char *func);
  129. /**
  130. * osif_driver_sync_wait_for_ops() - wait until all @driver_sync operations
  131. * complete
  132. * @driver_sync: the synchonization context tracking the operations
  133. *
  134. * Return: None
  135. */
  136. void osif_driver_sync_wait_for_ops(struct osif_driver_sync *driver_sync);
  137. #endif /* __OSIF_DRIVER_SYNC_H */