From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:45810) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qnz10-0006f9-98 for qemu-devel@nongnu.org; Mon, 01 Aug 2011 16:23:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qnz0y-0002b1-W4 for qemu-devel@nongnu.org; Mon, 01 Aug 2011 16:23:06 -0400 Received: from mail-pz0-f43.google.com ([209.85.210.43]:49826) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qnz0y-0002ar-P9 for qemu-devel@nongnu.org; Mon, 01 Aug 2011 16:23:04 -0400 Received: by pzk1 with SMTP id 1so12523910pzk.30 for ; Mon, 01 Aug 2011 13:23:03 -0700 (PDT) Message-ID: <4E370B24.6090700@codemonkey.ws> Date: Mon, 01 Aug 2011 15:23:00 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <1312135082-31985-1-git-send-email-avi@redhat.com> <1312135082-31985-21-git-send-email-avi@redhat.com> <20110801082600.GD5439@redhat.com> In-Reply-To: <20110801082600.GD5439@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 20/39] virtio-pci: convert to memory API List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: Avi Kivity , kvm@vger.kernel.org, qemu-devel@nongnu.org On 08/01/2011 03:26 AM, Michael S. Tsirkin wrote: > On Sun, Jul 31, 2011 at 08:57:43PM +0300, Avi Kivity wrote: >> @@ -491,30 +473,26 @@ static void virtio_pci_config_writel(void *opaque, 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 = container_of(pci_dev, VirtIOPCIProxy, pci_dev); >> - VirtIODevice *vdev = proxy->vdev; >> - unsigned config_len = VIRTIO_PCI_REGION_SIZE(pci_dev) + vdev->config_len; >> - >> - proxy->addr = addr; >> - >> - register_ioport_write(addr, config_len, 1, virtio_pci_config_writeb, proxy); >> - register_ioport_write(addr, config_len, 2, virtio_pci_config_writew, proxy); >> - register_ioport_write(addr, config_len, 4, virtio_pci_config_writel, proxy); >> - register_ioport_read(addr, config_len, 1, virtio_pci_config_readb, proxy); >> - register_ioport_read(addr, config_len, 2, virtio_pci_config_readw, proxy); >> - register_ioport_read(addr, config_len, 4, virtio_pci_config_readl, proxy); >> +const MemoryRegionPortio virtio_portio[] = { >> + { 0, 0x10000, 1, .write = virtio_pci_config_writeb, }, >> + { 0, 0x10000, 2, .write = virtio_pci_config_writew, }, >> + { 0, 0x10000, 4, .write = virtio_pci_config_writel, }, >> + { 0, 0x10000, 1, .read = virtio_pci_config_readb, }, >> + { 0, 0x10000, 2, .read = virtio_pci_config_readw, }, >> + { 0, 0x10000, 4, .read = virtio_pci_config_readl, }, >> + PORTIO_END >> +}; >> >> - if (vdev->config_len) >> - vdev->get_config(vdev, vdev->config); >> -} >> +static const MemoryRegionOps virtio_pci_config_ops = { >> + .old_portio = virtio_portio, >> + .endianness = DEVICE_LITTLE_ENDIAN, >> +}; >> >> static void virtio_write_config(PCIDevice *pci_dev, uint32_t address, >> uint32_t val, int len) >> { >> VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev); >> + VirtIODevice *vdev = proxy->vdev; >> >> if (PCI_COMMAND == address) { >> if (!(val& PCI_COMMAND_MASTER)) { >> @@ -525,6 +503,9 @@ static void virtio_write_config(PCIDevice *pci_dev, uint32_t address, >> } >> } >> } >> + if (address == PCI_BASE_ADDRESS_0&& vdev->config_len) { >> + vdev->get_config(vdev, vdev->config); >> + } >> >> pci_default_write_config(pci_dev, address, val, len); >> msix_write_config(pci_dev, address, val, len); > > I'm not really sure why did we get the config on map, > specifically - Anthony, do you know? It's just a mechanism to lazily load the config. We could just as easily read the config whenever the (virtio) config space was accessed. Regards, Anthony Liguori > But if we want to do that, memory space enable might > be a better place. Or maybe we just want a callback on > map. >