From nobody Wed Nov 04 06:36:25 2026 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 4jKG1Q0Cxlz6xq6W for ; Wed, 04 Nov 2026 06:36:26 +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 4jKG1P53Kcz3NgZ for ; Wed, 04 Nov 2026 06:36:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793774185; 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=UrZPCV63OzzjyJhscb8UUJD68R+kORzrr+Y7/jTACEw=; b=E2yvYqN4GFseztNyvglEmhIPSL+k92P7JLHx/6Rm+A7cGKRjy8TYy+Q2aQMRjf1zDJuiU6 SSppasEO2t2Vp5zaPgdvbztO5p/eMYgpJbnY2MzX50ds6hyIZXWRyJLs9MXT/zGyrp7CaD v95Cv1GC4o/laEvgZj9Hfc3Tn8igLoZgw/RXVpJFH17omZSIEDtdZMfxvgDZ8slctAJyFO tRjux1v4SXdqdRNKx9t3yFlr2dlzwFZAJ6g2UDHLWCLxMpFWTV0kJ/xWN4Y6wPxl9Pn8J1 bSB4lC2fBIoNto5wOUXM655957GoUimwOQr37HY1mVOwW+aZcPqd28Iw7mQ5tQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1793774185; b=ho+it92JZJlffUNUzd3Vl5UAUyIhp51iwG+6/YEhM8yAQNq/UKr4UGadnrxYlu3OK3FGUh 6PpmoWCpdh/rp8Tt7tZqfRJce9L4mEZN7yrBEytQjV4hV/Ok4fmYoDnCU6GoRRSiCQDVQu cQgOBfJK/RfkxgBA1UXDrQJ8+6/L94PUJ2T7qnLFyo5hkR/qVqEElaOeuW9NvE+5jy3KuU PqfURGoK2XoOjwLzlGAm7S7rmok5i8CZ3PrFJ2yMZM0/i4QBQIoUwgni3IERXGS3T6kBzS Sn+NMCRKSF1SsKgClnrSdCmNl/tIysNhi5JmbdUaJJ0jRymZYi4dYwDk1uAstQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793774185; 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=UrZPCV63OzzjyJhscb8UUJD68R+kORzrr+Y7/jTACEw=; b=G9CLcxlnIPYDQfRAFuyVxsaVKIHb7Kz1weVOEMRCuyrtANPaxYOTyeCvO1TrKZ+2RufAav SGKpzFG0cdzCqKIRad56VyJZWUYv4A3CDRBq3/zKFyzohkfKTYPlJMc5wh/9TiskPe40i9 88E+QKDnm7dM5O6MICTX7Zl5s49aPGN4MKEKZcx+6Av0/0OAJFWdxpJpuuNTGnRJGVI/Md yy5CcTsPeb7hFkBdlLttZiHYPPvQtmY/GRYWKUcwQ0QanhBrlKumoAWwIWMrvpFcr4Xi3k TBFCpG7ISwP3lxC0AGgX6cOAP7nMRzIjWiJXtlT6sHKYM107ccloYxI7tvz2Og== 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 4jKG1P4XFDzs9S for ; Wed, 04 Nov 2026 06:36:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 37b7a by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 04 Nov 2026 06:36:25 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: 71d26da7e43d - main - linuxkpi: Release devres on PCI driver detach List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: Commit messages for the main branch 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: 71d26da7e43db58116911e432dcb261f745e520b Auto-Submitted: auto-generated Date: Wed, 04 Nov 2026 06:36:25 +0000 Message-Id: <6aead269.37b7a.6bc789c4@gitrepo.freebsd.org> The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=71d26da7e43db58116911e432dcb261f745e520b commit 71d26da7e43db58116911e432dcb261f745e520b Author: Emmanuel Vadot AuthorDate: 2026-10-28 11:17:37 +0000 Commit: Emmanuel Vadot CommitDate: 2026-11-04 06:34:04 +0000 linuxkpi: Release devres on PCI driver detach linux_pci_detach_device() called the driver remove method and then only dropped its reference on the device, expecting the devres list to be released from lkpi_pci_dev_release() once the last reference is gone. That never happens when a devres action itself holds a reference on the device. The typical case is devm_drm_dev_alloc(): the drm_device takes a reference on its parent and the matching drm_dev_put() is a devres action. The device is thus never released, drm_dev_release() is never called and the DRM device and everything it owns is leaked, which makes unloading drm-kmod drivers fail ("failed due to N other pending references on the LinuxKPI device") and leaves the module unloadable or crashing. Linux releases the devres resources when a driver is unbound, so do the same: call lkpi_devres_release_free_list() right after the remove method. The list is empty when lkpi_pci_dev_release() runs later. Reviewed by: bz Sponsored by: Beckhoff Automation GmbH & Co. KG --- sys/compat/linuxkpi/common/src/linux_pci.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/compat/linuxkpi/common/src/linux_pci.c b/sys/compat/linuxkpi/common/src/linux_pci.c index bd51082fb4d1..9509cc81fa72 100644 --- a/sys/compat/linuxkpi/common/src/linux_pci.c +++ b/sys/compat/linuxkpi/common/src/linux_pci.c @@ -735,6 +735,14 @@ linux_pci_detach_device(struct pci_dev *pdev) if (pdev->pdrv != NULL) pdev->pdrv->remove(pdev); + /* + * As on Linux when a driver is unbound, release the devres actions now. + * Waiting for the last reference to go away is wrong: devres actions + * (e.g. the drm_dev_put() of devm_drm_dev_alloc()) may hold references + * on this very device, which then never gets released. + */ + lkpi_devres_release_free_list(&pdev->dev); + pci_dev_put(pdev); /*