Skip to content

Commit 37e0ffd

Browse files
Ziyao LiFearyncess
authored andcommitted
AOSCOS: PCI: loongson: Override PCIe bridge supported speeds for older Loongson 3C6000 series steppings
Older steppings of the Loongson 3C6000 series incorrectly report the supported link speeds on their PCIe bridges (device IDs 3c19, 3c29) as only 2.5 GT/s, despite the upstream bus supporting speeds from 2.5 GT/s up to 16 GT/s. As a result, certain PCIe devices would be incorrectly probed as a Gen1- only, even if higher link speeds are supported, harming performance and prevents dynamic link speed functionality from being enabled in drivers such as amdgpu. Manually override the `supported_speeds` field for affected PCIe bridges with those found on the upstream bus to correctly reflect the supported link speeds. This patch was originally found from AOSC OS[1]. Link: #2 #1 Tested-by: Lain Fearyncess Yang <fsf@live.com> Tested-by: Mingcong Bai <jeffbai@aosc.io> Tested-by: Ayden Meng <aydenmeng@yeah.net> Signed-off-by: Ayden Meng <aydenmeng@yeah.net> Signed-off-by: Mingcong Bai <jeffbai@aosc.io> [Xi Ruoyao: Fix falling through logic and add kernel log output.] Signed-off-by: Xi Ruoyao <xry111@xry111.site> Link: 4392f44 [Ziyao Li: move from drivers/pci/quirks.c to drivers/pci/controller/pci-loongson.c] Signed-off-by: Ziyao Li <liziyao@uniontech.com> [For testing before submission to mailing list.] Signed-off-by: Mingcong Bai <jeffbai@aosc.io>
1 parent 96e890f commit 37e0ffd

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

drivers/pci/controller/pci-loongson.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,47 @@ static void loongson_pci_msi_quirk(struct pci_dev *dev)
176176
}
177177
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LOONGSON, DEV_LS7A_PCIE_PORT5, loongson_pci_msi_quirk);
178178

179+
/*
180+
* Older steppings of the Loongson 3C6000 series incorrectly report the
181+
* supported link speeds on their PCIe bridges (device IDs 3c19, 3c29) as
182+
* only 2.5 GT/s, despite the upstream bus supporting speeds from 2.5 GT/s
183+
* up to 16 GT/s.
184+
*/
185+
186+
static void quirk_loongson_pci_bridge_supported_speeds(struct pci_dev *pdev)
187+
{
188+
u8 supported_speeds = pdev->supported_speeds;
189+
190+
switch (pdev->bus->max_bus_speed) {
191+
case PCIE_SPEED_16_0GT:
192+
supported_speeds |= PCI_EXP_LNKCAP2_SLS_16_0GB;
193+
fallthrough;
194+
case PCIE_SPEED_8_0GT:
195+
supported_speeds |= PCI_EXP_LNKCAP2_SLS_8_0GB;
196+
fallthrough;
197+
case PCIE_SPEED_5_0GT:
198+
supported_speeds |= PCI_EXP_LNKCAP2_SLS_5_0GB;
199+
fallthrough;
200+
case PCIE_SPEED_2_5GT:
201+
supported_speeds |= PCI_EXP_LNKCAP2_SLS_2_5GB;
202+
break;
203+
default:
204+
pci_warn(pdev, "unexpected max bus speed");
205+
return;
206+
}
207+
208+
if (supported_speeds != pdev->supported_speeds) {
209+
pci_info(pdev, "fixing up supported link speeds: 0x%x => 0x%x",
210+
pdev->supported_speeds, supported_speeds);
211+
pdev->supported_speeds = supported_speeds;
212+
}
213+
}
214+
215+
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_LOONGSON, 0x3c19,
216+
quirk_loongson_pci_bridge_supported_speeds);
217+
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_LOONGSON, 0x3c29,
218+
quirk_loongson_pci_bridge_supported_speeds);
219+
179220
static struct loongson_pci *pci_bus_to_loongson_pci(struct pci_bus *bus)
180221
{
181222
struct pci_config_window *cfg;

0 commit comments

Comments
 (0)