Lines Matching refs:hwlock

87 int __hwspin_trylock(struct hwspinlock *hwlock, int mode, unsigned long *flags)  in __hwspin_trylock()  argument
91 BUG_ON(!hwlock); in __hwspin_trylock()
109 ret = spin_trylock_irqsave(&hwlock->lock, *flags); in __hwspin_trylock()
112 ret = spin_trylock_irq(&hwlock->lock); in __hwspin_trylock()
118 ret = spin_trylock(&hwlock->lock); in __hwspin_trylock()
127 ret = hwlock->bank->ops->trylock(hwlock); in __hwspin_trylock()
133 spin_unlock_irqrestore(&hwlock->lock, *flags); in __hwspin_trylock()
136 spin_unlock_irq(&hwlock->lock); in __hwspin_trylock()
142 spin_unlock(&hwlock->lock); in __hwspin_trylock()
197 int __hwspin_lock_timeout(struct hwspinlock *hwlock, unsigned int to, in __hwspin_lock_timeout() argument
207 ret = __hwspin_trylock(hwlock, mode, flags); in __hwspin_lock_timeout()
222 if (hwlock->bank->ops->relax) in __hwspin_lock_timeout()
223 hwlock->bank->ops->relax(hwlock); in __hwspin_lock_timeout()
249 void __hwspin_unlock(struct hwspinlock *hwlock, int mode, unsigned long *flags) in __hwspin_unlock() argument
251 BUG_ON(!hwlock); in __hwspin_unlock()
268 hwlock->bank->ops->unlock(hwlock); in __hwspin_unlock()
273 spin_unlock_irqrestore(&hwlock->lock, *flags); in __hwspin_unlock()
276 spin_unlock_irq(&hwlock->lock); in __hwspin_unlock()
282 spin_unlock(&hwlock->lock); in __hwspin_unlock()
325 struct hwspinlock *hwlock; in of_hwspin_lock_get_id() local
340 hwlock = radix_tree_deref_slot(slot); in of_hwspin_lock_get_id()
341 if (unlikely(!hwlock)) in of_hwspin_lock_get_id()
343 if (radix_tree_deref_retry(hwlock)) { in of_hwspin_lock_get_id()
348 if (hwlock->bank->dev->of_node == args.np) { in of_hwspin_lock_get_id()
358 if (id < 0 || id >= hwlock->bank->num_locks) { in of_hwspin_lock_get_id()
362 id += hwlock->bank->base_id; in of_hwspin_lock_get_id()
399 static int hwspin_lock_register_single(struct hwspinlock *hwlock, int id) in hwspin_lock_register_single() argument
406 ret = radix_tree_insert(&hwspinlock_tree, id, hwlock); in hwspin_lock_register_single()
417 WARN_ON(tmp != hwlock); in hwspin_lock_register_single()
426 struct hwspinlock *hwlock = NULL; in hwspin_lock_unregister_single() local
438 hwlock = radix_tree_delete(&hwspinlock_tree, id); in hwspin_lock_unregister_single()
439 if (!hwlock) { in hwspin_lock_unregister_single()
446 return hwlock; in hwspin_lock_unregister_single()
467 struct hwspinlock *hwlock; in hwspin_lock_register() local
482 hwlock = &bank->lock[i]; in hwspin_lock_register()
484 spin_lock_init(&hwlock->lock); in hwspin_lock_register()
485 hwlock->bank = bank; in hwspin_lock_register()
487 ret = hwspin_lock_register_single(hwlock, base_id + i); in hwspin_lock_register()
514 struct hwspinlock *hwlock, *tmp; in hwspin_lock_unregister() local
518 hwlock = &bank->lock[i]; in hwspin_lock_unregister()
525 WARN_ON(tmp != hwlock); in hwspin_lock_unregister()
624 static int __hwspin_lock_request(struct hwspinlock *hwlock) in __hwspin_lock_request() argument
626 struct device *dev = hwlock->bank->dev; in __hwspin_lock_request()
646 tmp = radix_tree_tag_clear(&hwspinlock_tree, hwlock_to_id(hwlock), in __hwspin_lock_request()
650 WARN_ON(tmp != hwlock); in __hwspin_lock_request()
661 int hwspin_lock_get_id(struct hwspinlock *hwlock) in hwspin_lock_get_id() argument
663 if (!hwlock) { in hwspin_lock_get_id()
668 return hwlock_to_id(hwlock); in hwspin_lock_get_id()
687 struct hwspinlock *hwlock; in hwspin_lock_request() local
693 ret = radix_tree_gang_lookup_tag(&hwspinlock_tree, (void **)&hwlock, in hwspin_lock_request()
697 hwlock = NULL; in hwspin_lock_request()
705 ret = __hwspin_lock_request(hwlock); in hwspin_lock_request()
707 hwlock = NULL; in hwspin_lock_request()
711 return hwlock; in hwspin_lock_request()
730 struct hwspinlock *hwlock; in hwspin_lock_request_specific() local
736 hwlock = radix_tree_lookup(&hwspinlock_tree, id); in hwspin_lock_request_specific()
737 if (!hwlock) { in hwspin_lock_request_specific()
743 WARN_ON(hwlock_to_id(hwlock) != id); in hwspin_lock_request_specific()
749 hwlock = NULL; in hwspin_lock_request_specific()
754 ret = __hwspin_lock_request(hwlock); in hwspin_lock_request_specific()
756 hwlock = NULL; in hwspin_lock_request_specific()
760 return hwlock; in hwspin_lock_request_specific()
776 int hwspin_lock_free(struct hwspinlock *hwlock) in hwspin_lock_free() argument
782 if (!hwlock) { in hwspin_lock_free()
787 dev = hwlock->bank->dev; in hwspin_lock_free()
791 ret = radix_tree_tag_get(&hwspinlock_tree, hwlock_to_id(hwlock), in hwspin_lock_free()
806 tmp = radix_tree_tag_set(&hwspinlock_tree, hwlock_to_id(hwlock), in hwspin_lock_free()
810 WARN_ON(tmp != hwlock); in hwspin_lock_free()
822 struct hwspinlock **hwlock = res; in devm_hwspin_lock_match() local
824 if (WARN_ON(!hwlock || !*hwlock)) in devm_hwspin_lock_match()
827 return *hwlock == data; in devm_hwspin_lock_match()
848 int devm_hwspin_lock_free(struct device *dev, struct hwspinlock *hwlock) in devm_hwspin_lock_free() argument
853 devm_hwspin_lock_match, hwlock); in devm_hwspin_lock_free()
876 struct hwspinlock **ptr, *hwlock; in devm_hwspin_lock_request() local
882 hwlock = hwspin_lock_request(); in devm_hwspin_lock_request()
883 if (hwlock) { in devm_hwspin_lock_request()
884 *ptr = hwlock; in devm_hwspin_lock_request()
890 return hwlock; in devm_hwspin_lock_request()
912 struct hwspinlock **ptr, *hwlock; in devm_hwspin_lock_request_specific() local
918 hwlock = hwspin_lock_request_specific(id); in devm_hwspin_lock_request_specific()
919 if (hwlock) { in devm_hwspin_lock_request_specific()
920 *ptr = hwlock; in devm_hwspin_lock_request_specific()
926 return hwlock; in devm_hwspin_lock_request_specific()