From owner-svn-src-all@freebsd.org Tue Apr 25 23:46:54 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9CF12D5061B; Tue, 25 Apr 2017 23:46:54 +0000 (UTC) (envelope-from cognet@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6D36618B0; Tue, 25 Apr 2017 23:46:54 +0000 (UTC) (envelope-from cognet@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3PNkrBR045140; Tue, 25 Apr 2017 23:46:53 GMT (envelope-from cognet@FreeBSD.org) Received: (from cognet@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3PNkrdq045139; Tue, 25 Apr 2017 23:46:53 GMT (envelope-from cognet@FreeBSD.org) Message-Id: <201704252346.v3PNkrdq045139@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cognet set sender to cognet@FreeBSD.org using -f From: Olivier Houchard Date: Tue, 25 Apr 2017 23:46:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r317428 - head/sys/arm/arm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Apr 2017 23:46:54 -0000 Author: cognet Date: Tue Apr 25 23:46:53 2017 New Revision: 317428 URL: https://svnweb.freebsd.org/changeset/base/317428 Log: 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. Modified: head/sys/arm/arm/gic.c Modified: head/sys/arm/arm/gic.c ============================================================================== --- head/sys/arm/arm/gic.c Tue Apr 25 23:43:37 2017 (r317427) +++ head/sys/arm/arm/gic.c Tue Apr 25 23:46:53 2017 (r317428) @@ -1429,7 +1429,7 @@ arm_gicv2m_alloc_msi(device_t dev, devic 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, devic 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, devic break; } } + if (found) + break; } /* Not enough interrupts were found */