From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 10/12] drm/amdgpu: add independent DMA-buf export v3
Date: Fri, 3 May 2019 14:35:02 +0200 [thread overview]
Message-ID: <09619fce-fa36-2bbc-ad24-7814748a84e0@gmail.com> (raw)
In-Reply-To: <20190430141638.GT3271@phenom.ffwll.local>
Am 30.04.19 um 16:16 schrieb Daniel Vetter:
> [SNIP]
>> /**
>> - * amdgpu_gem_map_attach - &dma_buf_ops.attach implementation
>> - * @dma_buf: Shared DMA buffer
>> + * amdgpu_gem_pin_dma_buf - &dma_buf_ops.pin_dma_buf implementation
>> + *
>> + * @dma_buf: DMA-buf to pin in memory
>> + *
>> + * Pin the BO which is backing the DMA-buf so that it can't move any more.
>> + */
>> +static int amdgpu_gem_pin_dma_buf(struct dma_buf *dma_buf)
>> +{
>> + struct drm_gem_object *obj = dma_buf->priv;
>> + struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj);
>> +
>> + /* pin buffer into GTT */
>> + return amdgpu_bo_pin(bo, AMDGPU_GEM_DOMAIN_GTT);
> This is kinda what I mean with "shouldn't we pin the attachment" - afaiui
> this can fail is someone already pinned the buffer into vram. And that
> kind of checking is supposed to happen in the buffer attachment.
Why is that supposed to happen on the attachment? I mean it could be
nice to have for debugging, but I still don't see any practical reason
for this.
> Also will p2p pin into VRAM if all attachments are p2p capable? Or is your
> plan to require dynamic invalidate to avoid fragmenting vram badly with
> pinned stuff you can't move?
My plan was to make dynamic invalidation a must have for P2P, exactly
for the reason you noted.
> +/**
> + * amdgpu_gem_dma_buf_attach - &dma_buf_ops.attach implementation
> + *
> + * @dma_buf: DMA-buf we attach to
> * @attach: DMA-buf attachment
> *
> + * Returns:
> + * Always zero for success.
> + */
> +static int amdgpu_gem_dma_buf_attach(struct dma_buf *dma_buf,
> + struct dma_buf_attachment *attach)
> +{
> + struct drm_gem_object *obj = dma_buf->priv;
> + struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj);
> +
> + /* Make sure the buffer is pinned when userspace didn't set GTT as
> + * preferred domain. This avoid ping/pong situations with scan out BOs.
> + */
> + if (!(bo->preferred_domains & AMDGPU_GEM_DOMAIN_GTT))
> + attach->invalidate = NULL;
> Not following here at all. If the BO can't be in GTT I'd guess you should
> reject the attach outright, since the pinning/map later on will fail I
> guess? At least I'm not making the connection with why dynamic dma-buf
> won't work anymore, since dynamic dma-buf is to make p2p of bo in vram
> work better, which is exactly what this here seems to check for.
>
> Or is this just a quick check until you add full p2p support?
>
> Count me confused ...
Well completely amdgpu internal handling here. Key point is we have both
preferred_domains as well as allowed_domains.
During command submission we always try to move a BO to the
preferred_domains again.
Now what could happen if we don't have this check is the following:
1. BO is allocate in VRAM. And preferred_domains says only VRAM please,
but allowed_domains says VRAM or GTT.
2. DMA-buf Importer comes along and moves the BO to GTT, which is
perfectly valid because of the allowed_domains.
3. Command submission is made and moves the BO to VRAM again.
4. Importer comes along and moves the BO to GTT.
....
E.g. a nice ping/pong situation which just eats up memory bandwidth.
Christian.
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2019-05-03 12:35 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-26 12:36 [PATCH 01/12] dma-buf: add struct dma_buf_attach_info Christian König
2019-04-26 12:36 ` [PATCH 02/12] dma-buf: add explicit buffer pinning v2 Christian König
2019-04-29 8:40 ` Daniel Vetter
2019-04-30 13:42 ` Christian König
2019-04-30 13:59 ` Daniel Vetter
2019-04-30 14:26 ` Christian König
2019-04-30 14:34 ` Daniel Vetter
2019-04-30 14:41 ` Koenig, Christian
2019-04-30 15:22 ` Daniel Vetter
2019-04-26 12:36 ` [PATCH 03/12] dma-buf: start caching of sg_table objects Christian König
2019-04-29 8:54 ` Daniel Vetter
2019-04-30 14:18 ` Daniel Vetter
2019-04-26 12:36 ` [PATCH 04/12] dma-buf: lock the reservation object during (un)map_dma_buf v4 Christian König
2019-04-26 12:36 ` [PATCH 05/12] dma-buf: add dma_buf_(un)map_attachment_locked variants v4 Christian König
2019-04-26 12:36 ` [PATCH 06/12] dma-buf: add optional invalidate_mappings callback v5 Christian König
2019-04-29 8:42 ` Daniel Vetter
2019-04-26 12:36 ` [PATCH 07/12] drm: remove prime sg_table caching Christian König
2019-04-26 12:36 ` [PATCH 08/12] drm/ttm: remove the backing store if no placement is given Christian König
2019-04-26 12:36 ` [PATCH 09/12] drm/ttm: use the parent resv for ghost objects Christian König
2019-04-26 12:36 ` [PATCH 10/12] drm/amdgpu: add independent DMA-buf export v3 Christian König
2019-04-30 14:16 ` Daniel Vetter
2019-05-03 12:35 ` Christian König [this message]
2019-05-06 8:04 ` Daniel Vetter
2019-05-06 10:05 ` Koenig, Christian
2019-05-06 15:10 ` Daniel Vetter
2019-04-26 12:36 ` [PATCH 11/12] drm/amdgpu: add independent DMA-buf import v4 Christian König
2019-04-26 12:36 ` [PATCH 12/12] drm/amdgpu: add DMA-buf invalidation callback v2 Christian König
2019-04-29 8:24 ` [PATCH 01/12] dma-buf: add struct dma_buf_attach_info Daniel Vetter
2019-04-30 12:40 ` 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=09619fce-fa36-2bbc-ad24-7814748a84e0@gmail.com \
--to=ckoenig.leichtzumerken@gmail.com \
--cc=christian.koenig@amd.com \
--cc=daniel@ffwll.ch \
--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;
as well as URLs for NNTP newsgroup(s).