[Midnightbsd-cvs] src [12133] trunk/sys/x86/x86/msi.c: Fix MSI-X to properly fail allocations when full.
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Tue Jan 15 19:27:26 EST 2019
Revision: 12133
http://svnweb.midnightbsd.org/src/?rev=12133
Author: laffer1
Date: 2019-01-15 19:27:25 -0500 (Tue, 15 Jan 2019)
Log Message:
-----------
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 Paths:
--------------
trunk/sys/x86/x86/msi.c
Modified: trunk/sys/x86/x86/msi.c
===================================================================
--- trunk/sys/x86/x86/msi.c 2019-01-16 00:12:57 UTC (rev 12132)
+++ trunk/sys/x86/x86/msi.c 2019-01-16 00:27:25 UTC (rev 12133)
@@ -382,7 +382,7 @@
/* 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_INT + NUM_MSI_INTS) {
+ if (i + (count - cnt) > FIRST_MSI_INT + NUM_MSI_INTS) {
mtx_unlock(&msi_lock);
free(mirqs, M_MSI);
return (ENXIO);
@@ -557,13 +557,14 @@
break;
}
+ /* Are all IRQs in use? */
+ if (i == FIRST_MSI_INT + 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_INT + NUM_MSI_INTS) {
- mtx_unlock(&msi_lock);
- return (ENXIO);
- }
mtx_unlock(&msi_lock);
/* Create a new source. */
More information about the Midnightbsd-cvs
mailing list