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 3/7] vhost_vdpa: implement IRQ offloading functions in vhost_vdpa
Date: Mon, 13 Jul 2020 16:22:33 +0800 [thread overview]
Message-ID: <3fb9ecfc-a325-69b5-f5b7-476a5683a324@redhat.com> (raw)
In-Reply-To: <1594565366-3195-3-git-send-email-lingshan.zhu@intel.com>
On 2020/7/12 下午10:49, Zhu Lingshan wrote:
> This patch introduce a set of functions for setup/unsetup
> and update irq offloading respectively by register/unregister
> and re-register the irq_bypass_producer.
>
> Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com>
> ---
> drivers/vhost/vdpa.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 69 insertions(+)
>
> diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
> index 2fcc422..92683e4 100644
> --- a/drivers/vhost/vdpa.c
> +++ b/drivers/vhost/vdpa.c
> @@ -115,6 +115,63 @@ static irqreturn_t vhost_vdpa_config_cb(void *private)
> return IRQ_HANDLED;
> }
>
> +static void vhost_vdpa_setup_vq_irq(struct vdpa_device *dev, int qid, int irq)
> +{
> + struct vhost_vdpa *v = vdpa_get_drvdata(dev);
> + struct vhost_virtqueue *vq = &v->vqs[qid];
> + int ret;
> +
> + vq_err(vq, "setup irq bypass for vq %d with irq = %d\n", qid, irq);
> + spin_lock(&vq->call_ctx.ctx_lock);
> + if (!vq->call_ctx.ctx)
> + return;
> +
> + vq->call_ctx.producer.token = vq->call_ctx.ctx;
> + vq->call_ctx.producer.irq = irq;
> + ret = irq_bypass_register_producer(&vq->call_ctx.producer);
> + spin_unlock(&vq->call_ctx.ctx_lock);
> +
> + if (unlikely(ret))
> + vq_err(vq,
> + "irq bypass producer (token %p registration fails: %d\n",
> + vq->call_ctx.producer.token, ret);
Not sure this deserves a vq_err(), irq will be relayed through eventfd
if irq bypass manager can't work.
> +}
> +
> +static void vhost_vdpa_unsetup_vq_irq(struct vdpa_device *dev, int qid)
> +{
> + struct vhost_vdpa *v = vdpa_get_drvdata(dev);
> + struct vhost_virtqueue *vq = &v->vqs[qid];
> +
> + spin_lock(&vq->call_ctx.ctx_lock);
> + irq_bypass_unregister_producer(&vq->call_ctx.producer);
> + spin_unlock(&vq->call_ctx.ctx_lock);
> +
> + vq_err(vq, "unsetup irq bypass for vq %d\n", qid);
Why call vq_err() here?
> +}
> +
> +static void vhost_vdpa_update_vq_irq(struct vhost_virtqueue *vq)
> +{
> + struct eventfd_ctx *ctx;
> + void *token;
> +
> + spin_lock(&vq->call_ctx.ctx_lock);
> + ctx = vq->call_ctx.ctx;
> + token = vq->call_ctx.producer.token;
> + if (ctx == token)
> + return;
Need do unlock here.
> +
> + if (!ctx && token)
> + irq_bypass_unregister_producer(&vq->call_ctx.producer);
> +
> + if (ctx && ctx != token) {
> + irq_bypass_unregister_producer(&vq->call_ctx.producer);
> + vq->call_ctx.producer.token = ctx;
> + irq_bypass_register_producer(&vq->call_ctx.producer);
> + }
> +
> + spin_unlock(&vq->call_ctx.ctx_lock);
This should be rare so I'd use simple codes just do unregister and register.
> +}
> +
> static void vhost_vdpa_reset(struct vhost_vdpa *v)
> {
> struct vdpa_device *vdpa = v->vdpa;
> @@ -332,6 +389,7 @@ static long vhost_vdpa_set_config_call(struct vhost_vdpa *v, u32 __user *argp)
>
> return 0;
> }
> +
Unnecessary change.
> static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
> void __user *argp)
> {
> @@ -390,6 +448,16 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
> cb.private = NULL;
> }
> ops->set_vq_cb(vdpa, idx, &cb);
> +#ifdef CONFIG_HAVE_KVM_IRQ_BYPASS
> + /*
> + * if it has a non-zero irq, means there is a
> + * previsouly registered irq_bypass_producer,
> + * we should update it when ctx (its token)
> + * changes.
> + */
> + if (vq->call_ctx.producer.irq)
> + vhost_vdpa_update_vq_irq(vq);
> +#endif
> break;
>
> case VHOST_SET_VRING_NUM:
> @@ -741,6 +809,7 @@ static int vhost_vdpa_open(struct inode *inode, struct file *filep)
> vqs[i] = &v->vqs[i];
> vqs[i]->handle_kick = handle_vq_kick;
> }
> +
Unnecessary change.
Thanks
> vhost_dev_init(dev, vqs, nvqs, 0, 0, 0, false,
> vhost_vdpa_process_iotlb_msg);
>
next prev parent reply other threads:[~2020-07-13 8:22 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 ` Jason Wang [this message]
[not found] ` <e06f9706-441f-0d7a-c8c0-cd43a26c5296@intel.com>
2020-07-15 8:51 ` [PATCH 3/7] vhost_vdpa: implement IRQ offloading functions in vhost_vdpa 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 ` [PATCH 4/7] vDPA: implement IRQ offloading helpers in vDPA core Jason Wang
[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=3fb9ecfc-a325-69b5-f5b7-476a5683a324@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).