Skip to content

Commit 2d44168

Browse files
Milton Millerozbenh
authored andcommitted
powerpc: Return early if irq_host lookup type is wrong
If for some reason the code incrorectly calls the wrong function to manage the revmap, not only should we warn, we should take action. However, in the paths we expect to be taken every delivered interrupt change to WARN_ON_ONCE. Use the if (WARN_ON(x)) format to get the unlikely for free. Signed-off-by: Milton Miller <miltonm@bga.com> Reviewed-by: Grant Likely <grant.likely@secretlab.ca> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
1 parent 3af259d commit 2d44168

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

‎arch/powerpc/kernel/irq.c‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -814,8 +814,7 @@ void irq_dispose_mapping(unsigned int virq)
814814
return;
815815

816816
host = irq_map[virq].host;
817-
WARN_ON (host == NULL);
818-
if (host == NULL)
817+
if (WARN_ON(host == NULL))
819818
return;
820819

821820
/* Never unmap legacy interrupts */
@@ -898,7 +897,8 @@ unsigned int irq_radix_revmap_lookup(struct irq_host *host,
898897
struct irq_map_entry *ptr;
899898
unsigned int virq;
900899

901-
WARN_ON(host->revmap_type != IRQ_HOST_MAP_TREE);
900+
if (WARN_ON_ONCE(host->revmap_type != IRQ_HOST_MAP_TREE))
901+
return irq_find_mapping(host, hwirq);
902902

903903
/*
904904
* No rcu_read_lock(ing) needed, the ptr returned can't go under us
@@ -922,7 +922,8 @@ unsigned int irq_radix_revmap_lookup(struct irq_host *host,
922922
void irq_radix_revmap_insert(struct irq_host *host, unsigned int virq,
923923
irq_hw_number_t hwirq)
924924
{
925-
WARN_ON(host->revmap_type != IRQ_HOST_MAP_TREE);
925+
if (WARN_ON(host->revmap_type != IRQ_HOST_MAP_TREE))
926+
return;
926927

927928
if (virq != NO_IRQ) {
928929
mutex_lock(&revmap_trees_mutex);
@@ -937,7 +938,8 @@ unsigned int irq_linear_revmap(struct irq_host *host,
937938
{
938939
unsigned int *revmap;
939940

940-
WARN_ON(host->revmap_type != IRQ_HOST_MAP_LINEAR);
941+
if (WARN_ON_ONCE(host->revmap_type != IRQ_HOST_MAP_LINEAR))
942+
return irq_find_mapping(host, hwirq);
941943

942944
/* Check revmap bounds */
943945
if (unlikely(hwirq >= host->revmap_data.linear.size))

0 commit comments

Comments
 (0)