]>
Commit | Line | Data |
---|---|---|
af98e849 GKH |
1 | From foo@baz Tue Nov 28 10:58:31 CET 2017 |
2 | From: Bjorn Helgaas <bhelgaas@google.com> | |
3 | Date: Mon, 2 Jan 2017 14:04:24 -0600 | |
4 | Subject: PCI: Apply _HPX settings only to relevant devices | |
5 | ||
6 | From: Bjorn Helgaas <bhelgaas@google.com> | |
7 | ||
8 | ||
9 | [ Upstream commit 977509f7c5c6fb992ffcdf4291051af343b91645 ] | |
10 | ||
11 | Previously 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 | ||
14 | We don't support PCI-X Setting Records, so this was harmless, but the | |
15 | warning was useless. | |
16 | ||
17 | We do support PCIe Setting Records, and we didn't check whether a device | |
18 | was PCIe before applying settings. I don't think anything bad happened on | |
19 | non-PCIe devices because pcie_capability_clear_and_set_word(), | |
20 | pcie_cap_has_lnkctl(), etc., would fail before doing any harm. But it's | |
21 | ugly to depend on those internals. | |
22 | ||
23 | Check the device type before attempting to apply Type 1 and Type 2 Setting | |
24 | Records (Type 0 records are applicable to PCI, PCI-X, and PCIe devices). | |
25 | ||
26 | A side benefit is that this prevents useless "not supported" warnings when | |
27 | a BIOS supplies a Type 1 (PCI-X) Setting Record and we try to apply it to | |
28 | every single device: | |
29 | ||
30 | pci 0000:00:00.0: PCI-X settings not supported | |
31 | ||
32 | After this patch, we'll get the warning only when a BIOS supplies a Type 1 | |
33 | record and we have a PCI-X device to which it should be applied. | |
34 | ||
35 | Link: https://bugzilla.kernel.org/show_bug.cgi?id=187731 | |
36 | Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> | |
37 | Signed-off-by: Sasha Levin <alexander.levin@verizon.com> | |
38 | Signed-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); |