[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1618284983-55581-3-git-send-email-liulongfang@huawei.com>
Date: Tue, 13 Apr 2021 11:36:22 +0800
From: Longfang Liu <liulongfang@...wei.com>
To: <alex.williamson@...hat.com>
CC: <cohuck@...hat.com>, <linux-kernel@...r.kernel.org>,
<linuxarm@...neuler.org>, <liulongfang@...wei.com>
Subject: [RFC PATCH 2/3] vfio/hisilicon: register the driver to vfio
Register the live migration driver of the accelerator module to vfio
Signed-off-by: Longfang Liu <liulongfang@...wei.com>
---
drivers/vfio/pci/vfio_pci.c | 11 +++++++++++
drivers/vfio/pci/vfio_pci_private.h | 9 +++++++++
2 files changed, 20 insertions(+)
diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index 65e7e6b..e1b0e37 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -407,6 +407,17 @@ static int vfio_pci_enable(struct vfio_pci_device *vdev)
}
}
+ if (pdev->vendor == PCI_VENDOR_ID_HUAWEI &&
+ IS_ENABLED(CONFIG_VFIO_PCI_HISI_MIGRATION)) {
+ ret = vfio_pci_hisilicon_acc_init(vdev);
+ if (ret && ret != -ENODEV) {
+ dev_warn(&vdev->pdev->dev,
+ "Failed to setup Hisilicon ACC region\n");
+ vfio_pci_disable(vdev);
+ return ret;
+ }
+ }
+
vfio_pci_probe_mmaps(vdev);
return 0;
diff --git a/drivers/vfio/pci/vfio_pci_private.h b/drivers/vfio/pci/vfio_pci_private.h
index 9cd1882..83c51be 100644
--- a/drivers/vfio/pci/vfio_pci_private.h
+++ b/drivers/vfio/pci/vfio_pci_private.h
@@ -214,6 +214,15 @@ static inline int vfio_pci_ibm_npu2_init(struct vfio_pci_device *vdev)
}
#endif
+#ifdef CONFIG_VFIO_PCI_HISI_MIGRATION
+extern int vfio_pci_hisilicon_acc_init(struct vfio_pci_device *vdev);
+#else
+static inline int vfio_pci_hisilicon_acc_init(struct vfio_pci_device *vdev)
+{
+ return -ENODEV;
+}
+#endif
+
#ifdef CONFIG_S390
extern int vfio_pci_info_zdev_add_caps(struct vfio_pci_device *vdev,
struct vfio_info_cap *caps);
--
2.8.1
Powered by blists - more mailing lists