Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795040403; b=CVEFzM2Zz/FkxQZ24TDXhLjHJGwZrMDe3iH8sOBkQx20WiRxxM1EKdhnFLnND26Lx/mR ce68r3ZwvifsmIaamBA+uS5duF15FkuZBGf4TFXAayaYpBINN46nK+a5VwDe3YHZdAKMv AFyuP21OVEqz+VlmD6Utq1kNKnZwmQVVDglLevSQegFbTXEI6Mxr60jlACp/qkGQo7eN0 d1eRsSHmHNn2idUYU01MHxVzVxHVoA9UPMAy1TiStWWGlbSRmp/MJLpeVKcK9VxHF4TuE Q5YjTNoax4lv6me3uNVYCRVN8klCwgegCcVG8GlRYQ67AcYDguo8EAZ2ZlRQbSBYf6Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795040403; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=6HkxP3wnB4IrlWy52JXMf7oijYTA/54U7i3Jmw8RC9Y=; b=ydPtbcz1+mWPiWSj/jXkGaPsX2R7vqxdlWmw16FP5s1FMShHrPIrshX1txtfUKPPHl6U jZYOfNTFMvW9kDhOYNfj8t2Pcye7OHjrwQftZBYIU1wd3nvuu5ST7B3j3vuVREbScWh86 ZHogB7xdVOVPSxIax4DxvaDeR+ckSMCrrxaL/aMwPQfGY/YXHvUP6dbiAYaAlLMvvDJm3 MQAFXELVg4AkZtHG8FVSJNPz7CHCgwAOEu6x/BaWZ8/YEestxbj3Zt/lNRF2aJel6pqLp 0xwmWC7GZ5uLvLM1sMfv/R/4xYAtChdJZs6OTCrrKytWC4G6k6O3l3wkddwiP9w+biw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b="D/Y+T0sa"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09D80606A320; Wed, 18 Nov 2026 22:20:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=D/Y+T0sa Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A7591F000C5; Wed, 18 Nov 2026 22:20:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795040402; bh=6HkxP3wnB4IrlWy52JXMf7oijYTA/54U7i3Jmw8RC9Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=D/Y+T0sa0rJZ8EelJwy52BgTZuT43md0gi6b0zdOx57h1vn4KBHoSgAPsDro7OA61 Ex+aOT9d516X15Z0sKKYnNXVUqUYneIXhWSGSsMtkO0i9zHBTHzT2RPoP18yRpkzDG hGrfHOdJnMhE5LqIjgMMqOvHbSb70Lq3bq1U96+4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Logan Odell , Bjorn Helgaas , Sasha Levin Subject: [PATCH 6.6 2442/3318] PCI/IOV: Read VF config values that need not match PF Date: Wed, 18 Nov 2026 15:51:04 +0100 Message-ID: <20261118150434.708644335@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150313.527275416@linuxfoundation.org> References: <20261118150313.527275416@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Logan Odell [ Upstream commit ae43799529c480510dcc14bd0ed141a1d85b9259 ] Per PCIe r7.0, sec 7.5.1.1.5 and 7.5.1.2.3, VF Revision IDs and Subsystem IDs may differ from the PF's. Read these values from VF config space instead of using cached values from VF 0. Per 7.5.1.1.6 and 7.5.1.2.3, VF Class Codes and Subsystem Vendor IDs must be the same as the PF's. Use the PF's value instead of reading from VF config space. Per 7.5.1.1.9, the Header Type for a VF must be 0, so hardcode that assignment. Fixes: cf0921bea66c ("PCI/IOV: Use VF0 cached config registers for other VFs") Signed-off-by: Logan Odell [bhelgaas: commit log, move "rev" decl inside block that uses it] Signed-off-by: Bjorn Helgaas Link: https://patch.msgid.link/20260910173648.1304517-1-loganodell@google.com Signed-off-by: Sasha Levin --- drivers/pci/iov.c | 25 ------------------------- drivers/pci/pci.h | 4 ---- drivers/pci/probe.c | 15 ++++++++++----- 3 files changed, 10 insertions(+), 34 deletions(-) diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index d595a345a7d47..829c2be7ba956 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -153,29 +153,6 @@ resource_size_t pci_iov_resource_size(struct pci_dev *dev, int resno) return dev->sriov->barsz[resno - PCI_IOV_RESOURCES]; } -static void pci_read_vf_config_common(struct pci_dev *virtfn) -{ - struct pci_dev *physfn = virtfn->physfn; - - /* - * Some config registers are the same across all associated VFs. - * Read them once from VF0 so we can skip reading them from the - * other VFs. - * - * PCIe r4.0, sec 9.3.4.1, technically doesn't require all VFs to - * have the same Revision ID and Subsystem ID, but we assume they - * do. - */ - pci_read_config_dword(virtfn, PCI_CLASS_REVISION, - &physfn->sriov->class); - pci_read_config_byte(virtfn, PCI_HEADER_TYPE, - &physfn->sriov->hdr_type); - pci_read_config_word(virtfn, PCI_SUBSYSTEM_VENDOR_ID, - &physfn->sriov->subsystem_vendor); - pci_read_config_word(virtfn, PCI_SUBSYSTEM_ID, - &physfn->sriov->subsystem_device); -} - int pci_iov_sysfs_link(struct pci_dev *dev, struct pci_dev *virtfn, int id) { @@ -310,8 +287,6 @@ int pci_iov_add_virtfn(struct pci_dev *dev, int id) virtfn->physfn = pci_dev_get(dev); virtfn->no_command_memory = 1; - if (id == 0) - pci_read_vf_config_common(virtfn); rc = pci_setup_device(virtfn); if (rc) diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index c2ab22a353011..cde67b956f441 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -357,10 +357,6 @@ struct pci_sriov { u16 driver_max_VFs; /* Max num VFs driver supports */ struct pci_dev *dev; /* Lowest numbered PF */ struct pci_dev *self; /* This PF */ - u32 class; /* VF device */ - u8 hdr_type; /* VF header type */ - u16 subsystem_vendor; /* VF subsystem vendor */ - u16 subsystem_device; /* VF subsystem device */ resource_size_t barsz[PCI_SRIOV_NUM_BARS]; /* VF BAR size */ bool drivers_autoprobe; /* Auto probing of VFs by driver */ }; diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 9701917ce8380..1738dd06578b1 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1778,8 +1778,13 @@ static u32 pci_class(struct pci_dev *dev) u32 class; #ifdef CONFIG_PCI_IOV - if (dev->is_virtfn) - return dev->physfn->sriov->class; + if (dev->is_virtfn) { + u8 rev; + + if (pci_read_config_byte(dev, PCI_REVISION_ID, &rev)) + rev = 0; + return (dev->physfn->class << 8) | rev; + } #endif pci_read_config_dword(dev, PCI_CLASS_REVISION, &class); return class; @@ -1789,8 +1794,8 @@ static void pci_subsystem_ids(struct pci_dev *dev, u16 *vendor, u16 *device) { #ifdef CONFIG_PCI_IOV if (dev->is_virtfn) { - *vendor = dev->physfn->sriov->subsystem_vendor; - *device = dev->physfn->sriov->subsystem_device; + *vendor = dev->physfn->subsystem_vendor; + pci_read_config_word(dev, PCI_SUBSYSTEM_ID, device); return; } #endif @@ -1804,7 +1809,7 @@ static u8 pci_hdr_type(struct pci_dev *dev) #ifdef CONFIG_PCI_IOV if (dev->is_virtfn) - return dev->physfn->sriov->hdr_type; + return 0; #endif pci_read_config_byte(dev, PCI_HEADER_TYPE, &hdr_type); return hdr_type; -- 2.53.0