From nobody Tue Dec 2 18:46:58 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 4dLV9t3SZqz6Hx0x for ; Tue, 02 Dec 2025 18:46:58 +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 4dLV9t2tKTz3jXN for ; Tue, 02 Dec 2025 18:46:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1764701218; 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=JF1tC5d5wzNPo2SrDSQXjNlKqH8WSaRvNXMjs5Xx65o=; b=guFr7A0i7hoUwKFjD2Cp5AEUV0B1B+E2SCWqzsn+yobplwLOE+Hgy2LtPlF2FfHwktvhbS 7T1r5+Shls3Te3rTfemCJZeVZBCi6SmzvfT9hPFHbwSNHCa3vplHBFoVZZfppN4y6P6sKe uC+QS4i4zLGw4a3dOp+oEJJ2f8uN33lhYWKukw48dmsya4LWURjIiBkA47kvDx22j/vhK0 EvK7N5k2hEG234c9xFE+FtJhy0bOPgGVkU3Rn2vZG/7jhXG7GJ7pUpc4OqpFXG+kn+6Vg6 mEJDnhJRe0SRQhx6UNflITfWeuDOxKSvqI0DqGrn2i3H0+zVUoS094VUTwnjMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1764701218; 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=JF1tC5d5wzNPo2SrDSQXjNlKqH8WSaRvNXMjs5Xx65o=; b=nc1HiUm/s/pDUkRyriP+ovaLP/dqLn0Ff/r+yF8Ycu9VPj3tP5xs+5YtOnUla5+iM5VIsP gYmyVYeOdyQ6XpdXDEUKBdbyjsYDOW6muGg5H2kJ6bNGQ9YhNbqnCzKzG6CRjysIhL3Fov ilQxpBEzK6PJQO+dbqUzhMZe25IMPK72+7TBy6X1HcfmWSWbQH8H+I5XR5bKSerALt7mPK nDsBzD89CcRLIRmSIBLcO70cw6+aXQMogbRarsGtkxbg+/Rxr/nEmVwDgJcd/kYB20jEeV BNof9OtCHsUuXzU0Od7sOsMY/Jp9DDxuENQwzMJmXiR2tMY0U1B6jCIw5OzwzQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1764701218; a=rsa-sha256; cv=none; b=FkUgMAZ37mF2pqJC5SYMkhM3GGOR0kv+A2QYJE74dZaA9Hbh+k0CNcFjlTkGxpTm+jyhEm OSpMPfffOOLz3w6bJj9kXxhV9/YaTnbv41AG7hBIyCOBHm8Vna86JULO4dOr625zU5+yvr eYTnScK6mNHUSdG/Ey9Z98lk/qHUfaW/kGEQ4pk0cGhifU0lhqouudpT79/aHGI9QfOn+M iXmmt/Udlf1bFcXRetw7MyeSA31bqm54D374s0HdAxlxrnwHs4t6/DsPIIHbjLiftAYUwB PolJnYOszjpr5tuQyFxfxouakMsERRtax5IVx3AwQfoWG+EpLYYm3o5qxUQGdg== 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 4dLV9t29y1z1HfS for ; Tue, 02 Dec 2025 18:46:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id e4b4 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 02 Dec 2025 18:46:58 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Bjoern A. Zeeb Subject: git: ed29ffd396e5 - main - LinuxKPI: pci: undo the pci_resource_len() check in lkpi_pci_request_region() 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: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ed29ffd396e522a45ab1980c12a75b3409b51712 Auto-Submitted: auto-generated Date: Tue, 02 Dec 2025 18:46:58 +0000 Message-Id: <692f3422.e4b4.3f5f2017@gitrepo.freebsd.org> The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=ed29ffd396e522a45ab1980c12a75b3409b51712 commit ed29ffd396e522a45ab1980c12a75b3409b51712 Author: Bjoern A. Zeeb AuthorDate: 2025-12-02 16:04:22 +0000 Commit: Bjoern A. Zeeb CommitDate: 2025-12-02 18:46:20 +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 MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D53902 --- 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);