From patchwork Mon Jan 9 12:03:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 90424 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp46739qgi; Mon, 9 Jan 2017 04:05:40 -0800 (PST) X-Received: by 10.99.127.71 with SMTP id p7mr10702840pgn.125.1483963540399; Mon, 09 Jan 2017 04:05:40 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r39si4812531pld.320.2017.01.09.04.05.40; Mon, 09 Jan 2017 04:05:40 -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 S1752826AbdAIMFY (ORCPT + 4 others); Mon, 9 Jan 2017 07:05:24 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:19661 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752605AbdAIMER (ORCPT ); Mon, 9 Jan 2017 07:04:17 -0500 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OJI00HZRHJ2DP30@mailout1.w1.samsung.com> for linux-samsung-soc@vger.kernel.org; Mon, 09 Jan 2017 12:04:14 +0000 (GMT) Received: from eusmges1.samsung.com (unknown [203.254.199.239]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170109120414eucas1p2688da45548f170dc9f57e5090cee7aef~YGOYr9crC0808008080eucas1p2r; Mon, 9 Jan 2017 12:04:14 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1.samsung.com (EUCPMTA) with SMTP id 12.EB.16908.04C73785; Mon, 9 Jan 2017 12:04:16 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170109120413eucas1p19721a17d6e81e75e8f6e93ec2528f1b6~YGOXxd_iE2745427454eucas1p1U; Mon, 9 Jan 2017 12:04:13 +0000 (GMT) X-AuditID: cbfec7ef-f79d26d00000420c-df-58737c4063b9 Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 6C.FC.10233.43C73785; Mon, 9 Jan 2017 12:04:04 +0000 (GMT) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OJI00KQMHIPLS60@eusync3.samsung.com>; Mon, 09 Jan 2017 12:04:12 +0000 (GMT) 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 v2 4/4] iommu/exynos: Properly release device from the default domain in ->remove Date: Mon, 09 Jan 2017 13:03:56 +0100 Message-id: <1483963436-29803-5-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1483963436-29803-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrIIsWRmVeSWpSXmKPExsWy7djPc7oONcURBl3XuCw2zljParFgv7VF 5+wN7BbnzwOJGef3MVmsPXKX3YHN48nBeUwem1Z1snlMvrGc0aNvyypGj8+b5AJYo7hsUlJz MstSi/TtErgyDnVPZim4yFFx4+1q5gbGGexdjJwcEgImEl83b2OCsMUkLtxbz9bFyMUhJLCM UeLIgbmMEM5nRon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YxSiSWlqcm55b bKRXnJhbXJqXrpecn7uJERjA24793LKDsetd8CFGAQ5GJR7eCV5FEUKsiWXFlbmHGCU4mJVE eBdWFEcI8aYkVlalFuXHF5XmpBYfYjQFOmois5Rocj4wuvJK4g1NDM0tDY2MLSzMjYyUxHmn frgSLiSQnliSmp2aWpBaBNPHxMEp1cDYNj9X8S77BbGn07sNAq94B/dyuDqLbOW5ftTbTief 5fXvmFPX61t+ll/P6xOav5/jrKl1uIXF5f/rbsdNcepleDln7heOJ7u2HNpYaXtm71eL6dY1 0xwnskWaHtlZ7VPI42Kn4LvQdY6k7I1ZcfmL1F+xJExoCba9enCR7s/kTD3uYo+tZceUWIoz Eg21mIuKEwHlNVKSdgIAAA== X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170109120413eucas1p19721a17d6e81e75e8f6e93ec2528f1b6 X-Msg-Generator: CA X-Sender-IP: 182.198.249.180 X-Local-Sender: =?UTF-8?B?TWFyZWsgU3p5cHJvd3NraRtTUlBPTC1LZXJuZWwgKFRQKRs=?= =?UTF-8?B?7IK87ISx7KCE7J6QG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Global-Sender: =?UTF-8?B?TWFyZWsgU3p5cHJvd3NraRtTUlBPTC1LZXJuZWwgKFRQKRtT?= =?UTF-8?B?YW1zdW5nIEVsZWN0cm9uaWNzG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Sender-Code: =?UTF-8?B?QzEwG0VIURtDMTBDRDAyQ0QwMjczOTI=?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20170109120413eucas1p19721a17d6e81e75e8f6e93ec2528f1b6 X-RootMTR: 20170109120413eucas1p19721a17d6e81e75e8f6e93ec2528f1b6 References: <1483963436-29803-1-git-send-email-m.szyprowski@samsung.com> 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 8bf5a06a6c01..37d9738bd023 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -1242,9 +1242,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); }