git: b658158e9396 - main - ahci: Don't fail attach if the MSI-X BARs cannot be allocated

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Mon, 06 Oct 2025 17:57:03 UTC
The branch main has been updated by jhb:

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

commit b658158e9396848d3963e9555d356d0f4ca6900a
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2025-10-06 17:56:47 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2025-10-06 17:56:47 +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
---
 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 80547d178cd6..2b4cb37275a6 100644
--- a/sys/dev/ahci/ahci_pci.c
+++ b/sys/dev/ahci/ahci_pci.c
@@ -576,8 +576,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;
 			}
 		}
 
@@ -592,12 +592,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) {