linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Rob Clark <robdclark@gmail.com>
Cc: "Rob Clark" <robdclark@chromium.org>,
	"Tvrtko Ursulin" <tvrtko.ursulin@intel.com>,
	"Christian König" <ckoenig.leichtzumerken@gmail.com>,
	"Michel Dänzer" <michel@daenzer.net>,
	"open list" <linux-kernel@vger.kernel.org>,
	dri-devel@lists.freedesktop.org,
	"Pekka Paalanen" <ppaalanen@gmail.com>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
	"Alex Deucher" <alexander.deucher@amd.com>,
	freedreno@lists.freedesktop.org
Subject: Re: [Freedreno] [PATCH v4 10/14] drm/vblank: Add helper to get next vblank time
Date: Wed, 22 Feb 2023 00:46:04 +0200	[thread overview]
Message-ID: <Y/VJrNPX8EiwEyYt@intel.com> (raw)
In-Reply-To: <CAF6AEGtkgDNZTr-NS_rUuEDxPy5aoMycPDn2RXFEXfAiA7=E9A@mail.gmail.com>

On Tue, Feb 21, 2023 at 02:28:10PM -0800, Rob Clark wrote:
> On Tue, Feb 21, 2023 at 1:48 PM Ville Syrjälä
> <ville.syrjala@linux.intel.com> wrote:
> >
> > On Tue, Feb 21, 2023 at 11:39:40PM +0200, Ville Syrjälä wrote:
> > > On Tue, Feb 21, 2023 at 11:54:55AM -0800, Rob Clark wrote:
> > > > On Tue, Feb 21, 2023 at 5:01 AM Ville Syrjälä
> > > > <ville.syrjala@linux.intel.com> wrote:
> > > > >
> > > > > On Tue, Feb 21, 2023 at 10:45:51AM +0200, Pekka Paalanen wrote:
> > > > > > On Mon, 20 Feb 2023 07:55:41 -0800
> > > > > > Rob Clark <robdclark@gmail.com> wrote:
> > > > > >
> > > > > > > On Mon, Feb 20, 2023 at 1:08 AM Pekka Paalanen <ppaalanen@gmail.com> wrote:
> > > > > > > >
> > > > > > > > On Sat, 18 Feb 2023 13:15:53 -0800
> > > > > > > > Rob Clark <robdclark@gmail.com> wrote:
> > > > > > > >
> > > > > > > > > From: Rob Clark <robdclark@chromium.org>
> > > > > > > > >
> > > > > > > > > Will be used in the next commit to set a deadline on fences that an
> > > > > > > > > atomic update is waiting on.
> > > > > > > > >
> > > > > > > > > Signed-off-by: Rob Clark <robdclark@chromium.org>
> > > > > > > > > ---
> > > > > > > > >  drivers/gpu/drm/drm_vblank.c | 32 ++++++++++++++++++++++++++++++++
> > > > > > > > >  include/drm/drm_vblank.h     |  1 +
> > > > > > > > >  2 files changed, 33 insertions(+)
> > > > > > > > >
> > > > > > > > > diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
> > > > > > > > > index 2ff31717a3de..caf25ebb34c5 100644
> > > > > > > > > --- a/drivers/gpu/drm/drm_vblank.c
> > > > > > > > > +++ b/drivers/gpu/drm/drm_vblank.c
> > > > > > > > > @@ -980,6 +980,38 @@ u64 drm_crtc_vblank_count_and_time(struct drm_crtc *crtc,
> > > > > > > > >  }
> > > > > > > > >  EXPORT_SYMBOL(drm_crtc_vblank_count_and_time);
> > > > > > > > >
> > > > > > > > > +/**
> > > > > > > > > + * drm_crtc_next_vblank_time - calculate the time of the next vblank
> > > > > > > > > + * @crtc: the crtc for which to calculate next vblank time
> > > > > > > > > + * @vblanktime: pointer to time to receive the next vblank timestamp.
> > > > > > > > > + *
> > > > > > > > > + * Calculate the expected time of the next vblank based on time of previous
> > > > > > > > > + * vblank and frame duration
> > > > > > > >
> > > > > > > > Hi,
> > > > > > > >
> > > > > > > > for VRR this targets the highest frame rate possible for the current
> > > > > > > > VRR mode, right?
> > > > > > > >
> > > > > > >
> > > > > > > It is based on vblank->framedur_ns which is in turn based on
> > > > > > > mode->crtc_clock.  Presumably for VRR that ends up being a maximum?
> > > > > >
> > > > > > I don't know. :-)
> > > > >
> > > > > At least for i915 this will give you the maximum frame
> > > > > duration.
> > > > >
> > > > > Also this does not calculate the the start of vblank, it
> > > > > calculates the start of active video.
> > > >
> > > > AFAIU, vsync_end/vsync_start are in units of line, so I could do something like:
> > > >
> > > >   vsync_lines = vblank->hwmode.vsync_end - vblank->hwmode.vsync_start;
> > > >   vsyncdur = ns_to_ktime(vblank->linedur_ns * vsync_lines);
> > > >   framedur = ns_to_ktime(vblank->framedur_ns);
> > > >   *vblanktime = ktime_add(*vblanktime, ktime_sub(framedur, vsyncdur));
> > >
> > > Something like this should work:
> > >  vblank_start = framedur_ns * crtc_vblank_start / crtc_vtotal
> > >  deadline = vblanktime + vblank_start
> > >
> > > That would be the expected time when the next start of vblank
> > > happens.
> >
> > Except that drm_vblank_count_and_time() will give you the last
> > sampled timestamp, which may be long ago in the past. Would
> > need to add an _accurate version of that if we want to be
> > guaranteed a fresh sample.
> 
> IIRC the only time we wouldn't have a fresh sample is if the screen
> has been idle for some time?

IIRC "some time" == 1 idle frame, for any driver that sets
vblank_disable_immediate.

> In which case, I think that doesn't
> matter.
> 
> BR,
> -R
> 
> >
> > --
> > Ville Syrjälä
> > Intel

-- 
Ville Syrjälä
Intel

  reply	other threads:[~2023-02-21 22:46 UTC|newest]

Thread overview: 93+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-18 21:15 [PATCH v4 00/14] dma-fence: Deadline awareness Rob Clark
2023-02-18 21:15 ` [PATCH v4 01/14] dma-buf/dma-fence: Add deadline awareness Rob Clark
2023-02-22 10:23   ` Tvrtko Ursulin
2023-02-22 15:28     ` Christian König
2023-02-22 17:04       ` Tvrtko Ursulin
2023-02-22 17:16         ` Rob Clark
2023-02-22 17:33           ` Tvrtko Ursulin
2023-02-22 18:57             ` Rob Clark
2023-02-22 11:01   ` Luben Tuikov
2023-02-18 21:15 ` [PATCH v4 02/14] dma-buf/fence-array: Add fence deadline support Rob Clark
2023-02-18 21:15 ` [PATCH v4 03/14] dma-buf/fence-chain: " Rob Clark
2023-02-22 10:27   ` Tvrtko Ursulin
2023-02-22 15:55     ` Rob Clark
2023-02-18 21:15 ` [PATCH v4 04/14] dma-buf/dma-resv: Add a way to set fence deadline Rob Clark
2023-02-20  8:16   ` Christian König
2023-02-18 21:15 ` [PATCH v4 05/14] dma-buf/sync_file: Add SET_DEADLINE ioctl Rob Clark
2023-02-20  8:27   ` Christian König
2023-02-20 16:09     ` Rob Clark
2023-02-21  8:41       ` Pekka Paalanen
2023-02-23  9:19       ` Christian König
2023-02-20  8:48   ` Pekka Paalanen
2023-02-18 21:15 ` [PATCH v4 06/14] dma-buf/sync_file: Support (E)POLLPRI Rob Clark
2023-02-20  8:31   ` Christian König
2023-02-21  8:38     ` Pekka Paalanen
2023-02-20  8:53   ` Pekka Paalanen
2023-02-20 16:14     ` Rob Clark
2023-02-21  8:37       ` Pekka Paalanen
2023-02-21 16:01         ` Sebastian Wick
2023-02-21 17:55           ` Rob Clark
2023-02-21 16:48       ` Luben Tuikov
2023-02-21 17:53         ` Rob Clark
2023-02-22  9:49           ` Pekka Paalanen
2023-02-22 10:26             ` Luben Tuikov
2023-02-22 15:37             ` Rob Clark
2023-02-23  9:38               ` Pekka Paalanen
2023-02-23 18:51                 ` Rob Clark
2023-02-24  9:26                   ` Pekka Paalanen
2023-02-24  9:41                     ` Tvrtko Ursulin
2023-02-24 10:24                       ` Pekka Paalanen
2023-02-24 10:50                         ` Tvrtko Ursulin
2023-02-24 11:00                           ` Pekka Paalanen
2023-02-24 11:37                             ` Tvrtko Ursulin
2023-02-24 15:26                               ` Luben Tuikov
2023-02-24 17:59                                 ` Rob Clark
2023-02-27 21:35                                   ` Rodrigo Vivi
2023-02-27 22:20                                     ` Rob Clark
2023-02-27 22:44                                       ` Sebastian Wick
2023-02-27 23:48                                         ` Rob Clark
2023-02-28 14:30                                           ` Sebastian Wick
2023-02-28 22:52                                             ` Rob Clark
2023-03-01 15:31                                               ` Sebastian Wick
2023-03-01 16:02                                                 ` Rob Clark
2023-03-01 15:45                                       ` Rodrigo Vivi
2023-02-24 16:59                         ` Rob Clark
2023-02-24 19:44                         ` Rob Clark
2023-02-27  9:34                           ` Pekka Paalanen
2023-02-27 18:43                             ` Rob Clark
2023-02-18 21:15 ` [PATCH v4 07/14] dma-buf/sw_sync: Add fence deadline support Rob Clark
2023-02-20  8:29   ` Christian König
2023-02-18 21:15 ` [PATCH v4 08/14] drm/scheduler: " Rob Clark
2023-02-21 19:40   ` Luben Tuikov
2023-02-18 21:15 ` [PATCH v4 09/14] drm/syncobj: Add deadline support for syncobj waits Rob Clark
2023-02-19 16:09   ` Rob Clark
2023-02-20  9:05   ` Pekka Paalanen
2023-02-20 16:20     ` Rob Clark
2023-02-24  9:51   ` Tvrtko Ursulin
2023-02-18 21:15 ` [PATCH v4 10/14] drm/vblank: Add helper to get next vblank time Rob Clark
2023-02-20  9:08   ` Pekka Paalanen
2023-02-20 15:55     ` Rob Clark
2023-02-21  8:45       ` Pekka Paalanen
2023-02-21 13:01         ` Ville Syrjälä
2023-02-21 13:11           ` Pekka Paalanen
2023-02-21 13:42             ` Ville Syrjälä
2023-02-21 17:50           ` Rob Clark
2023-02-22  9:57             ` Pekka Paalanen
2023-02-22 15:44               ` Rob Clark
2023-02-22 15:55                 ` Ville Syrjälä
2023-02-21 19:54           ` Rob Clark
2023-02-21 21:39             ` Ville Syrjälä
2023-02-21 21:48               ` Ville Syrjälä
2023-02-21 22:28                 ` [Freedreno] " Rob Clark
2023-02-21 22:46                   ` Ville Syrjälä [this message]
2023-02-21 23:20                     ` Rob Clark
2023-02-21 23:25                       ` Rob Clark
2023-02-22 10:37   ` Luben Tuikov
2023-02-22 15:48     ` Rob Clark
2023-02-18 21:15 ` [PATCH v4 11/14] drm/atomic-helper: Set fence deadline for vblank Rob Clark
2023-02-22 10:46   ` Luben Tuikov
2023-02-22 15:50     ` Rob Clark
2023-02-18 21:15 ` [PATCH v4 12/14] drm/msm: Add deadline based boost support Rob Clark
2023-02-18 21:15 ` [PATCH v4 13/14] drm/msm: Add wait-boost support Rob Clark
2023-02-18 21:15 ` [PATCH v4 14/14] drm/i915: Add deadline based boost support Rob Clark
2023-02-20 15:46   ` Tvrtko Ursulin

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=Y/VJrNPX8EiwEyYt@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=alexander.deucher@amd.com \
    --cc=ckoenig.leichtzumerken@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michel@daenzer.net \
    --cc=ppaalanen@gmail.com \
    --cc=robdclark@chromium.org \
    --cc=robdclark@gmail.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=tvrtko.ursulin@intel.com \
    --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).