From owner-dev-commits-src-main@freebsd.org Tue Sep 28 12:43:48 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 32F9567C9EF; Tue, 28 Sep 2021 12:43:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HJfM80fmdz4v7x; Tue, 28 Sep 2021 12:43:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EA8C424C9F; Tue, 28 Sep 2021 12:43:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 18SChllv001989; Tue, 28 Sep 2021 12:43:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 18SChldh001988; Tue, 28 Sep 2021 12:43:47 GMT (envelope-from git) Date: Tue, 28 Sep 2021 12:43:47 GMT Message-Id: <202109281243.18SChldh001988@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: f3aa0098a82e - main - Use mtx_lock_spin in the gic driver MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f3aa0098a82ebf7712aa13716d794aa7e4ac59cd Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Sep 2021 12:43:48 -0000 The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=f3aa0098a82ebf7712aa13716d794aa7e4ac59cd commit f3aa0098a82ebf7712aa13716d794aa7e4ac59cd Author: Andrew Turner AuthorDate: 2021-09-28 11:36:42 +0000 Commit: Andrew Turner CommitDate: 2021-09-28 11:42:06 +0000 Use mtx_lock_spin in the gic driver The mutex was changed to a spin lock when the MSI/MSI-X handling was moved from the gicv2m to the gic driver. Update the calls to lock and unlock the mutex to the spin variant. Submitted by: jrtc27 ("Change all the mtx_(un)lock(&sc->mutex) to be the _spin versions.") Reported by: mw, antranigv@freebsd.am Sponsored by: The FreeBSD Foundation --- sys/arm/arm/gic.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sys/arm/arm/gic.c b/sys/arm/arm/gic.c index d7edd7885404..89db4e324600 100644 --- a/sys/arm/arm/gic.c +++ b/sys/arm/arm/gic.c @@ -1056,7 +1056,7 @@ arm_gic_alloc_msi(device_t dev, device_t child, int count, int maxcount, sc = device_get_softc(dev); - mtx_lock(&sc->mutex); + mtx_lock_spin(&sc->mutex); found = false; for (irq = sc->sc_spi_start; irq < sc->sc_spi_end; irq++) { @@ -1091,7 +1091,7 @@ arm_gic_alloc_msi(device_t dev, device_t child, int count, int maxcount, /* Not enough interrupts were found */ if (!found || irq == sc->sc_spi_end) { - mtx_unlock(&sc->mutex); + mtx_unlock_spin(&sc->mutex); return (ENXIO); } @@ -1099,7 +1099,7 @@ arm_gic_alloc_msi(device_t dev, device_t child, int count, int maxcount, /* Mark the interrupt as used */ sc->gic_irqs[irq + i].gi_flags |= GI_FLAG_MSI_USED; } - mtx_unlock(&sc->mutex); + mtx_unlock_spin(&sc->mutex); for (i = 0; i < count; i++) srcs[i] = (struct intr_irqsrc *)&sc->gic_irqs[irq + i]; @@ -1118,7 +1118,7 @@ arm_gic_release_msi(device_t dev, device_t child, int count, sc = device_get_softc(dev); - mtx_lock(&sc->mutex); + mtx_lock_spin(&sc->mutex); for (i = 0; i < count; i++) { gi = (struct gic_irqsrc *)isrc[i]; @@ -1128,7 +1128,7 @@ arm_gic_release_msi(device_t dev, device_t child, int count, gi->gi_flags &= ~GI_FLAG_MSI_USED; } - mtx_unlock(&sc->mutex); + mtx_unlock_spin(&sc->mutex); return (0); } @@ -1142,7 +1142,7 @@ arm_gic_alloc_msix(device_t dev, device_t child, device_t *pic, sc = device_get_softc(dev); - mtx_lock(&sc->mutex); + mtx_lock_spin(&sc->mutex); /* Find an unused interrupt */ for (irq = sc->sc_spi_start; irq < sc->sc_spi_end; irq++) { KASSERT((sc->gic_irqs[irq].gi_flags & GI_FLAG_MSI) != 0, @@ -1152,13 +1152,13 @@ arm_gic_alloc_msix(device_t dev, device_t child, device_t *pic, } /* No free interrupt was found */ if (irq == sc->sc_spi_end) { - mtx_unlock(&sc->mutex); + mtx_unlock_spin(&sc->mutex); return (ENXIO); } /* Mark the interrupt as used */ sc->gic_irqs[irq].gi_flags |= GI_FLAG_MSI_USED; - mtx_unlock(&sc->mutex); + mtx_unlock_spin(&sc->mutex); *isrcp = (struct intr_irqsrc *)&sc->gic_irqs[irq]; *pic = dev; @@ -1178,9 +1178,9 @@ arm_gic_release_msix(device_t dev, device_t child, struct intr_irqsrc *isrc) KASSERT((gi->gi_flags & GI_FLAG_MSI_USED) == GI_FLAG_MSI_USED, ("%s: Trying to release an unused MSI-X interrupt", __func__)); - mtx_lock(&sc->mutex); + mtx_lock_spin(&sc->mutex); gi->gi_flags &= ~GI_FLAG_MSI_USED; - mtx_unlock(&sc->mutex); + mtx_unlock_spin(&sc->mutex); return (0); }