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