linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Cornelia Huck <cohuck@redhat.com>
Cc: Viktor Prutyanov <viktor@daynix.com>,
	jasowang@redhat.com, pasic@linux.ibm.com, farman@linux.ibm.com,
	linux-s390@vger.kernel.org, kvm@vger.kernel.org,
	virtualization@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org, yan@daynix.com
Subject: Re: [PATCH v3] virtio: add VIRTIO_F_NOTIFICATION_DATA feature support
Date: Tue, 21 Mar 2023 12:04:39 -0400	[thread overview]
Message-ID: <20230321115854-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <87bkkmm89a.fsf@redhat.com>

On Tue, Mar 21, 2023 at 04:30:57PM +0100, Cornelia Huck wrote:
> On Tue, Mar 21 2023, Viktor Prutyanov <viktor@daynix.com> wrote:
> 
> > On Tue, Mar 21, 2023 at 5:59 PM Cornelia Huck <cohuck@redhat.com> wrote:
> >>
> >> On Tue, Mar 21 2023, Viktor Prutyanov <viktor@daynix.com> wrote:
> >>
> >> > According to VirtIO spec v1.2, VIRTIO_F_NOTIFICATION_DATA feature
> >> > indicates that the driver passes extra data along with the queue
> >> > notifications.
> >> >
> >> > In a split queue case, the extra data is 16-bit available index. In a
> >> > packed queue case, the extra data is 1-bit wrap counter and 15-bit
> >> > available index.
> >> >
> >> > Add support for this feature for MMIO, PCI and channel I/O transports.
> >> >
> >> > Signed-off-by: Viktor Prutyanov <viktor@daynix.com>
> >> > ---
> >> >  v3: support feature in virtio_ccw, remove VM_NOTIFY, use avail_idx_shadow,
> >> >     remove byte swap, rename to vring_notification_data
> >> >  v2: reject the feature in virtio_ccw, replace __le32 with u32
> >> >
> >> >  drivers/s390/virtio/virtio_ccw.c   |  4 +++-
> >> >  drivers/virtio/virtio_mmio.c       | 14 +++++++++++++-
> >> >  drivers/virtio/virtio_pci_common.c | 10 ++++++++++
> >> >  drivers/virtio/virtio_pci_common.h |  4 ++++
> >> >  drivers/virtio/virtio_pci_legacy.c |  2 +-
> >> >  drivers/virtio/virtio_pci_modern.c |  2 +-
> >> >  drivers/virtio/virtio_ring.c       | 17 +++++++++++++++++
> >> >  include/linux/virtio_ring.h        |  2 ++
> >> >  include/uapi/linux/virtio_config.h |  6 ++++++
> >> >  9 files changed, 57 insertions(+), 4 deletions(-)
> >> >
> >> > diff --git a/drivers/s390/virtio/virtio_ccw.c b/drivers/s390/virtio/virtio_ccw.c
> >> > index 954fc31b4bc7..c33172c5b8d5 100644
> >> > --- a/drivers/s390/virtio/virtio_ccw.c
> >> > +++ b/drivers/s390/virtio/virtio_ccw.c
> >> > @@ -396,13 +396,15 @@ static bool virtio_ccw_kvm_notify(struct virtqueue *vq)
> >> >       struct virtio_ccw_vq_info *info = vq->priv;
> >> >       struct virtio_ccw_device *vcdev;
> >> >       struct subchannel_id schid;
> >> > +     u32 data = __virtio_test_bit(vq->vdev, VIRTIO_F_NOTIFICATION_DATA) ?
> >> > +                     vring_notification_data(vq) : vq->index;
> >> >
> >> >       vcdev = to_vc_device(info->vq->vdev);
> >> >       ccw_device_get_schid(vcdev->cdev, &schid);
> >> >       BUILD_BUG_ON(sizeof(struct subchannel_id) != sizeof(unsigned int));
> >> >       info->cookie = kvm_hypercall3(KVM_S390_VIRTIO_CCW_NOTIFY,
> >> >                                     *((unsigned int *)&schid),
> >> > -                                   vq->index, info->cookie);
> >> > +                                   data, info->cookie);
> >> >       if (info->cookie < 0)
> >> >               return false;
> >> >       return true;
> >> > diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
> >> > index 3ff746e3f24a..7c16e622c33d 100644
> >> > --- a/drivers/virtio/virtio_mmio.c
> >> > +++ b/drivers/virtio/virtio_mmio.c
> >> > @@ -285,6 +285,16 @@ static bool vm_notify(struct virtqueue *vq)
> >> >       return true;
> >> >  }
> >> >
> >> > +static bool vm_notify_with_data(struct virtqueue *vq)
> >> > +{
> >> > +     struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vq->vdev);
> >> > +     u32 data = vring_notification_data(vq);
> >> > +
> >> > +     writel(data, vm_dev->base + VIRTIO_MMIO_QUEUE_NOTIFY);
> >>
> >> Can't you simply use the same method as for ccw, i.e. use one callback
> >> function that simply writes one value or the other?
> >
> > The idea is to eliminate the conditional branch induced by feature bit
> > testing from the notification function. Probably, this can be done in
> > the same way in ccw.
> 
> Hm, how noticable is that branch? IOW, is it worth making the code less
> readable for this?

I'm not sure but these things add up. I'm with Viktor here let's just
avoid the branch and not worry about whether it's important or not.
So let's use the same thing here then? And we can use a subfunction
to avoid code duplication.

> (In any case, all transports probably should use the same method.)


  reply	other threads:[~2023-03-21 16:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-21 13:44 [PATCH v3] virtio: add VIRTIO_F_NOTIFICATION_DATA feature support Viktor Prutyanov
2023-03-21 14:13 ` Michael S. Tsirkin
2023-03-21 14:59 ` Cornelia Huck
2023-03-21 15:22   ` Viktor Prutyanov
2023-03-21 15:30     ` Cornelia Huck
2023-03-21 16:04       ` Michael S. Tsirkin [this message]
2023-03-21 16:21         ` Cornelia Huck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230321115854-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=farman@linux.ibm.com \
    --cc=jasowang@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=pasic@linux.ibm.com \
    --cc=viktor@daynix.com \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=yan@daynix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).