From nobody Wed Aug 26 00:26:22 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4hV56l1CqWz6qJMS for ; Wed, 26 Aug 2026 00:26:23 +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 "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hV56k71XCz3nxP for ; Wed, 26 Aug 2026 00:26:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1787703983; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=TmLGESHYDMtSICWAedeoSZu11U+kfCp8oNtq1xj20SI=; b=JfA5i2e9QLzYM5RqLDtslo1O9CUVzt7tZGm73qfe2MkrVy9A1Ut6dlqisqZbXXEqaPU1S9 2rW6i7ICgTWbVNSFuIYdLOgOa1V5uDki4OUnDCArEloHSSJCz5BlF/btJW6Ds12rUfhAUG zPsNQhFlVJWlHou1i+hQPHtrlrC0l06UrZV5J1oUVQrZM5Gu9NirzMMqH383OMgx3N0Okz ZPB+dh/JijWzldCPBO6Bok72PL7bOYtAHmaeAXKSj81FU2to1MMD1AgW/cSK9w664531M+ xaT09nY4uG8Z8tOiVFxmu4RGj1Jf0PAPNwaJpNtppUx6AAZMMX3F6KwMgIUS0w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1787703983; a=rsa-sha256; cv=none; b=yFAvt5R0po9ipY7rGBI9uX/Hdf4GAe/73uX2yZKz1gSWqoP470+b2wM/ogXlJ/5EjaD4/q vEIzGjTnxveRzdG9ngZF3DwUKMg3utdSW6YWupLEHc7B1BlwyjdRwiKpytGyLMCrbXbTmC 9pNcHfSm85LGwpGw7dx4eMoql5j6a4U5yzVOzcdBcw4dVgY5lpyR6yIi2kFQsFdYmkMs8D /Rso97W9ibfocjng1XraBYSer/JVQcusRwZVYNvK/6Gr3LRKgvZ/8wBR0rMTIEhHB+LYgd BiBjFaMvvgFmoBcwX5yfzHW71vCIGwoZ9/G0ycgkp548GYqAJ3ORjgY4i1s2tA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1787703983; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=TmLGESHYDMtSICWAedeoSZu11U+kfCp8oNtq1xj20SI=; b=gZ4fzTiSy90l/7ruzt4gXAyQ8sNf5x0bHNy9gIO7O40RaoHF62cpoGmaymDOx0Bu71gBu4 /OVv6k567swhL9lZ6gPCYGYU3kFhfuJz094eQ6FH5pIl1vKLc7JZOTTXGduSDwzEHTLa2v nDufAaTsby/e5vt1yvEyfTaaUsbhbRc2Ga1ZAyhBQocmFC8/U1egQBSzoPLZcbUfqulZCs 5NZHVJU7OZPNt58+Jj1QQtLf7m5TTDcHwCpIstKvR60w2/9txtLk7V6lF9B0YrNch1Rllq 5QLueP2uLvRFZeoWx6xCXjZHZmWEy/ttoCF2Sfe2iPl4rzCUKBYNuyf06Ztn7w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hV56k5wP2zHX for ; Wed, 26 Aug 2026 00:26:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 40b50 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 26 Aug 2026 00:26:22 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: c287fb614943 - stable/14 - iflib: Defer LED control to the device taskqueue List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: c287fb614943a721adc0ef59a7e19c32b839e5d9 Auto-Submitted: auto-generated Date: Wed, 26 Aug 2026 00:26:22 +0000 Message-Id: <6a8e32ae.40b50.25d12963@gitrepo.freebsd.org> The branch stable/14 has been updated by kbowling: URL: https://cgit.FreeBSD.org/src/commit/?id=c287fb614943a721adc0ef59a7e19c32b839e5d9 commit c287fb614943a721adc0ef59a7e19c32b839e5d9 Author: Kevin Bowling AuthorDate: 2026-08-12 00:12:15 +0000 Commit: Kevin Bowling CommitDate: 2026-08-26 00:26:07 +0000 iflib: Defer LED control to the device taskqueue led(4) invokes driver callbacks while holding its mutex, including from a callout. iflib_led_func() cannot acquire the sleepable context lock in those contexts without causing a lock-order reversal or sleeping from the callout. Record the latest requested state under the iflib state lock and enqueue the existing per-device taskqueue. The task can safely take the context lock before invoking the driver. Coalescing requests also avoids accumulating stale blink transitions when hardware access is slow. Destroy the LED device before draining its task so no new callback can race driver detach. (cherry picked from commit 952994751911d5d059d53e73eb874e00ee98b9ed) --- sys/net/iflib.c | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/sys/net/iflib.c b/sys/net/iflib.c index f9e98dbbc1c7..87fc5254ef0c 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -175,10 +175,12 @@ struct iflib_ctx { int ifc_link_state; int ifc_watchdog_events; struct cdev *ifc_led_dev; + int ifc_led_state; struct resource *ifc_msix_mem; struct if_irq ifc_legacy_irq; struct task ifc_admin_task; + struct task ifc_led_task; struct task ifc_vflr_task; struct taskqueue *ifc_tq; struct iflib_filter_info ifc_filter_info; @@ -4669,15 +4671,39 @@ iflib_vlan_unregister(void *arg, if_t ifp, uint16_t vtag) } static void -iflib_led_func(void *arg, int onoff) +_task_fn_led(void *context, int pending __unused) { - if_ctx_t ctx = arg; + if_ctx_t ctx = context; + bool in_detach; + int onoff; + + STATE_LOCK(ctx); + in_detach = (ctx->ifc_flags & IFC_IN_DETACH) != 0; + onoff = ctx->ifc_led_state; + STATE_UNLOCK(ctx); + if (in_detach) + return; CTX_LOCK(ctx); IFDI_LED_FUNC(ctx, onoff); CTX_UNLOCK(ctx); } +static void +iflib_led_func(void *arg, int onoff) +{ + if_ctx_t ctx = arg; + bool in_detach; + + /* led(4) may invoke this callback from a non-sleepable callout. */ + STATE_LOCK(ctx); + ctx->ifc_led_state = onoff; + in_detach = (ctx->ifc_flags & IFC_IN_DETACH) != 0; + STATE_UNLOCK(ctx); + if (!in_detach) + taskqueue_enqueue(ctx->ifc_tq, &ctx->ifc_led_task); +} + /********************************************************************* * * BUS FUNCTION DEFINITIONS @@ -5271,6 +5297,7 @@ iflib_device_register(device_t dev, void *sc, if_shared_ctx_t sctx, if_ctx_t *ct } TASK_INIT(&ctx->ifc_admin_task, 0, _task_fn_admin, ctx); + TASK_INIT(&ctx->ifc_led_task, 0, _task_fn_led, ctx); /* Set up cpu set. If it fails, use the set of all CPUs. */ if (bus_get_cpus(dev, INTR_CPUS, sizeof(ctx->ifc_cpus), &ctx->ifc_cpus) != 0) { @@ -5472,8 +5499,10 @@ iflib_device_deregister(if_ctx_t ctx) CTX_UNLOCK(ctx); iflib_rem_pfil(ctx); - if (ctx->ifc_led_dev != NULL) + if (ctx->ifc_led_dev != NULL) { led_destroy(ctx->ifc_led_dev); + taskqueue_drain(ctx->ifc_tq, &ctx->ifc_led_task); + } iflib_tqg_detach(ctx); iflib_tx_structures_free(ctx);