diff mbox

[V4,06/19] virtio-ccw: using VIRTIO_NO_VECTOR instead of 0 for invalid virtqueue

Message ID 1426671309-13645-7-git-send-email-jasowang@redhat.com
State New
Headers show

Commit Message

Jason Wang March 18, 2015, 9:34 a.m. UTC
There's no need to use vector 0 for invalid virtqueue. So this patch
changes to use VIRTIO_NO_VECTOR instead.

Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
CC: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Alexander Graf <agraf@suse.de>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 hw/s390x/virtio-ccw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Michael S. Tsirkin March 18, 2015, 1:08 p.m. UTC | #1
On Wed, Mar 18, 2015 at 05:34:56PM +0800, Jason Wang wrote:
> There's no need to use vector 0 for invalid virtqueue. So this patch
> changes to use VIRTIO_NO_VECTOR instead.
> 
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
> CC: Christian Borntraeger <borntraeger@de.ibm.com>
> Cc: Richard Henderson <rth@twiddle.net>
> Cc: Alexander Graf <agraf@suse.de>
> Signed-off-by: Jason Wang <jasowang@redhat.com>

I don't know what does this actually do.
Cornelia?

> ---
>  hw/s390x/virtio-ccw.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
> index 130535c..c8b87aa 100644
> --- a/hw/s390x/virtio-ccw.c
> +++ b/hw/s390x/virtio-ccw.c
> @@ -281,7 +281,7 @@ static int virtio_ccw_set_vqs(SubchDev *sch, uint64_t addr, uint32_t align,
>  
>      virtio_queue_set_addr(vdev, index, addr);
>      if (!addr) {
> -        virtio_queue_set_vector(vdev, index, 0);
> +        virtio_queue_set_vector(vdev, index, VIRTIO_NO_VECTOR);
>      } else {
>          /* Fail if we don't have a big enough queue. */
>          /* TODO: Add interface to handle vring.num changing */

Right below this, we have
    /* tell notify handler in case of config change */
    vdev->config_vector = VIRTIO_PCI_QUEUE_MAX;

which also does not seem to make sense.

These changes need some testing though.

> -- 
> 2.1.0
Cornelia Huck March 20, 2015, 7:39 a.m. UTC | #2
On Wed, 18 Mar 2015 14:08:56 +0100
"Michael S. Tsirkin" <mst@redhat.com> wrote:

> On Wed, Mar 18, 2015 at 05:34:56PM +0800, Jason Wang wrote:
> > There's no need to use vector 0 for invalid virtqueue. So this patch
> > changes to use VIRTIO_NO_VECTOR instead.
> > 
> > Cc: Michael S. Tsirkin <mst@redhat.com>
> > Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
> > CC: Christian Borntraeger <borntraeger@de.ibm.com>
> > Cc: Richard Henderson <rth@twiddle.net>
> > Cc: Alexander Graf <agraf@suse.de>
> > Signed-off-by: Jason Wang <jasowang@redhat.com>
> 
> I don't know what does this actually do.
> Cornelia?

I actually have the same patch somewhere in my queue. The point here is
that 0 is plain wrong (it's a valid queue), while VIRTIO_NO_VECTOR is
most certainly no valid queue.

> 
> > ---
> >  hw/s390x/virtio-ccw.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
> > index 130535c..c8b87aa 100644
> > --- a/hw/s390x/virtio-ccw.c
> > +++ b/hw/s390x/virtio-ccw.c
> > @@ -281,7 +281,7 @@ static int virtio_ccw_set_vqs(SubchDev *sch, uint64_t addr, uint32_t align,
> >  
> >      virtio_queue_set_addr(vdev, index, addr);
> >      if (!addr) {
> > -        virtio_queue_set_vector(vdev, index, 0);
> > +        virtio_queue_set_vector(vdev, index, VIRTIO_NO_VECTOR);
> >      } else {
> >          /* Fail if we don't have a big enough queue. */
> >          /* TODO: Add interface to handle vring.num changing */
> 
> Right below this, we have
>     /* tell notify handler in case of config change */
>     vdev->config_vector = VIRTIO_PCI_QUEUE_MAX;
> 
> which also does not seem to make sense.

Basically we have:

- at most 64 virtqueues with their own indicators (always 64 indicator
bits when using classic I/O interrupts, up to 64 indicator bits when
using adapter interrupts)
- another indicator bit for configuration changes (bit 0 of the
secondary indicator bits)

That way, the configuration change indicator is always one bit behind
the last possible queue indicator.

> 
> These changes need some testing though.

My identical patch seemed to work for me.
Michael S. Tsirkin March 21, 2015, 6:27 p.m. UTC | #3
On Fri, Mar 20, 2015 at 08:39:24AM +0100, Cornelia Huck wrote:
> On Wed, 18 Mar 2015 14:08:56 +0100
> "Michael S. Tsirkin" <mst@redhat.com> wrote:
> 
> > On Wed, Mar 18, 2015 at 05:34:56PM +0800, Jason Wang wrote:
> > > There's no need to use vector 0 for invalid virtqueue. So this patch
> > > changes to use VIRTIO_NO_VECTOR instead.
> > > 
> > > Cc: Michael S. Tsirkin <mst@redhat.com>
> > > Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
> > > CC: Christian Borntraeger <borntraeger@de.ibm.com>
> > > Cc: Richard Henderson <rth@twiddle.net>
> > > Cc: Alexander Graf <agraf@suse.de>
> > > Signed-off-by: Jason Wang <jasowang@redhat.com>
> > 
> > I don't know what does this actually do.
> > Cornelia?
> 
> I actually have the same patch somewhere in my queue. The point here is
> that 0 is plain wrong (it's a valid queue), while VIRTIO_NO_VECTOR is
> most certainly no valid queue.
> 
> > 
> > > ---
> > >  hw/s390x/virtio-ccw.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
> > > index 130535c..c8b87aa 100644
> > > --- a/hw/s390x/virtio-ccw.c
> > > +++ b/hw/s390x/virtio-ccw.c
> > > @@ -281,7 +281,7 @@ static int virtio_ccw_set_vqs(SubchDev *sch, uint64_t addr, uint32_t align,
> > >  
> > >      virtio_queue_set_addr(vdev, index, addr);
> > >      if (!addr) {
> > > -        virtio_queue_set_vector(vdev, index, 0);
> > > +        virtio_queue_set_vector(vdev, index, VIRTIO_NO_VECTOR);
> > >      } else {
> > >          /* Fail if we don't have a big enough queue. */
> > >          /* TODO: Add interface to handle vring.num changing */
> > 
> > Right below this, we have
> >     /* tell notify handler in case of config change */
> >     vdev->config_vector = VIRTIO_PCI_QUEUE_MAX;
> > 
> > which also does not seem to make sense.
> 
> Basically we have:
> 
> - at most 64 virtqueues with their own indicators (always 64 indicator
> bits when using classic I/O interrupts, up to 64 indicator bits when
> using adapter interrupts)
> - another indicator bit for configuration changes (bit 0 of the
> secondary indicator bits)
> 
> That way, the configuration change indicator is always one bit behind
> the last possible queue indicator.

But VIRTIO_PCI_QUEUE_MAX only makes sense as a VQ number.
Why does it make sense as a vector number?
Jason's patches actually change VIRTIO_PCI_QUEUE_MAX
so we need to figure our what to do for this code.


> > 
> > These changes need some testing though.
> 
> My identical patch seemed to work for me.
Cornelia Huck March 23, 2015, 9:02 a.m. UTC | #4
On Sat, 21 Mar 2015 19:27:49 +0100
"Michael S. Tsirkin" <mst@redhat.com> wrote:

> On Fri, Mar 20, 2015 at 08:39:24AM +0100, Cornelia Huck wrote:
> > On Wed, 18 Mar 2015 14:08:56 +0100
> > "Michael S. Tsirkin" <mst@redhat.com> wrote:
> > 
> > > On Wed, Mar 18, 2015 at 05:34:56PM +0800, Jason Wang wrote:
> > > > There's no need to use vector 0 for invalid virtqueue. So this patch
> > > > changes to use VIRTIO_NO_VECTOR instead.
> > > > 
> > > > Cc: Michael S. Tsirkin <mst@redhat.com>
> > > > Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
> > > > CC: Christian Borntraeger <borntraeger@de.ibm.com>
> > > > Cc: Richard Henderson <rth@twiddle.net>
> > > > Cc: Alexander Graf <agraf@suse.de>
> > > > Signed-off-by: Jason Wang <jasowang@redhat.com>
> > > 
> > > I don't know what does this actually do.
> > > Cornelia?
> > 
> > I actually have the same patch somewhere in my queue. The point here is
> > that 0 is plain wrong (it's a valid queue), while VIRTIO_NO_VECTOR is
> > most certainly no valid queue.
> > 
> > > 
> > > > ---
> > > >  hw/s390x/virtio-ccw.c | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > 
> > > > diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
> > > > index 130535c..c8b87aa 100644
> > > > --- a/hw/s390x/virtio-ccw.c
> > > > +++ b/hw/s390x/virtio-ccw.c
> > > > @@ -281,7 +281,7 @@ static int virtio_ccw_set_vqs(SubchDev *sch, uint64_t addr, uint32_t align,
> > > >  
> > > >      virtio_queue_set_addr(vdev, index, addr);
> > > >      if (!addr) {
> > > > -        virtio_queue_set_vector(vdev, index, 0);
> > > > +        virtio_queue_set_vector(vdev, index, VIRTIO_NO_VECTOR);
> > > >      } else {
> > > >          /* Fail if we don't have a big enough queue. */
> > > >          /* TODO: Add interface to handle vring.num changing */
> > > 
> > > Right below this, we have
> > >     /* tell notify handler in case of config change */
> > >     vdev->config_vector = VIRTIO_PCI_QUEUE_MAX;
> > > 
> > > which also does not seem to make sense.
> > 
> > Basically we have:
> > 
> > - at most 64 virtqueues with their own indicators (always 64 indicator
> > bits when using classic I/O interrupts, up to 64 indicator bits when
> > using adapter interrupts)
> > - another indicator bit for configuration changes (bit 0 of the
> > secondary indicator bits)
> > 
> > That way, the configuration change indicator is always one bit behind
> > the last possible queue indicator.
> 
> But VIRTIO_PCI_QUEUE_MAX only makes sense as a VQ number.
> Why does it make sense as a vector number?
> Jason's patches actually change VIRTIO_PCI_QUEUE_MAX
> so we need to figure our what to do for this code.

We don't have "vectors" for virtio-ccw. It's just a concept mandated by
common code, we just do an identity mapping. Using this value just
pushes the notifier bits for config changes to behind the highest
possible virtqueue.
diff mbox

Patch

diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index 130535c..c8b87aa 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -281,7 +281,7 @@  static int virtio_ccw_set_vqs(SubchDev *sch, uint64_t addr, uint32_t align,
 
     virtio_queue_set_addr(vdev, index, addr);
     if (!addr) {
-        virtio_queue_set_vector(vdev, index, 0);
+        virtio_queue_set_vector(vdev, index, VIRTIO_NO_VECTOR);
     } else {
         /* Fail if we don't have a big enough queue. */
         /* TODO: Add interface to handle vring.num changing */