All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
	Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>,
	dri-devel@lists.freedesktop.org,
	Rodrigo Vivi <rodrigo.vivi@intel.com>
Subject: [PATCH v2 4/8] drm/vblank: Do not update vblank counts if vblanks are already disabled.
Date: Mon, 18 Dec 2017 21:26:55 -0800	[thread overview]
Message-ID: <20171219052659.2355-5-dhinakaran.pandiyan@intel.com> (raw)
In-Reply-To: <20171219052659.2355-1-dhinakaran.pandiyan@intel.com>

Updating the vblank counts requires register reads and these reads may not
return meaningful values after the vblank interrupts are disabled as the
device may go to low power state. An additional change would be to allow
the driver to save the vblank counts before entering a low power state, but
that's for the future.

Also, disable vblanks after reading the HW counter in the case where
_crtc_vblank_off() is disabling vblanks.

Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
---
 drivers/gpu/drm/drm_vblank.c | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
index 32d9bcf5be7f..7eee82c06ed8 100644
--- a/drivers/gpu/drm/drm_vblank.c
+++ b/drivers/gpu/drm/drm_vblank.c
@@ -347,23 +347,14 @@ void drm_vblank_disable_and_save(struct drm_device *dev, unsigned int pipe)
 	spin_lock_irqsave(&dev->vblank_time_lock, irqflags);
 
 	/*
-	 * Only disable vblank interrupts if they're enabled. This avoids
-	 * calling the ->disable_vblank() operation in atomic context with the
-	 * hardware potentially runtime suspended.
-	 */
-	if (vblank->enabled) {
-		__disable_vblank(dev, pipe);
-		vblank->enabled = false;
-	}
-
-	/*
-	 * Always update the count and timestamp to maintain the
+	 * Update the count and timestamp to maintain the
 	 * appearance that the counter has been ticking all along until
 	 * this time. This makes the count account for the entire time
 	 * between drm_crtc_vblank_on() and drm_crtc_vblank_off().
 	 */
 	drm_update_vblank_count(dev, pipe, false);
-
+	__disable_vblank(dev, pipe);
+	vblank->enabled = false;
 	spin_unlock_irqrestore(&dev->vblank_time_lock, irqflags);
 }
 
@@ -1122,8 +1113,12 @@ void drm_crtc_vblank_off(struct drm_crtc *crtc)
 		      pipe, vblank->enabled, vblank->inmodeset);
 
 	/* Avoid redundant vblank disables without previous
-	 * drm_crtc_vblank_on(). */
-	if (drm_core_check_feature(dev, DRIVER_ATOMIC) || !vblank->inmodeset)
+	 * drm_crtc_vblank_on() and only disable them if they're enabled. This
+	 * avoids calling the ->disable_vblank() operation in atomic context
+	 * with the hardware potentially runtime suspended.
+	 */
+	if ((drm_core_check_feature(dev, DRIVER_ATOMIC) || !vblank->inmodeset) &&
+	    vblank->enabled)
 		drm_vblank_disable_and_save(dev, pipe);
 
 	wake_up(&vblank->queue);
-- 
2.11.0

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

  parent reply	other threads:[~2017-12-19  5:26 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-19  5:26 [PATCH v2 0/8] Fix PSR-vblank-DMC interaction Dhinakaran Pandiyan
2017-12-19  5:26 ` [PATCH v2 1/8] drm/i915/psr: Kill psr.source_ok flag Dhinakaran Pandiyan
2017-12-19 21:16   ` Rodrigo Vivi
2017-12-19  5:26 ` [PATCH v2 2/8] drm/i915/psr: CAN_PSR() macro to check for PSR source and sink support Dhinakaran Pandiyan
2017-12-19 21:23   ` Rodrigo Vivi
2017-12-19  5:26 ` [PATCH v2 3/8] drm/i915/psr: Avoid initializing PSR if there is no " Dhinakaran Pandiyan
2017-12-19 21:29   ` Rodrigo Vivi
2017-12-19 21:40     ` Pandiyan, Dhinakaran
2018-01-03 21:59       ` Rodrigo Vivi
2018-01-03 22:20         ` Pandiyan, Dhinakaran
2017-12-19  5:26 ` Dhinakaran Pandiyan [this message]
2017-12-19  5:26 ` [PATCH v2 5/8] drm/vblank: Restoring vblank counts after device runtime PM events Dhinakaran Pandiyan
2017-12-19  5:26 ` [PATCH v2 6/8] drm/i915: Use an atomic_t array to track power domain use count Dhinakaran Pandiyan
2017-12-21 12:37   ` Maarten Lankhorst
2017-12-22  6:13     ` Pandiyan, Dhinakaran
2017-12-19  5:26 ` [PATCH v2 7/8] drm/i915: Introduce a non-blocking power domain for vblank interrupts Dhinakaran Pandiyan
2017-12-19 21:41   ` Rodrigo Vivi
2017-12-19 23:20     ` Pandiyan, Dhinakaran
2017-12-19  5:26 ` [PATCH v2 8/8] drm/i915: Use the vblank power domain disallow or disable DC states Dhinakaran Pandiyan
2017-12-19  5:49 ` ✓ Fi.CI.BAT: success for Fix PSR-vblank-DMC interaction Patchwork
2017-12-19  6:34 ` ✓ Fi.CI.IGT: " Patchwork

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=20171219052659.2355-5-dhinakaran.pandiyan@intel.com \
    --to=dhinakaran.pandiyan@intel.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=rodrigo.vivi@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.