From patchwork Thu Nov 24 11:20:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 83863 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp79183qgi; Thu, 24 Nov 2016 03:20:49 -0800 (PST) X-Received: by 10.99.116.92 with SMTP id e28mr3284907pgn.162.1479986449057; Thu, 24 Nov 2016 03:20:49 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g15si10357086pli.166.2016.11.24.03.20.48; Thu, 24 Nov 2016 03:20:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965132AbcKXLUs (ORCPT + 4 others); Thu, 24 Nov 2016 06:20:48 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:54307 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965131AbcKXLUr (ORCPT ); Thu, 24 Nov 2016 06:20:47 -0500 Received: from epcpsbgm2new.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OH502FMU8TW1J20@mailout1.samsung.com> for linux-samsung-soc@vger.kernel.org; Thu, 24 Nov 2016 20:20:42 +0900 (KST) X-AuditID: cbfee61b-f796f6d000004092-07-5836cd0a7892 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id 42.0E.16530.A0DC6385; Thu, 24 Nov 2016 20:20:42 +0900 (KST) Received: from AMDC2765.digital.local ([106.116.147.25]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OH500D6Y8U00G70@mmp1.samsung.com>; Thu, 24 Nov 2016 20:20:42 +0900 (KST) From: Marek Szyprowski To: iommu@lists.linux-foundation.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , Joerg Roedel , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz Subject: [PATCH 4/5] iommu/exynos: Add default_domain check in iommu_attach_device Date: Thu, 24 Nov 2016 12:20:19 +0100 Message-id: <1479986420-30859-5-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1479986420-30859-1-git-send-email-m.szyprowski@samsung.com> References: <1479986420-30859-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOLMWRmVeSWpSXmKPExsVy+t9jAV2us2YRBif7pSw2zljParFgv7VF 5+wN7BbnzwOJGef3MVmsPXKX3YHN48nBeUwem1Z1snlMvrGc0aNvyypGj8+b5AJYo9xsMlIT U1KLFFLzkvNTMvPSbZVCQ9x0LZQU8hJzU22VInR9Q4KUFMoSc0qBPCMDNODgHOAerKRvl+CW 8X/iN+aCaZwViw63sjQwXmHvYuTkkBAwkVj45QIbhC0mceHeeiCbi0NIYCmjxJwXr1lAEkIC vxglmvY6gthsAoYSXW+7wBpEBNwlrv95zgLSwCywgVFi3YwJzCAJYYEQiR0v+sGaWQRUJR58 eAvWwCvgIfHh0EImiG1yEiePTWYFsTkFPCWmb+yHWuYhcWHVW8YJjLwLGBlWMUqkFiQXFCel 5xrlpZbrFSfmFpfmpesl5+duYgQH8jPpHYyHd7kfYhTgYFTi4e0wMYsQYk0sK67MPcQowcGs JMJrcAooxJuSWFmVWpQfX1Sak1p8iNEU6LCJzFKiyfnAKMsriTc0MTcxNzawMLe0NDFSEudt nP0sXEggPbEkNTs1tSC1CKaPiYNTqoFxreOxtrSmUPkWmdXuKvKz+7e7hesJfZi/e8qOB9e7 7hY+1TxqcPZfhCxHxl5x1tByxifrl0RN1OH9uu7j0vfxe4SUH50/MrP58lkWn0f8F5XDE1b9 +7YhdnLzW77Gp22LotTfLt8R/aDs4yRX8aULBS/Pa/6pJxoVY/JkVpJJltkRJjfDy0GWSizF GYmGWsxFxYkAIwokD3oCAAA= X-MTR: 20000000000000000@CPGS Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org This patch adds default_domain check before calling exynos_iommu_detach_device. This path was intended only to cope with default domains, which are automatically attached by the iommu core, so return error if user tries to attach device, which is already attached to other (non-default) domain. Signed-off-by: Marek Szyprowski --- drivers/iommu/exynos-iommu.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index 426b1534d4d3..63d9358a6d9c 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -859,8 +859,17 @@ static int exynos_iommu_attach_device(struct iommu_domain *iommu_domain, if (!has_sysmmu(dev)) return -ENODEV; - if (owner->domain) + if (owner->domain) { + struct iommu_group *group = iommu_group_get(dev); + + if (!group || + owner->domain != iommu_group_default_domain(group)) { + iommu_group_put(group); + return -EINVAL; + } + iommu_group_put(group); exynos_iommu_detach_device(owner->domain, dev); + } mutex_lock(&owner->rpm_lock);