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>,
	"Christian König" <ckoenig.leichtzumerken@gmail.com>,
	daniel@ffwll.ch, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm: handle kernel fences in drm_gem_plane_helper_prepare_fb
Date: Thu, 28 Apr 2022 09:32:24 +0200	[thread overview]
Message-ID: <69a2da78-0325-c412-6b37-03d4242e5a5e@amd.com> (raw)
In-Reply-To: <877dc0d9-c6c6-022c-20d8-14b33e863934@suse.de>

Am 28.04.22 um 09:23 schrieb Thomas Zimmermann:
> [SNIP]
>> diff --git a/drivers/gpu/drm/drm_gem_atomic_helper.c 
>> b/drivers/gpu/drm/drm_gem_atomic_helper.c
>> index a6d89aed0bda..8fc0b42acdff 100644
>> --- a/drivers/gpu/drm/drm_gem_atomic_helper.c
>> +++ b/drivers/gpu/drm/drm_gem_atomic_helper.c
>> @@ -1,6 +1,7 @@
>>   // SPDX-License-Identifier: GPL-2.0-or-later
>>     #include <linux/dma-resv.h>
>> +#include <linux/dma-fence-chain.h>
>>     #include <drm/drm_atomic_state_helper.h>
>>   #include <drm/drm_atomic_uapi.h>
>> @@ -141,25 +142,67 @@
>>    * See drm_atomic_set_fence_for_plane() for a discussion of 
>> implicit and
>
> This comment still refers to the function you just deleted. Maybe the 
> deleted docs could be integrated here somehow, if still relevant?

Yeah, Daniel point that out as well.

>
>>    * explicit fencing in atomic modeset updates.
>>    */
>> -int drm_gem_plane_helper_prepare_fb(struct drm_plane *plane, struct 
>> drm_plane_state *state)
>> +int drm_gem_plane_helper_prepare_fb(struct drm_plane *plane,
>> +                    struct drm_plane_state *state)
>
> We have a 100-character limit. Please leave this on the same line.

Despite some efforts to change this that is still documented as 
80-character limit: 
https://www.kernel.org/doc/html/v5.18-rc4/process/coding-style.html#breaking-long-lines-and-strings

>
>>   {
>> +    struct dma_fence *fence = dma_fence_get(state->fence);
>>       struct drm_gem_object *obj;
>
> I'd declare this variable within the for loop.
>
>> -    struct dma_fence *fence;
>> +    enum dma_resv_usage usage;
>> +    size_t i;
>>       int ret;
>>         if (!state->fb)
>>           return 0;
>>   -    obj = drm_gem_fb_get_obj(state->fb, 0);
>> -    ret = dma_resv_get_singleton(obj->resv, DMA_RESV_USAGE_WRITE, 
>> &fence);
>> -    if (ret)
>> -        return ret;
>> -
>> -    /* TODO: drm_atomic_set_fence_for_plane() should be changed to 
>> be able
>> -     * to handle more fences in general for multiple BOs per fb.
>> +    /*
>> +     * Only add the kernel fences here if there is already a fence 
>> set via
>> +     * explicit fencing interfaces on the atomic ioctl.
>> +     *
>> +     * This way explicit fencing can be used to overrule implicit 
>> fencing,
>> +     * which is important to make explicit fencing use-cases work: One
>> +     * example is using one buffer for 2 screens with different refresh
>> +     * rates. Implicit fencing will clamp rendering to the refresh 
>> rate of
>> +     * the slower screen, whereas explicit fence allows 2 independent
>> +     * render and display loops on a single buffer. If a driver allows
>> +     * obeys both implicit and explicit fences for plane updates, 
>> then it
>> +     * will break all the benefits of explicit fencing.
>>        */
>> -    drm_atomic_set_fence_for_plane(state, fence);
>> +    usage = fence ? DMA_RESV_USAGE_KERNEL : DMA_RESV_USAGE_WRITE;
>> +
>> +    for (i = 0; i < ARRAY_SIZE(state->fb->obj); ++i) {
>
> Instead of ARRAY_SIZE, rather use state->fb->format->num_planes. It's 
> the number of planes (i.e., GEM objects) in the framebuffer.
>
>> +        struct dma_fence *new;
>> +
>> +        obj = drm_gem_fb_get_obj(state->fb, i);
>> +        if (!obj)
>
> With the use of num_planes in the for loop, there should probably be a 
> drm_WARN_ON_ONCE() around this test.
>
>> +            continue;
>
> goto error handling.
>
> Or is there a use case for framebuffers with empty planes? At least 
> it's not possible to instantiate one via drm_gem_fb_init_with_funcs().
>

I was asking myself the same thing, but found this handling be used at 
other places as well.

Thanks for taking a look,
Christian.

  reply	other threads:[~2022-04-28  7:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-21 19:10 [PATCH] drm: handle kernel fences in drm_gem_plane_helper_prepare_fb Christian König
2022-04-27 16:03 ` Daniel Vetter
2022-04-28  6:41   ` Christian König
2022-04-28 12:27     ` Daniel Vetter
2022-04-28  7:23 ` Thomas Zimmermann
2022-04-28  7:32   ` Christian König [this message]
2022-04-28  7:50     ` 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=69a2da78-0325-c412-6b37-03d4242e5a5e@amd.com \
    --to=christian.koenig@amd.com \
    --cc=ckoenig.leichtzumerken@gmail.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --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).