Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 13 Nov 2018 18:49:43 +0000 (UTC)
From:      Scott Long <scottl@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r340403 - in stable/11/sys/dev: mpr mps
Message-ID:  <201811131849.wADInhkw035752@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: scottl
Date: Tue Nov 13 18:49:43 2018
New Revision: 340403
URL: https://svnweb.freebsd.org/changeset/base/340403

Log:
  Fix a regression from prior to 11.2 that caused MSI (not MSI-X) interrupt
  allocation to fail.  While here, refactor the code so that it's more clear
  and less likely to break in the future.  This is not an MFC due to the code
  in 12/head being very different, but it follows the latter's structure
  more closely than before.
  
  Reported by:	Harry Schmalzbauer

Modified:
  stable/11/sys/dev/mpr/mpr_pci.c
  stable/11/sys/dev/mps/mps_pci.c

Modified: stable/11/sys/dev/mpr/mpr_pci.c
==============================================================================
--- stable/11/sys/dev/mpr/mpr_pci.c	Tue Nov 13 18:40:01 2018	(r340402)
+++ stable/11/sys/dev/mpr/mpr_pci.c	Tue Nov 13 18:49:43 2018	(r340403)
@@ -262,12 +262,16 @@ mpr_pci_alloc_interrupts(struct mpr_softc *sc)
 	error = 0;
 	msgs = 0;
 
-	if ((sc->disable_msix == 0) &&
-	    ((msgs = pci_msix_count(dev)) >= MPR_MSI_COUNT))
-		error = mpr_alloc_msix(sc, MPR_MSI_COUNT);
-	if ((error != 0) && (sc->disable_msi == 0) &&
-	    ((msgs = pci_msi_count(dev)) >= MPR_MSI_COUNT))
-		error = mpr_alloc_msi(sc, MPR_MSI_COUNT);
+	if (sc->disable_msix == 0) {
+		msgs = pci_msix_count(dev);
+		if (msgs >= MPR_MSI_COUNT)
+			error = mpr_alloc_msix(sc, MPR_MSI_COUNT);
+	}
+	if (((error != 0) || (msgs == 0)) && (sc->disable_msi == 0)) {
+		msgs = pci_msi_count(dev);
+		if (msgs >= MPR_MSI_COUNT)
+			error = mpr_alloc_msi(sc, MPR_MSI_COUNT);
+	}
 	if (error != 0)
 		msgs = 0;
 

Modified: stable/11/sys/dev/mps/mps_pci.c
==============================================================================
--- stable/11/sys/dev/mps/mps_pci.c	Tue Nov 13 18:40:01 2018	(r340402)
+++ stable/11/sys/dev/mps/mps_pci.c	Tue Nov 13 18:49:43 2018	(r340403)
@@ -247,12 +247,16 @@ mps_pci_alloc_interrupts(struct mps_softc *sc)
 	error = 0;
 	msgs = 0;
 
-	if ((sc->disable_msix == 0) &&
-	    ((msgs = pci_msix_count(dev)) >= MPS_MSI_COUNT))
-		error = mps_alloc_msix(sc, MPS_MSI_COUNT);
-	if ((error != 0) && (sc->disable_msi == 0) &&
-	    ((msgs = pci_msi_count(dev)) >= MPS_MSI_COUNT))
-		error = mps_alloc_msi(sc, MPS_MSI_COUNT);
+	if (sc->disable_msix == 0) {
+		msgs = pci_msix_count(dev);
+		if (msgs >= MPS_MSI_COUNT)
+			error = mps_alloc_msix(sc, MPS_MSI_COUNT);
+	}
+	if (((error != 0) || (msgs == 0)) && (sc->disable_msi == 0)) {
+		msgs = pci_msi_count(dev);
+		if (msgs >= MPS_MSI_COUNT)
+			error = mps_alloc_msi(sc, MPS_MSI_COUNT);
+	}
 	if (error != 0)
 		msgs = 0;
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201811131849.wADInhkw035752>