From patchwork Fri Feb 9 15:16:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 871502 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zdMpX12vMz9s7M for ; Sat, 10 Feb 2018 04:42:44 +1100 (AEDT) Received: from localhost ([::1]:49378 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ekCh8-0004dI-49 for incoming@patchwork.ozlabs.org; Fri, 09 Feb 2018 12:42:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39630) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ekAQO-0003tA-IK for qemu-devel@nongnu.org; Fri, 09 Feb 2018 10:17:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ekAQK-0003FV-Jq for qemu-devel@nongnu.org; Fri, 09 Feb 2018 10:17:16 -0500 Received: from baptiste.telenet-ops.be ([2a02:1800:120:4::f00:13]:44872) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ekAQK-0003En-Bg for qemu-devel@nongnu.org; Fri, 09 Feb 2018 10:17:12 -0500 Received: from ayla.of.borg ([84.194.111.163]) by baptiste.telenet-ops.be with bizsmtp id 8fH71x02P3XaVaC01fH7HZ; Fri, 09 Feb 2018 16:17:09 +0100 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.86_2) (envelope-from ) id 1ekAQF-0003RE-DL; Fri, 09 Feb 2018 16:17:07 +0100 Received: from geert by ramsan with local (Exim 4.86_2) (envelope-from ) id 1ekAQF-0000jY-8Z; Fri, 09 Feb 2018 16:17:07 +0100 From: Geert Uytterhoeven To: Baptiste Reynal , Alex Williamson Date: Fri, 9 Feb 2018 16:16:49 +0100 Message-Id: <1518189413-2761-3-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518189413-2761-1-git-send-email-geert+renesas@glider.be> References: <1518189413-2761-1-git-send-email-geert+renesas@glider.be> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 2a02:1800:120:4::f00:13 X-Mailman-Approved-At: Fri, 09 Feb 2018 12:38:16 -0500 Subject: [Qemu-devel] [PATCH/RFC 2/6] vfio: Ignore real IOMMUs if CONFIG_VFIO_NOIOMMU=y 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: Arnd Bergmann , kvm@vger.kernel.org, Magnus Damm , Alexander Graf , qemu-devel@nongnu.org, linux-renesas-soc@vger.kernel.org, Wolfram Sang , Laurent Pinchart , Geert Uytterhoeven Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Allow use of the No-IOMMU mode even if a real IOMMU is present. This is useful in case the device is not part of an actual IOMMU group. Not-Signed-off-by: Geert Uytterhoeven --- Question: - Some devices (e.g. rcar-gpio) don't use DMA, so why do they need an IOMMU group? - Even devices using DMA may do so using a separate DMAC module, pointed to by "dmas" DT properties (e.g. sh-sci), hence they may be not part of an IOMMU group. - How to know which devices do DMA? --- drivers/vfio/vfio.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 2bc3705a99bd2f1a..7736c3fbe468a3da 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -129,9 +129,13 @@ struct iommu_group *vfio_iommu_group_get(struct device *dev) * bus. We set iommudata simply to be able to identify these groups * as special use and for reclamation later. */ - if (group || !noiommu || iommu_present(dev->bus)) + if (group || !noiommu) return group; + if (iommu_present(dev->bus)) + dev_warn(dev, "iommu present (%ps), ignoring\n", + dev->bus->iommu_ops); + group = iommu_group_alloc(); if (IS_ERR(group)) return NULL;