@@ -122,8 +122,12 @@ static void vhost_vdpa_setup_vq_irq(struct vhost_vdpa *v, u16 qid)
struct vdpa_device *vdpa = v->vdpa;
int ret, irq;
- spin_lock(&vq->call_ctx.ctx_lock);
+ if (!ops->get_vq_irq)
+ return;
+
irq = ops->get_vq_irq(vdpa, qid);
+ spin_lock(&vq->call_ctx.ctx_lock);
+ irq_bypass_unregister_producer(&vq->call_ctx.producer);
if (!vq->call_ctx.ctx || irq < 0) {
spin_unlock(&vq->call_ctx.ctx_lock);
return;
@@ -144,26 +148,6 @@ static void vhost_vdpa_unsetup_vq_irq(struct vhost_vdpa *v, u16 qid)
spin_unlock(&vq->call_ctx.ctx_lock);
}
-static void vhost_vdpa_update_vq_irq(struct vhost_virtqueue *vq)
-{
- spin_lock(&vq->call_ctx.ctx_lock);
- /*
- * 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) {
- spin_unlock(&vq->call_ctx.ctx_lock);
- return;
- }
-
- irq_bypass_unregister_producer(&vq->call_ctx.producer);
- vq->call_ctx.producer.token = vq->call_ctx.ctx;
- irq_bypass_register_producer(&vq->call_ctx.producer);
- spin_unlock(&vq->call_ctx.ctx_lock);
-}
-
static void vhost_vdpa_reset(struct vhost_vdpa *v)
{
struct vdpa_device *vdpa = v->vdpa;
@@ -452,7 +436,7 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
cb.private = NULL;
}
ops->set_vq_cb(vdpa, idx, &cb);
- vhost_vdpa_update_vq_irq(vq);
+ vhost_vdpa_setup_vq_irq(v, idx);
break;
case VHOST_SET_VRING_NUM:
This commit merge vhost_vdpa_update_vq_irq() logics into vhost_vdpa_setup_vq_irq(), so that code are unified. In vhost_vdpa_setup_vq_irq(), added checks for the existence for get_vq_irq(). Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com> --- drivers/vhost/vdpa.c | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-)