svn commit: r342587 - in stable: 10/sys/x86/x86 11/sys/x86/x86 12/sys/x86/x86

John Baldwin jhb at FreeBSD.org
Sat Dec 29 01:19:16 UTC 2018


Author: jhb
Date: Sat Dec 29 01:19:14 2018
New Revision: 342587
URL: https://svnweb.freebsd.org/changeset/base/342587

Log:
  MFC 340441: Revert r332735 and fix MSI-X to properly fail allocations when full.
  
  The off-by-one errors in 332735 weren't actual errors and were
  preventing the last MSI interrupt source from being used.  Instead,
  the issue is that when all MSI interrupt sources were allocated, the
  loop in msix_alloc() would terminate with 'msi' still set to non-null.
  The only check for 'i' overflowing was in the 'msi' == NULL case, so
  msix_alloc() would try to reuse the last MSI interrupt source instead
  of failing.
  
  Fix by moving the check for all sources being in use to just after the
  loop.

Modified:
  stable/11/sys/x86/x86/msi.c
Directory Properties:
  stable/11/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/10/sys/x86/x86/msi.c
  stable/12/sys/x86/x86/msi.c
Directory Properties:
  stable/10/   (props changed)
  stable/12/   (props changed)

Modified: stable/11/sys/x86/x86/msi.c
==============================================================================
--- stable/11/sys/x86/x86/msi.c	Sat Dec 29 00:44:11 2018	(r342586)
+++ stable/11/sys/x86/x86/msi.c	Sat Dec 29 01:19:14 2018	(r342587)
@@ -404,7 +404,7 @@ again:
 	/* Do we need to create some new sources? */
 	if (cnt < count) {
 		/* If we would exceed the max, give up. */
-		if (i + (count - cnt) >= first_msi_irq + NUM_MSI_INTS) {
+		if (i + (count - cnt) > first_msi_irq + NUM_MSI_INTS) {
 			mtx_unlock(&msi_lock);
 			free(mirqs, M_MSI);
 			return (ENXIO);
@@ -639,13 +639,14 @@ again:
 			break;
 	}
 
+	/* Are all IRQs in use? */
+	if (i == first_msi_irq + NUM_MSI_INTS) {
+		mtx_unlock(&msi_lock);
+		return (ENXIO);
+	}
+
 	/* Do we need to create a new source? */
 	if (msi == NULL) {
-		/* If we would exceed the max, give up. */
-		if (i + 1 >= first_msi_irq + NUM_MSI_INTS) {
-			mtx_unlock(&msi_lock);
-			return (ENXIO);
-		}
 		mtx_unlock(&msi_lock);
 
 		/* Create a new source. */


More information about the svn-src-all mailing list