Skip to content

Commit 23750e3

Browse files
Eli Cohenmstsirkin
authored andcommitted
vdpa: Modify get_vq_state() to return error code
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 <[email protected]> Signed-off-by: Eli Cohen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]> Acked-by: Jason Wang <[email protected]>
1 parent aac50c0 commit 23750e3

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

drivers/vdpa/ifcvf/ifcvf_main.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,13 @@ static u16 ifcvf_vdpa_get_vq_num_max(struct vdpa_device *vdpa_dev)
237237
return IFCVF_QUEUE_MAX;
238238
}
239239

240-
static void ifcvf_vdpa_get_vq_state(struct vdpa_device *vdpa_dev, u16 qid,
241-
struct vdpa_vq_state *state)
240+
static int ifcvf_vdpa_get_vq_state(struct vdpa_device *vdpa_dev, u16 qid,
241+
struct vdpa_vq_state *state)
242242
{
243243
struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev);
244244

245245
state->avail_index = ifcvf_get_vq_state(vf, qid);
246+
return 0;
246247
}
247248

248249
static int ifcvf_vdpa_set_vq_state(struct vdpa_device *vdpa_dev, u16 qid,

drivers/vdpa/vdpa_sim/vdpa_sim.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,14 +464,15 @@ static int vdpasim_set_vq_state(struct vdpa_device *vdpa, u16 idx,
464464
return 0;
465465
}
466466

467-
static void vdpasim_get_vq_state(struct vdpa_device *vdpa, u16 idx,
468-
struct vdpa_vq_state *state)
467+
static int vdpasim_get_vq_state(struct vdpa_device *vdpa, u16 idx,
468+
struct vdpa_vq_state *state)
469469
{
470470
struct vdpasim *vdpasim = vdpa_to_sim(vdpa);
471471
struct vdpasim_virtqueue *vq = &vdpasim->vqs[idx];
472472
struct vringh *vrh = &vq->vring;
473473

474474
state->avail_index = vrh->last_avail_idx;
475+
return 0;
475476
}
476477

477478
static u32 vdpasim_get_vq_align(struct vdpa_device *vdpa)

drivers/vhost/vdpa.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,10 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
375375
ops->set_vq_ready(vdpa, idx, s.num);
376376
return 0;
377377
case VHOST_GET_VRING_BASE:
378-
ops->get_vq_state(v->vdpa, idx, &vq_state);
378+
r = ops->get_vq_state(v->vdpa, idx, &vq_state);
379+
if (r)
380+
return r;
381+
379382
vq->last_avail_idx = vq_state.avail_index;
380383
break;
381384
case VHOST_GET_BACKEND_FEATURES:

include/linux/vdpa.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ struct vdpa_config_ops {
193193
bool (*get_vq_ready)(struct vdpa_device *vdev, u16 idx);
194194
int (*set_vq_state)(struct vdpa_device *vdev, u16 idx,
195195
const struct vdpa_vq_state *state);
196-
void (*get_vq_state)(struct vdpa_device *vdev, u16 idx,
197-
struct vdpa_vq_state *state);
196+
int (*get_vq_state)(struct vdpa_device *vdev, u16 idx,
197+
struct vdpa_vq_state *state);
198198
struct vdpa_notification_area
199199
(*get_vq_notification)(struct vdpa_device *vdev, u16 idx);
200200
/* vq irq is not expected to be changed once DRIVER_OK is set */

0 commit comments

Comments
 (0)