From: Bjorn Andersson <bjorn.andersson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
To: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
Cc: David Airlie <airlied-cv59FeDIM0c@public.gmane.org>,
linux-arm-msm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Jordan Crouse <jcrouse-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Sushmita Susheelendra
<ssusheel-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
Eric Anholt <eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>,
Rob Clark <robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
freedreno-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH 1/2] drm/msm: gpu: don't abuse dma_alloc for non-DMA allocations
Date: Wed, 28 Jun 2017 22:06:57 -0700 [thread overview]
Message-ID: <20170629050657.GX18666@tuxbook> (raw)
In-Reply-To: <20170620201720.225593-1-arnd-r2nGTMty4D4@public.gmane.org>
On Tue 20 Jun 13:16 PDT 2017, Arnd Bergmann wrote:
> 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 <arnd@arndb.de>
Acked-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Regards,
Bjorn
> ---
> 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,
> --
> 2.9.0
>
_______________________________________________
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno
prev parent reply other threads:[~2017-06-29 5:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-20 20:16 [PATCH 1/2] drm/msm: gpu: don't abuse dma_alloc for non-DMA allocations Arnd Bergmann
2017-06-20 20:16 ` [PATCH 2/2] drm/msm: gpu: call qcom_mdt interfaces only for ARCH_QCOM Arnd Bergmann
[not found] ` <20170620201720.225593-2-arnd-r2nGTMty4D4@public.gmane.org>
2017-06-21 14:58 ` Jordan Crouse
2017-06-29 5:11 ` Bjorn Andersson
2017-06-21 14:53 ` [PATCH 1/2] drm/msm: gpu: don't abuse dma_alloc for non-DMA allocations Jordan Crouse
[not found] ` <20170620201720.225593-1-arnd-r2nGTMty4D4@public.gmane.org>
2017-06-29 5:06 ` Bjorn Andersson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170629050657.GX18666@tuxbook \
--to=bjorn.andersson-qsej5fyqhm4dnm+yrofe0a@public.gmane.org \
--cc=airlied-cv59FeDIM0c@public.gmane.org \
--cc=arnd-r2nGTMty4D4@public.gmane.org \
--cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
--cc=eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org \
--cc=freedreno-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
--cc=jcrouse-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
--cc=linux-arm-msm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=ssusheel-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox