Received: from eggs.gnu.org ([2001:4830:134:3::10]:48665) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZDVno-00013N-HE for qemu-devel@nongnu.org; Fri, 10 Jul 2015 06:45:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZDVnk-0006EZ-F9 for qemu-devel@nongnu.org; Fri, 10 Jul 2015 06:45:08 -0400 Received: from e23smtp01.au.ibm.com ([202.81.31.143]:44142) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZDVnj-0006Ay-U1 for qemu-devel@nongnu.org; Fri, 10 Jul 2015 06:45:04 -0400 Received: from /spool/local by e23smtp01.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 10 Jul 2015 20:44:57 +1000 From: Alexey Kardashevskiy Date: Fri, 10 Jul 2015 20:43:46 +1000 Message-Id: <1436525028-23963-4-git-send-email-aik@ozlabs.ru> In-Reply-To: <1436525028-23963-1-git-send-email-aik@ozlabs.ru> References: <1436525028-23963-1-git-send-email-aik@ozlabs.ru> Subject: [Qemu-devel] [PATCH qemu 3/5] vfio: Store IOMMU type in container List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Alexey Kardashevskiy , Alex Williamson , qemu-ppc@nongnu.org, David Gibson So far we were managing not to have an IOMMU type stored anywhere but since we are going to implement different behavior for different IOMMU types in the same memory listener, we need to know IOMMU type after initialization. This adds an IOMMU type into VFIOContainer and initializes it. Since zero is not used for any type, no additional initialization is necessarty for VFIOContainer::type. Signed-off-by: Alexey Kardashevskiy --- hw/vfio/common.c | 7 ++++--- include/hw/vfio/vfio-common.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 225cdc7..788c87a 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -683,8 +683,8 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as) goto free_container_exit; } - ret = ioctl(fd, VFIO_SET_IOMMU, - v2 ? VFIO_TYPE1v2_IOMMU : VFIO_TYPE1_IOMMU); + container->iommu_data.type = v2 ? VFIO_TYPE1v2_IOMMU : VFIO_TYPE1_IOMMU; + ret = ioctl(fd, VFIO_SET_IOMMU, container->iommu_data.type); if (ret) { error_report("vfio: failed to set iommu for container: %m"); ret = -errno; @@ -712,7 +712,8 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as) ret = -errno; goto free_container_exit; } - ret = ioctl(fd, VFIO_SET_IOMMU, VFIO_SPAPR_TCE_IOMMU); + container->iommu_data.type = VFIO_SPAPR_TCE_IOMMU; + ret = ioctl(fd, VFIO_SET_IOMMU, container->iommu_data.type); if (ret) { error_report("vfio: failed to set iommu for container: %m"); ret = -errno; diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 59a321d..0e96689 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -75,6 +75,7 @@ typedef struct VFIOContainer { int fd; /* /dev/vfio/vfio, empowered by the attached groups */ struct { /* enable abstraction to support various iommu backends */ + unsigned type; union { VFIOType1 type1; }; -- 2.4.0.rc3.8.gfb3e7d5