From patchwork Tue Feb 16 14:40:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 62034 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1703998lbl; Tue, 16 Feb 2016 06:42:02 -0800 (PST) X-Received: by 10.140.85.36 with SMTP id m33mr27475154qgd.91.1455633722448; Tue, 16 Feb 2016 06:42:02 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id t3si40884081qkl.123.2016.02.16.06.42.02; Tue, 16 Feb 2016 06:42:02 -0800 (PST) Received-SPF: pass (google.com: domain of linaro-mm-sig-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linaro-mm-sig-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=linaro-mm-sig-bounces@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 009AF61835; Tue, 16 Feb 2016 14:42:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id B1E56617DC; Tue, 16 Feb 2016 14:40:59 +0000 (UTC) X-Original-To: linaro-mm-sig@lists.linaro.org Delivered-To: linaro-mm-sig@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 493E861705; Tue, 16 Feb 2016 14:40:55 +0000 (UTC) Received: from mailout3.w1.samsung.com (mailout3.w1.samsung.com [210.118.77.13]) by lists.linaro.org (Postfix) with ESMTPS id BE449617C3 for ; Tue, 16 Feb 2016 14:40:52 +0000 (UTC) Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O2N00IWTA43TH20@mailout3.w1.samsung.com> for linaro-mm-sig@lists.linaro.org; Tue, 16 Feb 2016 14:40:51 +0000 (GMT) X-AuditID: cbfec7f5-f79b16d000005389-ee-56c334f262b8 Received: from eusync2.samsung.com ( [203.254.199.212]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 3C.28.21385.2F433C65; Tue, 16 Feb 2016 14:40:50 +0000 (GMT) Received: from amdc1339.digital.local ([106.116.147.30]) by eusync2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O2N009ERA3YAL40@eusync2.samsung.com>; Tue, 16 Feb 2016 14:40:50 +0000 (GMT) From: Marek Szyprowski To: iommu@lists.linux-foundation.org Date: Tue, 16 Feb 2016 15:40:32 +0100 Message-id: <1455633632-16873-3-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.2 In-reply-to: <1455633632-16873-1-git-send-email-m.szyprowski@samsung.com> References: <1455633632-16873-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpmluLIzCtJLcpLzFFi42I5/e/4Fd1PJofDDCbOsbHYOGM9q8WC/dYW nbM3sFt8ufKQyWLtkbvsDqweTw7OY/K4/e8xs8fkG8sZPfq2rGIMYInisklJzcksSy3St0vg yni8tIu5YCFHxfed2Q2Mj9m6GDk5JARMJGaunwFli0lcuLceyObiEBJYyijx5sscJpCEkEAT k0RXfx6IzSZgKNH1tgusQURARWLWzsUsIA3MAisZJTZ+u8gOkhAWCJZo+N7HCGKzCKhKvLnb xwJi8wp4SHw4foYRYpucxP+XK4AWcHBwCnhKbP2pBrHLQ+Lj9kdsExh5FzAyrGIUTS1NLihO Ss810itOzC0uzUvXS87P3cQICZqvOxiXHrM6xCjAwajEw7vB9VCYEGtiWXFl7iFGCQ5mJRHe f6+AQrwpiZVVqUX58UWlOanFhxilOViUxHln7nofIiSQnliSmp2aWpBaBJNl4uCUamD0tHL4 3O/ee/CxugGX7Ou9+4Wvvtl8xFJS+WTK8QL/nEtXhdR9dkZeZn2RaTNZ8cqkFQVsNY5R70Tu N32WF10sov8rfGOZwyx/nwOu8Xc1AmzP9Un+3quc1q/x4/tzywcOTE2XssKsxYIWCu6VE7jq 9OVGrcqs8w8dDvZPz9hR0OD28huffp4SS3FGoqEWc1FxIgChQ96OFgIAAA== Cc: linaro-mm-sig@lists.linaro.org, Joerg Roedel , Bartlomiej Zolnierkiewicz Subject: [Linaro-mm-sig] [PATCH 2/2] iommu: fix default domain handling in __iommu_detach_group() X-BeenThere: linaro-mm-sig@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "Unified memory management interest group." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linaro-mm-sig-bounces@lists.linaro.org Sender: "Linaro-mm-sig" This patch ensures that all devices will be first detached from the provided domain and then attached to the default_domain if such has been provided. Signed-off-by: Marek Szyprowski --- drivers/iommu/iommu.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index db231ad..045efb0 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1246,14 +1246,14 @@ static void __iommu_detach_group(struct iommu_domain *domain, { int ret; - if (!group->default_domain) { - __iommu_group_for_each_dev(group, domain, - iommu_group_do_detach_device); - group->domain = NULL; + if (group->domain == group->default_domain) return; - } - if (group->domain == group->default_domain) + __iommu_group_for_each_dev(group, domain, + iommu_group_do_detach_device); + group->domain = NULL; + + if (!group->default_domain) return; /* Detach by re-attaching to the default domain */