git: 32c301922dc1 - main - ena: Limit IO IRQ setup loop to active queues only

From: Arthur Kiyanovski <akiyano_at_FreeBSD.org>
Date: Thu, 29 Oct 2026 03:29:34 UTC
The branch main has been updated by akiyano:

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

commit 32c301922dc1e6f52bdd043046661ac1e2b462d8
Author:     Gilad Ben Yakov <giladben@amazon.com>
AuthorDate: 2026-04-29 12:10:38 +0000
Commit:     Arthur Kiyanovski <akiyano@FreeBSD.org>
CommitDate: 2026-10-29 03:25:50 +0000

    ena: Limit IO IRQ setup loop to active queues only
    
    The loop in ena_request_io_irq() iterated over adapter->msix_vecs,
    which reflects the maximum number of MSI-X vectors allocated at
    init time. When the number of IO queues is reduced at runtime via
    the io_queues_nb sysctl, msix_vecs is not updated, causing the
    driver to bind interrupts and log CPU affinity for queues that no
    longer exist.
    
    Replace the loop bound with ENA_IO_IRQ_IDX(adapter->num_io_queues)
    to iterate only over the currently active IO queues.
    
    Also replace the loop in ena_free_io_irq() the same.
    
    Reviewed by: cperciva
    Fixes: 56d41ad5fe9c ("Add sysctl node for ENA IO queues number adjustment")
    MFC after: 3 days
    Sponsored by: Amazon, Inc.
---
 sys/dev/ena/ena.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/dev/ena/ena.c b/sys/dev/ena/ena.c
index 060d9e26c1cf..b489c58e81e5 100644
--- a/sys/dev/ena/ena.c
+++ b/sys/dev/ena/ena.c
@@ -1939,7 +1939,7 @@ ena_request_io_irq(struct ena_adapter *adapter)
 		flags = RF_ACTIVE | RF_SHAREABLE;
 	}
 
-	for (i = ENA_IO_IRQ_FIRST_IDX; i < adapter->msix_vecs; i++) {
+	for (i = ENA_IO_IRQ_FIRST_IDX; i < ENA_IO_IRQ_IDX(adapter->num_io_queues); i++) {
 		irq = &adapter->irq_tbl[i];
 
 		if (unlikely(irq->requested))
@@ -2053,7 +2053,7 @@ ena_free_io_irq(struct ena_adapter *adapter)
 	struct ena_irq *irq;
 	int rc;
 
-	for (int i = ENA_IO_IRQ_FIRST_IDX; i < adapter->msix_vecs; i++) {
+	for (int i = ENA_IO_IRQ_FIRST_IDX; i < ENA_IO_IRQ_IDX(adapter->num_io_queues); i++) {
 		irq = &adapter->irq_tbl[i];
 		if (irq->requested) {
 			ena_log(pdev, DBG, "tear down irq: %d\n", irq->vector);