From mboxrd@z Thu Jan 1 00:00:00 1970 From: Zang Hongyong Subject: Re: [Qemu-devel] [PATCH] virtio-serial: Allow one MSI-X vector per virtqueue Date: Mon, 19 Dec 2011 14:09:43 +0800 Message-ID: <4EEED527.4070103@huawei.com> References: <1323998066-2396-1-git-send-email-zanghongyong@huawei.com> <20111216093945.GB3071@amit-x200.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, rusty@rustcorp.com.au, aliguori@us.ibm.com, xiaowei.yang@huawei.com, hanweidong@huawei.com, wusongwei@huawei.com, jiangningyu@huawei.com, "Michael S. Tsirkin" To: Amit Shah Return-path: Received: from szxga03-in.huawei.com ([119.145.14.66]:48170 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751262Ab1LSGLk (ORCPT ); Mon, 19 Dec 2011 01:11:40 -0500 Received: from huawei.com (szxga03-in [172.24.2.9]) by szxga03-in.huawei.com (iPlanet Messaging Server 5.2 HotFix 2.14 (built Aug 8 2006)) with ESMTP id <0LWF00BMXT5ZFJ@szxga03-in.huawei.com> for kvm@vger.kernel.org; Mon, 19 Dec 2011 14:10:48 +0800 (CST) Received: from szxrg01-dlp.huawei.com ([172.24.2.119]) by szxga03-in.huawei.com (iPlanet Messaging Server 5.2 HotFix 2.14 (built Aug 8 2006)) with ESMTP id <0LWF006D9T5Z6D@szxga03-in.huawei.com> for kvm@vger.kernel.org; Mon, 19 Dec 2011 14:10:47 +0800 (CST) In-reply-to: <20111216093945.GB3071@amit-x200.redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: =E4=BA=8E 2011/12/16,=E6=98=9F=E6=9C=9F=E4=BA=94 17:39, Amit Shah =E5=86= =99=E9=81=93: > On (Fri) 16 Dec 2011 [09:14:26], zanghongyong@huawei.com wrote: >> From: Hongyong Zang >> >> In pci_enable_msix(), the guest's virtio-serial driver tries to set = msi-x >> with one vector per queue. But it fails and eventually all virtio-se= rial >> ports share one MSI-X vector. Because every virtio-serial port has *= two* >> virtqueues, virtio-serial needs (port+1)*2 vectors other than (port+= 1). > Ouch, good catch. > > One comment below: > >> This patch allows every virtqueue to have its own MSI-X vector. >> (When the MSI-X vectors needed are more than MSIX_MAX_ENTRIES define= d in >> qemu: msix.c, all the queues still share one MSI-X vector as before.= ) >> >> Signed-off-by: Hongyong Zang >> --- >> hw/virtio-pci.c | 5 ++++- >> 1 files changed, 4 insertions(+), 1 deletions(-) >> >> diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c >> index 77b75bc..2c9c6fb 100644 >> --- a/hw/virtio-pci.c >> +++ b/hw/virtio-pci.c >> @@ -718,8 +718,11 @@ static int virtio_serial_init_pci(PCIDevice *pc= i_dev) >> return -1; >> } >> vdev->nvectors =3D proxy->nvectors =3D=3D DEV_NVECTORS_UNSPECI= =46IED >> - ? proxy->serial.max_virtser= ial_ports + 1 >> + ? (proxy->serial.max_virtse= rial_ports + 1) * 2 >> : proxy->nvectors; >> + /*msix.c: #define MSIX_MAX_ENTRIES 32*/ >> + if (vdev->nvectors> 32) >> + vdev->nvectors =3D 32; > This change isn't needed: if the proxy->nvectors value exceeds the ma= x > allowed, virtio_init_pci() will end up using a shared vector instead > of separate ones. > > Thanks, > > Amit > > . > Hi Amit, If the nvectors exceeds the max, msix_init() will return -EINVAL in QEM= U, and the front-end driver in Guest will use regular interrupt instead of= =20 MSI-X. Hongyong