All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brett Creeley <bcreeley@amd.com>
To: Xin Zeng <xin.zeng@intel.com>,
	linux-crypto@vger.kernel.org, kvm@vger.kernel.org
Cc: giovanni.cabiddu@intel.com, andriy.shevchenko@linux.intel.com,
	Yahui Cao <yahui.cao@intel.com>
Subject: Re: [RFC 5/5] vfio/qat: Add vfio_pci driver for Intel QAT VF devices
Date: Wed, 16 Aug 2023 09:20:07 -0700	[thread overview]
Message-ID: <10f3159d-62ae-0e4c-8ba4-6f7819a47ecb@amd.com> (raw)
In-Reply-To: <20230630131304.64243-6-xin.zeng@intel.com>

On 6/30/2023 6:13 AM, Xin Zeng wrote:
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
> 
> 
> Add vfio pci driver for Intel QAT VF devices.
> 
> This driver uses vfio_pci_core to register to the VFIO subsystem. It
> acts as a vfio agent and interacts with the QAT PF driver to implement
> VF live migration.
> 
> Co-developed-by: Yahui Cao <yahui.cao@intel.com>
> Signed-off-by: Yahui Cao <yahui.cao@intel.com>
> Signed-off-by: Xin Zeng <xin.zeng@intel.com>
> ---
>   drivers/vfio/pci/Kconfig                 |   2 +
>   drivers/vfio/pci/Makefile                |   1 +
>   drivers/vfio/pci/qat/Kconfig             |  13 +
>   drivers/vfio/pci/qat/Makefile            |   4 +
>   drivers/vfio/pci/qat/qat_vfio_pci_main.c | 518 +++++++++++++++++++++++
>   5 files changed, 538 insertions(+)
>   create mode 100644 drivers/vfio/pci/qat/Kconfig
>   create mode 100644 drivers/vfio/pci/qat/Makefile
>   create mode 100644 drivers/vfio/pci/qat/qat_vfio_pci_main.c
> 

[...]

> +
> +static int
> +qat_vf_vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> +{
> +       struct device *dev = &pdev->dev;
> +       struct qat_vf_core_device *qat_vdev;
> +       int ret;
> +
> +       qat_vdev = vfio_alloc_device(qat_vf_core_device, core_device.vdev, dev, &qat_vf_pci_ops);
> +       if (IS_ERR(qat_vdev))
> +               return PTR_ERR(qat_vdev);
> +
> +       qat_vdev->vf_id = pci_iov_vf_id(pdev);
> +       qat_vdev->parent = pdev->physfn;
> +       if (!qat_vdev->parent || qat_vdev->vf_id < 0)
> +               return -EINVAL;

Since vfio_alloc_device() was successful you need to call 
vfio_put_device() in this error case as well.

> +
> +       pci_set_drvdata(pdev, &qat_vdev->core_device);
> +       ret = vfio_pci_core_register_device(&qat_vdev->core_device);
> +       if (ret)
> +               goto out_put_device;
> +
> +       return 0;
> +
> +out_put_device:
> +       vfio_put_device(&qat_vdev->core_device.vdev);
> +       return ret;
> +}
> +
> +static struct qat_vf_core_device *qat_vf_drvdata(struct pci_dev *pdev)
> +{
> +       struct vfio_pci_core_device *core_device = pci_get_drvdata(pdev);
> +
> +       return container_of(core_device, struct qat_vf_core_device, core_device);
> +}
> +
> +static void qat_vf_vfio_pci_remove(struct pci_dev *pdev)
> +{
> +       struct qat_vf_core_device *qat_vdev = qat_vf_drvdata(pdev);
> +
> +       vfio_pci_core_unregister_device(&qat_vdev->core_device);
> +       vfio_put_device(&qat_vdev->core_device.vdev);
> +}
> +
> +static const struct pci_device_id qat_vf_vfio_pci_table[] = {
> +       /* Intel QAT GEN4 4xxx VF device */
> +       { PCI_DRIVER_OVERRIDE_DEVICE_VFIO(PCI_VENDOR_ID_INTEL, 0x4941) },
> +       {}
> +};
> +MODULE_DEVICE_TABLE(pci, qat_vf_vfio_pci_table);
> +
> +static struct pci_driver qat_vf_vfio_pci_driver = {
> +       .name = "qat_vfio_pci",
> +       .id_table = qat_vf_vfio_pci_table,
> +       .probe = qat_vf_vfio_pci_probe,
> +       .remove = qat_vf_vfio_pci_remove,
> +       .driver_managed_dma = true,
> +};
> +module_pci_driver(qat_vf_vfio_pci_driver)
> +
> +MODULE_LICENSE("GPL");
> +MODULE_AUTHOR("Intel Corporation");
> +MODULE_DESCRIPTION("QAT VFIO PCI - VFIO PCI driver with live migration support for Intel(R) QAT device family");
> --
> 2.18.2
> 

  parent reply	other threads:[~2023-08-16 16:21 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-30 13:12 [RFC 0/5] crypto: qat - enable SRIOV VF live migration Xin Zeng
2023-06-30 13:13 ` [RFC 1/5] crypto: qat - add bank save/restore and RP drain Xin Zeng
2023-08-04  7:51   ` Tian, Kevin
2023-08-11  8:52     ` Wan, Siming
2023-06-30 13:13 ` [RFC 2/5] crypto: qat - add interface for live migration Xin Zeng
2023-08-04  7:52   ` Tian, Kevin
2023-08-24  7:27     ` Zeng, Xin
2023-06-30 13:13 ` [RFC 3/5] units: Add HZ_PER_GHZ Xin Zeng
2023-06-30 13:13 ` [RFC 4/5] crypto: qat - implement interface for live migration Xin Zeng
2023-08-04  7:55   ` Tian, Kevin
2023-08-24  7:28     ` Zeng, Xin
2023-06-30 13:13 ` [RFC 5/5] vfio/qat: Add vfio_pci driver for Intel QAT VF devices Xin Zeng
2023-07-26 19:37   ` Alex Williamson
2023-08-23 15:29     ` Zeng, Xin
2023-08-24 15:25       ` Alex Williamson
2023-08-04  8:09   ` Tian, Kevin
2023-08-24  7:29     ` Zeng, Xin
2023-08-16 16:20   ` Brett Creeley [this message]
2023-08-24  7:31     ` Zeng, Xin

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=10f3159d-62ae-0e4c-8ba4-6f7819a47ecb@amd.com \
    --to=bcreeley@amd.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=giovanni.cabiddu@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=xin.zeng@intel.com \
    --cc=yahui.cao@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.