dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Thomas Zimmermann <tzimmermann@suse.de>, Daniel Vetter <daniel@ffwll.ch>
Cc: Dave Airlie <airlied@redhat.com>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	Hans de Goede <hdegoede@redhat.com>
Subject: Re: [PATCH 1/8] drm/gem: Write down some rules for vmap usage
Date: Tue, 1 Dec 2020 14:05:41 +0100	[thread overview]
Message-ID: <74ad99d1-9963-b648-ffa8-ae0858326749@amd.com> (raw)
In-Reply-To: <49c3560d-08f4-f49d-a55b-18ea87b2c2ad@suse.de>

Am 01.12.20 um 13:53 schrieb Thomas Zimmermann:
> Hi
>
> Am 01.12.20 um 13:51 schrieb Thomas Zimmermann:
>> Hi
>>
>> Am 01.12.20 um 13:38 schrieb Christian König:
>>> Am 01.12.20 um 13:33 schrieb Thomas Zimmermann:
>>>> Hi
>>>>
>>>> Am 01.12.20 um 13:14 schrieb Christian König:
>>>>> Am 01.12.20 um 12:30 schrieb Thomas Zimmermann:
>>>>>> Hi
>>>>>>
>>>>>> Am 01.12.20 um 11:34 schrieb Christian König:
>>>>>>>> [...]
>>>>>>>> In patch 6 of this series, there's ast cursor code that 
>>>>>>>> acquires two BO's reservation locks and vmaps them afterwards. 
>>>>>>>> That's probably how you intend to use dma_buf_vmap_local.
>>>>>>>>
>>>>>>>> However, I think it's more logically to have a vmap callback 
>>>>>>>> that only does the actual vmap. This is all that exporters 
>>>>>>>> would have to implement.
>>>>>>>>
>>>>>>>> And with that, build one helper that pins before vmap and one 
>>>>>>>> helper that gets the resv lock.
>>>>>>>
>>>>>>> I don't think that this is will work nor is it a good approach.
>>>>>>>
>>>>>>> See the ast cursor handling for example. You need to acquire two 
>>>>>>> BOs here, not just one. And this can't be done cleanly with a 
>>>>>>> single vmap call.
>>>>>>
>>>>>> That seems to be a misunderstanding.
>>>>>>
>>>>>> I don't mentioned it explicitly, but there's of course another 
>>>>>> helper that only vmaps and nothing else. This would be useful for 
>>>>>> cases like the cursor code. So there would be:
>>>>>>
>>>>>>  dma_buf_vmap() - pin + vmap
>>>>>>  dma_buf_vmap_local() - lock + vmap
>>>>>>  dma_buf_vmap_locked() - only vmap; caller has set up the BOs
>>>>>
>>>>> Well that zoo of helpers will certainly get a NAK from my side.
>>>>>
>>>>> See interfaces like this should implement simple functions and not 
>>>>> hide what's actually needs to be done inside the drivers using 
>>>>> this interface.
>>>>
>>>> If 9 of 10 invocations use the same pattern, why not put that 
>>>> pattern in a helper? I see nothing wrong with that.
>>>
>>> Because it hides the locking semantics inside the helper. See when 
>>> you have the lock/unlock inside the driver it is obvious that you 
>>> need to be careful not to take locks in different orders.
>>>
>>>>> What we could do is to add a pin count to the DMA-buf and then do 
>>>>> WARN_ON(dma_buf->pin_count || dma_resv_lock_help(dma_buf->resv)) 
>>>>> in the vmap/vunmap calls.
>>>>
>>>> Most of the vmap code is either CMA or SHMEM GEM stuff. They don't 
>>>> need to pin. It's just baggage to them. The TTM stuff that does 
>>>> need pinning is the minority.
>>>>
>>>>>
>>>>>>
>>>>>> I did some conversion of drivers that use vram and shmem. They 
>>>>>> occasionally update a buffer (ast cursors) or flush a BO from 
>>>>>> system memory to HW (udl, cirrus, mgag200). In terms of these 3 
>>>>>> interfaces: I never needed dma_buf_vmap() because pinning was 
>>>>>> never really required here. Almost all of the cases were handled 
>>>>>> by dma_buf_vmap_local(). And the ast cursor code uses the 
>>>>>> equivalent of dma_buf_vmap_locked().
>>>>>
>>>>> Yeah, that is kind of expected. I was already wondering as well 
>>>>> why we didn't used the reservation lock more extensively.
>>>>
>>>> As a side note, I found only 6 trivial implementations of vmap 
>>>> outside of drivers/gpu/drm. I cannot find a single implementation 
>>>> of pin there.  What am I missing?
>>>
>>> Amdgpu is the only one currently implementing the new interface. So 
>>> far we didn't had the time nor the need to correctly move the 
>>> locking into the calling drivers.
>>>
>>> That's what the whole dynamic DMA-buf patches where all about.
>>
>> Thanks for the pointer.
>
> That was not a snarky comment, although it might sound like one. I 
> found the series in my inbox. :)

