All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: "Jason-JH Lin (林睿祥)" <Jason-JH.Lin@mediatek.com>
Cc: "navaremanasi@google.com" <navaremanasi@google.com>,
	"Singo Chang (張興國)" <Singo.Chang@mediatek.com>,
	"jani.nikula@intel.com" <jani.nikula@intel.com>,
	"karthik.b.s@intel.com" <karthik.b.s@intel.com>,
	"swati2.sharma@intel.com" <swati2.sharma@intel.com>,
	"gildekel@google.com" <gildekel@google.com>,
	"Nancy Lin (林欣螢)" <Nancy.Lin@mediatek.com>,
	"Paul-pl Chen (陳柏霖)" <Paul-pl.Chen@mediatek.com>,
	"igt-dev@lists.freedesktop.org" <igt-dev@lists.freedesktop.org>,
	"kamil.konieczny@linux.intel.com"
	<kamil.konieczny@linux.intel.com>,
	Project_Global_Chrome_Upstream_Group
	<Project_Global_Chrome_Upstream_Group@mediatek.com>,
	"fshao@chromium.org" <fshao@chromium.org>,
	"markyacoub@chromium.org" <markyacoub@chromium.org>
Subject: Re: [PATCH i-g-t 2/2] tests/kms_setmode: Disable CPU deep sleep for accurate vblank timestamps
Date: Fri, 22 May 2026 21:14:26 +0300	[thread overview]
Message-ID: <ahCdAq03EHvn3zu9@intel.com> (raw)
In-Reply-To: <988bcdc233564b398a87190cb40489d43ed3922c.camel@mediatek.com>

On Fri, May 22, 2026 at 02:59:00AM +0000, Jason-JH Lin (林睿祥) wrote:
> On Thu, 2026-05-21 at 13:39 +0300, Ville Syrjälä wrote:
> > On Thu, May 21, 2026 at 03:01:25AM +0000, Jason-JH Lin (林睿祥) wrote:
> > > On Wed, 2026-05-20 at 16:50 +0300, Ville Syrjälä wrote:
> > > > On Wed, May 20, 2026 at 02:46:26PM +0800, Jason-JH Lin wrote:
> > > > > Use igt_disable_cpu_deep_sleep() to prevent CPU wakeup latency
> > > > > that
> > > > > affects vblank timestamp acquisition.
> > > > > 
> > > > > This addresses vblank timing stability issues on MediaTek
> > > > > platforms
> > > > > where CPU entering idle states can cause ~200us timestamp
> > > > > jitter
> > > > > and
> > > > > test failures.
> > > > 
> > > > Can't you fix the kernel to generate accurate timestamps?
> > > > 
> > > 
> > > Hi Ville,
> > > 
> > > Thanks for the feedback.
> > > 
> > > Currently, the kernel timestamp itself is accurate. The issue is
> > > that
> > > even though the vblank IRQ fires accurately, the timestamp captured
> > > by
> > > DRM core via ktime_get() in drm_crtc_get_last_vbltimestamp() cannot
> > > avoid the delay(randomly ~200us) introduced by the CPU idle exit
> > > sequence before the IRQ handler can actually execute.
> > > 
> > > After looking into this further, I referenced how Intel handles
> > > vblank
> > > timestamps and noticed they use
> > > drm_crtc_vblank_helper_get_vblank_timestamp() together with
> > > get_scanout_position() to calculate accurate timestamps by
> > > compensating
> > > for IRQ handling delays. Please correct me if I'm wrong :)
> > > 
> > > However, this approach requires the hardware to provide scanline
> > > position information. On MediaTek platforms, this has not been
> > > fully
> > > validated yet, so disabling CPU deep idle states seems to be the
> > > most
> > > appropriate solution for now.
> > 
> > Then you should probably do that in the kernel, or not at all. I
> > don't
> > think adding hacks to make tests pass makes any sense because then
> > what
> > you are testing doesn't match any real world use scenario at all.
> > So all you are doing is sweeping the problem under the carpet during 
> > testing, but the problem still remains and will still be hit during
> > actual use.
> > 
> 
> Hi Ville,
> 
> Thank you for the feedback.
> 
> You're right - the patch was purely to pass IGT tests, not to fix a
> real problem (although we haven't encountered any issue within
> randomly ~200us jitter on our current platform).
> 
> I've investigated the real-world impact of this ~200us timestamp
> jitter. In our current Android SurfaceFlinger implementation,
> real-world usage is stable with CPU deep sleep enabled.
> It seems this issue only appears in IGT single-CRTC testing where CPU
> enters deep sleep during idle periods between frames.
> Therefore, we prefer not to disable CPU deep sleep system-wide in
> kernel due to power consumption concerns.
> 
> However, I'd like to understand how the 1-scanline standard was
> originally defined for this test. Do real-world use cases actually
> require this level of precision?

