From patchwork Mon Mar 27 08:04:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 9645513 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 54FF8602D6 for ; Mon, 27 Mar 2017 08:04:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 476FC2815E for ; Mon, 27 Mar 2017 08:04:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C1FA28338; Mon, 27 Mar 2017 08:04:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D553C2815E for ; Mon, 27 Mar 2017 08:04:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752098AbdC0IEv (ORCPT ); Mon, 27 Mar 2017 04:04:51 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:20906 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752064AbdC0IEs (ORCPT ); Mon, 27 Mar 2017 04:04:48 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0ONG003UCRRRP680@mailout2.w1.samsung.com> for linux-samsung-soc@vger.kernel.org; Mon, 27 Mar 2017 09:04:39 +0100 (BST) Received: from eusmges5.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170327080439eucas1p1af2a7398ff1505af8051f65451934fe3~vroL3FgTR1220412204eucas1p1w; Mon, 27 Mar 2017 08:04:39 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges5.samsung.com (EUCPMTA) with SMTP id C9.8C.25577.697C8D85; Mon, 27 Mar 2017 09:04:38 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170327080438eucas1p28a1a20c1bfeafc037fe26d94639044a9~vroLNJsU40860008600eucas1p2S; Mon, 27 Mar 2017 08:04:38 +0000 (GMT) X-AuditID: cbfec7f5-f792f6d0000063e9-4b-58d8c79627b5 Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id A6.B8.20206.7A7C8D85; Mon, 27 Mar 2017 09:04:55 +0100 (BST) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0ONG00FT4RRM3N00@eusync1.samsung.com>; Mon, 27 Mar 2017 09:04:38 +0100 (BST) From: Marek Szyprowski To: dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , Inki Dae , Joonyoung Shim , Seung-Woo Kim , Andrzej Hajda , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz Subject: [PATCH] drm/exynos: Properly release default ARM DMA-IOMMU mapping Date: Mon, 27 Mar 2017 10:04:32 +0200 Message-id: <1490601872-17369-1-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrPIsWRmVeSWpSXmKPExsWy7djP87rTjt+IMDjwwcLi1rpzrBYbZ6xn tbjy9T2bxaT7E1gsXty7yGJx/vwGdosZ5/cxWaw9chfImvySzYHTY9OqT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ZginiUni8Iz1YFVsAoYSXW+72EBsEQE3iabDM1lBipgF1jBJtLZ/ZgdJCAt4 S/SfeQXWwCKgKjGh8wFYnFfAQ+L1nC+sEOvkJE4em8w6gZF7ASPDKkaR1NLi3PTcYiO94sTc 4tK8dL3k/NxNjMBA3Xbs55YdjF3vgg8xCnAwKvHw7hC7ESHEmlhWXJl7iFGCg1lJhPfgfqAQ b0piZVVqUX58UWlOavEhRlOg5ROZpUST84FRlFcSb2hiaG5paGRsYWFuZKQkzjv1w5VwIYH0 xJLU7NTUgtQimD4mDk6pBsbmG18Suu8l7ik7Xi0rdIRhvsHylOfaHw6em8f0OWHjZZ6mh0Fv dWdxqnJoScyIzO8pOD7bvas4b316R/DrFZNmXpl+yt/xnbvlw5xWVYlfXjvvJrNcanRLWNhx XlCs/drlOsbvF75+MXWY8DRG4qxIE5v2n9zr+VxfWpRaHL09k/fWsv6b0qXEUpyRaKjFXFSc CABT7NLFagIAAA== X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170327080438eucas1p28a1a20c1bfeafc037fe26d94639044a9 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: 20170327080438eucas1p28a1a20c1bfeafc037fe26d94639044a9 X-RootMTR: 20170327080438eucas1p28a1a20c1bfeafc037fe26d94639044a9 References: Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Exynos DRM on ARM architecture creates its own DMA-IOMMU mapping, shared between all devices that builds the Exynos DRM subsystem. Thus, the default DMA-IOMMU mapping structure created by platform init code can be released to avoid leaking resources, because after exynos_iommu_attach() the default mapping is no longer accessible. Reported-by: Seung-Woo Kim Signed-off-by: Marek Szyprowski --- drivers/gpu/drm/exynos/exynos_drm_iommu.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_iommu.h b/drivers/gpu/drm/exynos/exynos_drm_iommu.h index 87f6b5672e11..7a4528461bba 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_iommu.h +++ b/drivers/gpu/drm/exynos/exynos_drm_iommu.h @@ -37,8 +37,13 @@ static inline int __exynos_iommu_create_mapping(struct exynos_drm_private *priv, static inline int __exynos_iommu_attach(struct exynos_drm_private *priv, struct device *dev) { - if (dev->archdata.mapping) + struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev); + + /* release device from the default DMA-IOMMU mapping */ + if (mapping) { arm_iommu_detach_device(dev); + arm_iommu_release_mapping(mapping); + } return arm_iommu_attach_device(dev, priv->mapping); }