From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37590) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cluxB-0000UM-69 for qemu-devel@nongnu.org; Thu, 09 Mar 2017 05:05:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1clux8-0003GM-1K for qemu-devel@nongnu.org; Thu, 09 Mar 2017 05:05:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:25566) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1clux7-0003FW-RR for qemu-devel@nongnu.org; Thu, 09 Mar 2017 05:05:45 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C4C2E201FB for ; Thu, 9 Mar 2017 10:05:45 +0000 (UTC) References: <1488877751-13419-1-git-send-email-jasowang@redhat.com> <7594c183-6d38-3dce-75e7-62bf3be324fc@redhat.com> <20170308174043.10c2f056@nial.brq.redhat.com> <322da7ca-793c-fe83-9b9b-aded87742c18@redhat.com> <20170309102849.1db72ad5@nial.brq.redhat.com> <925a58ec-2a6a-6709-8139-db492af7800c@redhat.com> From: Paolo Bonzini Message-ID: <2add94d5-4d6f-6c62-4d63-085901afc63e@redhat.com> Date: Thu, 9 Mar 2017 11:05:36 +0100 MIME-Version: 1.0 In-Reply-To: <925a58ec-2a6a-6709-8139-db492af7800c@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH V3] virtio: do not require IOMMU to be created in advance List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jason Wang , Igor Mammedov Cc: Marcel Apfelbaum , mst@redhat.com, qemu-devel@nongnu.org, peterx@redhat.com On 09/03/2017 10:58, Jason Wang wrote: >=20 >=20 > On 2017=E5=B9=B403=E6=9C=8809=E6=97=A5 17:28, Igor Mammedov wrote: >> On Thu, 9 Mar 2017 10:32:44 +0800 >> Jason Wang wrote: >> >>> On 2017=E5=B9=B403=E6=9C=8809=E6=97=A5 00:40, Igor Mammedov wrote: >>>> On Tue, 7 Mar 2017 14:47:30 +0200 >>>> Marcel Apfelbaum wrote: >>>> =20 >>>>> On 03/07/2017 11:09 AM, Jason Wang wrote: >>>>>> After commit 96a8821d2141 ("virtio: unbreak virtio-pci with IOMMU >>>>>> after caching ring translations"), IOMMU was required to be >>>>>> created in >>>>>> advance. This is because we can only get the correct dma_as after = pci >>>>>> IOMMU (e.g intel_iommu) was initialized. This is suboptimal and >>>>>> inconvenient for user. This patch releases this by: >>>>>> >>>>>> - introduce a bus_master_ready method for PCIDeviceClass and trigg= er >>>>>> this during pci_init_bus_master >>>>>> - implement virtio-pci method and 1) reset the dma_as 2) re-regist= er >>>>>> the memory listener to the new dma_as >> Instead of trying to fix up later it's possible to refuse >> adding iommu device if other devices has been added before >> it with -device/device_add. >> That would match current CLI semantics where device that >> others depend on should be listed on CLI before that others >> are listed. >=20 > Yes, but it works by chance in the past for the device that does not > want bus_master_as in their realize. This change may surprise their use= rs. There is another posssibility. Create the address space at init time and add a container region instead of the bus_master_enable_region alias. Then at machine_done time you create the bus_master_enable_region= . This removes the need for the callbacks and makes the MemoryListener just work. Paolo