Skip to contentSkip to conversation

vfio/pci: Add pba_offset PCI quirk for BAIDU KUNLUN AI processor

PATCH New Cai Huoqing 1 participant 1 message Jul 13, 2021

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 vfio/pci: Add pba_offset PCI quirk for BAIDU KUNLUN AI processor

Fix pba_offset initialization value for BAIDU KUNLUN Virtual Function device. The KUNLUN hardware returns an incorrect value for the VF PBA offset, and add a quirk to instead return a hardcoded value of 0xb400.
v1->v2:
*add the incorrect value and BAR size to comment *use vfio_pci_is instead of using an "encoding" *remove unused device id PCI_DEVICE_ID_KUNLUN

---
 hw/vfio/pci.c            | 9 +++++++++
 include/hw/pci/pci_ids.h | 3 +++
 2 files changed, 12 insertions(+)
hw/vfio/pci.c +9 -0
index ab4077aad2..ad29fb4dff 100644
@@ -1499,6 +1499,15 @@ static void vfio_msix_early_setup(VFIOPCIDevice *vdev, Error **errp)
         if (vdev->vendor_id == PCI_VENDOR_ID_CHELSIO &&
             (vdev->device_id & 0xff00) == 0x5800) {
             msix->pba_offset = 0x1000;
+        /*
+         * BAIDU KUNLUN Virtual Function devices are encoded as 0x3685 for
+         * KUNLUN AI processor. The KUNLUN hardware returns an incorrect
+         * value of 0x460000 for the VF PBA offset while the BAR itself 0x10000.
+         * The correct value is 0xb400.
+         */
+        } else if (vfio_pci_is(vdev, PCI_VENDOR_ID_BAIDU,
+                   PCI_DEVICE_ID_KUNLUN_VF)) {
+            msix->pba_offset = 0xb400;
         } else if (vdev->msix_relo == OFF_AUTOPCIBAR_OFF) {
             error_setg(errp, "hardware reports invalid configuration, "
                        "MSIX PBA outside of specified BAR");
include/hw/pci/pci_ids.h +3 -0
index 5c14681b82..11abe22d46 100644
@@ -227,6 +227,9 @@
 #define PCI_VENDOR_ID_FREESCALE          0x1957
 #define PCI_DEVICE_ID_MPC8533E           0x0030
 
+#define PCI_VENDOR_ID_BAIDU              0x1d22
+#define PCI_DEVICE_ID_KUNLUN_VF          0x3685
+
 #define PCI_VENDOR_ID_INTEL              0x8086
 #define PCI_DEVICE_ID_INTEL_82378        0x0484
 #define PCI_DEVICE_ID_INTEL_82441        0x1237
Signature · 1 line
2.25.1