[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/4] vhost: toggle device callbacks using used event idx
From: |
Eugenio Perez Martin |
Subject: |
Re: [PATCH 2/4] vhost: toggle device callbacks using used event idx |
Date: |
Fri, 21 Oct 2022 09:45:14 +0200 |
On Fri, Oct 21, 2022 at 5:40 AM Jason Wang <jasowang@redhat.com> wrote:
>
> On Thu, Oct 20, 2022 at 11:53 PM Eugenio Pérez <eperezma@redhat.com> wrote:
> >
> > Actually use the new field of the used ring and tell the device if SVQ
> > wants to be notified.
> >
> > The code is not reachable at the moment.
> >
> > Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
> > ---
> > hw/virtio/vhost-shadow-virtqueue.c | 18 +++++++++++++++---
> > 1 file changed, 15 insertions(+), 3 deletions(-)
> >
> > diff --git a/hw/virtio/vhost-shadow-virtqueue.c
> > b/hw/virtio/vhost-shadow-virtqueue.c
> > index a518f84772..f5c0fad3fc 100644
> > --- a/hw/virtio/vhost-shadow-virtqueue.c
> > +++ b/hw/virtio/vhost-shadow-virtqueue.c
> > @@ -369,15 +369,27 @@ static bool vhost_svq_more_used(VhostShadowVirtqueue
> > *svq)
> > */
> > static bool vhost_svq_enable_notification(VhostShadowVirtqueue *svq)
> > {
> > - svq->vring.avail->flags &= ~cpu_to_le16(VRING_AVAIL_F_NO_INTERRUPT);
> > - /* Make sure the flag is written before the read of used_idx */
> > + if (virtio_vdev_has_feature(svq->vdev, VIRTIO_RING_F_EVENT_IDX)) {
> > + uint16_t *used_event = (uint16_t
> > *)&svq->vring.avail->ring[svq->vring.num];
> > + *used_event = svq->shadow_used_idx;
>
> Do we need to care about the endian here?
>
> E.g vduse has:
>
> *((uint16_t *)&vq->vring.used->ring[vq->vring.num]) = htole16(val);
>
Good catch, I forgot about endianness.
I'll review the series, thanks!
> Thanks
>
> > + } else {
> > + svq->vring.avail->flags &=
> > ~cpu_to_le16(VRING_AVAIL_F_NO_INTERRUPT);
> > + }
> > +
> > + /* Make sure the event is enabled before the read of used_idx */
> > smp_mb();
> > return !vhost_svq_more_used(svq);
> > }
> >
> > static void vhost_svq_disable_notification(VhostShadowVirtqueue *svq)
> > {
> > - svq->vring.avail->flags |= cpu_to_le16(VRING_AVAIL_F_NO_INTERRUPT);
> > + /*
> > + * No need to disable notification in the event idx case, since used
> > event
> > + * index is already an index too far away.
> > + */
> > + if (!virtio_vdev_has_feature(svq->vdev, VIRTIO_RING_F_EVENT_IDX)) {
> > + svq->vring.avail->flags |= cpu_to_le16(VRING_AVAIL_F_NO_INTERRUPT);
> > + }
> > }
> >
> > static uint16_t vhost_svq_last_desc_of_chain(const VhostShadowVirtqueue
> > *svq,
> > --
> > 2.31.1
> >
>
- [PATCH 0/4] Shadow VirtQueue event index support, Eugenio Pérez, 2022/10/20
- [PATCH 3/4] vhost: use avail event idx on vhost_svq_kick, Eugenio Pérez, 2022/10/20
- [PATCH 4/4] vhost: Accept event idx flag, Eugenio Pérez, 2022/10/20
- [PATCH 2/4] vhost: toggle device callbacks using used event idx, Eugenio Pérez, 2022/10/20
- Re: [PATCH 2/4] vhost: toggle device callbacks using used event idx, Jason Wang, 2022/10/20
- Re: [PATCH 2/4] vhost: toggle device callbacks using used event idx,
Eugenio Perez Martin <=
- Re: [PATCH 2/4] vhost: toggle device callbacks using used event idx, Michael S. Tsirkin, 2022/10/21
- Re: [PATCH 2/4] vhost: toggle device callbacks using used event idx, Jason Wang, 2022/10/23
- Re: [PATCH 2/4] vhost: toggle device callbacks using used event idx, Eugenio Perez Martin, 2022/10/24
- Re: [PATCH 2/4] vhost: toggle device callbacks using used event idx, Michael S. Tsirkin, 2022/10/24
- Re: [PATCH 2/4] vhost: toggle device callbacks using used event idx, Jason Wang, 2022/10/24
- Re: [PATCH 2/4] vhost: toggle device callbacks using used event idx, Michael S. Tsirkin, 2022/10/25
- Re: [PATCH 2/4] vhost: toggle device callbacks using used event idx, Jason Wang, 2022/10/25
- Re: [PATCH 2/4] vhost: toggle device callbacks using used event idx, Michael S. Tsirkin, 2022/10/25
- Re: [PATCH 2/4] vhost: toggle device callbacks using used event idx, Eugenio Perez Martin, 2022/10/25
- [PATCH 1/4] vhost: allocate event_idx fields on vring, Eugenio Pérez, 2022/10/20