From: Jason Wang <jasowang@redhat.com>
To: Zhu Lingshan <lingshan.zhu@intel.com>,
mst@redhat.com, alex.williamson@redhat.com, pbonzini@redhat.com,
sean.j.christopherson@intel.com, wanpengli@tencent.com
Cc: virtualization@lists.linux-foundation.org, kvm@vger.kernel.org,
netdev@vger.kernel.org, dan.daly@intel.com
Subject: Re: [PATCH 4/7] vDPA: implement IRQ offloading helpers in vDPA core
Date: Mon, 13 Jul 2020 16:27:08 +0800 [thread overview]
Message-ID: <6e8b267c-0734-1d9b-d3da-e2e6f44f7847@redhat.com> (raw)
In-Reply-To: <1594565366-3195-4-git-send-email-lingshan.zhu@intel.com>
On 2020/7/12 下午10:49, Zhu Lingshan wrote:
> This commit implements IRQ offloading helpers in vDPA core by
> introducing two couple of functions:
>
> vdpa_alloc_vq_irq() and vdpa_free_vq_irq(): request irq and free
> irq, will setup irq offloading if irq_bypass is enabled.
>
> vdpa_setup_irq() and vdpa_unsetup_irq(): supportive functions,
> will call vhost_vdpa helpers.
>
> Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com>
This patch should go before patch 3.
> ---
> drivers/vdpa/vdpa.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
> drivers/vhost/Kconfig | 1 +
> drivers/vhost/vdpa.c | 2 ++
> include/linux/vdpa.h | 11 +++++++++++
> 4 files changed, 60 insertions(+)
>
> diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
> index ff6562f..d8eba01 100644
> --- a/drivers/vdpa/vdpa.c
> +++ b/drivers/vdpa/vdpa.c
> @@ -163,6 +163,52 @@ void vdpa_unregister_driver(struct vdpa_driver *drv)
> }
> EXPORT_SYMBOL_GPL(vdpa_unregister_driver);
>
> +static void vdpa_setup_irq(struct vdpa_device *vdev, int qid, int irq)
> +{
> + struct vdpa_driver *drv = drv_to_vdpa(vdev->dev.driver);
> +
> +#ifdef CONFIG_HAVE_KVM_IRQ_BYPASS
Let's don't do the check here. It's the responsibility of driver to
decide what it should do.
> + if (drv->setup_vq_irq)
> + drv->setup_vq_irq(vdev, qid, irq);
> +#endif
> +}
> +
> +static void vdpa_unsetup_irq(struct vdpa_device *vdev, int qid)
> +{
> + struct vdpa_driver *drv = drv_to_vdpa(vdev->dev.driver);
> +
> +#ifdef CONFIG_HAVE_KVM_IRQ_BYPASS
> + if (drv->unsetup_vq_irq)
> + drv->unsetup_vq_irq(vdev, qid);
> +#endif
> +}
> +
> +int vdpa_alloc_vq_irq(struct device *dev, struct vdpa_device *vdev,
> + unsigned int irq, irq_handler_t handler,
> + unsigned long irqflags, const char *devname, void *dev_id,
> + int qid)
> +{
> + int ret;
> +
> + ret = devm_request_irq(dev, irq, handler, irqflags, devname, dev_id);
> + if (ret)
> + dev_err(dev, "Failed to request irq for vq %d\n", qid);
> + else
> + vdpa_setup_irq(vdev, qid, irq);
I'd like to squash the vdpa_setup_irq logic here.
> +
> + return ret;
> +
> +}
> +EXPORT_SYMBOL_GPL(vdpa_alloc_vq_irq);
> +
> +void vdpa_free_vq_irq(struct device *dev, struct vdpa_device *vdev, int irq,
> + int qid, void *dev_id)
> +{
> + devm_free_irq(dev, irq, dev_id);
> + vdpa_unsetup_irq(vdev, qid);
> +}
> +EXPORT_SYMBOL_GPL(vdpa_free_vq_irq);
> +
> static int vdpa_init(void)
> {
> return bus_register(&vdpa_bus);
> diff --git a/drivers/vhost/Kconfig b/drivers/vhost/Kconfig
Let squash the vhost patch into patch 3.
> index d3688c6..587fbae 100644
> --- a/drivers/vhost/Kconfig
> +++ b/drivers/vhost/Kconfig
> @@ -65,6 +65,7 @@ config VHOST_VDPA
> tristate "Vhost driver for vDPA-based backend"
> depends on EVENTFD
> select VHOST
> + select IRQ_BYPASS_MANAGER
> depends on VDPA
> help
> This kernel module can be loaded in host kernel to accelerate
> diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
> index 92683e4..6e25158 100644
> --- a/drivers/vhost/vdpa.c
> +++ b/drivers/vhost/vdpa.c
> @@ -1020,6 +1020,8 @@ static void vhost_vdpa_remove(struct vdpa_device *vdpa)
> },
> .probe = vhost_vdpa_probe,
> .remove = vhost_vdpa_remove,
> + .setup_vq_irq = vhost_vdpa_setup_vq_irq,
> + .unsetup_vq_irq = vhost_vdpa_unsetup_vq_irq,
> };
>
> static int __init vhost_vdpa_init(void)
> diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h
> index 239db79..9f9b245 100644
> --- a/include/linux/vdpa.h
> +++ b/include/linux/vdpa.h
> @@ -220,17 +220,28 @@ struct vdpa_device *__vdpa_alloc_device(struct device *parent,
>
> int vdpa_register_device(struct vdpa_device *vdev);
> void vdpa_unregister_device(struct vdpa_device *vdev);
> +int vdpa_alloc_vq_irq(struct device *dev, struct vdpa_device *vdev,
> + unsigned int irq, irq_handler_t handler,
> + unsigned long irqflags, const char *devname, void *dev_id,
> + int qid);
> +void vdpa_free_vq_irq(struct device *dev, struct vdpa_device *vdev, int irq,
> + int qid, void *dev_id);
You need to document the devres implications of those two helpers.
> +
>
> /**
> * vdpa_driver - operations for a vDPA driver
> * @driver: underlying device driver
> * @probe: the function to call when a device is found. Returns 0 or -errno.
> * @remove: the function to call when a device is removed.
> + * @setup_vq_irq: setup irq bypass for a vhost_vdpa vq.
> + * @unsetup_vq_irq: unsetup irq bypass for a vhost_vdpa vq.
Though irq bypass is used by vhost-vdpa, it's not necessarily to be true
in the future. So it's better not to mention irqbypass in the doc here.
Thanks
> */
> struct vdpa_driver {
> struct device_driver driver;
> int (*probe)(struct vdpa_device *vdev);
> void (*remove)(struct vdpa_device *vdev);
> + void (*setup_vq_irq)(struct vdpa_device *vdev, int qid, int irq);
> + void (*unsetup_vq_irq)(struct vdpa_device *vdev, int qid);
> };
>
> #define vdpa_register_driver(drv) \
next prev parent reply other threads:[~2020-07-13 8:27 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1594565366-3195-1-git-send-email-lingshan.zhu@intel.com>
[not found] ` <1594565366-3195-2-git-send-email-lingshan.zhu@intel.com>
2020-07-12 15:29 ` [PATCH 2/7] kvm/vfio: detect assigned device via irqbypass manager Alex Williamson
2020-07-13 7:57 ` Jason Wang
2020-07-12 21:06 ` Michael S. Tsirkin
2020-07-13 8:13 ` Jason Wang
2020-07-13 10:52 ` Michael S. Tsirkin
[not found] ` <aca899f7-ec2e-2b55-df78-44eacb923c00@intel.com>
2020-07-14 9:03 ` Michael S. Tsirkin
[not found] ` <1594565366-3195-3-git-send-email-lingshan.zhu@intel.com>
2020-07-13 8:22 ` [PATCH 3/7] vhost_vdpa: implement IRQ offloading functions in vhost_vdpa Jason Wang
[not found] ` <e06f9706-441f-0d7a-c8c0-cd43a26c5296@intel.com>
2020-07-15 8:51 ` Jason Wang
[not found] ` <8f52ee3a-7a08-db14-9194-8085432481a4@intel.com>
2020-07-15 9:06 ` Jason Wang
[not found] ` <61c1753a-43dc-e448-6ece-13a19058e621@intel.com>
2020-07-15 9:42 ` Jason Wang
2020-07-15 11:09 ` Zhu, Lingshan
[not found] ` <1594565366-3195-4-git-send-email-lingshan.zhu@intel.com>
2020-07-13 8:27 ` Jason Wang [this message]
[not found] ` <1594565366-3195-5-git-send-email-lingshan.zhu@intel.com>
2020-07-13 8:28 ` [PATCH 5/7] virtio_vdpa: init IRQ offloading function pointers to NULL Jason Wang
[not found] ` <ba1ea94c-b0ae-8bd8-8425-64b096512d3d@intel.com>
2020-07-15 8:43 ` Jason Wang
[not found] ` <1594565366-3195-6-git-send-email-lingshan.zhu@intel.com>
2020-07-13 8:33 ` [PATCH 6/7] ifcvf: replace irq_request/free with helpers in vDPA core Jason Wang
[not found] ` <f6fc09e2-7a45-aaa5-2b4a-f1f963c5ce2c@intel.com>
2020-07-15 8:40 ` Jason Wang
2020-07-15 10:01 ` Michael S. Tsirkin
2020-07-15 10:04 ` Jason Wang
2020-07-15 11:10 ` Zhu, Lingshan
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=6e8b267c-0734-1d9b-d3da-e2e6f44f7847@redhat.com \
--to=jasowang@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=dan.daly@intel.com \
--cc=kvm@vger.kernel.org \
--cc=lingshan.zhu@intel.com \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=sean.j.christopherson@intel.com \
--cc=virtualization@lists.linux-foundation.org \
--cc=wanpengli@tencent.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 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).