PCI: Add ACS quirk for Loongson PCIe
authorHuacai Chen <chenhuacai@loongson.cn>
Thu, 3 Apr 2025 04:07:56 +0000 (12:07 +0800)
committerBjorn Helgaas <bhelgaas@google.com>
Thu, 17 Apr 2025 20:26:46 +0000 (15:26 -0500)
Loongson PCIe Root Ports don't advertise an ACS capability, but they do not
allow peer-to-peer transactions between Root Ports. Add an ACS quirk so
each Root Port can be in a separate IOMMU group.

Signed-off-by: Xianglai Li <lixianglai@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20250403040756.720409-1-chenhuacai@loongson.cn
drivers/pci/quirks.c

index 8d610c17e0f2f0d59f54ee3fc16d808f119bfd27..eee96ad03614eab3a925285a707d104f132fa26c 100644 (file)
@@ -4995,6 +4995,18 @@ static int pci_quirk_brcm_acs(struct pci_dev *dev, u16 acs_flags)
                PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF);
 }
 
+static int pci_quirk_loongson_acs(struct pci_dev *dev, u16 acs_flags)
+{
+       /*
+        * Loongson PCIe Root Ports don't advertise an ACS capability, but
+        * they do not allow peer-to-peer transactions between Root Ports.
+        * Allow each Root Port to be in a separate IOMMU group by masking
+        * SV/RR/CR/UF bits.
+        */
+       return pci_acs_ctrl_enabled(acs_flags,
+               PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF);
+}
+
 /*
  * Wangxun 40G/25G/10G/1G NICs have no ACS capability, but on
  * multi-function devices, the hardware isolates the functions by
@@ -5128,6 +5140,17 @@ static const struct pci_dev_acs_enabled {
        { PCI_VENDOR_ID_BROADCOM, 0x1762, pci_quirk_mf_endpoint_acs },
        { PCI_VENDOR_ID_BROADCOM, 0x1763, pci_quirk_mf_endpoint_acs },
        { PCI_VENDOR_ID_BROADCOM, 0xD714, pci_quirk_brcm_acs },
+       /* Loongson PCIe Root Ports */
+       { PCI_VENDOR_ID_LOONGSON, 0x3C09, pci_quirk_loongson_acs },
+       { PCI_VENDOR_ID_LOONGSON, 0x3C19, pci_quirk_loongson_acs },
+       { PCI_VENDOR_ID_LOONGSON, 0x3C29, pci_quirk_loongson_acs },
+       { PCI_VENDOR_ID_LOONGSON, 0x7A09, pci_quirk_loongson_acs },
+       { PCI_VENDOR_ID_LOONGSON, 0x7A19, pci_quirk_loongson_acs },
+       { PCI_VENDOR_ID_LOONGSON, 0x7A29, pci_quirk_loongson_acs },
+       { PCI_VENDOR_ID_LOONGSON, 0x7A39, pci_quirk_loongson_acs },
+       { PCI_VENDOR_ID_LOONGSON, 0x7A49, pci_quirk_loongson_acs },
+       { PCI_VENDOR_ID_LOONGSON, 0x7A59, pci_quirk_loongson_acs },
+       { PCI_VENDOR_ID_LOONGSON, 0x7A69, pci_quirk_loongson_acs },
        /* Amazon Annapurna Labs */
        { PCI_VENDOR_ID_AMAZON_ANNAPURNA_LABS, 0x0031, pci_quirk_al_acs },
        /* Zhaoxin multi-function devices */