git: 9beb195fd9fd - main - Continue searching for an irq map from the start

From: Andrew Turner <andrew_at_FreeBSD.org>
Date: Wed, 28 Jun 2023 17:03:34 UTC
The branch main has been updated by andrew:

URL: https://cgit.FreeBSD.org/src/commit/?id=9beb195fd9fdc4beb7d5bca865cf5b19ccd7449b

commit 9beb195fd9fdc4beb7d5bca865cf5b19ccd7449b
Author:     Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2023-06-27 08:32:12 +0000
Commit:     Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2023-06-28 17:03:08 +0000

    Continue searching for an irq map from the start
    
    When searching for a free irq map location continue the search from the
    beginning of the list. There may be holes in the map before
    irq_map_first_free_idx, e.g. when removing an entries in order will
    increase the index past the current free entry.
    
    PR:             271990
    Reviewed by:    mhorne
    Sponsored by:   Arm Ltd
    
    Differential Revision:  https://reviews.freebsd.org/D40768
---
 sys/kern/subr_intr.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/sys/kern/subr_intr.c b/sys/kern/subr_intr.c
index 5c7c99f458c1..ab882209c1e3 100644
--- a/sys/kern/subr_intr.c
+++ b/sys/kern/subr_intr.c
@@ -1720,6 +1720,14 @@ intr_map_irq(device_t dev, intptr_t xref, struct intr_map_data *data)
 			return (i);
 		}
 	}
+	for (i = 0; i < irq_map_first_free_idx; i++) {
+		if (irq_map[i] == NULL) {
+			irq_map[i] = entry;
+			irq_map_first_free_idx = i + 1;
+			mtx_unlock(&irq_map_lock);
+			return (i);
+		}
+	}
 	mtx_unlock(&irq_map_lock);
 
 	/* XXX Expand irq_map table */