Skip to contentSkip to conversation

vdpa: Avoid duplicate call to vp_vdpa get_status

PATCH In review Eugenio Pérez 3 participants 3 messages Nov 4, 2021 – Nov 5, 2021

Subsystems (5)
lore
Share & tools
lore

Eugenio Pérez

author maintainer
#0 lore raw

PATCH 1/1 vdpa: Avoid duplicate call to vp_vdpa get_status

It has no sense to call get_status twice, since we already have a variable for that.

---
 drivers/vhost/vdpa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vhost/vdpa.c +1 -1
index 01c59ce7e250..10676ea0348b 100644
@@ -167,13 +167,13 @@ static long vhost_vdpa_set_status(struct vhost_vdpa *v, u8 __user *statusp)
 	status_old = ops->get_status(vdpa);
 
 	/*
 	 * Userspace shouldn't remove status bits unless reset the
 	 * status to 0.
 	 */
-	if (status != 0 && (ops->get_status(vdpa) & ~status) != 0)
+	if (status != 0 && (status_old & ~status) != 0)
 		return -EINVAL;
 
 	if ((status_old & VIRTIO_CONFIG_S_DRIVER_OK) && !(status & VIRTIO_CONFIG_S_DRIVER_OK))
 		for (i = 0; i < nvqs; i++)
 			vhost_vdpa_unsetup_vq_irq(v, i);
 
Signature · 1 line
2.27.0
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Eugenio Pérez

It has no sense to call get_status twice, since we already have a variable for that.

Quoted 26 lines
---
 drivers/vhost/vdpa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vhost/vdpa.c +1 -2
index 01c59ce7e250..10676ea0348b 100644
@@ -167,13 +167,13 @@ static long vhost_vdpa_set_status(struct vhost_vdpa *v, u8 __user *statusp)
        status_old = ops->get_status(vdpa);
 
        /*
         * Userspace shouldn't remove status bits unless reset the
         * status to 0.
         */
-       if (status != 0 && (ops->get_status(vdpa) & ~status) != 0)
+       if (status != 0 && (status_old & ~status) != 0)
                return -EINVAL;
 
        if ((status_old & VIRTIO_CONFIG_S_DRIVER_OK) && !(status & VIRTIO_CONFIG_S_DRIVER_OK))
                for (i = 0; i < nvqs; i++)
                        vhost_vdpa_unsetup_vq_irq(v, i);
 
--

2.27.0

Reviewed-by on v1 1/1
#2 lore raw
In reply to Eugenio Pérez
Quoted 30 lines · Eugenio Pérez

It has no sense to call get_status twice, since we already have a variable for that.

---
drivers/vhost/vdpa.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vhost/vdpa.c +1 -1
index 01c59ce7e250..10676ea0348b 100644
@@ -167,13 +167,13 @@ static long vhost_vdpa_set_status(struct vhost_vdpa *v, u8 __user *statusp)
 	status_old = ops->get_status(vdpa);
 
 	/*
 	 * Userspace shouldn't remove status bits unless reset the
 	 * status to 0.
 	 */
-	if (status != 0 && (ops->get_status(vdpa) & ~status) != 0)
+	if (status != 0 && (status_old & ~status) != 0)
 		return -EINVAL;
 
 	if ((status_old & VIRTIO_CONFIG_S_DRIVER_OK) && !(status & VIRTIO_CONFIG_S_DRIVER_OK))
 		for (i = 0; i < nvqs; i++)
 			vhost_vdpa_unsetup_vq_irq(v, i);
 
Signature · 1 line
2.27.0