aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/hwspinlock.txt
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation/hwspinlock.txt')
-rw-r--r--Documentation/hwspinlock.txt74
1 files changed, 44 insertions, 30 deletions
diff --git a/Documentation/hwspinlock.txt b/Documentation/hwspinlock.txt
index 7dcd1a4e726c..a903ee5e9776 100644
--- a/Documentation/hwspinlock.txt
+++ b/Documentation/hwspinlock.txt
@@ -39,23 +39,20 @@ independent, drivers.
39 in case an unused hwspinlock isn't available. Users of this 39 in case an unused hwspinlock isn't available. Users of this
40 API will usually want to communicate the lock's id to the remote core 40 API will usually want to communicate the lock's id to the remote core
41 before it can be used to achieve synchronization. 41 before it can be used to achieve synchronization.
42 Can be called from an atomic context (this function will not sleep) but 42 Should be called from a process context (might sleep).
43 not from within interrupt context.
44 43
45 struct hwspinlock *hwspin_lock_request_specific(unsigned int id); 44 struct hwspinlock *hwspin_lock_request_specific(unsigned int id);
46 - assign a specific hwspinlock id and return its address, or NULL 45 - assign a specific hwspinlock id and return its address, or NULL
47 if that hwspinlock is already in use. Usually board code will 46 if that hwspinlock is already in use. Usually board code will
48 be calling this function in order to reserve specific hwspinlock 47 be calling this function in order to reserve specific hwspinlock
49 ids for predefined purposes. 48 ids for predefined purposes.
50 Can be called from an atomic context (this function will not sleep) but 49 Should be called from a process context (might sleep).
51 not from within interrupt context.
52 50
53 int hwspin_lock_free(struct hwspinlock *hwlock); 51 int hwspin_lock_free(struct hwspinlock *hwlock);
54 - free a previously-assigned hwspinlock; returns 0 on success, or an 52 - free a previously-assigned hwspinlock; returns 0 on success, or an
55 appropriate error code on failure (e.g. -EINVAL if the hwspinlock 53 appropriate error code on failure (e.g. -EINVAL if the hwspinlock
56 is already free). 54 is already free).
57 Can be called from an atomic context (this function will not sleep) but 55 Should be called from a process context (might sleep).
58 not from within interrupt context.
59 56
60 int hwspin_lock_timeout(struct hwspinlock *hwlock, unsigned int timeout); 57 int hwspin_lock_timeout(struct hwspinlock *hwlock, unsigned int timeout);
61 - lock a previously-assigned hwspinlock with a timeout limit (specified in 58 - lock a previously-assigned hwspinlock with a timeout limit (specified in
@@ -230,45 +227,62 @@ int hwspinlock_example2(void)
230 227
2314. API for implementors 2284. API for implementors
232 229
233 int hwspin_lock_register(struct hwspinlock *hwlock); 230 int hwspin_lock_register(struct hwspinlock_device *bank, struct device *dev,
231 const struct hwspinlock_ops *ops, int base_id, int num_locks);
234 - to be called from the underlying platform-specific implementation, in 232 - to be called from the underlying platform-specific implementation, in
235 order to register a new hwspinlock instance. Can be called from an atomic 233 order to register a new hwspinlock device (which is usually a bank of
236 context (this function will not sleep) but not from within interrupt 234 numerous locks). Should be called from a process context (this function
237 context. Returns 0 on success, or appropriate error code on failure. 235 might sleep).
236 Returns 0 on success, or appropriate error code on failure.
238 237
239 struct hwspinlock *hwspin_lock_unregister(unsigned int id); 238 int hwspin_lock_unregister(struct hwspinlock_device *bank);
240 - to be called from the underlying vendor-specific implementation, in order 239 - to be called from the underlying vendor-specific implementation, in order
241 to unregister an existing (and unused) hwspinlock instance. 240 to unregister an hwspinlock device (which is usually a bank of numerous
242 Can be called from an atomic context (will not sleep) but not from 241 locks).
243 within interrupt context. 242 Should be called from a process context (this function might sleep).
244 Returns the address of hwspinlock on success, or NULL on error (e.g. 243 Returns the address of hwspinlock on success, or NULL on error (e.g.
245 if the hwspinlock is sill in use). 244 if the hwspinlock is sill in use).
246 245
2475. struct hwspinlock 2465. Important structs
248 247
249This struct represents an hwspinlock instance. It is registered by the 248struct hwspinlock_device is a device which usually contains a bank
250underlying hwspinlock implementation using the hwspin_lock_register() API. 249of hardware locks. It is registered by the underlying hwspinlock
250implementation using the hwspin_lock_register() API.
251 251
252/** 252/**
253 * struct hwspinlock - vendor-specific hwspinlock implementation 253 * struct hwspinlock_device - a device which usually spans numerous hwspinlocks
254 * 254 * @dev: underlying device, will be used to invoke runtime PM api
255 * @dev: underlying device, will be used with runtime PM api 255 * @ops: platform-specific hwspinlock handlers
256 * @ops: vendor-specific hwspinlock handlers 256 * @base_id: id index of the first lock in this device
257 * @id: a global, unique, system-wide, index of the lock. 257 * @num_locks: number of locks in this device
258 * @lock: initialized and used by hwspinlock core 258 * @lock: dynamically allocated array of 'struct hwspinlock'
259 * @owner: underlying implementation module, used to maintain module ref count
260 */ 259 */
261struct hwspinlock { 260struct hwspinlock_device {
262 struct device *dev; 261 struct device *dev;
263 const struct hwspinlock_ops *ops; 262 const struct hwspinlock_ops *ops;
264 int id; 263 int base_id;
264 int num_locks;
265 struct hwspinlock lock[0];
266};
267
268struct hwspinlock_device contains an array of hwspinlock structs, each
269of which represents a single hardware lock:
270
271/**
272 * struct hwspinlock - this struct represents a single hwspinlock instance
273 * @bank: the hwspinlock_device structure which owns this lock
274 * @lock: initialized and used by hwspinlock core
275 * @priv: private data, owned by the underlying platform-specific hwspinlock drv
276 */
277struct hwspinlock {
278 struct hwspinlock_device *bank;
265 spinlock_t lock; 279 spinlock_t lock;
266 struct module *owner; 280 void *priv;
267}; 281};
268 282
269The underlying implementation is responsible to assign the dev, ops, id and 283When registering a bank of locks, the hwspinlock driver only needs to
270owner members. The lock member, OTOH, is initialized and used by the hwspinlock 284set the priv members of the locks. The rest of the members are set and
271core. 285initialized by the hwspinlock core itself.
272 286
2736. Implementation callbacks 2876. Implementation callbacks
274 288