Lines Matching full:hwspinlock
20 #include <linux/hwspinlock.h>
31 #define HWSPINLOCK_UNUSED (0) /* tags an hwspinlock as unused */
34 * A radix tree is used to maintain the available hwspinlock instances.
35 * The tree associates hwspinlock pointers with their integer key id,
36 * and provides easy-to-use API which makes the hwspinlock core code simple
42 * used as the ID's of the hwspinlock instances).
45 * framework uses to mark unused hwspinlock instances (see the
47 * tree, looking for an unused hwspinlock instance, is now reduced to a
61 * __hwspin_trylock() - attempt to lock a specific hwspinlock
62 * @hwlock: an hwspinlock which we want to trylock
67 * This function attempts to lock an hwspinlock, and will immediately
68 * fail if the hwspinlock is already taken.
77 * so the caller must not sleep, and is advised to release the hwspinlock as
87 * Returns: %0 if we successfully locked the hwspinlock or -EBUSY if
88 * the hwspinlock was already taken.
92 int __hwspin_trylock(struct hwspinlock *hwlock, int mode, unsigned long *flags) in __hwspin_trylock()
103 * in which the hwspinlock is taken. This is important in order in __hwspin_trylock()
106 * 2. Make the hwspinlock SMP-safe (so we can take it from in __hwspin_trylock()
109 * problems with hwspinlock usage (e.g. scheduler checks like in __hwspin_trylock()
132 /* try to take the hwspinlock device */ in __hwspin_trylock()
159 * the hwspinlock, and we must make sure that subsequent memory in __hwspin_trylock()
161 * we actually took the hwspinlock. in __hwspin_trylock()
173 * __hwspin_lock_timeout() - lock an hwspinlock with timeout limit
174 * @hwlock: the hwspinlock to be locked
194 * so the caller must not sleep, and is advised to release the hwspinlock as
209 int __hwspin_lock_timeout(struct hwspinlock *hwlock, unsigned int to, in __hwspin_lock_timeout()
218 /* Try to take the hwspinlock */ in __hwspin_lock_timeout()
250 * __hwspin_unlock() - unlock a specific hwspinlock
251 * @hwlock: a previously-acquired hwspinlock which we want to unlock
255 * This function will unlock a specific hwspinlock, enable preemption and
268 void __hwspin_unlock(struct hwspinlock *hwlock, int mode, unsigned long *flags) in __hwspin_unlock()
275 * done before unlocking the hwspinlock, will not be reordered in __hwspin_unlock()
282 * take the hwspinlock, and by then we want to be sure our memory in __hwspin_unlock()
312 * This is a simple translation function, suitable for hwspinlock platform
332 * This function provides a means for DT users of the hwspinlock module to
333 * get the global lock id of a specific hwspinlock using the phandle of the
334 * hwspinlock device, so that it can be requested using the normal
338 * hwspinlock device is not yet registered, -EINVAL on invalid args
345 struct hwspinlock *hwlock; in of_hwspin_lock_get_id()
361 /* Find the hwspinlock device: we need its base_id */ in of_hwspin_lock_get_id()
400 * This function provides a means for DT users of the hwspinlock module to
401 * get the global lock id of a specific hwspinlock using the specified name of
402 * the hwspinlock device, so that it can be requested using the normal
406 * hwspinlock device is not yet registered, -EINVAL on invalid args
425 static int hwspin_lock_register_single(struct hwspinlock *hwlock, int id) in hwspin_lock_register_single()
427 struct hwspinlock *tmp; in hwspin_lock_register_single()
435 pr_err("hwspinlock id %d already exists!\n", id); in hwspin_lock_register_single()
439 /* mark this hwspinlock as available */ in hwspin_lock_register_single()
450 static struct hwspinlock *hwspin_lock_unregister_single(unsigned int id) in hwspin_lock_unregister_single()
452 struct hwspinlock *hwlock = NULL; in hwspin_lock_unregister_single()
457 /* make sure the hwspinlock is not in use (tag is set) */ in hwspin_lock_unregister_single()
460 pr_err("hwspinlock %d still in use (or not present)\n", id); in hwspin_lock_unregister_single()
466 pr_err("failed to delete hwspinlock %d\n", id); in hwspin_lock_unregister_single()
477 * @bank: the hwspinlock device, which usually provides numerous hw locks
479 * @ops: hwspinlock handlers for this device
484 * implementation, to register a new hwspinlock device instance.
493 struct hwspinlock *hwlock; in hwspin_lock_register()
529 * @bank: the hwspinlock device, which usually provides numerous hw locks
532 * implementation, to unregister an existing (and unused) hwspinlock.
540 struct hwspinlock *hwlock, *tmp; in hwspin_lock_unregister()
578 * @bank: the hwspinlock device, which usually provides numerous hw locks
581 * implementation, to unregister an existing (and unused) hwspinlock.
604 * @bank: the hwspinlock device, which usually provides numerous hw locks
605 * @ops: hwspinlock handlers for this device
610 * implementation, to register a new hwspinlock device instance.
641 * __hwspin_lock_request() - tag an hwspinlock as used and power it up
642 * @hwlock: the target hwspinlock
644 * This is an internal function that prepares an hwspinlock instance
651 static int __hwspin_lock_request(struct hwspinlock *hwlock) in __hwspin_lock_request()
654 struct hwspinlock *tmp; in __hwspin_lock_request()
674 /* mark hwspinlock as used, should not fail */ in __hwspin_lock_request()
685 * hwspin_lock_get_id() - retrieve id number of a given hwspinlock
686 * @hwlock: a valid hwspinlock instance
690 int hwspin_lock_get_id(struct hwspinlock *hwlock) in hwspin_lock_get_id()
702 * hwspin_lock_request() - request an hwspinlock
704 * This function should be called by users of the hwspinlock device,
705 * in order to dynamically assign them an unused hwspinlock.
712 * Returns: the address of the assigned hwspinlock, or %NULL on error
714 struct hwspinlock *hwspin_lock_request(void) in hwspin_lock_request()
716 struct hwspinlock *hwlock; in hwspin_lock_request()
725 pr_warn("a free hwspinlock is not available\n"); in hwspin_lock_request()
745 * hwspin_lock_request_specific() - request for a specific hwspinlock
746 * @id: index of the specific hwspinlock that is requested
748 * This function should be called by users of the hwspinlock module,
749 * in order to assign them a specific hwspinlock.
751 * reserve specific hwspinlock ids for predefined purposes.
755 * Returns: the address of the assigned hwspinlock, or %NULL on error
757 struct hwspinlock *hwspin_lock_request_specific(unsigned int id) in hwspin_lock_request_specific()
759 struct hwspinlock *hwlock; in hwspin_lock_request_specific()
764 /* make sure this hwspinlock exists */ in hwspin_lock_request_specific()
767 pr_warn("hwspinlock %u does not exist\n", id); in hwspin_lock_request_specific()
774 /* make sure this hwspinlock is unused */ in hwspin_lock_request_specific()
777 pr_warn("hwspinlock %u is already in use\n", id); in hwspin_lock_request_specific()
794 * hwspin_lock_free() - free a specific hwspinlock
795 * @hwlock: the specific hwspinlock to free
805 int hwspin_lock_free(struct hwspinlock *hwlock) in hwspin_lock_free()
808 struct hwspinlock *tmp; in hwspin_lock_free()
819 /* make sure the hwspinlock is used */ in hwspin_lock_free()
832 /* mark this hwspinlock as available */ in hwspin_lock_free()
849 struct hwspinlock **hwlock = res; in devm_hwspin_lock_match()
859 hwspin_lock_free(*(struct hwspinlock **)res); in devm_hwspin_lock_release()
863 * devm_hwspin_lock_free() - free a specific hwspinlock for a managed device
864 * @dev: the device to free the specific hwspinlock
865 * @hwlock: the specific hwspinlock to free
875 int devm_hwspin_lock_free(struct device *dev, struct hwspinlock *hwlock) in devm_hwspin_lock_free()
888 * devm_hwspin_lock_request() - request an hwspinlock for a managed device
889 * @dev: the device to request an hwspinlock
891 * This function should be called by users of the hwspinlock device,
892 * in order to dynamically assign them an unused hwspinlock.
899 * Returns: the address of the assigned hwspinlock, or %NULL on error
901 struct hwspinlock *devm_hwspin_lock_request(struct device *dev) in devm_hwspin_lock_request()
903 struct hwspinlock **ptr, *hwlock; in devm_hwspin_lock_request()
922 * devm_hwspin_lock_request_specific() - request for a specific hwspinlock for
924 * @dev: the device to request the specific hwspinlock
925 * @id: index of the specific hwspinlock that is requested
927 * This function should be called by users of the hwspinlock module,
928 * in order to assign them a specific hwspinlock.
930 * reserve specific hwspinlock ids for predefined purposes.
934 * Returns: the address of the assigned hwspinlock, or %NULL on error
936 struct hwspinlock *devm_hwspin_lock_request_specific(struct device *dev, in devm_hwspin_lock_request_specific()
939 struct hwspinlock **ptr, *hwlock; in devm_hwspin_lock_request_specific()