In arm_gicv2m_alloc_msi(), if we found a suitable irq range, leave the loop

before we increase irq again, or we'd end up choosing an irq, and then
really using the next one, even if it's not available.
Also in the inner loop, correct the end check so that we check every irq,
even the last one.
This makes the msk(4) adapter able to use MSI on Softiron Overdrive 1000.
This commit is contained in:
Olivier Houchard 2017-04-25 23:46:53 +00:00
parent ee990cefd9
commit 899a362907

View File

@ -1429,7 +1429,7 @@ arm_gicv2m_alloc_msi(device_t dev, device_t child, int count, int maxcount,
mtx_lock(&sc->sc_mutex);
found = false;
for (irq = sc->sc_spi_start; irq < sc->sc_spi_end && !found; irq++) {
for (irq = sc->sc_spi_start; irq < sc->sc_spi_end; irq++) {
/* Start on an aligned interrupt */
if ((irq & (maxcount - 1)) != 0)
continue;
@ -1438,7 +1438,7 @@ arm_gicv2m_alloc_msi(device_t dev, device_t child, int count, int maxcount,
found = true;
/* Check this range is valid */
for (end_irq = irq; end_irq != irq + count - 1; end_irq++) {
for (end_irq = irq; end_irq != irq + count; end_irq++) {
/* No free interrupts */
if (end_irq == sc->sc_spi_end) {
found = false;
@ -1455,6 +1455,8 @@ arm_gicv2m_alloc_msi(device_t dev, device_t child, int count, int maxcount,
break;
}
}
if (found)
break;
}
/* Not enough interrupts were found */