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, From patchwork Tue Jun 20 20:16:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 106019 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp1583415qgd; Tue, 20 Jun 2017 13:18:26 -0700 (PDT) X-Received: by 10.99.95.216 with SMTP id t207mr28395231pgb.19.1497989906433; Tue, 20 Jun 2017 13:18:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497989906; cv=none; d=google.com; s=arc-20160816; b=Gem0duYpRJiqguXDk+8CPTaxNopYBiHEXBNQyBjt5236IfkMnwDVAEpBvJMGCDbqOD ryBVrZ1SEmRq8uL0Fe0CH5oMBdub/Fy9WJCarD+NHUQ8z05xBSVeqFrNhUhUg4VjFd4E aYrL9tldFcri8Z+RK7F3WKTHuCd1/io2Ik8tnNU6E5HEQfd2jv10uR9xQwNFT7YaX8Io KRI0L3bQoq7wKlQJ/lus9HeKD00lorjGn9T6UfcrPBs3nuWEx+YBcyv2cSYD+9F+DbLK s8rXTSlXeB1h/Hm4co8C46b1cb/C1wlKEcvTx1guN+7dzka9/bHZyGho+jd5eQMPNQ12 jiTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=GU0ddlg2RnoX1fhwsOkUJIlyLzTLjviMVTpj0cdWuzU=; b=Ko12dPBVKI4QXn/y+vd57GUXD7uvg7oNI2t0qno3o2yckJrBQ0Zk6a2l/Ig6+ojq9x JiGWZEMq/0Gyre0K1uGYJotFWWnLgkPRsdrKLblvqvKx08LZ3aHq1jmmRLgXFItkzHIo UMbf53I+Of7wOESZNyNalEyrNfrMwTF6DJP+9svtDgpHCZQjVkZlx+rActq4P5AvKFO5 QxBptNLA9f8qK4h5EdryNBoxR3mFi+w1S+Lsr5Stf//Njxd0AeIAr4P4COEjdG0ywNsv ANA8MgkdqHy3gCQskVobXXBhmN/x5vilMPfHYDqmR4Ghms3LyaIR6BHfCmpXHl8vXlZA 4a7w== 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 d124si11525182pgc.156.2017.06.20.13.18.26; Tue, 20 Jun 2017 13:18:26 -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 S1752007AbdFTUSZ (ORCPT + 10 others); Tue, 20 Jun 2017 16:18:25 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:63148 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751639AbdFTUSY (ORCPT ); Tue, 20 Jun 2017 16:18:24 -0400 Received: from wuerfel.lan ([5.56.224.194]) by mrelayeu.kundenserver.de (mreue102 [212.227.15.145]) with ESMTPA (Nemesis) id 0MRD6F-1dDtzE21Ql-00UZjg; Tue, 20 Jun 2017 22:17:59 +0200 From: Arnd Bergmann To: Rob Clark Cc: Jordan Crouse , Bjorn Andersson , Arnd Bergmann , David Airlie , Srinivas Kandagatla , Daniel Vetter , Archit Taneja , 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 2/2] drm/msm: gpu: call qcom_mdt interfaces only for ARCH_QCOM Date: Tue, 20 Jun 2017 22:16:51 +0200 Message-Id: <20170620201720.225593-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170620201720.225593-1-arnd@arndb.de> References: <20170620201720.225593-1-arnd@arndb.de> X-Provags-ID: V03:K0:uhxBazX4VSdSataU5/CEIHYTJ0Dlj9ylJAGoTsvcxRmrXyTY5Be Jbur4K6KR/Wp7P+xMLN17yBwwi9yMZErdcKSy9cM2fP3aejjb//Qxl2BSvj+aowqtj0zNrh xbH0eBKlpXeIkQ/2psQzhQajXgGV0GSKCMJJQA+S+o/ano7mSxPYz76RwcMC+mCKXILHSba TvauoE6kFEcxlwVobEDXg== X-UI-Out-Filterresults: notjunk:1; V01:K0:E0NHW0Z3GE4=:Hl8DJmXfY38lclx6ERw8CH 0ydkflFltZndKuaTjfVML9cpfGftn9m2Ni6JbkPL5C1iTx0glQ+DmwgdfXajsdXuseAaLGnYp m3Ky+LDvetCyza0Y3BKS+/YJQKYlkBBlxX6rdPgbJbTBmfMEjvbty2semEkszJ65pGxpoLjKx CVd857hMFfP6GxEZHrkYnwX0dPVY4JVzOsH+HBZfbT6GwFwJwBmdrv1id1GW2zznkMe4NKqP4 kiAT8JJTQa0U+a00D43ePIzdFG/NI+lxk16r/tYHbaTeUFwmv3hZGj1Rarf92Yy5lUF88FifE gjsObCEgfN8o6PRqfmjtNL70e2BeHwK612cf+bTqk1+CHMDWW6DOuH3waHXOPShsUpVdshi2j xhetxr8Jy2lTlIDPIIKsDO2WsC7DXTvEhXxhJuuwjDg0JWZY2TG8WyXdS/ECSs9nbgvLJMWB9 wJexV0KEumdtF1KdI8i/qo2vuZajPOhgcMVU7juEP3srIYOzs2lHRXiieYnG4la7gRE4bnEiZ 4cGsQ9Ypse/FWbal4Pq4ZL8sMVBgKlM8I9eFSaF86JifhfA6QsQbRAbD6l4qtF3G3DOwypUaa NlkGt6libP+2IvUjvqqic2upFOf4zylQp59mQzQ7SkzJUF5nc/bhWbqDgqUNQiqUiK92SZyuC /87Swk/EZb5H89eD2//AQNSYVBpX5Wv8+DpDv2TorPA4tPmETOBcaAzbNrOySGyGtUvI= Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org When compile-testing for something other than ARCH_QCOM, we run into a link error: drivers/gpu/drm/msm/adreno/a5xx_gpu.o: In function `a5xx_hw_init': a5xx_gpu.c:(.text.a5xx_hw_init+0x600): undefined reference to `qcom_mdt_get_size' a5xx_gpu.c:(.text.a5xx_hw_init+0x93c): undefined reference to `qcom_mdt_load' There is already an #ifdef that tries to check for CONFIG_QCOM_MDT_LOADER, but that symbol is only meaningful when building for ARCH_QCOM. This adds a compile-time check for ARCH_QCOM, and clarifies the Kconfig select statement so we don't even try it for other targets. The check for CONFIG_QCOM_MDT_LOADER can then go away, which also improves compile-time coverage and makes the code a little nicer to read. Fixes: 7c65817e6d38 ("drm/msm: gpu: Enable zap shader for A5XX") Signed-off-by: Arnd Bergmann --- drivers/gpu/drm/msm/Kconfig | 2 +- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) -- 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 diff --git a/drivers/gpu/drm/msm/Kconfig b/drivers/gpu/drm/msm/Kconfig index b638d192ce5e..99d39b2aefa6 100644 --- a/drivers/gpu/drm/msm/Kconfig +++ b/drivers/gpu/drm/msm/Kconfig @@ -5,7 +5,7 @@ config DRM_MSM depends on ARCH_QCOM || (ARM && COMPILE_TEST) depends on OF && COMMON_CLK depends on MMU - select QCOM_MDT_LOADER + select QCOM_MDT_LOADER if ARCH_QCOM select REGULATOR select DRM_KMS_HELPER select DRM_PANEL diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c index eee9ac81aaa1..b719a5b5b88a 100644 --- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c @@ -26,8 +26,6 @@ static void a5xx_dump(struct msm_gpu *gpu); #define GPU_PAS_ID 13 -#if IS_ENABLED(CONFIG_QCOM_MDT_LOADER) - static int zap_shader_load_mdt(struct device *dev, const char *fwname) { const struct firmware *fw; @@ -36,6 +34,9 @@ static int zap_shader_load_mdt(struct device *dev, const char *fwname) void *mem_region = NULL; int ret; + if (!IS_ENABLED(CONFIG_ARCH_QCOM)) + return -EINVAL; + /* Request the MDT file for the firmware */ ret = request_firmware(&fw, fwname, dev); if (ret) { @@ -75,12 +76,6 @@ static int zap_shader_load_mdt(struct device *dev, const char *fwname) return ret; } -#else -static int zap_shader_load_mdt(struct device *dev, const char *fwname) -{ - return -ENODEV; -} -#endif static void a5xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit, struct msm_file_private *ctx)