Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

irqdomain: Use hwirq_max instead of revmap_size for NOMAP domains

NOMAP irq domains use the revmap_size field to indicate the maximum
hwirq number the domain accepts. This is a bit confusing as
revmap_size is usually used to indicate the size of the revmap array,
which a NOMAP domain doesn't have.

Instead, use the hwirq_max field which has the correct semantics, and
keep revmap_size to 0 for a NOMAP domain.

Signed-off-by: Xu Qiang <xuqiang36@huawei.com>
[maz: commit message]
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20220719063641.56541-3-xuqiang36@huawei.com

authored by

Xu Qiang and committed by
Marc Zyngier
ef50cd57 6f194c99

+6 -6
+6 -6
kernel/irq/irqdomain.c
··· 147 147 static atomic_t unknown_domains; 148 148 149 149 if (WARN_ON((size && direct_max) || 150 - (!IS_ENABLED(CONFIG_IRQ_DOMAIN_NOMAP) && direct_max))) 150 + (!IS_ENABLED(CONFIG_IRQ_DOMAIN_NOMAP) && direct_max) || 151 + (direct_max && (direct_max != hwirq_max)))) 151 152 return NULL; 152 153 153 154 domain = kzalloc_node(struct_size(domain, revmap, size), ··· 220 219 domain->hwirq_max = hwirq_max; 221 220 222 221 if (direct_max) { 223 - size = direct_max; 224 222 domain->flags |= IRQ_DOMAIN_FLAG_NO_MAP; 225 223 } 226 224 ··· 650 650 pr_debug("create_direct virq allocation failed\n"); 651 651 return 0; 652 652 } 653 - if (virq >= domain->revmap_size) { 654 - pr_err("ERROR: no free irqs available below %i maximum\n", 655 - domain->revmap_size); 653 + if (virq >= domain->hwirq_max) { 654 + pr_err("ERROR: no free irqs available below %lu maximum\n", 655 + domain->hwirq_max); 656 656 irq_free_desc(virq); 657 657 return 0; 658 658 } ··· 906 906 return desc; 907 907 908 908 if (irq_domain_is_nomap(domain)) { 909 - if (hwirq < domain->revmap_size) { 909 + if (hwirq < domain->hwirq_max) { 910 910 data = irq_domain_get_irq_data(domain, hwirq); 911 911 if (data && data->hwirq == hwirq) 912 912 desc = irq_data_to_desc(data);