From: Inki Dae <inki.dae@samsung.com>
To: Marek Szyprowski <m.szyprowski@samsung.com>,
dri-devel@lists.freedesktop.org,
linux-samsung-soc@vger.kernel.org
Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
Seung-Woo Kim <sw0312.kim@samsung.com>,
Andrzej Hajda <a.hajda@samsung.com>
Subject: Re: [PATCH v2 2/3] drm/exynos: gem: rework scatter-list contiguity check on prime import
Date: Fri, 24 Apr 2020 17:15:00 +0900 [thread overview]
Message-ID: <5688f66c-e83c-4741-34ee-2f02113f022a@samsung.com> (raw)
In-Reply-To: <20200422114059.29477-1-m.szyprowski@samsung.com>
20. 4. 22. 오후 8:40에 Marek Szyprowski 이(가) 쓴 글:
> Explicitly check if the imported buffer has been mapped as contiguous in
> the DMA address space, what is required by all Exynos DRM CRTC drivers.
> While touching this, set buffer flags depending on the availability of
> the IOMMU.
Picked it up.
Thanks,
Inki Dae
>
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
> v2:
> - reworked a check for sgt->nents
> - added a comment about a scatter-list contiguity check
> - removed additional 'return ERR_PTR(-EINVAL)' accidentaly left after debugging
> ---
> drivers/gpu/drm/exynos/exynos_drm_gem.c | 42 ++++++++++++++++++++++++---------
> 1 file changed, 31 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c b/drivers/gpu/drm/exynos/exynos_drm_gem.c
> index 40514d3..f136efb 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_gem.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c
> @@ -458,6 +458,29 @@ struct drm_gem_object *
> int npages;
> int ret;
>
> + if (sgt->nents < 1)
> + return ERR_PTR(-EINVAL);
> +
> + /*
> + * Check if the provided buffer has been mapped as contiguous
> + * into DMA address space.
> + */
> + if (sgt->nents > 1) {
> + dma_addr_t next_addr = sg_dma_address(sgt->sgl);
> + struct scatterlist *s;
> + unsigned int i;
> +
> + for_each_sg(sgt->sgl, s, sgt->nents, i) {
> + if (!sg_dma_len(s))
> + break;
> + if (sg_dma_address(s) != next_addr) {
> + DRM_ERROR("buffer chunks must be mapped contiguously");
> + return ERR_PTR(-EINVAL);
> + }
> + next_addr = sg_dma_address(s) + sg_dma_len(s);
> + }
> + }
> +
> exynos_gem = exynos_drm_gem_init(dev, attach->dmabuf->size);
> if (IS_ERR(exynos_gem)) {
> ret = PTR_ERR(exynos_gem);
> @@ -480,18 +503,15 @@ struct drm_gem_object *
>
> exynos_gem->sgt = sgt;
>
> - if (sgt->nents == 1) {
> - /* always physically continuous memory if sgt->nents is 1. */
> - exynos_gem->flags |= EXYNOS_BO_CONTIG;
> - } else {
> - /*
> - * this case could be CONTIG or NONCONTIG type but for now
> - * sets NONCONTIG.
> - * TODO. we have to find a way that exporter can notify
> - * the type of its own buffer to importer.
> - */
> + /*
> + * Buffer has been mapped as contiguous into DMA address space,
> + * but if there is IOMMU, it can be either CONTIG or NONCONTIG.
> + * We assume a simplified logic below:
> + */
> + if (is_drm_iommu_supported(dev))
> exynos_gem->flags |= EXYNOS_BO_NONCONTIG;
> - }
> + else
> + exynos_gem->flags |= EXYNOS_BO_CONTIG;
>
> return &exynos_gem->base;
>
>
next prev parent reply other threads:[~2020-04-24 8:10 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20200407134313eucas1p1d55cc16cb66b11ee5e1e5fd94cf25473@eucas1p1.samsung.com>
2020-04-07 13:42 ` [PATCH 0/3] ExynosDRM - rework GEM internals Marek Szyprowski
2020-04-07 13:42 ` [PATCH 1/3] drm/exynos: gem: Remove dead-code Marek Szyprowski
2020-04-21 6:47 ` Inki Dae
2020-04-07 13:42 ` [PATCH 2/3] drm/exynos: gem: Rework scatter-list contiguity check on Prime import Marek Szyprowski
2020-04-21 7:38 ` Inki Dae
2020-04-21 8:09 ` Marek Szyprowski
2020-04-22 3:37 ` Inki Dae
2020-04-22 4:36 ` Inki Dae
2020-04-22 8:16 ` Marek Szyprowski
2020-04-22 11:40 ` [PATCH v2 2/3] drm/exynos: gem: rework scatter-list contiguity check on prime import Marek Szyprowski
2020-04-24 8:15 ` Inki Dae [this message]
2020-04-07 13:42 ` [PATCH 3/3] drm/exynos: gem: Get rid of the internal 'pages' array Marek Szyprowski
2020-04-24 8:15 ` Inki Dae
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=5688f66c-e83c-4741-34ee-2f02113f022a@samsung.com \
--to=inki.dae@samsung.com \
--cc=a.hajda@samsung.com \
--cc=b.zolnierkie@samsung.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=sw0312.kim@samsung.com \
/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