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: 10209423 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8B493602D8 for ; Fri, 9 Feb 2018 15:17:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7AFD429792 for ; Fri, 9 Feb 2018 15:17:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6FBD529797; Fri, 9 Feb 2018 15:17:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 23C8529792 for ; Fri, 9 Feb 2018 15:17:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752193AbeBIPRO (ORCPT ); Fri, 9 Feb 2018 10:17:14 -0500 Received: from baptiste.telenet-ops.be ([195.130.132.51]:38714 "EHLO baptiste.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751099AbeBIPRL (ORCPT ); Fri, 9 Feb 2018 10:17:11 -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 Cc: Arnd Bergmann , Alexander Graf , Magnus Damm , Laurent Pinchart , Wolfram Sang , kvm@vger.kernel.org, linux-renesas-soc@vger.kernel.org, qemu-devel@nongnu.org, Geert Uytterhoeven Subject: [PATCH/RFC 2/6] vfio: Ignore real IOMMUs if CONFIG_VFIO_NOIOMMU=y 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> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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;