It wasn't recognized as such. And just to be clear your work here is 
extremely welcomed.

Regards,
Christian.

>
> Best regards
> Thomas
>
>>
>> Best regards
>> Thomas
>>
>>>
>>> Regards,
>>> Christian.
>>>
>>>>
>>>> Best regards
>>>> Thomas
>>>
>>> _______________________________________________
>>> dri-devel mailing list
>>> dri-devel@lists.freedesktop.org
>>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>>
>

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2020-12-01 13:05 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-30 12:04 [PATCH 0/8] drm/vram-helper: Lock GEM BOs while they are mapped Thomas Zimmermann
2020-11-30 12:04 ` [PATCH 1/8] drm/gem: Write down some rules for vmap usage Thomas Zimmermann
2020-11-30 15:30   ` Daniel Vetter
2020-11-30 15:33     ` Christian König
2020-12-01  8:32       ` Thomas Zimmermann
2020-12-01  9:10         ` Daniel Vetter
2020-12-01  9:40           ` Thomas Zimmermann
2020-12-01 10:00             ` Daniel Vetter
2020-12-01 10:27               ` Thomas Zimmermann
2020-12-01 10:34                 ` Christian König
2020-12-01 11:30                   ` Thomas Zimmermann
2020-12-01 12:14                     ` Christian König
2020-12-01 12:33                       ` Thomas Zimmermann
2020-12-01 12:38                         ` Christian König
2020-12-01 12:51                           ` Thomas Zimmermann
2020-12-01 12:53                             ` Thomas Zimmermann
2020-12-01 13:05                               ` Christian König [this message]
2020-12-01 16:54                 ` Daniel Vetter
2020-12-01 12:05               ` Thomas Zimmermann
2020-12-01  9:13         ` Christian König
2020-12-01  9:30           ` Thomas Zimmermann
2020-12-01  8:15     ` Thomas Zimmermann
2020-11-30 12:04 ` [PATCH 2/8] drm/ast: Only map cursor BOs during updates Thomas Zimmermann
2020-11-30 12:04 ` [PATCH 3/8] drm/vram-helper: Provide drm_gem_vram_vmap_unlocked() Thomas Zimmermann
2020-11-30 12:04 ` [PATCH 4/8] drm/ast: Use drm_gem_vram_vmap_unlocked() in ast_cursor_show() Thomas Zimmermann
2020-11-30 12:04 ` [PATCH 5/8] drm/vboxvideo: Use drm_gem_vram_vmap_unlocked() in cursor update Thomas Zimmermann
2020-11-30 12:04 ` [PATCH 6/8] drm/vram-helper: Remove pinning and locking from drm_gem_vram_vmap() Thomas Zimmermann
2020-11-30 12:04 ` [PATCH 7/8] drm/vram-helper: Remove vmap reference counting Thomas Zimmermann
2020-11-30 12:04 ` [PATCH 8/8] drm/vram-helper: Simplify vmap implementation Thomas Zimmermann
2020-11-30 12:27 ` [PATCH 0/8] drm/vram-helper: Lock GEM BOs while they are mapped Christian König
2020-11-30 12:45 ` Thomas Zimmermann

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=74ad99d1-9963-b648-ffa8-ae0858326749@amd.com \
    --to=christian.koenig@amd.com \
    --cc=airlied@redhat.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hdegoede@redhat.com \
    --cc=tzimmermann@suse.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 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).