On Tue, Apr 25, 2023 at 6:50 AM Shannon Nelson <shannon.nelson@xxxxxxx> wrote: > > Use the right structs for PACKED or split vqs when setting and > getting the vring base. > > Signed-off-by: Shannon Nelson <shannon.nelson@xxxxxxx> Acked-by: Jason Wang <jasowang@xxxxxxxxxx> Thanks > --- > drivers/vhost/vdpa.c | 21 +++++++++++++++++---- > 1 file changed, 17 insertions(+), 4 deletions(-) > > diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c > index 599b8cc238c7..fe392b67d5be 100644 > --- a/drivers/vhost/vdpa.c > +++ b/drivers/vhost/vdpa.c > @@ -585,7 +585,14 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd, > if (r) > return r; > > - vq->last_avail_idx = vq_state.split.avail_index; > + if (vhost_has_feature(vq, VIRTIO_F_RING_PACKED)) { > + vq->last_avail_idx = vq_state.packed.last_avail_idx | > + (vq_state.packed.last_avail_counter << 15); > + vq->last_used_idx = vq_state.packed.last_used_idx | > + (vq_state.packed.last_used_counter << 15); > + } else { > + vq->last_avail_idx = vq_state.split.avail_index; > + } > break; > } > > @@ -603,9 +610,15 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd, > break; > > case VHOST_SET_VRING_BASE: > - vq_state.split.avail_index = vq->last_avail_idx; > - if (ops->set_vq_state(vdpa, idx, &vq_state)) > - r = -EINVAL; > + if (vhost_has_feature(vq, VIRTIO_F_RING_PACKED)) { > + vq_state.packed.last_avail_idx = vq->last_avail_idx & 0x7fff; > + vq_state.packed.last_avail_counter = !!(vq->last_avail_idx & 0x8000); > + vq_state.packed.last_used_idx = vq->last_used_idx & 0x7fff; > + vq_state.packed.last_used_counter = !!(vq->last_used_idx & 0x8000); > + } else { > + vq_state.split.avail_index = vq->last_avail_idx; > + } > + r = ops->set_vq_state(vdpa, idx, &vq_state); > break; > > case VHOST_SET_VRING_CALL: > -- > 2.17.1 > _______________________________________________ Virtualization mailing list Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linuxfoundation.org/mailman/listinfo/virtualization