Skip to content

Commit ef50cd5

Browse files
Xu QiangMarc Zyngier
authored andcommitted
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
1 parent 6f194c9 commit ef50cd5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

kernel/irq/irqdomain.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, unsigned int s
147147
static atomic_t unknown_domains;
148148

149149
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))))
151152
return NULL;
152153

153154
domain = kzalloc_node(struct_size(domain, revmap, size),
@@ -219,7 +220,6 @@ struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, unsigned int s
219220
domain->hwirq_max = hwirq_max;
220221

221222
if (direct_max) {
222-
size = direct_max;
223223
domain->flags |= IRQ_DOMAIN_FLAG_NO_MAP;
224224
}
225225

@@ -650,9 +650,9 @@ unsigned int irq_create_direct_mapping(struct irq_domain *domain)
650650
pr_debug("create_direct virq allocation failed\n");
651651
return 0;
652652
}
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);
656656
irq_free_desc(virq);
657657
return 0;
658658
}
@@ -906,7 +906,7 @@ struct irq_desc *__irq_resolve_mapping(struct irq_domain *domain,
906906
return desc;
907907

908908
if (irq_domain_is_nomap(domain)) {
909-
if (hwirq < domain->revmap_size) {
909+
if (hwirq < domain->hwirq_max) {
910910
data = irq_domain_get_irq_data(domain, hwirq);
911911
if (data && data->hwirq == hwirq)
912912
desc = irq_data_to_desc(data);

0 commit comments

Comments
 (0)