From: Tobias Jakobi <liquid.acid@gmx.net>
To: Lucas Stach <l.stach@pengutronix.de>,
Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Cc: linux-samsung-soc <linux-samsung-soc@vger.kernel.org>,
dri-devel@lists.sourceforge.net, Inki Dae <inki.dae@samsung.com>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Joonyoung Shim <jy0922.shim@samsung.com>
Subject: Re: drm/exynos: g2d userptr memory corruption
Date: Mon, 17 Aug 2015 17:41:26 +0200 [thread overview]
Message-ID: <55D200A6.4070304@gmx.net> (raw)
In-Reply-To: <1439807175.3050.30.camel@pengutronix.de>
Thanks Lucas for the explanation!
Lucas Stach wrote:
> Hi Tobias,
>
> Am Sonntag, den 16.08.2015, 14:48 +0200 schrieb Tobias Jakobi:
>> Hello,
>>
>> some time ago I checked whether I could use the userptr functionality to
>> do zero-copy from userspace allocated buffers via the G2D. This didn't
>> work out so well, so kinda put this to the bottom of my TODO list.
>>
>> Now that IOMMU support has landed and Jan Kara has rewrote page pinning
>> using frame vectors (see [1]) I gave userptr another try.
>>
>> The results are much better. I'm not experiencing any kernel lockups or
>> sysmmu pagefaults anymore. However the image now suffers from visual
>> artifacts. These images show the nature of the artifacts:
>> http://i.imgur.com/nzT6g3Y.jpg
>> http://i.imgur.com/wkuYI6X.jpg
>>
>> The corruption always manifests itself in these pixel lines of fixed
>> size and wrong color.
>>
>> I have written a testcase as part of libdrm for this issue:
>> https://github.com/tobiasjakobi/libdrm/commit/db8bf6844436598251f67a71fc334b929bfb2b71
>>
>> It allocates N (N an even number) buffers which are aligned to the
>> system pagesize. Then it does this each iteration:
>> 1) Fill the first N/2 buffers with random data
>> 2) Copy the first half to the second half of the buffers
>> 3) memcmp() first and second half (verification pass)
>>
>> Usually this verification already fails on the first iteration. An
>> interesting observation is that increasing (!) the buffer size (so the
>> amount of pixels that have to copied per buffer grows) makes this issue
>> less likely to happen.
>>
>> With the default 512x512 buffers however it happens, like I said above,
>> almost immediately.
>>
> This is obviously a cache flush missing. The memory you get from
> userspace is normal cached memory, so to make it visible to the GPU you
> need to flush parts of the cache out to main memory.
>
> The corruption you are seeing is just unflushed cachelines. This also
> explains why increasing the buffer size helps: the more memory the CPU
> touches the more cachelines will be flushed out to be replaced with new
> data.
I should point out that the snapshots I uploaded were done with a
different setup. There only the source memory of the G2D operation is a
userspace allocated buffer. The destination is a GEM buffer allocated
through libdrm, which is then used as framebuffer. So the issue already
appears when just the source is userspace allocated.
What works however is an operation between GEM to GEM. However this
might be related to the default allocation flags libdrm uses.
> So you need to go and have a look at dma_map() and dma_sync_*_for_*()
> and friends.
>
> Regards,
> Lucas
>
With best wishes,
Tobias
next prev parent reply other threads:[~2015-08-17 15:41 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-16 12:48 drm/exynos: g2d userptr memory corruption Tobias Jakobi
2015-08-17 10:26 ` Lucas Stach
2015-08-17 10:26 ` Lucas Stach
2015-08-17 15:41 ` Tobias Jakobi [this message]
2015-08-19 13:53 ` Tobias Jakobi
2015-08-19 14:08 ` Jerome Glisse
2015-08-19 14:41 ` Rob Clark
2015-08-27 15:10 ` Tobias Jakobi
2015-08-27 17:08 ` Tobias Jakobi
2015-08-17 15:41 ` Tobias Jakobi
2015-08-17 15:41 ` Tobias Jakobi
2015-08-17 10:26 ` Lucas Stach
-- strict thread matches above, loose matches on Subject: below --
2015-08-16 12:48 Tobias Jakobi
2015-08-16 12:48 Tobias Jakobi
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=55D200A6.4070304@gmx.net \
--to=liquid.acid@gmx.net \
--cc=dri-devel@lists.sourceforge.net \
--cc=inki.dae@samsung.com \
--cc=jy0922.shim@samsung.com \
--cc=l.stach@pengutronix.de \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=tjakobi@math.uni-bielefeld.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.