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.
91 int __hwspin_trylock(struct hwspinlock *hwlock, int mode, unsigned long *flags) in __hwspin_trylock()
102 * in which the hwspinlock is taken. This is important in order in __hwspin_trylock()
105 * 2. Make the hwspinlock SMP-safe (so we can take it from in __hwspin_trylock()
108 * problems with hwspinlock usage (e.g. scheduler checks like in __hwspin_trylock()
131 /* try to take the hwspinlock device */ in __hwspin_trylock()
158 * the hwspinlock, and we must make sure that subsequent memory in __hwspin_trylock()
160 * we actually took the hwspinlock. in __hwspin_trylock()
172 * __hwspin_lock_timeout() - lock an hwspinlock with timeout limit
173 * @hwlock: the hwspinlock to be locked
193 * so the caller must not sleep, and is advised to release the hwspinlock as
206 int __hwspin_lock_timeout(struct hwspinlock *hwlock, unsigned int to, in __hwspin_lock_timeout()
215 /* Try to take the hwspinlock */ in __hwspin_lock_timeout()
247 * __hwspin_unlock() - unlock a specific hwspinlock
248 * @hwlock: a previously-acquired hwspinlock which we want to unlock
252 * This function will unlock a specific hwspinlock, enable preemption and
265 void __hwspin_unlock(struct hwspinlock *hwlock, int mode, unsigned long *flags) in __hwspin_unlock()
272 * done before unlocking the hwspinlock, will not be reordered in __hwspin_unlock()
279 * take the hwspinlock, and by then we want to be sure our memory in __hwspin_unlock()
307 * @bank: the hwspinlock device bank
310 * This is a simple translation function, suitable for hwspinlock platform
330 * This function provides a means for DT users of the hwspinlock module to
331 * get the global lock id of a specific hwspinlock using the phandle of the
332 * hwspinlock device, so that it can be requested using the normal
335 * Returns the global lock id number on success, -EPROBE_DEFER if the hwspinlock
342 struct hwspinlock *hwlock; in of_hwspin_lock_get_id()
358 /* Find the hwspinlock device: we need its base_id */ in of_hwspin_lock_get_id()
397 * This function provides a means for DT users of the hwspinlock module to
398 * get the global lock id of a specific hwspinlock using the specified name of
399 * the hwspinlock device, so that it can be requested using the normal
402 * Returns the global lock id number on success, -EPROBE_DEFER if the hwspinlock
421 static int hwspin_lock_register_single(struct hwspinlock *hwlock, int id) in hwspin_lock_register_single()
423 struct hwspinlock *tmp; in hwspin_lock_register_single()
431 pr_err("hwspinlock id %d already exists!\n", id); in hwspin_lock_register_single()
435 /* mark this hwspinlock as available */ in hwspin_lock_register_single()
446 static struct hwspinlock *hwspin_lock_unregister_single(unsigned int id) in hwspin_lock_unregister_single()
448 struct hwspinlock *hwlock = NULL; in hwspin_lock_unregister_single()
453 /* make sure the hwspinlock is not in use (tag is set) */ in hwspin_lock_unregister_single()
456 pr_err("hwspinlock %d still in use (or not present)\n", id); in hwspin_lock_unregister_single()
462 pr_err("failed to delete hwspinlock %d\n", id); in hwspin_lock_unregister_single()
473 * @bank: the hwspinlock device, which usually provides numerous hw locks
475 * @ops: hwspinlock handlers for this device
480 * implementation, to register a new hwspinlock device instance.
489 struct hwspinlock *hwlock; in hwspin_lock_register()
525 * @bank: the hwspinlock device, which usually provides numerous hw locks
528 * implementation, to unregister an existing (and unused) hwspinlock.
536 struct hwspinlock *hwlock, *tmp; in hwspin_lock_unregister()
574 * @bank: the hwspinlock device, which usually provides numerous hw locks
577 * implementation, to unregister an existing (and unused) hwspinlock.
600 * @bank: the hwspinlock device, which usually provides numerous hw locks
601 * @ops: hwspinlock handlers for this device
606 * implementation, to register a new hwspinlock device instance.
637 * __hwspin_lock_request() - tag an hwspinlock as used and power it up
639 * This is an internal function that prepares an hwspinlock instance
646 static int __hwspin_lock_request(struct hwspinlock *hwlock) in __hwspin_lock_request()
649 struct hwspinlock *tmp; in __hwspin_lock_request()
669 /* mark hwspinlock as used, should not fail */ in __hwspin_lock_request()
680 * hwspin_lock_get_id() - retrieve id number of a given hwspinlock
681 * @hwlock: a valid hwspinlock instance
685 int hwspin_lock_get_id(struct hwspinlock *hwlock) in hwspin_lock_get_id()
697 * hwspin_lock_request() - request an hwspinlock
699 * This function should be called by users of the hwspinlock device,
700 * in order to dynamically assign them an unused hwspinlock.
707 * Returns the address of the assigned hwspinlock, or NULL on error
709 struct hwspinlock *hwspin_lock_request(void) in hwspin_lock_request()
711 struct hwspinlock *hwlock; in hwspin_lock_request()
720 pr_warn("a free hwspinlock is not available\n"); in hwspin_lock_request()
740 * hwspin_lock_request_specific() - request for a specific hwspinlock
741 * @id: index of the specific hwspinlock that is requested
743 * This function should be called by users of the hwspinlock module,
744 * in order to assign them a specific hwspinlock.
746 * reserve specific hwspinlock ids for predefined purposes.
750 * Returns the address of the assigned hwspinlock, or NULL on error
752 struct hwspinlock *hwspin_lock_request_specific(unsigned int id) in hwspin_lock_request_specific()
754 struct hwspinlock *hwlock; in hwspin_lock_request_specific()
759 /* make sure this hwspinlock exists */ in hwspin_lock_request_specific()
762 pr_warn("hwspinlock %u does not exist\n", id); in hwspin_lock_request_specific()
769 /* make sure this hwspinlock is unused */ in hwspin_lock_request_specific()
772 pr_warn("hwspinlock %u is already in use\n", id); in hwspin_lock_request_specific()
789 * hwspin_lock_free() - free a specific hwspinlock
790 * @hwlock: the specific hwspinlock to free
800 int hwspin_lock_free(struct hwspinlock *hwlock) in hwspin_lock_free()
803 struct hwspinlock *tmp; in hwspin_lock_free()
814 /* make sure the hwspinlock is used */ in hwspin_lock_free()
827 /* mark this hwspinlock as available */ in hwspin_lock_free()
844 struct hwspinlock **hwlock = res; in devm_hwspin_lock_match()
854 hwspin_lock_free(*(struct hwspinlock **)res); in devm_hwspin_lock_release()
858 * devm_hwspin_lock_free() - free a specific hwspinlock for a managed device
859 * @dev: the device to free the specific hwspinlock
860 * @hwlock: the specific hwspinlock to free
870 int devm_hwspin_lock_free(struct device *dev, struct hwspinlock *hwlock) in devm_hwspin_lock_free()
883 * devm_hwspin_lock_request() - request an hwspinlock for a managed device
884 * @dev: the device to request an hwspinlock
886 * This function should be called by users of the hwspinlock device,
887 * in order to dynamically assign them an unused hwspinlock.
894 * Returns the address of the assigned hwspinlock, or NULL on error
896 struct hwspinlock *devm_hwspin_lock_request(struct device *dev) in devm_hwspin_lock_request()
898 struct hwspinlock **ptr, *hwlock; in devm_hwspin_lock_request()
917 * devm_hwspin_lock_request_specific() - request for a specific hwspinlock for
919 * @dev: the device to request the specific hwspinlock
920 * @id: index of the specific hwspinlock that is requested
922 * This function should be called by users of the hwspinlock module,
923 * in order to assign them a specific hwspinlock.
925 * reserve specific hwspinlock ids for predefined purposes.
929 * Returns the address of the assigned hwspinlock, or NULL on error
931 struct hwspinlock *devm_hwspin_lock_request_specific(struct device *dev, in devm_hwspin_lock_request_specific()
934 struct hwspinlock **ptr, *hwlock; in devm_hwspin_lock_request_specific()