Lines Matching refs:hwlock

89 int __hwspin_trylock(struct hwspinlock *hwlock, int mode, unsigned long *flags)  in __hwspin_trylock()  argument
93 BUG_ON(!hwlock); in __hwspin_trylock()
110 ret = spin_trylock_irqsave(&hwlock->lock, *flags); in __hwspin_trylock()
112 ret = spin_trylock_irq(&hwlock->lock); in __hwspin_trylock()
114 ret = spin_trylock(&hwlock->lock); in __hwspin_trylock()
121 ret = hwlock->bank->ops->trylock(hwlock); in __hwspin_trylock()
126 spin_unlock_irqrestore(&hwlock->lock, *flags); in __hwspin_trylock()
128 spin_unlock_irq(&hwlock->lock); in __hwspin_trylock()
130 spin_unlock(&hwlock->lock); in __hwspin_trylock()
178 int __hwspin_lock_timeout(struct hwspinlock *hwlock, unsigned int to, in __hwspin_lock_timeout() argument
188 ret = __hwspin_trylock(hwlock, mode, flags); in __hwspin_lock_timeout()
203 if (hwlock->bank->ops->relax) in __hwspin_lock_timeout()
204 hwlock->bank->ops->relax(hwlock); in __hwspin_lock_timeout()
230 void __hwspin_unlock(struct hwspinlock *hwlock, int mode, unsigned long *flags) in __hwspin_unlock() argument
232 BUG_ON(!hwlock); in __hwspin_unlock()
249 hwlock->bank->ops->unlock(hwlock); in __hwspin_unlock()
253 spin_unlock_irqrestore(&hwlock->lock, *flags); in __hwspin_unlock()
255 spin_unlock_irq(&hwlock->lock); in __hwspin_unlock()
257 spin_unlock(&hwlock->lock); in __hwspin_unlock()
298 struct hwspinlock *hwlock; in of_hwspin_lock_get_id() local
313 hwlock = radix_tree_deref_slot(slot); in of_hwspin_lock_get_id()
314 if (unlikely(!hwlock)) in of_hwspin_lock_get_id()
316 if (radix_tree_is_indirect_ptr(hwlock)) { in of_hwspin_lock_get_id()
321 if (hwlock->bank->dev->of_node == args.np) { in of_hwspin_lock_get_id()
331 if (id < 0 || id >= hwlock->bank->num_locks) { in of_hwspin_lock_get_id()
335 id += hwlock->bank->base_id; in of_hwspin_lock_get_id()
343 static int hwspin_lock_register_single(struct hwspinlock *hwlock, int id) in hwspin_lock_register_single() argument
350 ret = radix_tree_insert(&hwspinlock_tree, id, hwlock); in hwspin_lock_register_single()
361 WARN_ON(tmp != hwlock); in hwspin_lock_register_single()
370 struct hwspinlock *hwlock = NULL; in hwspin_lock_unregister_single() local
382 hwlock = radix_tree_delete(&hwspinlock_tree, id); in hwspin_lock_unregister_single()
383 if (!hwlock) { in hwspin_lock_unregister_single()
390 return hwlock; in hwspin_lock_unregister_single()
411 struct hwspinlock *hwlock; in hwspin_lock_register() local
426 hwlock = &bank->lock[i]; in hwspin_lock_register()
428 spin_lock_init(&hwlock->lock); in hwspin_lock_register()
429 hwlock->bank = bank; in hwspin_lock_register()
431 ret = hwspin_lock_register_single(hwlock, base_id + i); in hwspin_lock_register()
458 struct hwspinlock *hwlock, *tmp; in hwspin_lock_unregister() local
462 hwlock = &bank->lock[i]; in hwspin_lock_unregister()
469 WARN_ON(tmp != hwlock); in hwspin_lock_unregister()
486 static int __hwspin_lock_request(struct hwspinlock *hwlock) in __hwspin_lock_request() argument
488 struct device *dev = hwlock->bank->dev; in __hwspin_lock_request()
508 tmp = radix_tree_tag_clear(&hwspinlock_tree, hwlock_to_id(hwlock), in __hwspin_lock_request()
512 WARN_ON(tmp != hwlock); in __hwspin_lock_request()
523 int hwspin_lock_get_id(struct hwspinlock *hwlock) in hwspin_lock_get_id() argument
525 if (!hwlock) { in hwspin_lock_get_id()
530 return hwlock_to_id(hwlock); in hwspin_lock_get_id()
549 struct hwspinlock *hwlock; in hwspin_lock_request() local
555 ret = radix_tree_gang_lookup_tag(&hwspinlock_tree, (void **)&hwlock, in hwspin_lock_request()
559 hwlock = NULL; in hwspin_lock_request()
567 ret = __hwspin_lock_request(hwlock); in hwspin_lock_request()
569 hwlock = NULL; in hwspin_lock_request()
573 return hwlock; in hwspin_lock_request()
592 struct hwspinlock *hwlock; in hwspin_lock_request_specific() local
598 hwlock = radix_tree_lookup(&hwspinlock_tree, id); in hwspin_lock_request_specific()
599 if (!hwlock) { in hwspin_lock_request_specific()
605 WARN_ON(hwlock_to_id(hwlock) != id); in hwspin_lock_request_specific()
611 hwlock = NULL; in hwspin_lock_request_specific()
616 ret = __hwspin_lock_request(hwlock); in hwspin_lock_request_specific()
618 hwlock = NULL; in hwspin_lock_request_specific()
622 return hwlock; in hwspin_lock_request_specific()
638 int hwspin_lock_free(struct hwspinlock *hwlock) in hwspin_lock_free() argument
644 if (!hwlock) { in hwspin_lock_free()
649 dev = hwlock->bank->dev; in hwspin_lock_free()
653 ret = radix_tree_tag_get(&hwspinlock_tree, hwlock_to_id(hwlock), in hwspin_lock_free()
668 tmp = radix_tree_tag_set(&hwspinlock_tree, hwlock_to_id(hwlock), in hwspin_lock_free()
672 WARN_ON(tmp != hwlock); in hwspin_lock_free()