From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Rob Clark <robdclark@gmail.com>, David Airlie <airlied@linux.ie>,
Jordan Crouse <jcrouse@codeaurora.org>,
Stanimir Varbanov <stanimir.varbanov@linaro.org>,
Sushmita Susheelendra <ssusheel@codeaurora.org>,
linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org,
freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] drm/msm: gpu: don't abuse dma_alloc for non-DMA allocations
Date: Wed, 26 Jul 2017 14:19:08 -0700 [thread overview]
Message-ID: <20170726211908.GR20973@minitux> (raw)
In-Reply-To: <20170726200007.2432476-1-arnd@arndb.de>
On Wed 26 Jul 12:59 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. What the code actually wants to do is to get
> the physical address from the reserved-mem node. It goes through
> the dma-mapping interfaces for obscure reasons, and this
> apparently only works by chance, relying on specific bugs
> in the error handling of the arm64 dma-mapping implementation.
>
> The same problem existed in the "venus" media driver, which was
> now fixed by Stanimir Varbanov after long discussions.
>
> In order to make some progress here, I have now ported his
> approach over to the adreno driver. The patch is currently
> untested, and should get a good review, but it is now much
> simpler than the original, and it should be obvious what
> goes wrong if I made a mistake in the port.
>
> See also: a6e2d36bf6b7 ("media: venus: don't abuse dma_alloc for non-DMA allocations")
> Cc: Stanimir Varbanov <stanimir.varbanov@linaro.org>
> Fixes: 7c65817e6d38 ("drm/msm: gpu: Enable zap shader for A5XX")
> Acked-and-Tested-by: Jordan Crouse <jcrouse@codeaurora.org>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Bjorn Andersson <bjorn.andersson@linaro.org>
However...
[..]
> @@ -37,6 +39,21 @@ static int zap_shader_load_mdt(struct device *dev, const char *fwname)
> if (!IS_ENABLED(CONFIG_ARCH_QCOM))
> return -EINVAL;
>
> + np = of_get_child_by_name(dev->of_node, "zap-shader");
> + if (!np)
> + return -ENODEV;
> +
> + np = of_parse_phandle(np, "memory-region", 0);
> + if (!np)
> + return -EINVAL;
> +
> + ret = of_address_to_resource(np, 0, &r);
> + if (ret)
> + return ret;
> +
> + mem_phys = r.start;
> + mem_size = resource_size(&r);
> +
...this means that it's now required that the reserved-memory region has
a "reg", the prior solution supported that we just specify a "size".
I have another driver where I need to figure out a mechanism of getting
hold of the dynamically allocated "base" of struct reserved_mem.
So I think it's appropriate to apply this fix now and loosen the
restrictions on placement later.
Regards,
Bjorn
prev parent reply other threads:[~2017-07-26 21:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-26 19:59 [PATCH v3] drm/msm: gpu: don't abuse dma_alloc for non-DMA allocations Arnd Bergmann
2017-07-26 21:19 ` 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=20170726211908.GR20973@minitux \
--to=bjorn.andersson@linaro.org \
--cc=airlied@linux.ie \
--cc=arnd@arndb.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=freedreno@lists.freedesktop.org \
--cc=jcrouse@codeaurora.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robdclark@gmail.com \
--cc=ssusheel@codeaurora.org \
--cc=stanimir.varbanov@linaro.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;
as well as URLs for NNTP newsgroup(s).