From patchwork Tue Jul 23 10:01:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonios Motakis X-Patchwork-Id: 2831903 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 5EEC39F243 for ; Tue, 23 Jul 2013 10:09:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 88420201EA for ; Tue, 23 Jul 2013 10:09:10 +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 26E3A2018A for ; Tue, 23 Jul 2013 10:09:09 +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 1V1ZWi-0000tC-Jz; Tue, 23 Jul 2013 10:09:04 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V1ZWg-0005Aa-1Y; Tue, 23 Jul 2013 10:09:02 +0000 Received: from mail-we0-f172.google.com ([74.125.82.172]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V1ZWd-0005A2-SB for linux-arm-kernel@lists.infradead.org; Tue, 23 Jul 2013 10:09:00 +0000 Received: by mail-we0-f172.google.com with SMTP id t61so1973259wes.3 for ; Tue, 23 Jul 2013 03:08:37 -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:x-gm-message-state; bh=LZOSzLbc5tq5Onqi6pgwHJQHIKocvHo5fdJkQcd2J68=; b=UezFI9OZjX8LSCTaIkgTchGpO5cV2AnAspyKQdVqhrjKEFEKkAKqYNFhOYkToiEqur N9DzJsmnLLj+WQkiEM8UilPb0ZO8XQDmaH4JYvR7LxEYMoYrDZ0VJyw5h/vRoa6B/Ory 7BVe7+Xn/YtTNyrgGEs9e068EBKZLD+yB8R40Gk22UMrJomjjPNOpR3SJ5mYg9B81Buz aNKFj5eqmZkl9pPPWevXt4hToLHmsTpPtXm8JPsg74TPjgDE6ePsj2MzyeewNnuOVxzI 0S0r+jRi+P+vpS2j7muytNSvZmWOsxzbqeN9+G+C6dQ+hzeoC3og43L4C+VkrRk4ttCD /7OQ== X-Received: by 10.194.176.41 with SMTP id cf9mr21778726wjc.66.1374573713099; Tue, 23 Jul 2013 03:01:53 -0700 (PDT) Received: from localhost.localdomain (home.tvelocity.eu. [82.67.68.96]) by mx.google.com with ESMTPSA id eu1sm4702331wib.8.2013.07.23.03.01.50 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 23 Jul 2013 03:01:52 -0700 (PDT) From: Antonios Motakis To: linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH] iommu/exynos: add devices attached to the System MMU to an IOMMU group Date: Tue, 23 Jul 2013 12:01:32 +0200 Message-Id: <1374573694-30595-1-git-send-email-a.motakis@virtualopensystems.com> X-Mailer: git-send-email 1.8.1.2 X-Gm-Message-State: ALoCoQkYyRn6/f8+Jyp80hz0kmSjebuKAgmE9eMEgQ9f/fpOh+yBxh4RhEtpp99u7j+WECyutSGI X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130723_060900_026254_65C459AD X-CRM114-Status: GOOD ( 11.65 ) X-Spam-Score: -2.6 (--) Cc: Sachin Kamat , Jiri Kosina , Joerg Roedel , open list , Wei Yongjun , Antonios Motakis , Cho KyongHo , 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 IOMMU groups are expected by certain users of the IOMMU API, e.g. VFIO. Since each device is behind its own System MMU, we can allocate a new IOMMU group for each device. This patch depends on Cho KyongHo's patch series titled "[PATCH v7 00/12] iommu/exynos: Fixes and Enhancements of System MMU driver with DT", applied on a Linux 3.10.1 kernel. It has been tested on the Arndale board. Signed-off-by: Antonios Motakis --- drivers/iommu/exynos-iommu.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index 51d43bb..9f39eaa 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -1134,6 +1134,28 @@ static phys_addr_t exynos_iommu_iova_to_phys(struct iommu_domain *domain, return phys; } +static int exynos_iommu_add_device(struct device *dev) +{ + struct iommu_group *group; + int ret; + + group = iommu_group_alloc(); + if (IS_ERR(group)) { + dev_err(dev, "Failed to allocate IOMMU group\n"); + return PTR_ERR(group); + } + + ret = iommu_group_add_device(group, dev); + iommu_group_put(group); + + return ret; +} + +static void exynos_iommu_remove_device(struct device *dev) +{ + iommu_group_remove_device(dev); +} + static struct iommu_ops exynos_iommu_ops = { .domain_init = &exynos_iommu_domain_init, .domain_destroy = &exynos_iommu_domain_destroy, @@ -1142,6 +1164,8 @@ static struct iommu_ops exynos_iommu_ops = { .map = &exynos_iommu_map, .unmap = &exynos_iommu_unmap, .iova_to_phys = &exynos_iommu_iova_to_phys, + .add_device = exynos_iommu_add_device, + .remove_device = exynos_iommu_remove_device, .pgsize_bitmap = SECT_SIZE | LPAGE_SIZE | SPAGE_SIZE, };