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: 147795 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp943549lji; Fri, 28 Sep 2018 09:09:51 -0700 (PDT) X-Google-Smtp-Source: ACcGV63KNNdSgMGAsyywzY01P/xBMRJxg2OVnFk5s4q0cAe1Sp4/jPmxUn6m7EVtTzji/7BpL08N X-Received: by 2002:a17:902:9047:: with SMTP id w7-v6mr17146764plz.291.1538150991611; Fri, 28 Sep 2018 09:09:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538150991; cv=none; d=google.com; s=arc-20160816; b=yZHX4aeEP8vRPwpahT1s+U+cwl3R2hbjKeACSZ2VphJvEu2AVPVTYq7TyuJuAYasLE HRpHqy2R4Km3G9Nh/09xxJDSjAVi1+BaW0mqOwyn+hgngL4o8/YLgfCLUrtUGEL9LW38 LZ3L2a0hm24L9bhXyW08ukmdDCiogsUys/JJ78Vcx6dGZ0ckBKB5vf9W5gAp9+o5KIIr qA4gNYeDRXzKVHfPCYMjseGEopiWX5nMq1udQ+FuyrK3nzAZckFgabYxYS9Wq9Ru4m9x Z2PIeq+ERinN9dHLklZrGE1BD9xTSupshktB1GW/mfGHYCXCiPWjuVFR1lhb9buu4+CC xArg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=FT+6xeiPDLbkzprZXnjTdXAG3ozmrK6NYwcgUZoFvSU=; b=OBhBbZ+gQagvkGElgJZez8T5YAcmwSVPEVtJ6QaQUm6j9W5aOKi6mJR+fYxECJ3xnB NK0295CeXH5HwcG0Ii7CIaNrr1+Ovrum09v3jU8n1V0g+DkZia8XT5Bulw+XHn/vNrz2 ff4kpowihrdDVpVgRVqszv42CSPLF7oEqJJgRYHlJ/XE8A+ZJcAPV992doYd/codHng2 Pl8Uk635EEmFu7qYvYf0P7c2Zp1KP/jx73Rp6LP8Y3eu10ax20MFBpUK5UqvO+YRoGU4 yVBifY2r3i3W89XvkpZghlOr3t/ety1ViETsxMqf/K+Z1mc4oLOjR6xrf9hVuuSxEDL/ s9Wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=DS9m9x7U; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k5-v6si4984160pgi.99.2018.09.28.09.09.51; Fri, 28 Sep 2018 09:09:51 -0700 (PDT) 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; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=DS9m9x7U; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726288AbeI1WeQ (ORCPT + 3 others); Fri, 28 Sep 2018 18:34:16 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:50664 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726738AbeI1WeQ (ORCPT ); Fri, 28 Sep 2018 18:34:16 -0400 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 Cc: Marek Szyprowski , linux-samsung-soc@vger.kernel.org, Inki Dae , Seung-Woo Kim , Bartlomiej Zolnierkiewicz , Robin Murphy , joro@8bytes.org, hch@lst.de, linux-arm-kernel@lists.infradead.org, Andrzej Hajda 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/HZLH2yF12i4MfngC5k1+yOfB4 PDk4j8ljzbw1jB73u48zeWxeUu8x+cZyRo/dNxvYPPq2rGL0+LxJLoAjissmJTUnsyy1SN8u gStjz94m9oKTIhVzPxQ1MM4V7GLk5JAQMJF482sFSxcjF4eQwApGiYsLJjBBOJ8ZJeYunMUK U/X95hJWiMQyRolZT36xQzgNTBLdew6wg1SxCRhKdL3tYgOxRQRcJY7PfgJWxCzwgkniwezv TCAJYYE4ia49D5lBbBYBVYlFz3+DxXkFbCX6OroYIdbJS6zecACshlPAWuLXlE0sEPE9bBKT N+p0MXIA2S4ST3oSIMLCEq+Ob2GHsGUkLk/uBvtHQqCZUaJ9xix2CKeHUWLrnB1sEFXWEoeP XwT7jVmAT2LStunMEEN5JTrahCBKPCTWfZsDDZg+RolL15awT2CUXMDIsIpRPLW0ODc9tdgo L7Vcrzgxt7g0L10vOT93EyMwmk//O/5lB+OuP0mHGAU4GJV4eF9YrYsWYk0sK67MPcQowcGs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MailID: 20180928160945eucas1p17ff77fe34854548719880638ecb9c54d X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180928160945eucas1p17ff77fe34854548719880638ecb9c54d References: Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org 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 --- 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(-) -- 2.17.1 Reviewed-by: Robin Murphy 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