From nobody Tue May 7 15:46:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513055883626860.8812950331568; Mon, 11 Dec 2017 21:18:03 -0800 (PST) Received: from localhost ([::1]:56710 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eOcwu-0004FV-G0 for importer@patchew.org; Tue, 12 Dec 2017 00:17:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46673) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eOcvp-0003DT-6W for qemu-devel@nongnu.org; Tue, 12 Dec 2017 00:16:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eOcvl-0005Iw-77 for qemu-devel@nongnu.org; Tue, 12 Dec 2017 00:16:41 -0500 Received: from ozlabs.ru ([107.173.13.209]:60302) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eOcvl-0005HX-0s; Tue, 12 Dec 2017 00:16:37 -0500 Received: from vpl1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id F1FA83A60026; Tue, 12 Dec 2017 00:15:56 -0500 (EST) From: Alexey Kardashevskiy To: qemu-devel@nongnu.org Date: Tue, 12 Dec 2017 16:16:19 +1100 Message-Id: <20171212051619.24456-1-aik@ozlabs.ru> X-Mailer: git-send-email 2.11.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 107.173.13.209 Subject: [Qemu-devel] [PATCH qemu v2] vfio/spapr: Allow fallback to SPAPR TCE IOMMU v1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Kardashevskiy , Alex Williamson , qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The vfio_iommu_spapr_tce driver advertises kernel's support for v1 and v2 IOMMU support, however it is not always possible to use the requested IOMMU type. For example, a pseries host platform does not support dynamic DMA windows so v2 cannot initialize and QEMU fails to start. This adds a fallback to the v1 IOMMU if v2 cannot be used. Fixes: 318f67ce1371 "vfio: spapr: Add DMA memory preregistering (SPAPR IOMM= U v2)" Signed-off-by: Alexey Kardashevskiy Reviewed-by: David Gibson --- Changes: v2: * updated commit log --- hw/vfio/common.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 7b2924c..cd81cc9 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -1040,6 +1040,11 @@ static int vfio_connect_container(VFIOGroup *group, = AddressSpace *as, v2 ? VFIO_SPAPR_TCE_v2_IOMMU : VFIO_SPAPR_TCE_IOMMU; ret =3D ioctl(fd, VFIO_SET_IOMMU, container->iommu_type); if (ret) { + container->iommu_type =3D VFIO_SPAPR_TCE_IOMMU; + v2 =3D false; + ret =3D ioctl(fd, VFIO_SET_IOMMU, container->iommu_type); + } + if (ret) { error_setg_errno(errp, errno, "failed to set iommu for contain= er"); ret =3D -errno; goto free_container_exit; --=20 2.11.0