From patchwork Thu Nov 24 11:20:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 83864 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp79188qgi; Thu, 24 Nov 2016 03:20:49 -0800 (PST) X-Received: by 10.84.132.34 with SMTP id 31mr4386608ple.14.1479986449363; 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.49; 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 S965131AbcKXLUs (ORCPT + 4 others); Thu, 24 Nov 2016 06:20:48 -0500 Received: from mailout4.samsung.com ([203.254.224.34]:60303 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964851AbcKXLUr (ORCPT ); Thu, 24 Nov 2016 06:20:47 -0500 Received: from epcpsbgm1new.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OH500L408U38N00@mailout4.samsung.com> for linux-samsung-soc@vger.kernel.org; Thu, 24 Nov 2016 20:20:46 +0900 (KST) X-AuditID: cbfee61a-f79916d0000062de-0e-5836cd0e09b0 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id 77.89.25310.E0DC6385; Thu, 24 Nov 2016 20:20:46 +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:46 +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 5/5] iommu/exynos: Properly release device from the default domain in ->remove Date: Thu, 24 Nov 2016 12:20:20 +0100 Message-id: <1479986420-30859-6-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+t9jAV2+s2YRBid2KVpsnLGe1WLBfmuL ztkb2C3OnwcSM87vY7JYe+QuuwObx5OD85g8Nq3qZPOYfGM5o0ffllWMHp83yQWwRrnZZKQm pqQWKaTmJeenZOal2yqFhrjpWigp5CXmptoqRej6hgQpKZQl5pQCeUYGaMDBOcA9WEnfLsEt 4/We5awFFzkqLq57z9LAOIO9i5GTQ0LAROLP1KfMELaYxIV769m6GLk4hASWMkrMn7GDCcL5 xSgxa8UlFpAqNgFDia63XWwgtoiAu8T1P89ZQIqYBTYwSqybMQFslLBAgsTLl4vAVrAIqEps n/IUqIGDg1fAQ2LtDXmIbXISJ49NZgWxOQU8JaZv7AebLwRUcmHVW8YJjLwLGBlWMUqkFiQX FCel5xrmpZbrFSfmFpfmpesl5+duYgQH8jOpHYwHd7kfYhTgYFTi4X1gZhYhxJpYVlyZe4hR goNZSYTX4BRQiDclsbIqtSg/vqg0J7X4EKMp0F0TmaVEk/OBUZZXEm9oYm5ibmxgYW5paWKk JM7bOPtZuJBAemJJanZqakFqEUwfEwenVAPjbP/fcWLiv/2SaucGnbvSZuawPU1lSX7hSc8j G01NKqsbqqzZp9zszb4661n8HgfZUr5gjjnrNnurXjCue89q0sY7cdkirwdmkxfs819tlj91 2vG1X9c9kLPV9dHlm8AYMNk4NIDx8Fy+/wZzU5+4NXY3Kew9/6Xc2+PSO9Z9T7M+Rv96KBWh xFKckWioxVxUnAgAmu6fPXoCAAA= 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 IOMMU core doesn't detach device from the default domain before calling ->iommu_remove_device, so check that and do the proper cleanup or warn if device is still attached to non-default domain. Signed-off-by: Marek Szyprowski --- drivers/iommu/exynos-iommu.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) -- 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 63d9358a6d9c..0223db074d03 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -1245,9 +1245,21 @@ static int exynos_iommu_add_device(struct device *dev) static void exynos_iommu_remove_device(struct device *dev) { + struct exynos_iommu_owner *owner = dev->archdata.iommu; + if (!has_sysmmu(dev)) return; + if (owner->domain) { + struct iommu_group *group = iommu_group_get(dev); + + if (group) { + WARN_ON(owner->domain != + iommu_group_default_domain(group)); + exynos_iommu_detach_device(owner->domain, dev); + iommu_group_put(group); + } + } iommu_group_remove_device(dev); }