From patchwork Mon Aug 5 13:17:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonios Motakis X-Patchwork-Id: 2838685 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9E0E49F479 for ; Mon, 5 Aug 2013 13:24:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7430020149 for ; Mon, 5 Aug 2013 13:24:51 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2D8942017A for ; Mon, 5 Aug 2013 13:24:50 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V6KmE-00059d-KK; Mon, 05 Aug 2013 13:24:46 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V6KmC-0002zY-G5; Mon, 05 Aug 2013 13:24:44 +0000 Received: from mail-we0-f181.google.com ([74.125.82.181]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V6Km9-0002z0-7k for linux-arm-kernel@lists.infradead.org; Mon, 05 Aug 2013 13:24:41 +0000 Received: by mail-we0-f181.google.com with SMTP id p58so2375178wes.26 for ; Mon, 05 Aug 2013 06:24:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=BGkTqNVGN/N9qF1KsQ5X1jLLK4Anj8FZWKhaQrUzy/A=; b=V8cCxYigCD1HYRnNhYahbnUSxVdMWM5uwmUfPsPNfn9RXedfC/EAp8+kofQofJD+Kf Or3jgDRNIURI4Uv9vp9WdN28RdGr8Ek0YvHcw0vgdrtKMNS4cLvCdcpODCsYrDG+PAM0 wrCDfH1Iefyk5VQ52p9gJLbnnv6QMc3gk2Y3+64LVEhHuI4AgltYKMZaS7u56YGFf2sV WBevLZfrNqq5T8YxZk2yBGx1HFFq6GErkXIBqv/4msCMd+i391UQ4aJeTW3lMdoV/5Ay uN2CjIzNubTGkp7Xtj+3jVZxfG2YBkvRvRvUDxY9bpuvjsZKepnzXQbQX2YPWg9gcDr2 /rSA== X-Received: by 10.194.47.167 with SMTP id e7mr13265940wjn.57.1375708686948; Mon, 05 Aug 2013 06:18:06 -0700 (PDT) Received: from localhost.localdomain (home.tvelocity.eu. [82.67.68.96]) by mx.google.com with ESMTPSA id lp4sm18736449wic.2.2013.08.05.06.18.04 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 05 Aug 2013 06:18:06 -0700 (PDT) From: Antonios Motakis To: linux-arm-kernel@lists.infradead.org, alex.williamson@redhat.com Subject: [PATCH 1/3] VFIO_IOMMU_TYPE1 workaround to build for platform devices Date: Mon, 5 Aug 2013 15:17:10 +0200 Message-Id: <1375708632-26356-2-git-send-email-a.motakis@virtualopensystems.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1375708632-26356-1-git-send-email-a.motakis@virtualopensystems.com> References: <1375708632-26356-1-git-send-email-a.motakis@virtualopensystems.com> X-Gm-Message-State: ALoCoQkgVEWv7GI9Z5GiCDZju7fAAH467OhBTZmX28bNo3AhI5O0KtujjLZlCjdG77dIEB3/jwMe X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130805_092441_384408_A3A1DC43 X-CRM114-Status: GOOD ( 14.93 ) X-Spam-Score: -2.6 (--) Cc: linux-samsung-soc@vger.kernel.org, kvm@vger.kernel.org, agraf@suse.de, B08248@freescale.com, iommu@lists.linux-foundation.org, Antonios Motakis , kvmarm@lists.cs.columbia.edu X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This is a workaround to make the VFIO_IOMMU_TYPE1 driver usable with platform devices instead of PCI. A future permanent fix should support both. This is required in order to use the Exynos SMMU, or the ARM SMMU driver with VFIO. Signed-off-by: Antonios Motakis --- drivers/vfio/Kconfig | 2 +- drivers/vfio/vfio_iommu_type1.c | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/vfio/Kconfig b/drivers/vfio/Kconfig index 7cd5dec..1f84eda 100644 --- a/drivers/vfio/Kconfig +++ b/drivers/vfio/Kconfig @@ -6,7 +6,7 @@ config VFIO_IOMMU_TYPE1 menuconfig VFIO tristate "VFIO Non-Privileged userspace driver framework" depends on IOMMU_API - select VFIO_IOMMU_TYPE1 if X86 + select VFIO_IOMMU_TYPE1 if X86 || ARM help VFIO provides a framework for secure userspace device drivers. See Documentation/vfio.txt for more details. diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index 6f3fbc4..4339603 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -30,7 +30,8 @@ #include #include #include -#include /* pci_bus_type */ +#include /* pci_bus_type */ +#include /* platform_bus_type */ #include #include #include @@ -610,9 +611,17 @@ static void *vfio_iommu_type1_open(unsigned long arg) mutex_init(&iommu->lock); /* + * ARM SMMU compatibility workaround + */ + iommu->domain = iommu_domain_alloc(&platform_bus_type); + if (iommu->domain) + return iommu; + + /* * Wish we didn't have to know about bus_type here. */ - iommu->domain = iommu_domain_alloc(&pci_bus_type); + //iommu->domain = iommu_domain_alloc(&pci_bus_type); + if (!iommu->domain) { kfree(iommu); return ERR_PTR(-EIO); @@ -733,7 +742,7 @@ static const struct vfio_iommu_driver_ops vfio_iommu_driver_ops_type1 = { static int __init vfio_iommu_type1_init(void) { - if (!iommu_present(&pci_bus_type)) + if (!iommu_present(&platform_bus_type)) return -ENODEV; return vfio_register_iommu_driver(&vfio_iommu_driver_ops_type1);