From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33327) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XRf4x-0006XF-Vg for qemu-devel@nongnu.org; Wed, 10 Sep 2014 06:24:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XRf4t-000117-HB for qemu-devel@nongnu.org; Wed, 10 Sep 2014 06:24:47 -0400 Date: Wed, 10 Sep 2014 14:27:58 +0300 From: "Michael S. Tsirkin" Message-ID: <20140910112758.GH7902@redhat.com> References: <1410192283-4026-1-git-send-email-mst@redhat.com> <20140910003532.22d72602@bahia.local> <87oaunops6.fsf@abhimanyu.in.ibm.com> <20140910093230.GB7902@redhat.com> <20140910110148.6eaf913f@bahia.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140910110148.6eaf913f@bahia.local> Subject: Re: [Qemu-devel] [PATCH] virtio-pci: enable bus master for old guests List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Greg Kurz Cc: Nikunj A Dadhania , Alexey Kardashevskiy , Jan Kiszka , qemu-stable@nongnu.org, qemu-devel@nongnu.org, Anthony Liguori On Wed, Sep 10, 2014 at 11:01:48AM +0200, Greg Kurz wrote: > On Wed, 10 Sep 2014 12:32:30 +0300 > "Michael S. Tsirkin" wrote: > > > On Wed, Sep 10, 2014 at 01:44:49PM +0530, Nikunj A Dadhania wrote: > > > Greg Kurz writes: > > > > > > > On Mon, 8 Sep 2014 19:05:02 +0300 > > > > "Michael S. Tsirkin" wrote: > > > > > > > >> commit cc943c36faa192cd4b32af8fe5edb31894017d35 > > > >> pci: Use bus master address space for delivering MSI/MSI-X messages > > > >> breaks virtio-net for rhel6.[56] x86 guests because they don't > > > >> enable bus mastering for virtio PCI devices > > > >> > > > >> Old guests forgot to enable bus mastering, enable it > > > >> automatically on DRIVER_OK. > > > >> > > > >> Note: we should either back out the original patch from > > > >> stable or apply this one on top. > > > >> > > > >> Cc: qemu-stable@nongnu.org > > > >> Reported-by: Greg Kurz > > > >> Signed-off-by: Jan Kiszka > > > >> Signed-off-by: Michael S. Tsirkin > > > >> --- > > > >> hw/virtio/virtio-pci.c | 2 ++ > > > >> 1 file changed, 2 insertions(+) > > > >> > > > >> diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c > > > >> index ddb5da1..af937d2 100644 > > > >> --- a/hw/virtio/virtio-pci.c > > > >> +++ b/hw/virtio/virtio-pci.c > > > >> @@ -320,6 +320,8 @@ static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val) > > > >> if ((val & VIRTIO_CONFIG_S_DRIVER_OK) && > > > >> !(proxy->pci_dev.config[PCI_COMMAND] & PCI_COMMAND_MASTER)) { > > > >> proxy->flags |= VIRTIO_PCI_FLAG_BUS_MASTER_BUG; > > > >> + memory_region_set_enabled(&proxy->pci_dev.bus_master_enable_region, > > > >> + true); > > > >> } > > > >> break; > > > >> case VIRTIO_MSI_CONFIG_VECTOR: > > > > > > > > Cc'ing Alexey for some SLOF and early boot of the ppc64 kernel expertise. > > > > > > > > Michael, > > > > > > > > This was enough to fix virtio-net in the rhel6.5 x86 guest case. Unfortunately, > > > > this fails for rhel6.5 ppc64 because it is never called... > > > > > > > I did some debugging: it looks like the guest kernel calls the OF > > > > quisece call to flush pending DMA and disables bus master on the > > > > virtio-blk device (PCI_COMMAND == 0x3). > > > > > > Getting confused, above you are talking about virtio-net and here it is > > > virtio-blk. > > > > > > Anyways, the routines still remains same for both of them. From SLOF > > > during init we set DRIVER_OK, and after using the device during the > > > quiesce, called from linux kernel VIRTIO_CONFIG_S_FAILED is set and then > > > a VIRTIO_DEVICE_RESET is done. > > > > BTW, you really should start enabling bus mastering, avoid relying > > on the work-around we have for broken guests. > > > > FWIW during my debug session, I see that SLOF enables bus mastering... > unfortunately, it gets disabled at some point after the guest kernel > is started (around the ppc64 prom_init() call). OK I'm not sure I have all the details but does the patch I sent help you? -- MST