From nobody Sat Mar 29 20:18:06 2025 X-Original-To: dev-commits-src-main@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 4ZQ7xV4Zgjz5s2GY; Sat, 29 Mar 2025 20:18:06 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ZQ7xV1wX9z3h9v; Sat, 29 Mar 2025 20:18:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1743279486; 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=/659T9Qrz2CzhIvf8dEqbMhvWEo1PAR5ccx32xEuZFM=; b=K6T1ElhKvdZQjPL3F2GbY2xNn0D/xhbAHxrkPTVs70kVw9+W1w79T7T1R6WEyxA0s3aH6f nK6PR/3byfW/6k+hAmmnMjprxOASZ7mvmb7cJ0b7aJc7/Oyd9rLhg/aWQy282ux7kPK1NT WabmepfmdZ31FfS63sKXK/QgBswHjMkQy8T3mq1V8ehF2q7dud6uvKchexa8Q+/IgbByGS oHtUEXuLPaytr6ecBqK9o1tgFofVoxRPDUACZ5JtyLDaM/34s9hwP2f2yS0+ZPRRXiHDBN l5ak/+zq4TxBeh3ryVE1WU7W7/a7u3YYLFA/dRAJEwEBSph7UZeTwEUd9aLJyw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1743279486; a=rsa-sha256; cv=none; b=PgMb/QOnbvzpGrAba4p9CWheFAcxzLRaIt8w8sr/gGq7Ekjgf4aqo7WCvGDX1Uv6W2nr5J v+MjNN1jolcceMC3ge4bMef5B36U/wG4JTh8A85LFiJakJs434Z5oOztIX3EQBSAZop/YM oF0IkHBsBSU5iRUuovlPyGaTjYsKN0Ze1A1r7SEPTIGyZsbCrVrueGfDtCOq2JY7vCWafA 3R5R7frgMHVwwrIb0UYFxFMu4nZqiQ0jeFgSfkJSJ05ynQXMjC9uY+J5kBeCBx1PlQWYSI UEUhYFG28w2/C89FAf3qo7eL98YuRxO/gvsWZNuoBDW17ALzxXJoEw3yYP4Kiw== 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=1743279486; 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=/659T9Qrz2CzhIvf8dEqbMhvWEo1PAR5ccx32xEuZFM=; b=YdpWUvr0NBTDW4SnDUQY3SMGol21ntumN5Doe2ezui/5MEQ7+1YLty2QZs7hlZj2CLPkIQ rEaokYzoZhAfyPAYLH1JiS2ef4/09X3J4fLj6w4wVKFL3Ty88sPGJnTAHXeiOOKWJTxz1K tS5S0+lbCQYhqbm4ThL3iLRYE8N2hvZa04zNZSDEp0gRkstMzYnI3vxsdPgSOtl6uP/VW5 cK2wLIDZAtbZzDZTfBNL6jVS2k2oWY7GbDqVf2UR53GE5gUmokYAW7+IRwvXOUw/mfBvGm SyTAJeANCSlVbkWGtKttUZMMnksYt8vVcFRqdQafZ1f/TH36tb9loY7vh71oMQ== 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 4ZQ7xV1WNWzkpx; Sat, 29 Mar 2025 20:18:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 52TKI6K9048347; Sat, 29 Mar 2025 20:18:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 52TKI6bb048344; Sat, 29 Mar 2025 20:18:06 GMT (envelope-from git) Date: Sat, 29 Mar 2025 20:18:06 GMT Message-Id: <202503292018.52TKI6bb048344@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Colin Percival Subject: git: 4cb527be7a25 - main - Correctly track index of first free irq map entry List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cperciva X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4cb527be7a251d89fa5955532300e08eec136051 Auto-Submitted: auto-generated The branch main has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=4cb527be7a251d89fa5955532300e08eec136051 commit 4cb527be7a251d89fa5955532300e08eec136051 Author: Colin Percival AuthorDate: 2025-03-27 23:17:10 +0000 Commit: Colin Percival CommitDate: 2025-03-29 20:17:29 +0000 Correctly track index of first free irq map entry Any time an IRQ map entry was removed, irq_map_first_free_idx was being set to the index of the removed entry; this caused problems when entries were removed in random order since irq_map_first_free_idx was set to a larger value than the index of the first free map entry, and in 9beb195fd9fd ("Continue searching for an irq map from the start") the IRQ map allocation code was adjusted to use irq_map_first_free_idx as a starting point but ultimately scan the entire map if necessary, including values less than irq_map_first_free_idx. Remove that workaround and instead make irq_map_first_free_idx do what the name suggests -- tracking the index of the first free map entry -- by only setting to the index of a newly-freed entry if that index is lower than the existing irq_map_first_free_idx value. Reviewed by: imp, mhorne Sponsored by: Amazon Differential Revision: https://reviews.freebsd.org/D49543 --- sys/kern/subr_intr.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/sys/kern/subr_intr.c b/sys/kern/subr_intr.c index b7cb088f58c7..dec40aa04e4a 100644 --- a/sys/kern/subr_intr.c +++ b/sys/kern/subr_intr.c @@ -1733,14 +1733,6 @@ intr_map_irq(device_t dev, intptr_t xref, struct intr_map_data *data) return (i); } } - for (i = 0; i < irq_map_first_free_idx; i++) { - if (irq_map[i] == NULL) { - irq_map[i] = entry; - irq_map_first_free_idx = i + 1; - mtx_unlock(&irq_map_lock); - return (i); - } - } mtx_unlock(&irq_map_lock); /* XXX Expand irq_map table */ @@ -1760,7 +1752,8 @@ intr_unmap_irq(u_int res_id) panic("Attempt to unmap invalid resource id: %u\n", res_id); entry = irq_map[res_id]; irq_map[res_id] = NULL; - irq_map_first_free_idx = res_id; + if (res_id < irq_map_first_free_idx) + irq_map_first_free_idx = res_id; mtx_unlock(&irq_map_lock); intr_free_intr_map_data(entry->map_data); free(entry, M_INTRNG);