From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id AEF075A6C for ; Fri, 20 Nov 2015 16:17:50 +0100 (CET) Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id D5DEDC0C0582; Fri, 20 Nov 2015 15:17:49 +0000 (UTC) Received: from redhat.com (vpn-200-159.tlv.redhat.com [10.35.200.159]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id tAKFHj4u015333; Fri, 20 Nov 2015 10:17:47 -0500 Date: Fri, 20 Nov 2015 17:17:45 +0200 From: Victor Kaplansky To: dev@dpdk.org Message-ID: <20151120171725-mutt-send-email-victork@redhat.com> References: <1448026465-27460-1-git-send-email-victork@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1448026465-27460-1-git-send-email-victork@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Cc: Marcel Apfelbaum , Marc-Andre Lureau , "Michael S. Tsirkin" Subject: Re: [dpdk-dev] [PATCH] vhost-user: fix enabling of queue pair X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2015 15:17:50 -0000 On Fri, Nov 20, 2015 at 03:45:00PM +0200, Victor Kaplansky wrote: > The VHOST_USER_SET_VRING_ENABLE request is sent for each queue in > queue-pair separately. So, a queue-pair should be considered > enabled only when both RX and TX queues are enabled. > > The old code caused segfault when last TX queue was enabled. Since the problem causes segfault, it's important to review this soon before QEMU 2.5 is out. Thanks, -- Victor > > Signed-off-by: Victor Kaplansky > --- > lib/librte_vhost/vhost_user/virtio-net-user.c | 14 +++++++++----- > 1 file changed, 9 insertions(+), 5 deletions(-) > > diff --git a/lib/librte_vhost/vhost_user/virtio-net-user.c b/lib/librte_vhost/vhost_user/virtio-net-user.c > index d07452a..c06e53e 100644 > --- a/lib/librte_vhost/vhost_user/virtio-net-user.c > +++ b/lib/librte_vhost/vhost_user/virtio-net-user.c > @@ -317,21 +317,25 @@ user_set_vring_enable(struct vhost_device_ctx ctx, > struct vhost_vring_state *state) > { > struct virtio_net *dev = get_device(ctx); > - uint16_t base_idx = state->index; > + uint16_t idx = state->index; > + uint16_t base_idx = (idx / VIRTIO_QNUM) * VIRTIO_QNUM; > int enable = (int)state->num; > + int qpair_enabled; > > RTE_LOG(INFO, VHOST_CONFIG, > "set queue enable: %d to qp idx: %d\n", > enable, state->index); > > + dev->virtqueue[idx]->enabled = enable; > + qpair_enabled = > + dev->virtqueue[base_idx + VIRTIO_RXQ]->enabled && > + dev->virtqueue[base_idx + VIRTIO_TXQ]->enabled; > + > if (notify_ops->vring_state_changed) { > notify_ops->vring_state_changed(dev, base_idx / VIRTIO_QNUM, > - enable); > + qpair_enabled); > } > > - dev->virtqueue[base_idx + VIRTIO_RXQ]->enabled = enable; > - dev->virtqueue[base_idx + VIRTIO_TXQ]->enabled = enable; > - > return 0; > } > > -- > --Victor