All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: "Noralf Trønnes" <noralf@tronnes.org>,
	"Gerd Hoffmann" <kraxel@redhat.com>
Cc: feng.tang@intel.com, rong.a.chen@intel.com,
	dri-devel@lists.freedesktop.org, ying.huang@intel.com,
	airlied@redhat.com
Subject: Re: [PATCH 1/2] drm/fb-helper: Synchronize dirty worker with vblank
Date: Tue, 10 Sep 2019 15:51:40 +0200	[thread overview]
Message-ID: <52be9b77-51aa-62b6-8de7-cfb1165c1470@suse.de> (raw)
In-Reply-To: <1223403a-17a5-638b-49ce-5dba23fe23d5@tronnes.org>


[-- Attachment #1.1.1: Type: text/plain, Size: 3199 bytes --]

Hi

Am 10.09.19 um 15:34 schrieb Noralf Trønnes:
> 
> 
> Den 10.09.2019 14.48, skrev Thomas Zimmermann:
>> Hi
>>
>> Am 10.09.19 um 13:52 schrieb Gerd Hoffmann:
>>> On Mon, Sep 09, 2019 at 04:06:32PM +0200, Thomas Zimmermann wrote:
>>>> Before updating the display from the console's shadow buffer, the dirty
>>>> worker now waits for vblank. This allows several screen updates to pile
>>>> up and acts as a rate limiter.
>>>>
>>>> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
>>>> ---
>>>>  drivers/gpu/drm/drm_fb_helper.c | 12 ++++++++++++
>>>>  1 file changed, 12 insertions(+)
>>>>
>>>> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
>>>> index a7ba5b4902d6..017e2f6bd1b9 100644
>>>> --- a/drivers/gpu/drm/drm_fb_helper.c
>>>> +++ b/drivers/gpu/drm/drm_fb_helper.c
>>>> @@ -402,8 +402,20 @@ static void drm_fb_helper_dirty_work(struct work_struct *work)
>>>>  						    dirty_work);
>>>>  	struct drm_clip_rect *clip = &helper->dirty_clip;
>>>>  	struct drm_clip_rect clip_copy;
>>>> +	struct drm_crtc *crtc;
>>>>  	unsigned long flags;
>>>>  	void *vaddr;
>>>> +	int ret;
>>>> +
>>>> +	/* rate-limit update frequency */
>>>> +	mutex_lock(&helper->lock);
>>>> +	crtc = helper->client.modesets[0].crtc;
>>>> +	ret = drm_crtc_vblank_get(crtc);
>>>> +	if (!ret) {
>>>> +		drm_crtc_wait_one_vblank(crtc);
>>>> +		drm_crtc_vblank_put(crtc);
>>>> +	}
>>>> +	mutex_unlock(&helper->lock);
>>>
>>> Hmm, not sure it is the best plan to sleep for a while in the worker,
>>> especially while holding the lock.
>>>
>>> What does the lock protect against here?  Accessing
>>
>> This lock is hold by the fbdev code during mode-setting operations (but
>> not drawing operations). So *crtc might be gone if we don't hold it here.
>>
>>> helper->client.modesets?  If so then you can unlock before going to
>>> sleep in drm_crtc_wait_one_vblank() I think.
>>
>> I looked, but I cannot find any code that protects crtc while vblank is
>> active. I'd rather not change the current code until someone can clarify.
>>
> 
> The client->modesets array and the crtc struct member are invariant over
> the lifetime of client (drm_client_modeset_create()). No need to take a
> lock for access. See drm_client_modeset_release() for the things that
> _can_ change and needs protection (protected by client->modeset_mutex).

Thanks for the reply. So we don't need the lock? But why does
drm_fb_helper_ioctl() take it? ioctl exclusiveness?

> I don't see a problem with sleeping in the worker though, but I might
> miss out on something. AFAICS changes will just pile up in >dirty_clip
> and the worker will be scheduled for a new run to happen when it's done
> with the current update.

Yes, that's the intention of the patch. We hope to reduce the number of
memcpys by handling several of them at once.

Best regards
Thomas

> 
> Noralf.
> 
>> Best regards
>> Thomas
>>
>>>
>>> cheers,
>>>   Gerd
>>>
>>

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Linux GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah
HRB 21284 (AG Nürnberg)


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

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

  reply	other threads:[~2019-09-10 13:51 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-09 14:06 [PATCH 0/2] Rate-limit shadow-FB-to-console-update to screen refresh Thomas Zimmermann
2019-09-09 14:06 ` [PATCH 1/2] drm/fb-helper: Synchronize dirty worker with vblank Thomas Zimmermann
2019-09-10 11:52   ` Gerd Hoffmann
2019-09-10 12:48     ` Thomas Zimmermann
2019-09-10 13:34       ` Noralf Trønnes
2019-09-10 13:51         ` Thomas Zimmermann [this message]
2019-09-10 14:59           ` Noralf Trønnes
2019-09-17 12:55             ` Daniel Vetter
2019-09-17 13:25               ` Noralf Trønnes
2019-09-09 14:06 ` [PATCH 2/2] drm/mgag200: Add vblank support Thomas Zimmermann
2019-09-10 11:47   ` Gerd Hoffmann
2019-09-10 14:01   ` Ville Syrjälä
2019-09-10 14:38     ` Thomas Zimmermann
2019-09-11 15:08     ` Thomas Zimmermann
2019-09-11 15:21       ` Ville Syrjälä
2019-09-11 17:31         ` Thomas Zimmermann
2019-09-10 15:12   ` Ville Syrjälä

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=52be9b77-51aa-62b6-8de7-cfb1165c1470@suse.de \
    --to=tzimmermann@suse.de \
    --cc=airlied@redhat.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=feng.tang@intel.com \
    --cc=kraxel@redhat.com \
    --cc=noralf@tronnes.org \
    --cc=rong.a.chen@intel.com \
    --cc=ying.huang@intel.com \
    /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.