Lines Matching +full:interconnect +full:-
4 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com
6 * Contact: Ohad Ben-Cohen <ohad@wizery.com>
26 #include <linux/radix-tree.h>
39 * and provides easy-to-use API which makes the hwspinlock core code simple
57 * as the radix-tree API requires that users provide all synchronisation.
58 * A mutex is needed because we're using non-atomic radix tree allocations.
64 * __hwspin_trylock() - attempt to lock a specific hwspinlock
76 * minimize remote cores polling on the hardware interconnect.
84 * Returns 0 if we successfully locked the hwspinlock or -EBUSY if
100 * to minimize the possible polling on the hardware interconnect in __hwspin_trylock()
102 * 2. Make the hwspinlock SMP-safe (so we can take it from in __hwspin_trylock()
109 ret = spin_trylock_irqsave(&hwlock->lock, *flags); in __hwspin_trylock()
111 ret = spin_trylock_irq(&hwlock->lock); in __hwspin_trylock()
113 ret = spin_trylock(&hwlock->lock); in __hwspin_trylock()
117 return -EBUSY; in __hwspin_trylock()
120 ret = hwlock->bank->ops->trylock(hwlock); in __hwspin_trylock()
125 spin_unlock_irqrestore(&hwlock->lock, *flags); in __hwspin_trylock()
127 spin_unlock_irq(&hwlock->lock); in __hwspin_trylock()
129 spin_unlock(&hwlock->lock); in __hwspin_trylock()
131 return -EBUSY; in __hwspin_trylock()
151 * __hwspin_lock_timeout() - lock an hwspinlock with timeout limit
166 * hardware interconnect.
174 * error code otherwise (most notably -ETIMEDOUT if the @hwlock is still
188 if (ret != -EBUSY) in __hwspin_lock_timeout()
196 return -ETIMEDOUT; in __hwspin_lock_timeout()
199 * Allow platform-specific relax handlers to prevent in __hwspin_lock_timeout()
200 * hogging the interconnect (no sleeping, though) in __hwspin_lock_timeout()
202 if (hwlock->bank->ops->relax) in __hwspin_lock_timeout()
203 hwlock->bank->ops->relax(hwlock); in __hwspin_lock_timeout()
211 * __hwspin_unlock() - unlock a specific hwspinlock
212 * @hwlock: a previously-acquired hwspinlock which we want to unlock
248 hwlock->bank->ops->unlock(hwlock); in __hwspin_unlock()
252 spin_unlock_irqrestore(&hwlock->lock, *flags); in __hwspin_unlock()
254 spin_unlock_irq(&hwlock->lock); in __hwspin_unlock()
256 spin_unlock(&hwlock->lock); in __hwspin_unlock()
269 if (ret == -EEXIST) in hwspin_lock_register_single()
277 /* self-sanity check which should never fail */ in hwspin_lock_register_single()
311 * hwspin_lock_register() - register a new hw spinlock device
318 * This function should be called from the underlying platform-specific
331 if (!bank || !ops || !dev || !num_locks || !ops->trylock || in hwspin_lock_register()
332 !ops->unlock) { in hwspin_lock_register()
334 return -EINVAL; in hwspin_lock_register()
337 bank->dev = dev; in hwspin_lock_register()
338 bank->ops = ops; in hwspin_lock_register()
339 bank->base_id = base_id; in hwspin_lock_register()
340 bank->num_locks = num_locks; in hwspin_lock_register()
343 hwlock = &bank->lock[i]; in hwspin_lock_register()
345 spin_lock_init(&hwlock->lock); in hwspin_lock_register()
346 hwlock->bank = bank; in hwspin_lock_register()
356 while (--i >= 0) in hwspin_lock_register()
363 * hwspin_lock_unregister() - unregister an hw spinlock device
366 * This function should be called from the underlying platform-specific
378 for (i = 0; i < bank->num_locks; i++) { in hwspin_lock_unregister()
379 hwlock = &bank->lock[i]; in hwspin_lock_unregister()
381 tmp = hwspin_lock_unregister_single(bank->base_id + i); in hwspin_lock_unregister()
383 return -EBUSY; in hwspin_lock_unregister()
385 /* self-sanity check that should never fail */ in hwspin_lock_unregister()
394 * __hwspin_lock_request() - tag an hwspinlock as used and power it up
405 struct device *dev = hwlock->bank->dev; in __hwspin_lock_request()
410 if (!try_module_get(dev->driver->owner)) { in __hwspin_lock_request()
412 return -EINVAL; in __hwspin_lock_request()
426 /* self-sanity check that should never fail */ in __hwspin_lock_request()
433 * hwspin_lock_get_id() - retrieve id number of a given hwspinlock
436 * Returns the id number of a given @hwlock, or -EINVAL if @hwlock is invalid.
442 return -EINVAL; in hwspin_lock_get_id()
450 * hwspin_lock_request() - request an hwspinlock
493 * hwspin_lock_request_specific() - request for a specific hwspinlock
542 * hwspin_lock_free() - free a specific hwspinlock
555 struct device *dev = hwlock->bank->dev; in hwspin_lock_free()
561 return -EINVAL; in hwspin_lock_free()
572 ret = -EINVAL; in hwspin_lock_free()
588 module_put(dev->driver->owner); in hwspin_lock_free()
598 MODULE_AUTHOR("Ohad Ben-Cohen <ohad@wizery.com>");