@@ -6199,38 +6199,64 @@ u32 pcie_bandwidth_available(struct pci_dev *dev, struct pci_dev **limiting_dev, |
6199 | 6199 | EXPORT_SYMBOL(pcie_bandwidth_available); |
6200 | 6200 |
|
6201 | 6201 | /** |
6202 | | - * pcie_get_speed_cap - query for the PCI device's link speed capability |
| 6202 | + * pcie_get_supported_speeds - query Supported Link Speed Vector |
6203 | 6203 | * @dev: PCI device to query |
6204 | 6204 | * |
6205 | | - * Query the PCI device speed capability. Return the maximum link speed |
6206 | | - * supported by the device. |
| 6205 | + * Query @dev supported link speeds. |
| 6206 | + * |
| 6207 | + * Implementation Note in PCIe r6.0 sec 7.5.3.18 recommends determining |
| 6208 | + * supported link speeds using the Supported Link Speeds Vector in the Link |
| 6209 | + * Capabilities 2 Register (when available). |
| 6210 | + * |
| 6211 | + * Link Capabilities 2 was added in PCIe r3.0, sec 7.8.18. |
| 6212 | + * |
| 6213 | + * Without Link Capabilities 2, i.e., prior to PCIe r3.0, Supported Link |
| 6214 | + * Speeds field in Link Capabilities is used and only 2.5 GT/s and 5.0 GT/s |
| 6215 | + * speeds were defined. |
| 6216 | + * |
| 6217 | + * For @dev without Supported Link Speed Vector, the field is synthesized |
| 6218 | + * from the Max Link Speed field in the Link Capabilities Register. |
| 6219 | + * |
| 6220 | + * Return: Supported Link Speeds Vector (+ reserved 0 at LSB). |
6207 | 6221 | */ |
6208 | | -enum pci_bus_speed pcie_get_speed_cap(struct pci_dev *dev) |
| 6222 | +u8 pcie_get_supported_speeds(struct pci_dev *dev) |
6209 | 6223 | { |
6210 | 6224 | u32 lnkcap2, lnkcap; |
| 6225 | + u8 speeds; |
6211 | 6226 |
|
6212 | 6227 | /* |
6213 | | - * Link Capabilities 2 was added in PCIe r3.0, sec 7.8.18. The |
6214 | | - * implementation note there recommends using the Supported Link |
6215 | | - * Speeds Vector in Link Capabilities 2 when supported. |
6216 | | - * |
6217 | | - * Without Link Capabilities 2, i.e., prior to PCIe r3.0, software |
6218 | | - * should use the Supported Link Speeds field in Link Capabilities, |
6219 | | - * where only 2.5 GT/s and 5.0 GT/s speeds were defined. |
| 6228 | + * Speeds retain the reserved 0 at LSB before PCIe Supported Link |
| 6229 | + * Speeds Vector to allow using SLS Vector bit defines directly. |
6220 | 6230 | */ |
6221 | 6231 | pcie_capability_read_dword(dev, PCI_EXP_LNKCAP2, &lnkcap2); |
| 6232 | + speeds = lnkcap2 & PCI_EXP_LNKCAP2_SLS; |
6222 | 6233 |
|
6223 | 6234 | /* PCIe r3.0-compliant */ |
6224 | | - if (lnkcap2) |
6225 | | - return PCIE_LNKCAP2_SLS2SPEED(lnkcap2); |
| 6235 | + if (speeds) |
| 6236 | + return speeds; |
6226 | 6237 |
|
6227 | 6238 | pcie_capability_read_dword(dev, PCI_EXP_LNKCAP, &lnkcap); |
| 6239 | + |
| 6240 | + /* Synthesize from the Max Link Speed field */ |
6228 | 6241 | if ((lnkcap & PCI_EXP_LNKCAP_SLS) == PCI_EXP_LNKCAP_SLS_5_0GB) |
6229 | | - return PCIE_SPEED_5_0GT; |
| 6242 | + speeds = PCI_EXP_LNKCAP2_SLS_5_0GB | PCI_EXP_LNKCAP2_SLS_2_5GB; |
6230 | 6243 | else if ((lnkcap & PCI_EXP_LNKCAP_SLS) == PCI_EXP_LNKCAP_SLS_2_5GB) |
6231 | | - return PCIE_SPEED_2_5GT; |
| 6244 | + speeds = PCI_EXP_LNKCAP2_SLS_2_5GB; |
6232 | 6245 |
|
6233 | | - return PCI_SPEED_UNKNOWN; |
| 6246 | + return speeds; |
| 6247 | +} |
| 6248 | + |
| 6249 | +/** |
| 6250 | + * pcie_get_speed_cap - query for the PCI device's link speed capability |
| 6251 | + * @dev: PCI device to query |
| 6252 | + * |
| 6253 | + * Query the PCI device speed capability. |
| 6254 | + * |
| 6255 | + * Return: the maximum link speed supported by the device. |
| 6256 | + */ |
| 6257 | +enum pci_bus_speed pcie_get_speed_cap(struct pci_dev *dev) |
| 6258 | +{ |
| 6259 | + return PCIE_LNKCAP2_SLS2SPEED(dev->supported_speeds); |
6234 | 6260 | } |
6235 | 6261 | EXPORT_SYMBOL(pcie_get_speed_cap); |
6236 | 6262 |
|
|