Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

vhost_vdpa: support PACKED when setting-getting vring_base

Use the right structs for PACKED or split vqs when setting and
getting the vring base.

Fixes: 4c8cf31885f6 ("vhost: introduce vDPA-based backend")
Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
Message-Id: <20230424225031.18947-4-shannon.nelson@amd.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>

authored by

Shannon Nelson and committed by
Michael S. Tsirkin
beee7fdb 55d8122f

+17 -4
+17 -4
drivers/vhost/vdpa.c
··· 607 607 if (r) 608 608 return r; 609 609 610 - vq->last_avail_idx = vq_state.split.avail_index; 610 + if (vhost_has_feature(vq, VIRTIO_F_RING_PACKED)) { 611 + vq->last_avail_idx = vq_state.packed.last_avail_idx | 612 + (vq_state.packed.last_avail_counter << 15); 613 + vq->last_used_idx = vq_state.packed.last_used_idx | 614 + (vq_state.packed.last_used_counter << 15); 615 + } else { 616 + vq->last_avail_idx = vq_state.split.avail_index; 617 + } 611 618 break; 612 619 } 613 620 ··· 632 625 break; 633 626 634 627 case VHOST_SET_VRING_BASE: 635 - vq_state.split.avail_index = vq->last_avail_idx; 636 - if (ops->set_vq_state(vdpa, idx, &vq_state)) 637 - r = -EINVAL; 628 + if (vhost_has_feature(vq, VIRTIO_F_RING_PACKED)) { 629 + vq_state.packed.last_avail_idx = vq->last_avail_idx & 0x7fff; 630 + vq_state.packed.last_avail_counter = !!(vq->last_avail_idx & 0x8000); 631 + vq_state.packed.last_used_idx = vq->last_used_idx & 0x7fff; 632 + vq_state.packed.last_used_counter = !!(vq->last_used_idx & 0x8000); 633 + } else { 634 + vq_state.split.avail_index = vq->last_avail_idx; 635 + } 636 + r = ops->set_vq_state(vdpa, idx, &vq_state); 638 637 break; 639 638 640 639 case VHOST_SET_VRING_CALL: