git: a3ccd06dd965 - stable/13 - intrng: Releasing interrupt source should clear interrupt table full state.

From: Michal Meloun <mmel_at_FreeBSD.org>
Date: Thu, 20 Jan 2022 10:09:39 UTC
The branch stable/13 has been updated by mmel:

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

commit a3ccd06dd96530022d56ed59e5929874966b6ba7
Author:     Michal Meloun <mmel@FreeBSD.org>
AuthorDate: 2021-07-02 18:17:36 +0000
Commit:     Michal Meloun <mmel@FreeBSD.org>
CommitDate: 2022-01-20 10:07:44 +0000

    intrng: Releasing interrupt source should clear interrupt table full state.
    
    The first release of an interrupt in a situation where the interrupt table
    is full should schedule a full table check the next time an interrupt is
    allocated. A full check is necessary to ensure maximum separation between
    the order of allocation and the order of release.
    
    Submitted by:   ehem_freebsd@m5p.com (initial version)
    Discussed in:   https://reviews.freebsd.org/D29310
    MFC after:      4 weeks
    
    (cherry picked from commit a49f208d94b873b2187adbfe1d785b3bc8bdc598)
---
 sys/kern/subr_intr.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/sys/kern/subr_intr.c b/sys/kern/subr_intr.c
index df6bf9e63ba0..d4926b2e2364 100644
--- a/sys/kern/subr_intr.c
+++ b/sys/kern/subr_intr.c
@@ -447,6 +447,16 @@ isrc_free_irq(struct intr_irqsrc *isrc)
 
 	irq_sources[isrc->isrc_irq] = NULL;
 	isrc->isrc_irq = INTR_IRQ_INVALID;	/* just to be safe */
+
+	/*
+	 * If we are recovering from the state irq_sources table is full,
+	 * then the following allocation should check the entire table. This
+	 * will ensure maximum separation of allocation order from release
+	 * order.
+	 */
+	if (irq_next_free >= intr_nirq)
+		irq_next_free = 0;
+
 	return (0);
 }