All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: daniel@ffwll.ch, airlied@redhat.com, noralf@tronnes.org,
	rong.a.chen@intel.com, ying.huang@intel.com,
	ville.syrjala@linux.intel.com, sam@ravnborg.org,
	emil.velikov@collabora.com, maarten.lankhorst@linux.intel.com,
	mripard@kernel.org
Cc: Thomas Zimmermann <tzimmermann@suse.de>, dri-devel@lists.freedesktop.org
Subject: [PATCH v3 4/4] drm/fb-helper: Synchronize dirty worker with vblank
Date: Thu,  5 Dec 2019 17:01:42 +0100	[thread overview]
Message-ID: <20191205160142.3588-5-tzimmermann@suse.de> (raw)
In-Reply-To: <20191205160142.3588-1-tzimmermann@suse.de>

Before updating the display from the console's shadow buffer, the dirty
worker now waits for a vblank. This allows several screen updates to pile
up and acts as a rate limiter. If a DRM master is present, it could
interfere with the vblank. Don't wait in this case.

v3:
	* add back helper->lock
	* acquire DRM master status while waiting for vblank
v2:
	* don't hold helper->lock while waiting for vblank

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/drm_fb_helper.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index fb9bff0f4581..ba20ad92fb90 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -404,8 +404,29 @@ 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 to vblank. If there's a DRM master
+	 * present, it could interfere while we're waiting for the vblank
+	 * event. Don't wait in this case.
+	 */
+	mutex_lock(&helper->lock);
+	if (!drm_master_internal_acquire(helper->dev)) {
+		goto unlock;
+	}
+	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);
+	}
+	drm_master_internal_release(helper->dev);
+unlock:
+	mutex_unlock(&helper->lock);
 
 	spin_lock_irqsave(&helper->dirty_lock, flags);
 	clip_copy = *clip;
-- 
2.23.0

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

  parent reply	other threads:[~2019-12-05 16:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-05 16:01 [PATCH v3 0/4] Rate-limit shadow-FB-to-console-update to screen refresh Thomas Zimmermann
2019-12-05 16:01 ` [PATCH v3 1/4] drm/mgag200: Create fbdev console after registering device Thomas Zimmermann
2019-12-05 16:01 ` [PATCH v3 2/4] drm/mgag200: Rename constant MGAREG_Status to MGAREG_STATUS Thomas Zimmermann
2019-12-05 16:01 ` [PATCH v3 3/4] drm/mgag200: Add vblank support Thomas Zimmermann
2019-12-05 17:25   ` Sam Ravnborg
2019-12-05 18:28     ` Thomas Zimmermann
2019-12-05 18:56       ` Emil Velikov
2019-12-05 16:01 ` Thomas Zimmermann [this message]
2019-12-09 14:11   ` [PATCH v3 4/4] drm/fb-helper: Synchronize dirty worker with vblank Emil Velikov
2019-12-05 17:31 ` [PATCH v3 0/4] Rate-limit shadow-FB-to-console-update to screen refresh Sam Ravnborg

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=20191205160142.3588-5-tzimmermann@suse.de \
    --to=tzimmermann@suse.de \
    --cc=airlied@redhat.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=emil.velikov@collabora.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=noralf@tronnes.org \
    --cc=rong.a.chen@intel.com \
    --cc=sam@ravnborg.org \
    --cc=ville.syrjala@linux.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.