From patchwork Mon Oct 30 07:28:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 117451 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2254451qgn; Mon, 30 Oct 2017 00:28:34 -0700 (PDT) X-Google-Smtp-Source: ABhQp+RLXwbYDiYws1CGOwm81LELcSAyj2C8G0JlzYxIBXZuTSbj3UKBXJ3DFQysXSih8aJnumKI X-Received: by 10.98.186.11 with SMTP id k11mr8008300pff.141.1509348514050; Mon, 30 Oct 2017 00:28:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509348514; cv=none; d=google.com; s=arc-20160816; b=f/moNyD1WkW4+gdJLLUzN0np2fLCMF4WhEabewMFsDJ88EULj9cmAftjtnL0y9rRi2 fteHAmMLNDif+afNqn22AEzTOXwmDrzAqbya1FXjSjfVSF2vjJc1wrqvgfDGhZZBP29n A4W2ZnN4Artfhjq8MGbyOjM7Cv8B5PWlIJxE4alObcQxyQpYfRTS33fhWGvKWSTYE+/f EeHlLTPvxhniRA/INXFSbQw5s/LuBNLFwccbZ/pPjgy0NQch6q/FGifmQAuIwpEGJsIp yqLKlBOEBo7HS3dnkMILum4DHzT9C2UOJJCGu5EZQV4s44vd8Vg+g508d99LB5MjadKJ HUGA== 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:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=DBnbtld2IcOt3lutqZZuHW8vsXvabf0g7xat6lvWMzY=; b=mFb2HBoRjvn69Tt1Ys89z0tjQFtbu/739tbB2eNSUzQufOdWsJvhT0t1gpXo4HTjcl wqfEo6x8m3JPOao5tjpsNSg+VhPgqzUBLOlbIcAg0Is+gLc3fNkls1c2cltCX/W18rFR rEMdQeKUxJRaRd/3EDVzbaxhabdzrtAhuPbnZYnnhFJpcwvOkouNvVqkZzJ09JwCAODo sg1u0WYRtDf9qxG592VgRzKh0SUXOZT7U792dGh/ofLdrf3phD+Gm9Yqnc6qteJBSOQI vVl8JSURDA/EFxKkPTegS5EOVUCzGnkjBo0jULr7Pu9ZmKY6JBFZboPZQwXzeVrWTSKN tIPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=CP1+VOrK; 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=fail (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 1si8637302plt.597.2017.10.30.00.28.33; Mon, 30 Oct 2017 00:28:34 -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=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=CP1+VOrK; 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=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751665AbdJ3H2d (ORCPT + 4 others); Mon, 30 Oct 2017 03:28:33 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:54933 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751624AbdJ3H2c (ORCPT ); Mon, 30 Oct 2017 03:28:32 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20171030072829euoutp02c95fd5b4f8565119f089a070af911dd4~ySHj0qygJ1642216422euoutp02F; Mon, 30 Oct 2017 07:28:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20171030072829euoutp02c95fd5b4f8565119f089a070af911dd4~ySHj0qygJ1642216422euoutp02F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1509348509; bh=aUpxEjjNxDLDPFQWEEqWis5Ix5CKqvRGP+2brMaMIeQ=; h=From:To:Cc:Subject:Date:References:From; b=CP1+VOrKsuTE36B7rCc5dcwHG/kNgKXCXYBsaRxPBGdRgqoGK6VeSsXQTlOFrSkpg 51eSQcP9I6KJMwpj8p/VPRXOiegC+wKLgAp+vW2rH5R0FORX12SjHD+7y1PaddNo0Q PBX8gA7OcL/cu5hfgNmzIAb7NN1gWJrofUmGe1FI= Received: from eusmges5.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20171030072828eucas1p239887a6ea22db27dce952b3f7fbba047~ySHi4kmsy2049420494eucas1p2c; Mon, 30 Oct 2017 07:28:28 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges5.samsung.com (EUCPMTA) with SMTP id F7.7F.12743.C94D6F95; Mon, 30 Oct 2017 07:28:28 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20171030072827eucas1p2264ae476f8c5dba59f917ac09246b04e~ySHiM2Ras1853418534eucas1p2r; Mon, 30 Oct 2017 07:28:27 +0000 (GMT) X-AuditID: cbfec7f5-f79d06d0000031c7-8c-59f6d49ce1f6 Received: from eusync2.samsung.com ( [203.254.199.212]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 49.5A.18832.B94D6F95; Mon, 30 Oct 2017 07:28:27 +0000 (GMT) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OYM00E7GKR8B000@eusync2.samsung.com>; Mon, 30 Oct 2017 07:28:27 +0000 (GMT) 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 , Marian Mihailescu Subject: [PATCH] drm/exynos: Fix dma-buf import Date: Mon, 30 Oct 2017 08:28:09 +0100 Message-id: <20171030072809.12456-1-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.14.2 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrHIsWRmVeSWpSXmKPExsWy7djP87pzrnyLNDi4gd3i1rpzrBYbZ6xn tbjy9T2bxaT7E1gsXty7yGJx/jxQdsb5fUwWa4/cZbdYP+0nq8WMyS/ZHLg8ds66y+6xaVUn m8f97uNMHn1bVjF6fN4kF8AaxWWTkpqTWZZapG+XwJXxafU2loK3UhWXP/5namA8IN7FyMkh IWAi8XrxNVYIW0ziwr31bF2MXBxCAksZJd5s2ckI4XxmlFj/4RQjTMe/i4ugEssYJebPPsnS xcgB5DQwSUyqBalhEzCU6HrbxQZiiwi4STQdnskKUs8scINJYs2iFlaQemEBfYnHi3RBalgE VCV+tS8Bq+cVsJU40neUGWKXvMT7BffBdkkITGGTmHvtKhNEwkXi96fb7BC2sMSr41ugbBmJ zo6DUDX9jBJNrdoQ9gxGiXNveSFsa4nDxy+CvcwswCcxadt0ZpB7JAR4JTrahCBKPCQOfrkM NdJRYtbth2C3CQnESjxbd4VtAqPUAkaGVYwiqaXFuempxaZ6xYm5xaV56XrJ+bmbGIGxevrf 8a87GJceszrEKMDBqMTDeyP3W6QQa2JZcWXuIUYJDmYlEd5LF4FCvCmJlVWpRfnxRaU5qcWH GKU5WJTEeW2j2iKFBNITS1KzU1MLUotgskwcnFINjIF3nMQXcnSoscRPXDGnsjhHSP9/EbfM zyPyitd22ch2cr5nqbHeojFrxYKIztk99UVCwWtKznLefLp7n2tk7/+Tx/6/3uLCZGvhJcay avud2NNv6ueKnjCzWtbx2Xb3N931j9mzH5m/OfF6Y+mHHfGMtpF7K2rNb19M/PxDcZHs9STJ JIujJUosxRmJhlrMRcWJAPKnr1LRAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupkluLIzCtJLcpLzFFi42I5/e/4Fd3ZV75FGkyfqWVxa905VouNM9az Wlz5+p7NYtL9CSwWL+5dZLE4f34Du8WM8/uYLNYeuctusX7aT1aLGZNfsjlweeycdZfdY9Oq TjaP+93HmTz6tqxi9Pi8SS6ANYrLJiU1J7MstUjfLoEr49PqbSwFb6UqLn/8z9TAeEC8i5GT Q0LAROLfxUWMELaYxIV769m6GLk4hASWMEps69/DApIQEmhikvjb7w9iswkYSnS97WIDsUUE 3CSaDs9kBWlgFrjFJHH87V6mLkYODmEBfYnHi3RBalgEVCV+tS8Bq+cVsJU40neUGWKZvMT7 BfcZJzByL2BkWMUoklpanJueW2yoV5yYW1yal66XnJ+7iREYQNuO/dy8g/HSxuBDjAIcjEo8 vDdyv0UKsSaWFVfmHmKU4GBWEuG9dBEoxJuSWFmVWpQfX1Sak1p8iFGag0VJnLd3z+pIIYH0 xJLU7NTUgtQimCwTB6dUA2PfcvM7G2/e+JEa/M6mtXKZw+TT+YecSiQ3H078afFYQEH3o1ZR 4cfWqQusuhharj49YyET1H747Vr1Jzv8eZ82cR90WxnIy7koJlX6zbzPiz0mLYy27/rJ8Vpq 2XaPRe/vfmlx4ZtpvlEvsNej8dbWow82LKn5ZiyzjUV1yzbm5++/PJ2ft8ZPiaU4I9FQi7mo OBEAh6imNhwCAAA= X-CMS-MailID: 20171030072827eucas1p2264ae476f8c5dba59f917ac09246b04e X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20171030072827eucas1p2264ae476f8c5dba59f917ac09246b04e X-RootMTR: 20171030072827eucas1p2264ae476f8c5dba59f917ac09246b04e References: Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org When IOMMU support was enabled, dma-buf import in Exynos DRM was broken since commit f43c35966a5a ("drm/exynos: use real device for DMA-mapping operations") due to using wrong struct device in drm_gem_prime_import() function. This patch fixes following kernel BUG caused by incorrect buffer mapping to DMA address space: exynos-sysmmu 14650000.sysmmu: 14450000.mixer: PAGE FAULT occurred at 0xb2e00000 ------------[ cut here ]------------ kernel BUG at drivers/iommu/exynos-iommu.c:449! Internal error: Oops - BUG: 0 [#1] PREEMPT SMP ARM Modules linked in: CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.14.0-rc4-next-20171016-00033-g990d723669fd #3165 Hardware name: SAMSUNG EXYNOS (Flattened Device Tree) task: c0e0b7c0 task.stack: c0e00000 PC is at exynos_sysmmu_irq+0x1d0/0x24c LR is at exynos_sysmmu_irq+0x154/0x24c ------------[ cut here ]------------ Reported-by: Marian Mihailescu Fixes: f43c35966a5a ("drm/exynos: use real device for DMA-mapping operations") Signed-off-by: Marek Szyprowski --- drivers/gpu/drm/exynos/exynos_drm_drv.c | 2 +- drivers/gpu/drm/exynos/exynos_drm_gem.c | 6 ++++++ drivers/gpu/drm/exynos/exynos_drm_gem.h | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) -- 2.14.2 -- 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/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c index e651a58c18cf..0822c5341ba4 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c @@ -148,7 +148,7 @@ static struct drm_driver exynos_drm_driver = { .prime_handle_to_fd = drm_gem_prime_handle_to_fd, .prime_fd_to_handle = drm_gem_prime_fd_to_handle, .gem_prime_export = drm_gem_prime_export, - .gem_prime_import = drm_gem_prime_import, + .gem_prime_import = exynos_drm_gem_prime_import, .gem_prime_get_sg_table = exynos_drm_gem_prime_get_sg_table, .gem_prime_import_sg_table = exynos_drm_gem_prime_import_sg_table, .gem_prime_vmap = exynos_drm_gem_prime_vmap, diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c b/drivers/gpu/drm/exynos/exynos_drm_gem.c index 077de014d610..ef35bc23bb36 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_gem.c +++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c @@ -506,6 +506,12 @@ int exynos_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma) } /* low-level interface prime helpers */ +struct drm_gem_object *exynos_drm_gem_prime_import(struct drm_device *dev, + struct dma_buf *dma_buf) +{ + return drm_gem_prime_import_dev(dev, dma_buf, to_dma_dev(dev)); +} + struct sg_table *exynos_drm_gem_prime_get_sg_table(struct drm_gem_object *obj) { struct exynos_drm_gem *exynos_gem = to_exynos_gem(obj); diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.h b/drivers/gpu/drm/exynos/exynos_drm_gem.h index e86d1a9518c3..5a4c7de80f65 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_gem.h +++ b/drivers/gpu/drm/exynos/exynos_drm_gem.h @@ -117,6 +117,8 @@ int exynos_drm_gem_fault(struct vm_fault *vmf); int exynos_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma); /* low-level interface prime helpers */ +struct drm_gem_object *exynos_drm_gem_prime_import(struct drm_device *dev, + struct dma_buf *dma_buf); struct sg_table *exynos_drm_gem_prime_get_sg_table(struct drm_gem_object *obj); struct drm_gem_object * exynos_drm_gem_prime_import_sg_table(struct drm_device *dev,