linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Longfang Liu <liulongfang@huawei.com>
To: <alex.williamson@redhar.com>
Cc: <cohuck@redhat.com>, <linux-kernel@vger.kernel.org>,
	<linuxarm@openeuler.org>, <liulongfang@huawei.com>
Subject: [RFC PATCH 2/3] vfio/hisilicon: register the driver to vfio
Date: Mon, 12 Apr 2021 16:53:15 +0800	[thread overview]
Message-ID: <1618217596-13621-3-git-send-email-liulongfang@huawei.com> (raw)
In-Reply-To: <1618217596-13621-1-git-send-email-liulongfang@huawei.com>

Register the live migration driver of the accelerator module to vfio

Signed-off-by: Longfang Liu <liulongfang@huawei.com>
Reviewed-by: Zengtao <prime.zeng@hisilicon.com>
---
 drivers/vfio/pci/vfio_pci.c         | 11 +++++++++++
 drivers/vfio/pci/vfio_pci_private.h | 10 ++++++++++
 2 files changed, 21 insertions(+)

diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index f041b1a..50d1138 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -293,6 +293,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 f561ac1..74bb611 100644
--- a/drivers/vfio/pci/vfio_pci_private.h
+++ b/drivers/vfio/pci/vfio_pci_private.h
@@ -138,4 +138,14 @@ static inline int vfio_pci_igd_init(struct vfio_pci_device *vdev)
 	return -ENODEV;
 }
 #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
+
 #endif /* VFIO_PCI_PRIVATE_H */
-- 
2.8.1


  parent reply	other threads:[~2021-04-12  9:11 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-12  8:53 [RFC PATCH v3 0/3] vfio/hisilicon: add acc live migration driver Longfang Liu
2021-04-12  8:53 ` [RFC PATCH 1/3] " Longfang Liu
2021-04-12  8:53 ` Longfang Liu [this message]
2021-04-12  8:53 ` [RFC PATCH 3/3] vfio/hisilicom: add debugfs for driver Longfang Liu
2021-04-13  1:17 ` [RFC PATCH v3 0/3] vfio/hisilicon: add acc live migration driver liulongfang
2021-04-13  1:20 Longfang Liu
2021-04-13  1:20 ` [RFC PATCH 2/3] vfio/hisilicon: register the driver to vfio Longfang Liu
2021-04-13  3:36 [RFC PATCH 0/3] vfio/hisilicon: add acc live migration driver Longfang Liu
2021-04-13  3:36 ` [RFC PATCH 2/3] vfio/hisilicon: register the driver to vfio Longfang Liu
2021-04-15 22:01   ` Jason Gunthorpe
2021-04-19 12:24     ` liulongfang
2021-04-19 12:33       ` Jason Gunthorpe
2021-04-20 12:50         ` liulongfang
2021-04-20 12:59           ` Jason Gunthorpe
2021-04-20 13:28             ` liulongfang
2021-04-20 14:55               ` Jason Gunthorpe
2021-04-20 22:04             ` Alex Williamson
2021-04-20 23:18               ` Jason Gunthorpe
2021-04-21  9:59                 ` liulongfang
2021-04-21  9:59               ` liulongfang
2021-04-21 18:12                 ` Alex Williamson
2021-04-26 11:49                   ` liulongfang
2021-05-12  8:39                   ` liulongfang
2021-05-12 12:10                     ` Jason Gunthorpe
2021-05-13  2:08                       ` liulongfang
2021-05-13 13:44                         ` Jason Gunthorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1618217596-13621-3-git-send-email-liulongfang@huawei.com \
    --to=liulongfang@huawei.com \
    --cc=alex.williamson@redhar.com \
    --cc=cohuck@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxarm@openeuler.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).