I don't have specific examples, but people cared about precision
enough to add the whole timestamp correction thingy into the kernel.
And in i915 we also sometimes use the timestamps to cook up a frame
counter (when the hardware lacks one) and I wouldn't want to do that
without adjusting the timestamps based on the scanout position.

Anyways, since this is usually implemented via a scanline counter
(sometimes even a pixel counter) that's the kind of accuracy one
would expect to get, and so that's what one tests for to make sure
it's working correctly.

> 
> Not all platforms support or implement get_scanout_position() -
> could the standard be relaxed for such platforms?

If you don't implement accurate timestamps then the test is
expected to fail. I see nothing wrong in that.

Relaxing the test doesn't make sense to me because then it can
no longer tell you whether your timestamps are accurate or not.
Although I guess you could have another similar test that
makes sure that the timestamps are at least somewhat sane,
even if not very accurate.

-- 
Ville Syrjälä
Intel

  parent reply	other threads:[~2026-05-22 18:14 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-20  6:46 [PATCH i-g-t 0/2] Add CPU idle state control for accurate vblank timing Jason-JH Lin
2026-05-20  6:46 ` [PATCH i-g-t 1/2] lib/igt_kms: Add igt_disable_cpu_deep_sleep() to control CPU C-states Jason-JH Lin
2026-05-20  9:48   ` Kamil Konieczny
2026-05-20 10:17     ` Jason-JH Lin (林睿祥)
2026-05-20 16:55       ` Kamil Konieczny
2026-05-21  3:04         ` Jason-JH Lin (林睿祥)
2026-05-20  6:46 ` [PATCH i-g-t 2/2] tests/kms_setmode: Disable CPU deep sleep for accurate vblank timestamps Jason-JH Lin
2026-05-20  9:45   ` Kamil Konieczny
2026-05-20 10:05     ` Jason-JH Lin (林睿祥)
2026-05-20 13:50   ` Ville Syrjälä
2026-05-21  3:01     ` Jason-JH Lin (林睿祥)
2026-05-21 10:39       ` Ville Syrjälä
2026-05-22  2:59         ` Jason-JH Lin (林睿祥)
2026-05-22  5:27           ` Jason-JH Lin (林睿祥)
2026-05-22 18:14           ` Ville Syrjälä [this message]
2026-05-23  6:01             ` Jason-JH Lin (林睿祥)
2026-05-25 13:07               ` Mark Yacoub
2026-05-27 15:49                 ` Jason-JH Lin (林睿祥)
2026-05-27 17:58                   ` Ville Syrjälä
2026-05-29  3:03                     ` Jason-JH Lin (林睿祥)
2026-05-20  7:17 ` ✓ Xe.CI.BAT: success for Add CPU idle state control for accurate vblank timing Patchwork
2026-05-20  7:35 ` ✓ i915.CI.BAT: " Patchwork
2026-05-20 14:38 ` ✓ Xe.CI.FULL: " Patchwork
2026-05-21  9:26 ` ✓ i915.CI.Full: " 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=ahCdAq03EHvn3zu9@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=Jason-JH.Lin@mediatek.com \
    --cc=Nancy.Lin@mediatek.com \
    --cc=Paul-pl.Chen@mediatek.com \
    --cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
    --cc=Singo.Chang@mediatek.com \
    --cc=fshao@chromium.org \
    --cc=gildekel@google.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=jani.nikula@intel.com \
    --cc=kamil.konieczny@linux.intel.com \
    --cc=karthik.b.s@intel.com \
    --cc=markyacoub@chromium.org \
    --cc=navaremanasi@google.com \
    --cc=swati2.sharma@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.