git: 07f4fa7a0db9 - stable/14 - ahci: Don't fail attach if the MSI-X BARs cannot be allocated

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Fri, 10 Oct 2025 21:05:15 UTC
The branch stable/14 has been updated by jhb:

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

commit 07f4fa7a0db931c47cc78c711e05d5d51a4e2448
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2025-10-06 17:56:47 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2025-10-10 21:04:35 +0000

    ahci: Don't fail attach if the MSI-X BARs cannot be allocated
    
    If the MSI-X table and/or PBA live in separate BAR(s) and those BAR(s)
    cannot be allocated, fall back to using MSI or INTx instead of failing
    attach.
    
    PR:             289748
    Reported by:    Vitalij Satanivskij <satan@Ukr.net>
    Reviewed by:    avg, imp
    Differential Revision:  https://reviews.freebsd.org/D52889
    
    (cherry picked from commit b658158e9396848d3963e9555d356d0f4ca6900a)
---
 sys/dev/ahci/ahci_pci.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sys/dev/ahci/ahci_pci.c b/sys/dev/ahci/ahci_pci.c
index a460ed32b103..3de1f6a79ef5 100644
--- a/sys/dev/ahci/ahci_pci.c
+++ b/sys/dev/ahci/ahci_pci.c
@@ -573,8 +573,8 @@ ahci_pci_attach(device_t dev)
 			ctlr->r_msix_table = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
 			    &ctlr->r_msix_tab_rid, RF_ACTIVE);
 			if (ctlr->r_msix_table == NULL) {
-				ahci_free_mem(dev);
-				return (ENXIO);
+				msix_count = 0;
+				goto no_msix;
 			}
 		}
 
@@ -589,12 +589,12 @@ ahci_pci_attach(device_t dev)
 			ctlr->r_msix_pba = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
 			    &ctlr->r_msix_pba_rid, RF_ACTIVE);
 			if (ctlr->r_msix_pba == NULL) {
-				ahci_free_mem(dev);
-				return (ENXIO);
+				msix_count = 0;
 			}
 		}
 	}
 
+no_msix:
 	pci_enable_busmaster(dev);
 	/* Reset controller */
 	if ((error = ahci_pci_ctlr_reset(dev)) != 0) {