From nobody Wed Nov 04 06:36:26 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 4jKG1R0R1Sz6xq6d for ; Wed, 04 Nov 2026 06:36:27 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jKG1Q5l7Sz3Nlk for ; Wed, 04 Nov 2026 06:36:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793774186; 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=1lHszpqGjxktCubh8E+Q87qcsUsudgN0fMwMkzcfBhg=; b=ra6KzqIp6Jk+Ww7xBwgj3Vk5lSV81Z0E0wobysOz4JPUmjpZ7hpWKP+2/n5BNHfCimwogn Awfa3rht2qT2CXGfw8hyd8O8DSBMSytiL7j1Oa1aetvT2Tu90QtzY/MVU/gEaSAXp2vlDy o9LNWv1VFLymhWC5RQlEj/hvIikV7autAlN/TGH4X8/rRbstM5/ZffAO1Fxt+UB15hPDXD tMMzUtpwNqX4+uwdaTSLWSRalKZ94oOmxvQlJkWtS8Y4iqW2tBQTNJ/0YimMBNg52kcQfz uN/n3gD1mxswyL9v/xOigz7liOMDiIApa54ELAdlBaW5sEZ8AcQTCOE3dPUnbw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1793774186; b=NckldztJDeTF77EWOC2XvzvWut9m5TGVvsrmq11iXr1502PqJ+BmBgjHu8QsGeOM4A0l1P 54QV622pXIes+H2wYDKPonEfmlIMCKMH2UxFwnVNe0e/9ub8u68WuqgqzgW8tu304jlh7V iUdoA1uo7+9UKJoUQ5Co3E95tx009eJcpqccEAvm02Do73SuWs4UvJkk2eGYudr3N6Jpry KEPXmoaNcI0jec3qPv1qDwVxgIvps+Jk84XQG7ZmEBKu9+AoDTUrSxiPzwGfafX7dBzd6e 59zcaCgIkmfS/PawCme8CO5J/h/6WY5U6TSt+vHzYhaF+KeqmGWYPIuiSJt1og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793774186; 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=1lHszpqGjxktCubh8E+Q87qcsUsudgN0fMwMkzcfBhg=; b=hJE1ah3rjn9Gay2EHOomSKMCC1t1mUngnSWnNHG8WhEaOtgptoiiYxh2KCKMnF+SFEUxzh k2BwuZ7K7IhztKqcjfMUJS+x4ER6hstJ3jQaViT3plrIs0Fs0KbCENg+3NPN86tw8CL9Tb 5cxe/UdonhMjoV25czeTK+JPCaQSc3TEZh+QZVGOhPyDPpKo2XjuBrQ9581IQzJ91rP1uR CGwu38Qw+0oQIRvPoOhPWeiFA7hyFdEn1RFKaqxvQ3OP+2UkMxXicyhKnzGd8TH/fDKW82 6MsAErJMbHAprwX/z5Y2e36yL+yk6xxJXFvJd8jbapN4WEVf/xSSZV8KxLgL8A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jKG1Q5N1mzsPY for ; Wed, 04 Nov 2026 06:36:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 378f9 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 04 Nov 2026 06:36:26 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: c15aab01e9ea - main - linuxkpi: Fix lkpi_i2c_del_adapter() leaving the devices behind List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: Commit messages for all branches of the src repository 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: manu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c15aab01e9ea281f5fb071866619d9e664667672 Auto-Submitted: auto-generated Date: Wed, 04 Nov 2026 06:36:26 +0000 Message-Id: <6aead26a.378f9.5625c38e@gitrepo.freebsd.org> The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=c15aab01e9ea281f5fb071866619d9e664667672 commit c15aab01e9ea281f5fb071866619d9e664667672 Author: Emmanuel Vadot AuthorDate: 2026-10-28 13:05:32 +0000 Commit: Emmanuel Vadot CommitDate: 2026-11-04 06:35:06 +0000 linuxkpi: Fix lkpi_i2c_del_adapter() leaving the devices behind lkpi_i2c_del_adapter() looked for the lkpi_iic or lkpi_iicbb device to delete with device_find_child() on increasing unit numbers, and stopped at the first unit that does not exist. Units are allocated globally per devclass, so as soon as one adapter was removed (leaving a hole) or when the units of a parent do not start at 0, the adapter was not found and its device was never deleted. The i2c devices of a driver such as i915 then accumulate, with a new set of unit numbers, each time it is loaded. Walk the children of the parent instead and match on the adapter. Sponsored by: Beckhoff Automation GmbH & Co. KG --- sys/compat/linuxkpi/common/src/linux_i2c.c | 56 ++++++++++++++++-------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_i2c.c b/sys/compat/linuxkpi/common/src/linux_i2c.c index f18570202f74..c48a74c95298 100644 --- a/sys/compat/linuxkpi/common/src/linux_i2c.c +++ b/sys/compat/linuxkpi/common/src/linux_i2c.c @@ -342,40 +342,42 @@ lkpi_i2c_add_adapter(struct i2c_adapter *adapter) int lkpi_i2c_del_adapter(struct i2c_adapter *adapter) { - device_t child; - int unit, rv; + device_t parent, *children, child; + const char *name; + int count, i, rv; if (adapter == NULL) return (-EINVAL); + parent = adapter->dev.parent->bsddev; if (bootverbose) - device_printf(adapter->dev.parent->bsddev, - "Removing i2c adapter %s\n", adapter->name); + device_printf(parent, "Removing i2c adapter %s\n", + adapter->name); sx_xlock(&lkpi_sx_i2c); - unit = 0; - while ((child = device_find_child(adapter->dev.parent->bsddev, "lkpi_iic", unit++)) != NULL) { - - if (adapter == LKPI_IIC_GET_ADAPTER(child)) { - bus_topo_lock(); - device_delete_child(adapter->dev.parent->bsddev, child); - bus_topo_unlock(); - rv = 0; - goto out; - } - } - - unit = 0; - while ((child = device_find_child(adapter->dev.parent->bsddev, "lkpi_iicbb", unit++)) != NULL) { - - if (adapter == LKPI_IIC_GET_ADAPTER(child)) { - bus_topo_lock(); - device_delete_child(adapter->dev.parent->bsddev, child); - bus_topo_unlock(); - rv = 0; - goto out; + /* + * Look at every child: the units of the lkpi_iic and lkpi_iicbb + * devices are not contiguous once other adapters have been removed, + * so searching by increasing unit until the first hole would miss + * the device and leave it behind. + */ + rv = -EINVAL; + bus_topo_lock(); + if (device_get_children(parent, &children, &count) == 0) { + for (i = 0; i < count; i++) { + child = children[i]; + name = device_get_name(child); + if (name == NULL || + (strcmp(name, "lkpi_iic") != 0 && + strcmp(name, "lkpi_iicbb") != 0)) + continue; + if (adapter == LKPI_IIC_GET_ADAPTER(child)) { + device_delete_child(parent, child); + rv = 0; + break; + } } + free(children, M_TEMP); } - rv = -EINVAL; -out: + bus_topo_unlock(); sx_xunlock(&lkpi_sx_i2c); return (rv); }