Author: mav
Date: Fri Jun  5 02:21:46 2020
New Revision: 361816
URL: https://svnweb.freebsd.org/changeset/base/361816

Log:
  Limit AHCI to only one MSI if more is not needed.
  
  My AMD Ryzen system has 4 AHCI controllers, each supporting 16 MSI vectors.
  Since two of the controllers have only one SATA port, limit to single MSI
  saves system 30 interrupt vectors for free.
  
  It may be possible to also limit number of MSI vectors to 4 and 8 for the
  other two controllers, but according to the AHCI specification after that
  controllers may revert to only one vector, that would be a bigger loss to
  risk.
  
  MFC after:    2 weeks

Modified:
  head/sys/dev/ahci/ahci_pci.c

Modified: head/sys/dev/ahci/ahci_pci.c
==============================================================================
--- head/sys/dev/ahci/ahci_pci.c        Fri Jun  5 01:44:33 2020        
(r361815)
+++ head/sys/dev/ahci/ahci_pci.c        Fri Jun  5 02:21:46 2020        
(r361816)
@@ -470,6 +470,7 @@ ahci_pci_attach(device_t dev)
        uint8_t revid = pci_get_revid(dev);
        int msi_count, msix_count;
        uint8_t table_bar = 0, pba_bar = 0;
+       uint32_t caps, pi;
 
        msi_count = pci_msi_count(dev);
        msix_count = pci_msix_count(dev);
@@ -604,9 +605,12 @@ ahci_pci_attach(device_t dev)
 
        /* Setup MSI register parameters */
        /* Process hints. */
+       caps = ATA_INL(ctlr->r_mem, AHCI_CAP);
+       pi = ATA_INL(ctlr->r_mem, AHCI_PI);
        if (ctlr->quirks & AHCI_Q_NOMSI)
                ctlr->msi = 0;
-       else if (ctlr->quirks & AHCI_Q_1MSI)
+       else if ((ctlr->quirks & AHCI_Q_1MSI) ||
+           ((caps & (AHCI_CAP_NPMASK | AHCI_CAP_CCCS)) == 0 && pi == 1))
                ctlr->msi = 1;
        else
                ctlr->msi = 2;
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to