From nobody Thu Feb 27 14:17:31 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 4Z3YMJ0pRnz5qG2R; Thu, 27 Feb 2025 14:17:32 +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 4Z3YMJ06chz3xXS; Thu, 27 Feb 2025 14:17:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1740665852; 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=jcmeIKxE9R4ObTfG7gMl9/tMdA9kbnWJg7EbGBpLhwE=; b=xvUJtPsMXI8cBle9P/QfN3r4u07n6gJn4zwovjjcgBu2rqywzlaWrJJ/V0zxMBwyeHemcd /Hnvl1QKwliaBxziVz3vgMkQtOAS5BlT4M5+MvE0qHMxwlbhK5bbWOOIxYqlNUsEJNcS7O 44hOCS3DuzvEHkWc9O7bXBNvFCjG2G0P9SYgbsCfI8e9Rk6Bir++OqKBH85n9ZtPMlR4VT H5DW4U3F9zm0ChqKGmykGrbf3qhNwR+DdTnAtx/lpw8JDSp8DzZC6+/EhbF/tivqfLbgfr mDVBqiD1F0UMwJUTdth2hm1GGjOieMdsQbOjctQR34xEx+//JhTFUIAqilkV/w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1740665852; a=rsa-sha256; cv=none; b=gHNZHUHVgwNb/mt085z2ny4SZytNSa8f576OZ4RfU+iIWCYfKmoQF3fYrgnT7PfILvVJAX 720ucC7h3zsliGwutE2OX9ykrJv3yfhD9WdJnCawb9yJyvQXEz23S3flj+DfGg9bi4JDA1 +VUcv2W78zt3eAEtKqfUMhm98IaGdgYKTHVR2TQ0S8MFXWPAfkupSQUyQIhn4Ta79EcOij 0h4aXqgFIjTZcRUsqAJgre9qlCi1Oh19p4vf1seMYQ7CG+p0Vk5/NZMBn72XzOJV6RLLWO 1VbLgjKqIwxPEs+8s3kInDl3eGfa2kxe+ZjoULhY7qeRGV0qpMM48cIuPb5rrw== 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=1740665852; 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=jcmeIKxE9R4ObTfG7gMl9/tMdA9kbnWJg7EbGBpLhwE=; b=AjCuEz6AaNtMHSKYMSj28xPDurCc84BHnnr7tC+MfRJdvyetEFO2AyPgjsZOKuugwXbAkk LawfcUVsrWU6/VMaIXxWyhTvJC5YlCPO7xqR0K7AKgB3bAHgAKVggnmPfPIFlDwieJDwBp +uEf75lh3QEaMY44+q25mqGP2T58apoTAZxHqARtA2rCvecn53ngtCvrY8VWuUDSWKKjqu 6EZP5TeDiVgcCAXrIoNvr9iwJnBWmXWwCARo8UBLWUuO0u+rCufPUwLqHbAKW0wXrLUNAQ d6vE4KpTN7naN5zzX1I786S8ZMk1qAJzwTc/OLmZQgmhbcqeu0dueTQmqLuMzw== 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 4Z3YMH6qYtzmQK; Thu, 27 Feb 2025 14:17:31 +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 51REHVop017539; Thu, 27 Feb 2025 14:17:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 51REHVPJ017536; Thu, 27 Feb 2025 14:17:31 GMT (envelope-from git) Date: Thu, 27 Feb 2025 14:17:31 GMT Message-Id: <202502271417.51REHVPJ017536@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 60662799b126 - stable/14 - pci: Only add special VF handling for direct children in bus methods 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: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 60662799b1268ddbed2896223a77493b8def436c Auto-Submitted: auto-generated The branch stable/14 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=60662799b1268ddbed2896223a77493b8def436c commit 60662799b1268ddbed2896223a77493b8def436c Author: John Baldwin AuthorDate: 2024-06-05 16:50:05 +0000 Commit: John Baldwin CommitDate: 2025-02-27 13:09:23 +0000 pci: Only add special VF handling for direct children in bus methods For activate/deactivate resource, use a more standard check at the start of the function since the addition of the PCI_IOV code made this more complex. For the three recently added methods, just add the typical check at the beginning that I missed. This wasn't always fatal as if your system only had PCI device_t's as children of PCI bus devices it would happen to work ok, but if you have a non-PCI child device (e.g. an ATA channel) then dereferencing ivars for non-direct-children could fault. Reported by: Cirrus-CI (via emaste) Reviewed by: emaste Fixes: 871b33ad65ba pci: Consistently use pci_vf_* for suballocated VF memory resources Differential Revision: https://reviews.freebsd.org/D45499 (cherry picked from commit 56b822a17cde5940909633c50623d463191a7852) --- sys/dev/pci/pci.c | 48 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index 8ff31beca696..4be3210840fc 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -5702,6 +5702,10 @@ pci_activate_resource(device_t dev, device_t child, int type, int rid, struct pci_devinfo *dinfo; int error; + if (device_get_parent(child) != dev) + return (bus_generic_activate_resource(dev, child, type, rid, + r)); + dinfo = device_get_ivars(child); #ifdef PCI_IOV if (dinfo->cfg.flags & PCICFG_VF) { @@ -5724,18 +5728,17 @@ pci_activate_resource(device_t dev, device_t child, int type, int rid, if (error) return (error); + /* Device ROMs need their decoding explicitly enabled. */ + if (type == SYS_RES_MEMORY && PCIR_IS_BIOS(&dinfo->cfg, rid)) + pci_write_bar(child, pci_find_bar(child, rid), + rman_get_start(r) | PCIM_BIOS_ENABLE); + /* Enable decoding in the command register when activating BARs. */ - if (device_get_parent(child) == dev) { - /* Device ROMs need their decoding explicitly enabled. */ - if (type == SYS_RES_MEMORY && PCIR_IS_BIOS(&dinfo->cfg, rid)) - pci_write_bar(child, pci_find_bar(child, rid), - rman_get_start(r) | PCIM_BIOS_ENABLE); - switch (type) { - case SYS_RES_IOPORT: - case SYS_RES_MEMORY: - error = PCI_ENABLE_IO(dev, child, type); - break; - } + switch (type) { + case SYS_RES_IOPORT: + case SYS_RES_MEMORY: + error = PCI_ENABLE_IO(dev, child, type); + break; } return (error); } @@ -5747,6 +5750,10 @@ pci_deactivate_resource(device_t dev, device_t child, int type, struct pci_devinfo *dinfo; int error; + if (device_get_parent(child) != dev) + return (bus_generic_deactivate_resource(dev, child, type, rid, + r)); + dinfo = device_get_ivars(child); #ifdef PCI_IOV if (dinfo->cfg.flags & PCICFG_VF) { @@ -5771,11 +5778,9 @@ pci_deactivate_resource(device_t dev, device_t child, int type, return (error); /* Disable decoding for device ROMs. */ - if (device_get_parent(child) == dev) { - if (type == SYS_RES_MEMORY && PCIR_IS_BIOS(&dinfo->cfg, rid)) - pci_write_bar(child, pci_find_bar(child, rid), - rman_get_start(r)); - } + if (type == SYS_RES_MEMORY && PCIR_IS_BIOS(&dinfo->cfg, rid)) + pci_write_bar(child, pci_find_bar(child, rid), + rman_get_start(r)); return (0); } @@ -5786,6 +5791,10 @@ pci_adjust_resource(device_t dev, device_t child, int type, struct resource *r, { struct pci_devinfo *dinfo; + if (device_get_parent(child) != dev) + return (bus_generic_adjust_resource(dev, child, type, r, start, + end)); + dinfo = device_get_ivars(child); if (dinfo->cfg.flags & PCICFG_VF) { switch (rman_get_type(r)) { @@ -5809,6 +5818,10 @@ pci_map_resource(device_t dev, device_t child, int type, struct resource *r, { struct pci_devinfo *dinfo; + if (device_get_parent(child) != dev) + return (bus_generic_map_resource(dev, child, type, r, argsp, + map)); + dinfo = device_get_ivars(child); if (dinfo->cfg.flags & PCICFG_VF) { switch (rman_get_type(r)) { @@ -5832,6 +5845,9 @@ pci_unmap_resource(device_t dev, device_t child, int type, struct resource *r, { struct pci_devinfo *dinfo; + if (device_get_parent(child) != dev) + return (bus_generic_unmap_resource(dev, child, type, r, map)); + dinfo = device_get_ivars(child); if (dinfo->cfg.flags & PCICFG_VF) { switch (rman_get_type(r)) {