From patchwork Tue Jun 20 20:16:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9800165 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 92A006038C for ; Tue, 20 Jun 2017 20:17:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8781326861 for ; Tue, 20 Jun 2017 20:17:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B09A206AC; Tue, 20 Jun 2017 20:17:36 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0216E28501 for ; Tue, 20 Jun 2017 20:17:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 18A4D6E3E0; Tue, 20 Jun 2017 20:17:34 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 62A436E3E0 for ; Tue, 20 Jun 2017 20:17:32 +0000 (UTC) Received: from wuerfel.lan ([5.56.224.194]) by mrelayeu.kundenserver.de (mreue102 [212.227.15.145]) with ESMTPA (Nemesis) id 0LkhPw-1dxZkl2668-00aWzX; Tue, 20 Jun 2017 22:17:23 +0200 From: Arnd Bergmann To: Rob Clark Subject: [PATCH 1/2] drm/msm: gpu: don't abuse dma_alloc for non-DMA allocations Date: Tue, 20 Jun 2017 22:16:50 +0200 Message-Id: <20170620201720.225593-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:iZ5k12MJiy0VebrCKeiakvaiHx00W2/ncf2wvlkch5MB+wuft2j Eouh2i3WJHTOa74zHd/8L4NgBgxAJ05uH+4jmgnSM9BzlML9ktdDvrM+vLSFOgDSkh1w4Nq H5WbO08EgEg/aIkdtXoTy374MB30JtnGKXG066T/F5lUfOCL/u+6c5MhzgPHBgOCiD/CKI0 ZaFBT/uK4RD+yegqAR5bw== X-UI-Out-Filterresults: notjunk:1; V01:K0:zvoBwUCQRI0=:6q32eUw0N5+u5XGEGMaKJR xQ/XdvWXsFzq7L/Pcg6+uccB0oJ4rcpIAKLRWwNM0Xdbys1ni8DaBw5q/BBeGb73eF/NHL/LV bdgfXVbsKUO7X1dYaZWXKaoT9osTZspVPAS3gwoVg6VU4qoXYPxz4WNgxG2TNEJT2FaE480+E qIec1GLM8kXmL+UqhxqSkOfNclIiRbBuCCp141kue9Z2xptlD/ahuCDxowcKrdi5AGbQTyPeU T/qoC22MHjDuxO7X7CPcQ/RdsWDn88EbPIh3tt+LxAuBYtheuB/mJAyyab5SIVA3/85paziho 1zY/Yt7m1zJjjXBpXShUKcEgsb7FBvSRfyd6CGH4+C121pMFBKFtZXprOgYtdpLOOVX7FUO5v r9hIJl892ZVGchranAOkEaNuYgvuMpJMvoiF/X4igYFAom2PHX9cmB1ssWfEEs518LzNJ9Zft EeYobq450YqKuQHFU0dCP1q8UIcJoUtWRyhTldjt9Ujpbdt1sTzvJlqoLdIg7f0H7xytJV8gN cWznnIkYH8SMXxX/jcy2sG2LVOdcOkzxvZw8FMahjVEni9ch/hEcqowpNU7ainv2/Q3+Lf0sj LB9SJ16yhYjPOOPZbpuysk8GxuRRWwkE7fokq9U56PEo0POpXBFhqWiuAg96RFTz1CwMtmEww ZOXvQs5456mgTXeY6Xq7HZOvYxnYXI/YIZqACdW3rvNVW/j/7AF30d6HcdOjv4AH/GHY= Cc: Arnd Bergmann , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Bjorn Andersson , Sushmita Susheelendra , freedreno@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP In zap_shader_load_mdt(), we pass a pointer to a phys_addr_t into dmam_alloc_coherent, which the compiler warns about: drivers/gpu/drm/msm/adreno/a5xx_gpu.c: In function 'zap_shader_load_mdt': drivers/gpu/drm/msm/adreno/a5xx_gpu.c:54:50: error: passing argument 3 of 'dmam_alloc_coherent' from incompatible pointer type [-Werror=incompatible-pointer-types] The returned DMA address is later passed on to a function that takes a phys_addr_t, so it's clearly wrong to use the DMA mapping interface here: the memory may be uncached, or the address may be completely wrong if there is an IOMMU connected to the device. My interpretation is that using dmam_alloc_coherent() had two purposes: a) get a chunk of consecutive memory that may be larger than the limit for kmalloc() b) use the devres infrastructure to simplify the unwinding in the error case. I think ideally we'd use a devres-based version of alloc_pages_exact() here, but since that doesn't exist, let's use devm_get_free_pages() instead. This wastes a little memory as the size gets rounded up to a power of two, but is otherwise harmless. If we want to save memory here, calling devm_free_pages() to release the memory once it is no longer needed is probably better anyway. Fixes: 7c65817e6d38 ("drm/msm: gpu: Enable zap shader for A5XX") Signed-off-by: Arnd Bergmann Acked-by: Jordan Crouse Acked-by: Bjorn Andersson --- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c index b4b54f1c24bc..eee9ac81aaa1 100644 --- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c @@ -51,11 +51,13 @@ static int zap_shader_load_mdt(struct device *dev, const char *fwname) } /* Allocate memory for the firmware image */ - mem_region = dmam_alloc_coherent(dev, mem_size, &mem_phys, GFP_KERNEL); + mem_region = (void *)devm_get_free_pages(dev, GFP_KERNEL, + get_order(mem_size)); if (!mem_region) { ret = -ENOMEM; goto out; } + mem_phys = virt_to_phys(mem_region); /* Load the rest of the MDT */ ret = qcom_mdt_load(dev, fw, fwname, GPU_PAS_ID, mem_region, mem_phys,