]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/3.18.85/pci-apply-_hpx-settings-only-to-relevant-devices.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.18.85 / pci-apply-_hpx-settings-only-to-relevant-devices.patch
CommitLineData
af98e849
GKH
1From foo@baz Tue Nov 28 10:58:31 CET 2017
2From: Bjorn Helgaas <bhelgaas@google.com>
3Date: Mon, 2 Jan 2017 14:04:24 -0600
4Subject: PCI: Apply _HPX settings only to relevant devices
5
6From: Bjorn Helgaas <bhelgaas@google.com>
7
8
9[ Upstream commit 977509f7c5c6fb992ffcdf4291051af343b91645 ]
10
11Previously we didn't check the type of device before trying to apply Type 1
12(PCI-X) or Type 2 (PCIe) Setting Records from _HPX.
13
14We don't support PCI-X Setting Records, so this was harmless, but the
15warning was useless.
16
17We do support PCIe Setting Records, and we didn't check whether a device
18was PCIe before applying settings. I don't think anything bad happened on
19non-PCIe devices because pcie_capability_clear_and_set_word(),
20pcie_cap_has_lnkctl(), etc., would fail before doing any harm. But it's
21ugly to depend on those internals.
22
23Check the device type before attempting to apply Type 1 and Type 2 Setting
24Records (Type 0 records are applicable to PCI, PCI-X, and PCIe devices).
25
26A side benefit is that this prevents useless "not supported" warnings when
27a BIOS supplies a Type 1 (PCI-X) Setting Record and we try to apply it to
28every single device:
29
30 pci 0000:00:00.0: PCI-X settings not supported
31
32After this patch, we'll get the warning only when a BIOS supplies a Type 1
33record and we have a PCI-X device to which it should be applied.
34
35Link: https://bugzilla.kernel.org/show_bug.cgi?id=187731
36Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
37Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
38Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
39---
40 drivers/pci/probe.c | 15 +++++++++++++--
41 1 file changed, 13 insertions(+), 2 deletions(-)
42
43--- a/drivers/pci/probe.c
44+++ b/drivers/pci/probe.c
45@@ -1329,8 +1329,16 @@ static void program_hpp_type0(struct pci
46
47 static void program_hpp_type1(struct pci_dev *dev, struct hpp_type1 *hpp)
48 {
49- if (hpp)
50- dev_warn(&dev->dev, "PCI-X settings not supported\n");
51+ int pos;
52+
53+ if (!hpp)
54+ return;
55+
56+ pos = pci_find_capability(dev, PCI_CAP_ID_PCIX);
57+ if (!pos)
58+ return;
59+
60+ dev_warn(&dev->dev, "PCI-X settings not supported\n");
61 }
62
63 static void program_hpp_type2(struct pci_dev *dev, struct hpp_type2 *hpp)
64@@ -1341,6 +1349,9 @@ static void program_hpp_type2(struct pci
65 if (!hpp)
66 return;
67
68+ if (!pci_is_pcie(dev))
69+ return;
70+
71 if (hpp->revision > 1) {
72 dev_warn(&dev->dev, "PCIe settings rev %d not supported\n",
73 hpp->revision);