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()
309 * hwspin_lock_bust() - bust a specific hwspinlock
310 * @hwlock: a previously-acquired hwspinlock which we want to bust
313 * This function will bust a hwspinlock that was previously acquired as
318 * Returns: 0 on success, or -EINVAL if the hwspinlock does not exist, or
320 * defined for the hwspinlock.
322 int hwspin_lock_bust(struct hwspinlock *hwlock, unsigned int id) in hwspin_lock_bust()
340 * This is a simple translation function, suitable for hwspinlock platform
360 * This function provides a means for DT users of the hwspinlock module to
361 * get the global lock id of a specific hwspinlock using the phandle of the
362 * hwspinlock device, so that it can be requested using the normal
366 * hwspinlock device is not yet registered, -EINVAL on invalid args
373 struct hwspinlock *hwlock; in of_hwspin_lock_get_id()
389 /* Find the hwspinlock device: we need its base_id */ in of_hwspin_lock_get_id()
428 * This function provides a means for DT users of the hwspinlock module to
429 * get the global lock id of a specific hwspinlock using the specified name of
430 * the hwspinlock device, so that it can be requested using the normal
434 * hwspinlock device is not yet registered, -EINVAL on invalid args
453 static int hwspin_lock_register_single(struct hwspinlock *hwlock, int id) in hwspin_lock_register_single()
455 struct hwspinlock *tmp; in hwspin_lock_register_single()
463 pr_err("hwspinlock id %d already exists!\n", id); in hwspin_lock_register_single()
467 /* mark this hwspinlock as available */ in hwspin_lock_register_single()
478 static struct hwspinlock *hwspin_lock_unregister_single(unsigned int id) in hwspin_lock_unregister_single()
480 struct hwspinlock *hwlock = NULL; in hwspin_lock_unregister_single()
485 /* make sure the hwspinlock is not in use (tag is set) */ in hwspin_lock_unregister_single()
488 pr_err("hwspinlock %d still in use (or not present)\n", id); in hwspin_lock_unregister_single()
494 pr_err("failed to delete hwspinlock %d\n", id); in hwspin_lock_unregister_single()
505 * @bank: the hwspinlock device, which usually provides numerous hw locks
507 * @ops: hwspinlock handlers for this device
512 * implementation, to register a new hwspinlock device instance.
521 struct hwspinlock *hwlock; in hwspin_lock_register()
557 * @bank: the hwspinlock device, which usually provides numerous hw locks
560 * implementation, to unregister an existing (and unused) hwspinlock.
568 struct hwspinlock *hwlock, *tmp; in hwspin_lock_unregister()
606 * @bank: the hwspinlock device, which usually provides numerous hw locks
609 * implementation, to unregister an existing (and unused) hwspinlock.
632 * @bank: the hwspinlock device, which usually provides numerous hw locks
633 * @ops: hwspinlock handlers for this device
638 * implementation, to register a new hwspinlock device instance.
669 * __hwspin_lock_request() - tag an hwspinlock as used and power it up
670 * @hwlock: the target hwspinlock
672 * This is an internal function that prepares an hwspinlock instance
679 static int __hwspin_lock_request(struct hwspinlock *hwlock) in __hwspin_lock_request()
682 struct hwspinlock *tmp; in __hwspin_lock_request()
702 /* mark hwspinlock as used, should not fail */ in __hwspin_lock_request()
713 * hwspin_lock_get_id() - retrieve id number of a given hwspinlock
714 * @hwlock: a valid hwspinlock instance
718 int hwspin_lock_get_id(struct hwspinlock *hwlock) in hwspin_lock_get_id()
730 * hwspin_lock_request() - request an hwspinlock
732 * This function should be called by users of the hwspinlock device,
733 * in order to dynamically assign them an unused hwspinlock.
740 * Returns: the address of the assigned hwspinlock, or %NULL on error
742 struct hwspinlock *hwspin_lock_request(void) in hwspin_lock_request()
744 struct hwspinlock *hwlock; in hwspin_lock_request()
753 pr_warn("a free hwspinlock is not available\n"); in hwspin_lock_request()
773 * hwspin_lock_request_specific() - request for a specific hwspinlock
774 * @id: index of the specific hwspinlock that is requested
776 * This function should be called by users of the hwspinlock module,
777 * in order to assign them a specific hwspinlock.
779 * reserve specific hwspinlock ids for predefined purposes.
783 * Returns: the address of the assigned hwspinlock, or %NULL on error
785 struct hwspinlock *hwspin_lock_request_specific(unsigned int id) in hwspin_lock_request_specific()
787 struct hwspinlock *hwlock; in hwspin_lock_request_specific()
792 /* make sure this hwspinlock exists */ in hwspin_lock_request_specific()
795 pr_warn("hwspinlock %u does not exist\n", id); in hwspin_lock_request_specific()
802 /* make sure this hwspinlock is unused */ in hwspin_lock_request_specific()
805 pr_warn("hwspinlock %u is already in use\n", id); in hwspin_lock_request_specific()
822 * hwspin_lock_free() - free a specific hwspinlock
823 * @hwlock: the specific hwspinlock to free
833 int hwspin_lock_free(struct hwspinlock *hwlock) in hwspin_lock_free()
836 struct hwspinlock *tmp; in hwspin_lock_free()
847 /* make sure the hwspinlock is used */ in hwspin_lock_free()
860 /* mark this hwspinlock as available */ in hwspin_lock_free()
877 struct hwspinlock **hwlock = res; in devm_hwspin_lock_match()
887 hwspin_lock_free(*(struct hwspinlock **)res); in devm_hwspin_lock_release()
891 * devm_hwspin_lock_free() - free a specific hwspinlock for a managed device
892 * @dev: the device to free the specific hwspinlock
893 * @hwlock: the specific hwspinlock to free
903 int devm_hwspin_lock_free(struct device *dev, struct hwspinlock *hwlock) in devm_hwspin_lock_free()
916 * devm_hwspin_lock_request() - request an hwspinlock for a managed device
917 * @dev: the device to request an hwspinlock
919 * This function should be called by users of the hwspinlock device,
920 * in order to dynamically assign them an unused hwspinlock.
927 * Returns: the address of the assigned hwspinlock, or %NULL on error
929 struct hwspinlock *devm_hwspin_lock_request(struct device *dev) in devm_hwspin_lock_request()
931 struct hwspinlock **ptr, *hwlock; in devm_hwspin_lock_request()
950 * devm_hwspin_lock_request_specific() - request for a specific hwspinlock for
952 * @dev: the device to request the specific hwspinlock
953 * @id: index of the specific hwspinlock that is requested
955 * This function should be called by users of the hwspinlock module,
956 * in order to assign them a specific hwspinlock.
958 * reserve specific hwspinlock ids for predefined purposes.
962 * Returns: the address of the assigned hwspinlock, or %NULL on error
964 struct hwspinlock *devm_hwspin_lock_request_specific(struct device *dev, in devm_hwspin_lock_request_specific()
967 struct hwspinlock **ptr, *hwlock; in devm_hwspin_lock_request_specific()