git: 9a92ce22df7c - stable/13 - pci: return 0 for pci_remap_intr_method MSI-X non-error case

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Mon, 21 Aug 2023 00:36:14 UTC
The branch stable/13 has been updated by emaste:

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

commit 9a92ce22df7c746331da63b169db14a817d9abad
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2023-08-14 20:35:34 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2023-08-21 00:35:45 +0000

    pci: return 0 for pci_remap_intr_method MSI-X non-error case
    
    When remapping a MSI-X vector, we would always return ENOENT, even if
    successful.  This didn't really matter, as the sole caller of
    BUS_REMAP_INTR also didn't check for errors.
    
    Return 0 if there's no error, so that we can start handling (or at least
    warning about) actual failures.
    
    Reviewed by:    jhb
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D41449
    
    (cherry picked from commit 43e545e8e016d22346a4fe278ea2570328b20cc1)
---
 sys/dev/pci/pci.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c
index 065b7080f206..15bb76377f40 100644
--- a/sys/dev/pci/pci.c
+++ b/sys/dev/pci/pci.c
@@ -2466,6 +2466,8 @@ pci_remap_intr_method(device_t bus, device_t dev, u_int irq)
 	 * through all the slots that use this IRQ and update them.
 	 */
 	if (cfg->msix.msix_alloc > 0) {
+		bool found = false;
+
 		for (i = 0; i < cfg->msix.msix_alloc; i++) {
 			mv = &cfg->msix.msix_vectors[i];
 			if (mv->mv_irq == irq) {
@@ -2485,9 +2487,10 @@ pci_remap_intr_method(device_t bus, device_t dev, u_int irq)
 					pci_enable_msix(dev, j, addr, data);
 					pci_unmask_msix(dev, j);
 				}
+				found = true;
 			}
 		}
-		return (ENOENT);
+		return (found ? 0 : ENOENT);
 	}
 
 	return (ENOENT);