From: Daniel Vetter <daniel@ffwll.ch>
To: "Christian König" <ckoenig.leichtzumerken@gmail.com>
Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 2/5] drm/prime: make the pages array optional for drm_prime_sg_to_page_addr_arrays
Date: Tue, 6 Mar 2018 10:21:02 +0100 [thread overview]
Message-ID: <20180306092102.GM22212@phenom.ffwll.local> (raw)
In-Reply-To: <20180227115000.4105-2-christian.koenig@amd.com>
On Tue, Feb 27, 2018 at 12:49:57PM +0100, Christian König wrote:
> Most of the time we only need the dma addresses.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/drm_prime.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
> index c38dacda6119..7856a9b3f8a8 100644
> --- a/drivers/gpu/drm/drm_prime.c
> +++ b/drivers/gpu/drm/drm_prime.c
> @@ -922,40 +922,40 @@ EXPORT_SYMBOL(drm_prime_pages_to_sg);
> /**
> * drm_prime_sg_to_page_addr_arrays - convert an sg table into a page array
> * @sgt: scatter-gather table to convert
> - * @pages: array of page pointers to store the page array in
> + * @pages: optional array of page pointers to store the page array in
> * @addrs: optional array to store the dma bus address of each page
> - * @max_pages: size of both the passed-in arrays
> + * @max_entries: size of both the passed-in arrays
> *
> * Exports an sg table into an array of pages and addresses. This is currently
> * required by the TTM driver in order to do correct fault handling.
> */
Can't we just teach ttm to use sgts wherever needed, and deprecate
exporting dma-bufs to page arrays (which really breaks the abstraction
entirely and was just a quick hack to get things going that stuck around
for years). Last time I looked into ttm the only thing it did is convert
it back to sgts again (after calling dma_map once more, which the exporter
should have done already for you).
-Daniel
> int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct page **pages,
> - dma_addr_t *addrs, int max_pages)
> + dma_addr_t *addrs, int max_entries)
> {
> unsigned count;
> struct scatterlist *sg;
> struct page *page;
> - u32 len;
> - int pg_index;
> + u32 len, index;
> dma_addr_t addr;
>
> - pg_index = 0;
> + index = 0;
> for_each_sg(sgt->sgl, sg, sgt->nents, count) {
> len = sg->length;
> page = sg_page(sg);
> addr = sg_dma_address(sg);
>
> while (len > 0) {
> - if (WARN_ON(pg_index >= max_pages))
> + if (WARN_ON(index >= max_entries))
> return -1;
> - pages[pg_index] = page;
> + if (pages)
> + pages[index] = page;
> if (addrs)
> - addrs[pg_index] = addr;
> + addrs[index] = addr;
>
> page++;
> addr += PAGE_SIZE;
> len -= PAGE_SIZE;
> - pg_index++;
> + index++;
> }
> }
> return 0;
> --
> 2.14.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2018-03-06 9:21 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-27 11:49 [PATCH 1/5] drm/prime: fix potential race in drm_gem_map_detach Christian König
2018-02-28 9:48 ` Lucas Stach
[not found] ` <1519811307.6253.5.camel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2018-02-28 10:25 ` Christian König
[not found] ` <3a4f9020-235d-ef05-a246-1ba920070f09-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-03-06 9:15 ` Daniel Vetter
2018-03-06 9:30 ` Christian König
2018-03-06 9:39 ` Daniel Vetter
[not found] ` <20180227115000.4105-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-02-27 11:49 ` [PATCH 2/5] drm/prime: make the pages array optional for drm_prime_sg_to_page_addr_arrays Christian König
2018-03-06 9:21 ` Daniel Vetter [this message]
[not found] ` <20180306092102.GM22212-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2018-03-06 9:25 ` Christian König
2018-03-06 9:37 ` Daniel Vetter
2018-02-27 11:49 ` [PATCH 3/5] drm/ttm: move ttm_tt defines into ttm_tt.h Christian König
[not found] ` <20180227115000.4105-3-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-03-06 9:13 ` Christian König
2018-03-06 9:56 ` Michel Dänzer
2018-03-06 10:00 ` Thomas Hellstrom
2018-02-27 11:49 ` [PATCH 4/5] drm/ttm: add ttm_sg_tt_init Christian König
[not found] ` <20180227115000.4105-4-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2018-02-27 12:07 ` Christian König
[not found] ` <b5cb1980-7865-f45a-bc9d-9569f860fb50-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-03-05 12:06 ` Christian König
2018-03-05 20:55 ` Ben Skeggs
[not found] ` <1592dc9f-d76e-7174-1785-624cbd69d744-5C7GfCeVMHo@public.gmane.org>
2018-03-06 1:52 ` He, Roger
2018-03-06 9:19 ` [Nouveau] " Daniel Vetter
2018-02-27 11:50 ` [PATCH 5/5] drm/amdgpu: stop allocating a page array for prime shared BOs Christian König
2018-03-05 12:05 ` [PATCH 1/5] drm/prime: fix potential race in drm_gem_map_detach Christian König
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=20180306092102.GM22212@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=amd-gfx@lists.freedesktop.org \
--cc=ckoenig.leichtzumerken@gmail.com \
--cc=dri-devel@lists.freedesktop.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