From patchwork Wed Aug 3 15:37:50 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 108287 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 464F9B71E3 for ; Thu, 4 Aug 2011 01:37:25 +1000 (EST) Received: from localhost ([::1]:34727 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QodVa-0001wY-L7 for incoming@patchwork.ozlabs.org; Wed, 03 Aug 2011 11:37:22 -0400 Received: from eggs.gnu.org ([140.186.70.92]:53437) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QodVU-0001wB-BQ for qemu-devel@nongnu.org; Wed, 03 Aug 2011 11:37:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QodVT-0002fn-6u for qemu-devel@nongnu.org; Wed, 03 Aug 2011 11:37:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:25952) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QodVS-0002fe-Qr for qemu-devel@nongnu.org; Wed, 03 Aug 2011 11:37:15 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p73FbEIN009302 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 3 Aug 2011 11:37:14 -0400 Received: from redhat.com (vpn-203-160.tlv.redhat.com [10.35.203.160]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id p73FbBNA012388; Wed, 3 Aug 2011 11:37:12 -0400 Date: Wed, 3 Aug 2011 18:37:50 +0300 From: "Michael S. Tsirkin" To: avi@redhat.com, qemu-devel@nongnu.org Message-ID: <20110803153750.GA16332@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Anthony Liguori Subject: [Qemu-devel] [PATCH] virtio-pci: get config on init X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org We originally did get config on map, so that following write accesses are done on an updated config. New memory API doesn't give us a callback on map, and arguably, devices don't know when cpu really can access there. So updating on init seems cleaner. Signed-off-by: Michael S. Tsirkin --- OK, this should go on Avi's branch and the memory API can go on top. hw/virtio-pci.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index 4f770fe..afae846 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -507,9 +507,6 @@ static void virtio_map(PCIDevice *pci_dev, int region_num, 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); - - if (vdev->config_len) - vdev->get_config(vdev, vdev->config); } static void virtio_write_config(PCIDevice *pci_dev, uint32_t address, @@ -689,6 +686,10 @@ void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev) proxy->host_features |= 0x1 << VIRTIO_F_NOTIFY_ON_EMPTY; proxy->host_features |= 0x1 << VIRTIO_F_BAD_FEATURE; proxy->host_features = vdev->get_features(vdev, proxy->host_features); + + if (vdev->config_len) { + vdev->get_config(vdev, vdev->config); + } } static int virtio_blk_init_pci(PCIDevice *pci_dev)