From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anthony Liguori Subject: Re: [Qemu-devel] [PATCH v4 20/39] virtio-pci: convert to memory API Date: Mon, 08 Aug 2011 10:21:15 -0500 Message-ID: <4E3FFEEB.8000509@codemonkey.ws> References: <1312808972-1718-1-git-send-email-avi@redhat.com> <1312808972-1718-21-git-send-email-avi@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, "Michael S. Tsirkin" To: Avi Kivity Return-path: Received: from mail-pz0-f42.google.com ([209.85.210.42]:41965 "EHLO mail-pz0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750973Ab1HHPVU (ORCPT ); Mon, 8 Aug 2011 11:21:20 -0400 Received: by pzk37 with SMTP id 37so8461060pzk.1 for ; Mon, 08 Aug 2011 08:21:19 -0700 (PDT) In-Reply-To: <1312808972-1718-21-git-send-email-avi@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 08/08/2011 08:09 AM, Avi Kivity wrote: > except msix. > > [jan: fix build] This actually breaks the build: CC libhw64/virtio-pci.o cc1: warnings being treated as errors /home/anthony/git/qemu/hw/virtio-pci.c: In function =91virtio_write_con= fig=92: /home/anthony/git/qemu/hw/virtio-pci.c:496:19: error: unused variable =91= vdev=92 make[1]: *** [virtio-pci.o] Error 1 make: *** [subdir-libhw64] Error 2 > > Reviewed-by: Richard Henderson > Reviewed-by: Anthony Liguori > Signed-off-by: Avi Kivity > --- > hw/virtio-pci.c | 71 +++++++++++++++++++++-----------------------= ----------- > hw/virtio-pci.h | 2 +- > 2 files changed, 28 insertions(+), 45 deletions(-) > > diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c > index f3b3293..5df380d 100644 > --- a/hw/virtio-pci.c > +++ b/hw/virtio-pci.c > @@ -162,7 +162,8 @@ static int virtio_pci_set_host_notifier_internal(= VirtIOPCIProxy *proxy, > { > VirtQueue *vq =3D virtio_get_queue(proxy->vdev, n); > EventNotifier *notifier =3D virtio_queue_get_host_notifier(vq); > - int r; > + int r =3D 0; > + > if (assign) { > r =3D event_notifier_init(notifier, 1); > if (r< 0) { > @@ -170,24 +171,11 @@ static int virtio_pci_set_host_notifier_interna= l(VirtIOPCIProxy *proxy, > __func__, r); > return r; > } > - r =3D kvm_set_ioeventfd_pio_word(event_notifier_get_fd(notif= ier), > - proxy->addr + VIRTIO_PCI_QUEU= E_NOTIFY, > - n, assign); > - if (r< 0) { > - error_report("%s: unable to map ioeventfd: %d", > - __func__, r); > - event_notifier_cleanup(notifier); > - } > + memory_region_add_eventfd(&proxy->bar, VIRTIO_PCI_QUEUE_NOTI= =46Y, 2, > + true, n, event_notifier_get_fd(not= ifier)); > } else { > - r =3D kvm_set_ioeventfd_pio_word(event_notifier_get_fd(notif= ier), > - proxy->addr + VIRTIO_PCI_QUEU= E_NOTIFY, > - n, assign); > - if (r< 0) { > - error_report("%s: unable to unmap ioeventfd: %d", > - __func__, r); > - return r; > - } > - > + memory_region_del_eventfd(&proxy->bar, VIRTIO_PCI_QUEUE_NOTI= =46Y, 2, > + true, n, event_notifier_get_fd(not= ifier)); > /* Handle the race condition where the guest kicked and we = deassigned > * before we got around to handling the kick. > */ > @@ -424,7 +412,6 @@ static uint32_t virtio_pci_config_readb(void *opa= que, uint32_t addr) > { > VirtIOPCIProxy *proxy =3D opaque; > uint32_t config =3D VIRTIO_PCI_CONFIG(&proxy->pci_dev); > - addr -=3D proxy->addr; > if (addr< config) > return virtio_ioport_read(proxy, addr); > addr -=3D config; > @@ -435,7 +422,6 @@ static uint32_t virtio_pci_config_readw(void *opa= que, uint32_t addr) > { > VirtIOPCIProxy *proxy =3D opaque; > uint32_t config =3D VIRTIO_PCI_CONFIG(&proxy->pci_dev); > - addr -=3D proxy->addr; > if (addr< config) > return virtio_ioport_read(proxy, addr); > addr -=3D config; > @@ -446,7 +432,6 @@ static uint32_t virtio_pci_config_readl(void *opa= que, uint32_t addr) > { > VirtIOPCIProxy *proxy =3D opaque; > uint32_t config =3D VIRTIO_PCI_CONFIG(&proxy->pci_dev); > - addr -=3D proxy->addr; > if (addr< config) > return virtio_ioport_read(proxy, addr); > addr -=3D config; > @@ -457,7 +442,6 @@ static void virtio_pci_config_writeb(void *opaque= , uint32_t addr, uint32_t val) > { > VirtIOPCIProxy *proxy =3D opaque; > uint32_t config =3D VIRTIO_PCI_CONFIG(&proxy->pci_dev); > - addr -=3D proxy->addr; > if (addr< config) { > virtio_ioport_write(proxy, addr, val); > return; > @@ -470,7 +454,6 @@ static void virtio_pci_config_writew(void *opaque= , uint32_t addr, uint32_t val) > { > VirtIOPCIProxy *proxy =3D opaque; > uint32_t config =3D VIRTIO_PCI_CONFIG(&proxy->pci_dev); > - addr -=3D proxy->addr; > if (addr< config) { > virtio_ioport_write(proxy, addr, val); > return; > @@ -483,7 +466,6 @@ static void virtio_pci_config_writel(void *opaque= , uint32_t addr, uint32_t val) > { > VirtIOPCIProxy *proxy =3D opaque; > uint32_t config =3D VIRTIO_PCI_CONFIG(&proxy->pci_dev); > - addr -=3D proxy->addr; > if (addr< config) { > virtio_ioport_write(proxy, addr, val); > return; > @@ -492,30 +474,26 @@ static void virtio_pci_config_writel(void *opaq= ue, uint32_t addr, uint32_t val) > virtio_config_writel(proxy->vdev, addr, val); > } > > -static void virtio_map(PCIDevice *pci_dev, int region_num, > - pcibus_t addr, pcibus_t size, int type) > -{ > - VirtIOPCIProxy *proxy =3D container_of(pci_dev, VirtIOPCIProxy, = pci_dev); > - VirtIODevice *vdev =3D proxy->vdev; > - unsigned config_len =3D VIRTIO_PCI_REGION_SIZE(pci_dev) + vdev->= config_len; > - > - proxy->addr =3D addr; > - > - register_ioport_write(addr, config_len, 1, virtio_pci_config_wri= teb, proxy); > - register_ioport_write(addr, config_len, 2, virtio_pci_config_wri= tew, proxy); > - register_ioport_write(addr, config_len, 4, virtio_pci_config_wri= tel, proxy); > - register_ioport_read(addr, config_len, 1, virtio_pci_config_read= b, proxy); > - register_ioport_read(addr, config_len, 2, virtio_pci_config_read= w, proxy); > - register_ioport_read(addr, config_len, 4, virtio_pci_config_read= l, proxy); > +const MemoryRegionPortio virtio_portio[] =3D { > + { 0, 0x10000, 1, .write =3D virtio_pci_config_writeb, }, > + { 0, 0x10000, 2, .write =3D virtio_pci_config_writew, }, > + { 0, 0x10000, 4, .write =3D virtio_pci_config_writel, }, > + { 0, 0x10000, 1, .read =3D virtio_pci_config_readb, }, > + { 0, 0x10000, 2, .read =3D virtio_pci_config_readw, }, > + { 0, 0x10000, 4, .read =3D virtio_pci_config_readl, }, > + PORTIO_END_OF_LIST() > +}; > > - if (vdev->config_len) > - vdev->get_config(vdev, vdev->config); > -} > +static const MemoryRegionOps virtio_pci_config_ops =3D { > + .old_portio =3D virtio_portio, > + .endianness =3D DEVICE_LITTLE_ENDIAN, > +}; > > static void virtio_write_config(PCIDevice *pci_dev, uint32_t addres= s, > uint32_t val, int len) > { > VirtIOPCIProxy *proxy =3D DO_UPCAST(VirtIOPCIProxy, pci_dev, pc= i_dev); > + VirtIODevice *vdev =3D proxy->vdev; This variable isn't needed. I'll remove it. Regards, Anthony Liguori