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: 106018 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp1583131qgd; Tue, 20 Jun 2017 13:17:38 -0700 (PDT) X-Received: by 10.84.233.204 with SMTP id m12mr18835558pln.292.1497989858005; Tue, 20 Jun 2017 13:17:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497989857; cv=none; d=google.com; s=arc-20160816; b=bFEralfIkEfw/IbfgUQPIy+biqvWotsWuup2uHuOmwtm0fkLgD44rivo4NUkeCfCVA UW4IOu7YyLzXpIcBuza/L1fOxsL50u7689doS2KnciAdBqWLWbUEkyiR7yu2W3tRjOH0 64EaGKwnhGjEp3E83nNsOO1yKPvcvLeYK7ghrc37CxSyGtufP5BCfLxjzaE6Rfw7k9YG 2y9z3QDPkZFAEs16AoLaKbXNArIDiYa2Gku5YFZNHl/v7vCCV1rDzyb4Px5Tfx1DSp6j GlMuNZegk1te5G/1cJPm33iz6O+8tRScbnUmq8L34N6M328SNuZU/kD9Qp5WNxGP9rpZ AMXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=FfPIEbIv3FS6frs3nKGzWbmWFAK3Hosz5PXt5xrMnxo=; b=MzSj2wP98tLJE+m/e4UPPZJlYkhSOmxQ7ZiNgnR5NETH7nZiLg5ereCCfYnGYRuPqn mOWGxYH000kYzy2P58QuEis0EFyYCvmd1mwer0FXvoi5eVAo58dcrrBlzRzeGZH6D3pS jQFU8HKmPgNoEoX+vn3raxRkHppLfEznJZgVzWKbc4Ax/5nlwZa2Qav6nwIAGe22Vo+Q GXs0KldxkS8XDmqTqHIAAYkqegI11rw6/pe+T2ViKk9d1zz+U5RSupNAMW21tjdxh9xu OJWfQlDWxbafwzpcOJ11WZXIUiYuJER7B4Xawb0aCSyB93tI1WSWdErxG9BAVNUH8Z86 pGFA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k6si11507201pgr.16.2017.06.20.13.17.37; Tue, 20 Jun 2017 13:17:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751036AbdFTURg (ORCPT + 10 others); Tue, 20 Jun 2017 16:17:36 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:58923 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751131AbdFTURf (ORCPT ); Tue, 20 Jun 2017 16:17:35 -0400 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 Cc: Jordan Crouse , Bjorn Andersson , Arnd Bergmann , David Airlie , Eric Anholt , Sushmita Susheelendra , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org 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= Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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 --- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.9.0 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Acked-by: Jordan Crouse 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,