Lines Matching refs:hwlock

92 int __hwspin_trylock(struct hwspinlock *hwlock, int mode, unsigned long *flags)  in __hwspin_trylock()  argument
96 if (WARN_ON(!hwlock || (!flags && mode == HWLOCK_IRQSTATE))) in __hwspin_trylock()
114 ret = spin_trylock_irqsave(&hwlock->lock, *flags); in __hwspin_trylock()
117 ret = spin_trylock_irq(&hwlock->lock); in __hwspin_trylock()
124 ret = spin_trylock(&hwlock->lock); in __hwspin_trylock()
133 ret = hwlock->bank->ops->trylock(hwlock); in __hwspin_trylock()
139 spin_unlock_irqrestore(&hwlock->lock, *flags); in __hwspin_trylock()
142 spin_unlock_irq(&hwlock->lock); in __hwspin_trylock()
149 spin_unlock(&hwlock->lock); in __hwspin_trylock()
209 int __hwspin_lock_timeout(struct hwspinlock *hwlock, unsigned int to, in __hwspin_lock_timeout() argument
219 ret = __hwspin_trylock(hwlock, mode, flags); in __hwspin_lock_timeout()
241 if (hwlock->bank->ops->relax) in __hwspin_lock_timeout()
242 hwlock->bank->ops->relax(hwlock); in __hwspin_lock_timeout()
268 void __hwspin_unlock(struct hwspinlock *hwlock, int mode, unsigned long *flags) in __hwspin_unlock() argument
270 if (WARN_ON(!hwlock || (!flags && mode == HWLOCK_IRQSTATE))) in __hwspin_unlock()
287 hwlock->bank->ops->unlock(hwlock); in __hwspin_unlock()
292 spin_unlock_irqrestore(&hwlock->lock, *flags); in __hwspin_unlock()
295 spin_unlock_irq(&hwlock->lock); in __hwspin_unlock()
302 spin_unlock(&hwlock->lock); in __hwspin_unlock()
322 int hwspin_lock_bust(struct hwspinlock *hwlock, unsigned int id) in hwspin_lock_bust() argument
324 if (WARN_ON(!hwlock)) in hwspin_lock_bust()
327 if (!hwlock->bank->ops->bust) { in hwspin_lock_bust()
332 return hwlock->bank->ops->bust(hwlock, id); in hwspin_lock_bust()
373 struct hwspinlock *hwlock; in of_hwspin_lock_get_id() local
393 hwlock = radix_tree_deref_slot(slot); in of_hwspin_lock_get_id()
394 if (unlikely(!hwlock)) in of_hwspin_lock_get_id()
396 if (radix_tree_deref_retry(hwlock)) { in of_hwspin_lock_get_id()
401 if (device_match_of_node(hwlock->bank->dev, args.np)) { in of_hwspin_lock_get_id()
411 if (id < 0 || id >= hwlock->bank->num_locks) { in of_hwspin_lock_get_id()
415 id += hwlock->bank->base_id; in of_hwspin_lock_get_id()
453 static int hwspin_lock_register_single(struct hwspinlock *hwlock, int id) in hwspin_lock_register_single() argument
460 ret = radix_tree_insert(&hwspinlock_tree, id, hwlock); in hwspin_lock_register_single()
471 WARN_ON(tmp != hwlock); in hwspin_lock_register_single()
480 struct hwspinlock *hwlock = NULL; in hwspin_lock_unregister_single() local
492 hwlock = radix_tree_delete(&hwspinlock_tree, id); in hwspin_lock_unregister_single()
493 if (!hwlock) { in hwspin_lock_unregister_single()
500 return hwlock; in hwspin_lock_unregister_single()
521 struct hwspinlock *hwlock; in hwspin_lock_register() local
536 hwlock = &bank->lock[i]; in hwspin_lock_register()
538 spin_lock_init(&hwlock->lock); in hwspin_lock_register()
539 hwlock->bank = bank; in hwspin_lock_register()
541 ret = hwspin_lock_register_single(hwlock, base_id + i); in hwspin_lock_register()
568 struct hwspinlock *hwlock, *tmp; in hwspin_lock_unregister() local
572 hwlock = &bank->lock[i]; in hwspin_lock_unregister()
579 WARN_ON(tmp != hwlock); in hwspin_lock_unregister()
679 static int __hwspin_lock_request(struct hwspinlock *hwlock) in __hwspin_lock_request() argument
681 struct device *dev = hwlock->bank->dev; in __hwspin_lock_request()
703 tmp = radix_tree_tag_clear(&hwspinlock_tree, hwlock_to_id(hwlock), in __hwspin_lock_request()
707 WARN_ON(tmp != hwlock); in __hwspin_lock_request()
718 int hwspin_lock_get_id(struct hwspinlock *hwlock) in hwspin_lock_get_id() argument
720 if (!hwlock) { in hwspin_lock_get_id()
725 return hwlock_to_id(hwlock); in hwspin_lock_get_id()
744 struct hwspinlock *hwlock; in hwspin_lock_request() local
750 ret = radix_tree_gang_lookup_tag(&hwspinlock_tree, (void **)&hwlock, in hwspin_lock_request()
754 hwlock = NULL; in hwspin_lock_request()
762 ret = __hwspin_lock_request(hwlock); in hwspin_lock_request()
764 hwlock = NULL; in hwspin_lock_request()
768 return hwlock; in hwspin_lock_request()
787 struct hwspinlock *hwlock; in hwspin_lock_request_specific() local
793 hwlock = radix_tree_lookup(&hwspinlock_tree, id); in hwspin_lock_request_specific()
794 if (!hwlock) { in hwspin_lock_request_specific()
800 WARN_ON(hwlock_to_id(hwlock) != id); in hwspin_lock_request_specific()
806 hwlock = NULL; in hwspin_lock_request_specific()
811 ret = __hwspin_lock_request(hwlock); in hwspin_lock_request_specific()
813 hwlock = NULL; in hwspin_lock_request_specific()
817 return hwlock; in hwspin_lock_request_specific()
833 int hwspin_lock_free(struct hwspinlock *hwlock) in hwspin_lock_free() argument
839 if (!hwlock) { in hwspin_lock_free()
844 dev = hwlock->bank->dev; in hwspin_lock_free()
848 ret = radix_tree_tag_get(&hwspinlock_tree, hwlock_to_id(hwlock), in hwspin_lock_free()
861 tmp = radix_tree_tag_set(&hwspinlock_tree, hwlock_to_id(hwlock), in hwspin_lock_free()
865 WARN_ON(tmp != hwlock); in hwspin_lock_free()
877 struct hwspinlock **hwlock = res; in devm_hwspin_lock_match() local
879 if (WARN_ON(!hwlock || !*hwlock)) in devm_hwspin_lock_match()
882 return *hwlock == data; in devm_hwspin_lock_match()
903 int devm_hwspin_lock_free(struct device *dev, struct hwspinlock *hwlock) in devm_hwspin_lock_free() argument
908 devm_hwspin_lock_match, hwlock); in devm_hwspin_lock_free()
931 struct hwspinlock **ptr, *hwlock; in devm_hwspin_lock_request() local
937 hwlock = hwspin_lock_request(); in devm_hwspin_lock_request()
938 if (hwlock) { in devm_hwspin_lock_request()
939 *ptr = hwlock; in devm_hwspin_lock_request()
945 return hwlock; in devm_hwspin_lock_request()
967 struct hwspinlock **ptr, *hwlock; in devm_hwspin_lock_request_specific() local
973 hwlock = hwspin_lock_request_specific(id); in devm_hwspin_lock_request_specific()
974 if (hwlock) { in devm_hwspin_lock_request_specific()
975 *ptr = hwlock; in devm_hwspin_lock_request_specific()
981 return hwlock; in devm_hwspin_lock_request_specific()