From nobody Mon Dec 8 15:44:14 2025 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 4dQ5rG4Dyzz6Jybl for ; Mon, 08 Dec 2025 15:44:14 +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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dQ5rG1NDLz4408 for ; Mon, 08 Dec 2025 15:44:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1765208654; 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=ggU601CqC6M7002dE/oNFfmypBo6AX8hebO+Dj3KtrE=; b=PtpN9jF48dkNUO0GQcSEv090qBB916a65SGzUbXoX6OefkJGSBNFfsF68TXuM2QvSvK5iQ vzNjZRr07EHP8pqGlIh+P3dWTeIcl4q7OEwGSkY/mVAXZI9sAh9ikLwM0HhLE+6s+aLCKX bQr+PzFvnmxPSkqI74+9dSEHoS2b2CAOnXMSJCzan8TZoCthWjfdeDxStIng0KBkpMRS/j XiDW+eSEc8jCmhlYJNZE0CsqtuwfVPaz2imXHp2zHX0fTuVJkjoVBm7HFlzUk+Wx7BRJG3 sOJmfPY1G8CCyzxHuSsGXBqtTVAmuNL3TFva22n38cx/ax5fQiBdY8D5/ikExA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1765208654; 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=ggU601CqC6M7002dE/oNFfmypBo6AX8hebO+Dj3KtrE=; b=gGrpcLtV41E4u+14lMQzpfBXI+EHo8NrnxBrNuTTs9iiVfyeDugBpHGr8izVuaka5yjBAl W/zZDfdOf/G8iArLuf/ryCrpkrs9yKjmncnYXWb8r2krL8nPwHbArT27aHQe0uHP/S1TcL KNZaiMkXVpKa7Lg/bZ/mrA7VsjROVBHofGcLuqPwZ1VX2+V9MocrNEstY+5E3ntkW9uoHc 0rh00FWpYCczsKAhbV4RcxIfxhHVBQmGJ6fHtNLQutFzdIelPWfmuPe0fXYKOs7Erdf55n FIiYhTXkdeNUJFSf53b3hx66VR2F1NapX8qrKiMfXm3EPacUlejFljOHP12lzQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1765208654; a=rsa-sha256; cv=none; b=kThS78Wjlt1Wtb0mPzmcaHfhdz+AXiXEA34iOg2oXtAucF3kmRlJfud31twbskI04ZeeQQ q04icIvZEiuryeGYauFchxjIvmgIyZWPXARlI7YfoOzygfOs/zbvjvX7YtEkQ21hTDmyh5 9vtDov/1SWuAV4AGXJMIePdr4qhZNKTq25Wt3x+C2a6AEXnz5vrX/kLUmwyrZz54yt6xde W3NncgHy3S7lU2aeBrdDHLFYPXcjWf0lBT5Bmm7D0v0PPXCcfYgGdzUjzjGj3wlFdOHrF0 nLeunr3PFZcrnUhGgk4+N1z4OUbjfEiYKcOFNd2l32sG70nI9jR8o9gapyhhVQ== 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 4dQ5rG0mX5z3sk for ; Mon, 08 Dec 2025 15:44:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 384bc by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 08 Dec 2025 15:44:14 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Bjoern A. Zeeb Subject: git: 2032abb31cbe - stable/15 - LinuxKPI: pci: undo the pci_resource_len() check in lkpi_pci_request_region() 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 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 2032abb31cbe067d41067a81e529d91f1bace4c9 Auto-Submitted: auto-generated Date: Mon, 08 Dec 2025 15:44:14 +0000 Message-Id: <6936f24e.384bc.79fe44ba@gitrepo.freebsd.org> The branch stable/15 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=2032abb31cbe067d41067a81e529d91f1bace4c9 commit 2032abb31cbe067d41067a81e529d91f1bace4c9 Author: Bjoern A. Zeeb AuthorDate: 2025-12-02 16:04:22 +0000 Commit: Bjoern A. Zeeb CommitDate: 2025-12-08 15:43:51 +0000 LinuxKPI: pci: undo the pci_resource_len() check in lkpi_pci_request_region() Creating non-passthru SR-IOV interfaces on a mlx5en(4) failed. The problem lies in the pci_resource_len() call but not that the BAR length is tmeporary 0 but in that we call lkpi_pci_get_bar() with a true argument which will create the BAR resource for us and report the approriate length back. However, the later call to bus_alloc_resource_any() will then fail given the resource already exists. Restore the previous behaviour and let bus_alloc_resource_any() do the work. Adjust the return values from -ENODEV to -EBUSY to match callers expectations. In linuxkpi_pcim_request_all_regions(), like in linuxkpi_pci_request_regions(), filter out the -EBUSY errors as "not an error" and try the next bar. This also seems to be consistent with the expectations of the callers. PR: 290793 Reported by: David BOYER (jcduss13 gmail.com) Tested on: mlx5en, iwlwifi, mt7921 Reviewed by: kib Fixes: 7e21158d44cd "implement [linuxkpi_]pcim_request_all_regions()" Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D53902 (cherry picked from commit ed29ffd396e522a45ab1980c12a75b3409b51712) --- sys/compat/linuxkpi/common/src/linux_pci.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_pci.c b/sys/compat/linuxkpi/common/src/linux_pci.c index 8507a59a8df3..fb3f648df496 100644 --- a/sys/compat/linuxkpi/common/src/linux_pci.c +++ b/sys/compat/linuxkpi/common/src/linux_pci.c @@ -1223,13 +1223,6 @@ lkpi_pci_request_region(struct pci_dev *pdev, int bar, const char *res_name, if (!lkpi_pci_bar_id_valid(bar)) return (-EINVAL); - /* - * If the bar is not valid, return success without adding the BAR; - * otherwise linuxkpi_pcim_request_all_regions() will error. - */ - if (pci_resource_len(pdev, bar) == 0) - return (0); - /* Likewise if it is neither IO nor MEM, nothing to do for us. */ type = pci_resource_type(pdev, bar); if (type < 0) return (0); @@ -1241,7 +1234,7 @@ lkpi_pci_request_region(struct pci_dev *pdev, int bar, const char *res_name, device_printf(pdev->dev.bsddev, "%s: failed to alloc " "bar %d type %d rid %d\n", __func__, bar, type, PCIR_BAR(bar)); - return (-ENODEV); + return (-EBUSY); } /* @@ -1285,7 +1278,7 @@ linuxkpi_pci_request_regions(struct pci_dev *pdev, const char *res_name) for (i = 0; i <= PCIR_MAX_BAR_0; i++) { error = pci_request_region(pdev, i, res_name); - if (error && error != -ENODEV) { + if (error && error != -EBUSY) { pci_release_regions(pdev); return (error); } @@ -1300,7 +1293,7 @@ linuxkpi_pcim_request_all_regions(struct pci_dev *pdev, const char *res_name) for (bar = 0; bar <= PCIR_MAX_BAR_0; bar++) { error = lkpi_pci_request_region(pdev, bar, res_name, true); - if (error != 0) { + if (error != 0 && error != -EBUSY) { device_printf(pdev->dev.bsddev, "%s: bar %d res_name '%s': " "lkpi_pci_request_region returned %d\n", __func__, bar, res_name, error);