Lines Matching +full:attr +full:- +full:cnt +full:- +full:name

1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 1992, 1998-2006 Linus Torvalds, Ingo Molnar
4 * Copyright (C) 2005-2006, Thomas Gleixner, Russell King
7 * information is available in Documentation/core-api/genericirq.rst
22 * lockdep: we want to handle all irq_desc locks as a single lock-class:
56 if (!zalloc_cpumask_var_node(&desc->irq_common_data.affinity, in alloc_masks()
58 return -ENOMEM; in alloc_masks()
61 if (!zalloc_cpumask_var_node(&desc->irq_common_data.effective_affinity, in alloc_masks()
63 free_cpumask_var(desc->irq_common_data.affinity); in alloc_masks()
64 return -ENOMEM; in alloc_masks()
69 if (!zalloc_cpumask_var_node(&desc->pending_mask, GFP_KERNEL, node)) { in alloc_masks()
71 free_cpumask_var(desc->irq_common_data.effective_affinity); in alloc_masks()
73 free_cpumask_var(desc->irq_common_data.affinity); in alloc_masks()
74 return -ENOMEM; in alloc_masks()
85 cpumask_copy(desc->irq_common_data.affinity, affinity); in desc_smp_init()
88 cpumask_clear(desc->pending_mask); in desc_smp_init()
91 desc->irq_common_data.node = node; in desc_smp_init()
107 desc->irq_common_data.handler_data = NULL; in desc_set_defaults()
108 desc->irq_common_data.msi_desc = NULL; in desc_set_defaults()
110 desc->irq_data.common = &desc->irq_common_data; in desc_set_defaults()
111 desc->irq_data.irq = irq; in desc_set_defaults()
112 desc->irq_data.chip = &no_irq_chip; in desc_set_defaults()
113 desc->irq_data.chip_data = NULL; in desc_set_defaults()
115 irqd_set(&desc->irq_data, IRQD_IRQ_DISABLED); in desc_set_defaults()
116 irqd_set(&desc->irq_data, IRQD_IRQ_MASKED); in desc_set_defaults()
117 desc->handle_irq = handle_bad_irq; in desc_set_defaults()
118 desc->depth = 1; in desc_set_defaults()
119 desc->irq_count = 0; in desc_set_defaults()
120 desc->irqs_unhandled = 0; in desc_set_defaults()
121 desc->tot_count = 0; in desc_set_defaults()
122 desc->name = NULL; in desc_set_defaults()
123 desc->owner = owner; in desc_set_defaults()
125 *per_cpu_ptr(desc->kstat_irqs, cpu) = 0; in desc_set_defaults()
139 static int irq_find_free_area(unsigned int from, unsigned int cnt) in irq_find_free_area() argument
143 if (mas_empty_area(&mas, from, MAX_SPARSE_IRQS, cnt)) in irq_find_free_area()
144 return -ENOSPC; in irq_find_free_area()
182 struct kobj_attribute *attr, char *buf) in per_cpu_count_show() argument
192 ret += scnprintf(buf + ret, PAGE_SIZE - ret, "%s%u", p, c); in per_cpu_count_show()
196 ret += scnprintf(buf + ret, PAGE_SIZE - ret, "\n"); in per_cpu_count_show()
202 struct kobj_attribute *attr, char *buf) in chip_name_show() argument
207 raw_spin_lock_irq(&desc->lock); in chip_name_show()
208 if (desc->irq_data.chip && desc->irq_data.chip->name) { in chip_name_show()
210 desc->irq_data.chip->name); in chip_name_show()
212 raw_spin_unlock_irq(&desc->lock); in chip_name_show()
219 struct kobj_attribute *attr, char *buf) in hwirq_show() argument
224 raw_spin_lock_irq(&desc->lock); in hwirq_show()
225 if (desc->irq_data.domain) in hwirq_show()
226 ret = sprintf(buf, "%lu\n", desc->irq_data.hwirq); in hwirq_show()
227 raw_spin_unlock_irq(&desc->lock); in hwirq_show()
234 struct kobj_attribute *attr, char *buf) in type_show() argument
239 raw_spin_lock_irq(&desc->lock); in type_show()
241 irqd_is_level_type(&desc->irq_data) ? "level" : "edge"); in type_show()
242 raw_spin_unlock_irq(&desc->lock); in type_show()
250 struct kobj_attribute *attr, char *buf) in wakeup_show() argument
255 raw_spin_lock_irq(&desc->lock); in wakeup_show()
257 irqd_is_wakeup_set(&desc->irq_data) ? "enabled" : "disabled"); in wakeup_show()
258 raw_spin_unlock_irq(&desc->lock); in wakeup_show()
266 struct kobj_attribute *attr, char *buf) in name_show() argument
271 raw_spin_lock_irq(&desc->lock); in name_show()
272 if (desc->name) in name_show()
273 ret = scnprintf(buf, PAGE_SIZE, "%s\n", desc->name); in name_show()
274 raw_spin_unlock_irq(&desc->lock); in name_show()
278 IRQ_ATTR_RO(name);
281 struct kobj_attribute *attr, char *buf) in actions_show() argument
288 raw_spin_lock_irq(&desc->lock); in actions_show()
290 ret += scnprintf(buf + ret, PAGE_SIZE - ret, "%s%s", in actions_show()
291 p, action->name); in actions_show()
294 raw_spin_unlock_irq(&desc->lock); in actions_show()
297 ret += scnprintf(buf + ret, PAGE_SIZE - ret, "\n"); in actions_show()
304 &per_cpu_count_attr.attr,
305 &chip_name_attr.attr,
306 &hwirq_attr.attr,
307 &type_attr.attr,
308 &wakeup_attr.attr,
309 &name_attr.attr,
310 &actions_attr.attr,
329 if (kobject_add(&desc->kobj, irq_kobj_base, "%d", irq)) in irq_sysfs_add()
332 desc->istate |= IRQS_SYSFS; in irq_sysfs_add()
344 if (desc->istate & IRQS_SYSFS) in irq_sysfs_del()
345 kobject_del(&desc->kobj); in irq_sysfs_del()
359 return -ENOMEM; in irq_sysfs_init()
394 free_cpumask_var(desc->pending_mask); in free_masks()
396 free_cpumask_var(desc->irq_common_data.affinity); in free_masks()
398 free_cpumask_var(desc->irq_common_data.effective_affinity); in free_masks()
425 desc->kstat_irqs = alloc_percpu(unsigned int); in alloc_desc()
426 if (!desc->kstat_irqs) in alloc_desc()
432 raw_spin_lock_init(&desc->lock); in alloc_desc()
433 lockdep_set_class(&desc->lock, &irq_desc_lock_class); in alloc_desc()
434 mutex_init(&desc->request_mutex); in alloc_desc()
435 init_rcu_head(&desc->rcu); in alloc_desc()
436 init_waitqueue_head(&desc->wait_for_threads); in alloc_desc()
439 irqd_set(&desc->irq_data, flags); in alloc_desc()
440 kobject_init(&desc->kobj, &irq_kobj_type); in alloc_desc()
446 free_percpu(desc->kstat_irqs); in alloc_desc()
457 free_percpu(desc->kstat_irqs); in irq_kobj_release()
465 kobject_put(&desc->kobj); in delayed_free_desc()
493 call_rcu(&desc->rcu, delayed_free_desc); in free_desc()
496 static int alloc_descs(unsigned int start, unsigned int cnt, int node, in alloc_descs() argument
505 for (i = 0; i < cnt; i++) { in alloc_descs()
507 return -EINVAL; in alloc_descs()
511 for (i = 0; i < cnt; i++) { in alloc_descs()
516 if (affinity->is_managed) { in alloc_descs()
521 mask = &affinity->mask; in alloc_descs()
536 for (i--; i >= 0; i--) in alloc_descs()
538 return -ENOMEM; in alloc_descs()
544 return -ENOMEM; in irq_expand_nr_irqs()
580 [0 ... NR_IRQS-1] = {
583 .lock = __RAW_SPIN_LOCK_UNLOCKED(irq_desc->lock),
623 raw_spin_lock_irqsave(&desc->lock, flags); in free_desc()
625 raw_spin_unlock_irqrestore(&desc->lock, flags); in free_desc()
629 static inline int alloc_descs(unsigned int start, unsigned int cnt, int node, in alloc_descs() argument
635 for (i = 0; i < cnt; i++) { in alloc_descs()
638 desc->owner = owner; in alloc_descs()
646 return -ENOMEM; in irq_expand_nr_irqs()
670 return -EINVAL; in handle_irq_desc()
674 return -EPERM; in handle_irq_desc()
681 * generic_handle_irq - Invoke the handler for a particular irq
684 * Returns: 0 on success, or -EINVAL if conversion has failed
696 * generic_handle_irq_safe - Invoke the handler for a particular irq from any
704 * marked to enforce IRQ-context only.
720 * generic_handle_domain_irq - Invoke the handler for a HW irq belonging
725 * Returns: 0 on success, or -EINVAL if conversion has failed
737 * generic_handle_irq_safe - Invoke the handler for a HW irq belonging
745 * context). If the interrupt is marked as 'enforce IRQ-context only' then
761 * generic_handle_domain_nmi - Invoke the handler for a HW nmi belonging
766 * Returns: 0 on success, or -EINVAL if conversion has failed
781 * irq_free_descs - free irq descriptors
783 * @cnt: Number of consecutive irqs to free
785 void irq_free_descs(unsigned int from, unsigned int cnt) in irq_free_descs() argument
789 if (from >= nr_irqs || (from + cnt) > nr_irqs) in irq_free_descs()
793 for (i = 0; i < cnt; i++) in irq_free_descs()
801 * __irq_alloc_descs - allocate and initialize a range of irq descriptors
804 * @cnt: Number of consecutive irqs to allocate.
807 * @affinity: Optional pointer to an affinity mask array of size @cnt which
814 __irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node, in __irq_alloc_descs() argument
819 if (!cnt) in __irq_alloc_descs()
820 return -EINVAL; in __irq_alloc_descs()
824 return -EINVAL; in __irq_alloc_descs()
837 start = irq_find_free_area(from, cnt); in __irq_alloc_descs()
838 ret = -EEXIST; in __irq_alloc_descs()
842 if (start + cnt > nr_irqs) { in __irq_alloc_descs()
843 ret = irq_expand_nr_irqs(start + cnt); in __irq_alloc_descs()
847 ret = alloc_descs(start, cnt, node, affinity, owner); in __irq_alloc_descs()
855 * irq_get_next_irq - get next allocated irq number
884 raw_spin_lock_irqsave(&desc->lock, *flags); in __irq_get_desc_lock()
890 __releases(&desc->lock) in __irq_put_desc_unlock()
892 raw_spin_unlock_irqrestore(&desc->lock, flags); in __irq_put_desc_unlock()
903 return -EINVAL; in irq_set_percpu_devid_partition()
905 if (desc->percpu_enabled) in irq_set_percpu_devid_partition()
906 return -EINVAL; in irq_set_percpu_devid_partition()
908 desc->percpu_enabled = kzalloc(sizeof(*desc->percpu_enabled), GFP_KERNEL); in irq_set_percpu_devid_partition()
910 if (!desc->percpu_enabled) in irq_set_percpu_devid_partition()
911 return -ENOMEM; in irq_set_percpu_devid_partition()
914 desc->percpu_affinity = affinity; in irq_set_percpu_devid_partition()
916 desc->percpu_affinity = cpu_possible_mask; in irq_set_percpu_devid_partition()
931 if (!desc || !desc->percpu_enabled) in irq_get_percpu_devid_partition()
932 return -EINVAL; in irq_get_percpu_devid_partition()
935 cpumask_copy(affinity, desc->percpu_affinity); in irq_get_percpu_devid_partition()
947 * kstat_irqs_cpu - Get the statistics for an interrupt on a cpu
959 return desc && desc->kstat_irqs ? in kstat_irqs_cpu()
960 *per_cpu_ptr(desc->kstat_irqs, cpu) : 0; in kstat_irqs_cpu()
965 return desc->istate & IRQS_NMI; in irq_is_nmi()
974 if (!desc || !desc->kstat_irqs) in kstat_irqs()
979 return data_race(desc->tot_count); in kstat_irqs()
982 sum += data_race(*per_cpu_ptr(desc->kstat_irqs, cpu)); in kstat_irqs()
987 * kstat_irqs_usr - Get the statistics for an interrupt from thread context
1013 lockdep_set_class(&desc->lock, lock_class); in __irq_set_lockdep_class()
1014 lockdep_set_class(&desc->request_mutex, request_class); in __irq_set_lockdep_class()