vdpa: Modify get_vq_state() to return error code
authorEli Cohen <eli@mellanox.com>
Tue, 4 Aug 2020 16:20:44 +0000 (19:20 +0300)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 5 Aug 2020 23:00:23 +0000 (19:00 -0400)
Modify get_vq_state() so it returns an error code. In case of hardware
acceleration, the available index may be retrieved from the device, an
operation that can possibly fail.

Reviewed-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Eli Cohen <eli@mellanox.com>
Link: https://lore.kernel.org/r/20200804162048.22587-9-eli@mellanox.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
drivers/vdpa/ifcvf/ifcvf_main.c
drivers/vdpa/vdpa_sim/vdpa_sim.c
drivers/vhost/vdpa.c
include/linux/vdpa.h

index dc311e9..076d7ac 100644 (file)
@@ -237,12 +237,13 @@ static u16 ifcvf_vdpa_get_vq_num_max(struct vdpa_device *vdpa_dev)
        return IFCVF_QUEUE_MAX;
 }
 
-static void ifcvf_vdpa_get_vq_state(struct vdpa_device *vdpa_dev, u16 qid,
-                                   struct vdpa_vq_state *state)
+static int ifcvf_vdpa_get_vq_state(struct vdpa_device *vdpa_dev, u16 qid,
+                                  struct vdpa_vq_state *state)
 {
        struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev);
 
        state->avail_index = ifcvf_get_vq_state(vf, qid);
+       return 0;
 }
 
 static int ifcvf_vdpa_set_vq_state(struct vdpa_device *vdpa_dev, u16 qid,
index c93126a..df3224b 100644 (file)
@@ -464,14 +464,15 @@ static int vdpasim_set_vq_state(struct vdpa_device *vdpa, u16 idx,
        return 0;
 }
 
-static void vdpasim_get_vq_state(struct vdpa_device *vdpa, u16 idx,
-                                struct vdpa_vq_state *state)
+static int vdpasim_get_vq_state(struct vdpa_device *vdpa, u16 idx,
+                               struct vdpa_vq_state *state)
 {
        struct vdpasim *vdpasim = vdpa_to_sim(vdpa);
        struct vdpasim_virtqueue *vq = &vdpasim->vqs[idx];
        struct vringh *vrh = &vq->vring;
 
        state->avail_index = vrh->last_avail_idx;
+       return 0;
 }
 
 static u32 vdpasim_get_vq_align(struct vdpa_device *vdpa)
index 066b165..3fab94f 100644 (file)
@@ -375,7 +375,10 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
                ops->set_vq_ready(vdpa, idx, s.num);
                return 0;
        case VHOST_GET_VRING_BASE:
-               ops->get_vq_state(v->vdpa, idx, &vq_state);
+               r = ops->get_vq_state(v->vdpa, idx, &vq_state);
+               if (r)
+                       return r;
+
                vq->last_avail_idx = vq_state.avail_index;
                break;
        case VHOST_GET_BACKEND_FEATURES:
index d7399c9..eae0bfd 100644 (file)
@@ -193,8 +193,8 @@ struct vdpa_config_ops {
        bool (*get_vq_ready)(struct vdpa_device *vdev, u16 idx);
        int (*set_vq_state)(struct vdpa_device *vdev, u16 idx,
                            const struct vdpa_vq_state *state);
-       void (*get_vq_state)(struct vdpa_device *vdev, u16 idx,
-                            struct vdpa_vq_state *state);
+       int (*get_vq_state)(struct vdpa_device *vdev, u16 idx,
+                           struct vdpa_vq_state *state);
        struct vdpa_notification_area
        (*get_vq_notification)(struct vdpa_device *vdev, u16 idx);
        /* vq irq is not expected to be changed once DRIVER_OK is set */