From patchwork Fri Sep 28 16:09:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 10620151 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 609B1417B for ; Fri, 28 Sep 2018 16:10:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4145E2BE62 for ; Fri, 28 Sep 2018 16:10:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 33C552BE5A; Fri, 28 Sep 2018 16:10:20 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BC6312BE56 for ; Fri, 28 Sep 2018 16:10:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-reply-to:Message-id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=hbD+W/L5pi0qauYPBK6y1V6JDpXFsc9gT2akt5xhTCc=; b=bRAHioNxonoU2OgowK2SsMzrWp 4+eULtjjUpyCvts0VH2iJdMS7hmhfvKSS/O8cTGDHnNtiOmy5gBU9W2XCZG+vM3Syl8Ws6hsz2XrN KvXQ1M6wq7GrvzdReGG04VUAJEQnkiBB1UmRg45EhaBYr4Qn17GPHwA/blI/F7O4k7ZaD+DcaFZl2 2168M7RQo+zGJmNx9sdDDTJKw8zhg5nCBINZUCNaOZMM59BCDZZ1tYWj5N7menlV0kSVC9yyMNGXS zEvOLha7RvnXZyZUdXSAU/Xglw7ypEZ8UC1YRT77y1UEOimX8idW+V3fTm+/SklyfyAYbr3NedIcC 4x4HREWw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g5vLB-0005GM-VU; Fri, 28 Sep 2018 16:10:05 +0000 Received: from mailout1.w1.samsung.com ([210.118.77.11]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g5vL6-0005A7-LD for linux-arm-kernel@lists.infradead.org; Fri, 28 Sep 2018 16:10:03 +0000 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20180928160947euoutp01ea02e1d7fcbf8cd4dabf6ec0d7072b82~YnCyGFQnL1150011500euoutp01P; Fri, 28 Sep 2018 16:09:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180928160947euoutp01ea02e1d7fcbf8cd4dabf6ec0d7072b82~YnCyGFQnL1150011500euoutp01P DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1538150987; bh=FT+6xeiPDLbkzprZXnjTdXAG3ozmrK6NYwcgUZoFvSU=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=DS9m9x7UvXbdKbfxyXSKpqH38ftbBjphHjpA/+4mweiaEXdVzugiun0Tva/v+hr0m e7MoLIZ5l07rJy/Qmx8DAzdYm44NqdOqEWXZC07hCqjcUY2TiswU0MkqVHUg0zL2Tg UOCuOcbt6yEJJurRp/PXWJaaWc9fqIKv5OAG3pGc= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180928160946eucas1p268387a6527fe7bf8e925f580db2b765e~YnCxNsqoe1886218862eucas1p2r; Fri, 28 Sep 2018 16:09:46 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 89.6C.04294.A425EAB5; Fri, 28 Sep 2018 17:09:46 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180928160945eucas1p17ff77fe34854548719880638ecb9c54d~YnCwAXZn00655806558eucas1p1o; Fri, 28 Sep 2018 16:09:45 +0000 (GMT) X-AuditID: cbfec7f4-835ff700000010c6-6b-5bae524af644 Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id F8.5A.04128.9425EAB5; Fri, 28 Sep 2018 17:09:45 +0100 (BST) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0PFR008RLWW5YX40@eusync4.samsung.com>; Fri, 28 Sep 2018 17:09:45 +0100 (BST) From: Marek Szyprowski To: dri-devel@lists.freedesktop.org, iommu@lists.linux-foundation.org Subject: [PATCH] drm/exynos: Use selected dma_dev default iommu domain instead of a fake one Date: Fri, 28 Sep 2018 18:09:23 +0200 Message-id: <20180928160923.12311-1-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-reply-to: X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrPIsWRmVeSWpSXmKPExsWy7djP87peQeuiDeY/k7e4te4cq8XGGetZ La58fc9msXL1USaLSfcnsFgs2G9t0Tl7A7vFpsfXWC1mnN/HZL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JaxcjF4eQwBJGif0td5ghnCYmibkdL1hA qtgEDCW63naxgdgiAq4Sx2c/YQcpYhZ4wSTx/s8bRpCEsECcxMkVy1hBbBYBVYlFz38zgdi8 ArYSfR1djBDr5CVWbzjADGJzClhL/JqyCWgBB9A2K4lLjRYTGHkWMDKsYhRJLS3OTc8tNtIr TswtLs1L10vOz93ECAzDbcd+btnB2PUu+BCjAAejEg+vg+26aCHWxLLiytxDjBIczEoivPuq 10YL8aYkVlalFuXHF5XmpBYfYpTmYFES5z1vUBklJJCeWJKanZpakFoEk2Xi4JRqYBQouLp/ +vPnrz+7vunrrndaY9ea8M/p0Iat0iu5Cw9NsQq+nHZ4WRNXo2mvq6HpsW+r48Qn5Zl/VN3G /IE/w1RTQPL/8l88SxjrV7TcL8j972d7Zk2bubeKZH7X7J2nTDa/CNd4823OzuA2j8rc39zn mWR7TSZo2jj5PO9111j29XezZ/2UYiWW4oxEQy3mouJEAPXe5oE/AgAA X-CMS-MailID: 20180928160945eucas1p17ff77fe34854548719880638ecb9c54d X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180928160945eucas1p17ff77fe34854548719880638ecb9c54d References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180928_091001_008212_9C528B8A X-CRM114-Status: GOOD ( 16.27 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-samsung-soc@vger.kernel.org, Bartlomiej Zolnierkiewicz , joro@8bytes.org, Seung-Woo Kim , Inki Dae , Andrzej Hajda , Robin Murphy , hch@lst.de, linux-arm-kernel@lists.infradead.org, Marek Szyprowski MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of allocating a fake IOMMU domain for all Exynos DRM components, simply reuse the default IOMMU domain of the already selected DMA device. This allows some design changes in IOMMU framework without breaking IOMMU support in Exynos DRM. Signed-off-by: Marek Szyprowski Reviewed-by: Robin Murphy --- Inki: If possible, please consider this patch as a fix for v4.19-rc, this will help doing a rework in IOMMU and DMA-IOMMU frameworks in v4.20 without breaking Exynos DRM. It worked for current IOMMU code, but such usage is considered as a hack. --- drivers/gpu/drm/exynos/exynos_drm_iommu.h | 34 ++++------------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_iommu.h b/drivers/gpu/drm/exynos/exynos_drm_iommu.h index 87f6b5672e11..797d9ee5f15a 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_iommu.h +++ b/drivers/gpu/drm/exynos/exynos_drm_iommu.h @@ -55,37 +55,12 @@ static inline void __exynos_iommu_detach(struct exynos_drm_private *priv, static inline int __exynos_iommu_create_mapping(struct exynos_drm_private *priv, unsigned long start, unsigned long size) { - struct iommu_domain *domain; - int ret; - - domain = iommu_domain_alloc(priv->dma_dev->bus); - if (!domain) - return -ENOMEM; - - ret = iommu_get_dma_cookie(domain); - if (ret) - goto free_domain; - - ret = iommu_dma_init_domain(domain, start, size, NULL); - if (ret) - goto put_cookie; - - priv->mapping = domain; + priv->mapping = iommu_get_domain_for_dev(priv->dma_dev); return 0; - -put_cookie: - iommu_put_dma_cookie(domain); -free_domain: - iommu_domain_free(domain); - return ret; } static inline void __exynos_iommu_release_mapping(struct exynos_drm_private *priv) { - struct iommu_domain *domain = priv->mapping; - - iommu_put_dma_cookie(domain); - iommu_domain_free(domain); priv->mapping = NULL; } @@ -94,7 +69,9 @@ static inline int __exynos_iommu_attach(struct exynos_drm_private *priv, { struct iommu_domain *domain = priv->mapping; - return iommu_attach_device(domain, dev); + if (dev != priv->dma_dev) + return iommu_attach_device(domain, dev); + return 0; } static inline void __exynos_iommu_detach(struct exynos_drm_private *priv, @@ -102,7 +79,8 @@ static inline void __exynos_iommu_detach(struct exynos_drm_private *priv, { struct iommu_domain *domain = priv->mapping; - iommu_detach_device(domain, dev); + if (dev != priv->dma_dev) + iommu_detach_device(domain, dev); } #else #error Unsupported architecture and IOMMU/DMA-mapping glue code