All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Koenig, Christian" <Christian.Koenig@amd.com>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: "dri-devel@lists.freedesktop.org" <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH 10/12] drm/amdgpu: add independent DMA-buf export v3
Date: Mon, 6 May 2019 10:05:07 +0000	[thread overview]
Message-ID: <5825dded-25eb-d266-4bb6-5f40d358ae9d@amd.com> (raw)
In-Reply-To: <20190506080455.GC17751@phenom.ffwll.local>

Am 06.05.19 um 10:04 schrieb Daniel Vetter:
> [SNIP]
>>>> + /* 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.
> dma_buf_attach is supposed to make sure the buffer won't land somewhere
> where you can't get at it anymore. Wrt pin that means the exporter needs
> to make sure it can't get pinned into a wrong place, and also isn't pinned
> into a wrong place anymore. That's why I think pinning ties in with
> dma_buf_attach and not the overall buffer.
>
> In a way there's two pieces of a pin:
> - Do not move the buffer anymore.
> - Make sure I can still get at it.
>
> Internally the 2nd part is encoded in the domain parameter you pass to
> amdgpu_bo_pin. When going through dma-buf that information is derived
> from the attachment (e.g. if it's a p2p one, then you can put it wherever
> you feel like, if it's a normal one it must be in system ram). The dma-buf
> alone doesn't tell you _where_ to pin something.

Ok, that finally makes some sense. So the attachment describes where the 
buffer needs to be for the attaching device/use case to be able to 
access it.

Going to change it to use an attachment instead.

>> 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.
> Hm yeah the ping/pong is bad, but I figure you have to already handle that
> (with some bias or whatever). Outright disabling invalidate/dynamic
> dma-buf seems like overkill.
>
> What about upgradging preferred_domains to include GTT here? Defacto what
> you do is forcing GTT, so just adding GTT as a possible domain seems like
> the better choice. Bonus points for undoing that when the last importer
> disappears.

Well that's exactly what we want to avoid here.

The preferred_domains is where userspace likes the buffer to be and 
should never be changed by the kernel.

The allowed_domains is where the buffer should be based on the hardware 
restrictions and is usually updated by the kernel driver.

> In general I think dynamic dma-buf needs to be able to handle this
> somehow, or it won't really work. Simplest is probably to just stop moving
> buffers around so much for buffers that are dynamically exported (so maybe
> could also change that in the CS ioctl to not move exported buffers
> anymore, would achieve the same).

Yeah, that's the obvious alternative. But I didn't wanted to add even 
more complexity to the patch right now.

Cleaning this up is pure amdgpu internally, e.g. we need to make sure to 
not move buffers around so much on command submission.

Christian.

> -Daniel
> --
> 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

  reply	other threads:[~2019-05-06 10:05 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
2019-05-06  8:04       ` Daniel Vetter
2019-05-06 10:05         ` Koenig, Christian [this message]
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=5825dded-25eb-d266-4bb6-5f40d358ae9d@amd.com \
    --to=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 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.