Date: Sun, 9 Oct 2016 04:29:42 +0000 (UTC) From: Oleksandr Tymoshenko <gonzo@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r306897 - head/sys/arm/nvidia Message-ID: <201610090429.u994TgoR031694@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: gonzo Date: Sun Oct 9 04:29:42 2016 New Revision: 306897 URL: https://svnweb.freebsd.org/changeset/base/306897 Log: Fix MSI allocation for NVidia Tegra - Fix range check - Due to checking found value in for(;;) condition irq after loop was always + 1 from actually found slot and wrong entry was marked as used which lead to returning slot 0 for all requests. Modified: head/sys/arm/nvidia/tegra_pcie.c Modified: head/sys/arm/nvidia/tegra_pcie.c ============================================================================== --- head/sys/arm/nvidia/tegra_pcie.c Sun Oct 9 03:20:58 2016 (r306896) +++ head/sys/arm/nvidia/tegra_pcie.c Sun Oct 9 04:29:42 2016 (r306897) @@ -710,7 +710,7 @@ tegra_pcib_msi_alloc_msi(device_t dev, d mtx_lock(&sc->mtx); found = false; - for (irq = 0; irq < TEGRA_PCIB_MAX_MSI && !found; irq++) { + for (irq = 0; (irq + count - 1) < TEGRA_PCIB_MAX_MSI; irq++) { /* Start on an aligned interrupt */ if ((irq & (maxcount - 1)) != 0) continue; @@ -719,20 +719,17 @@ tegra_pcib_msi_alloc_msi(device_t dev, d found = true; /* Check this range is valid */ - for (end_irq = irq; end_irq != irq + count - 1; end_irq++) { - /* No free interrupts */ - if (end_irq == (TEGRA_PCIB_MAX_MSI - 1)) { - found = false; - break; - } - + for (end_irq = irq; end_irq < irq + count; end_irq++) { /* This is already used */ - if ((sc->isrcs[irq].flags & TEGRA_FLAG_MSI_USED) == + if ((sc->isrcs[end_irq].flags & TEGRA_FLAG_MSI_USED) == TEGRA_FLAG_MSI_USED) { found = false; break; } } + + if (found) + break; } /* Not enough interrupts were found */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201610090429.u994TgoR031694>