From: "Michel Dänzer" <michel@daenzer.net>
To: Chris Wilson <chris@chris-wilson.co.uk>, dri-devel@lists.freedesktop.org
Cc: Dave Airlie <airlied@redhat.com>,
intel-gfx@lists.freedesktop.org,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Daniel Vetter <daniel.vetter@intel.com>
Subject: Re: [PATCH] drm: Return current vblank value for drmWaitVBlank queries
Date: Wed, 18 Mar 2015 12:13:50 +0900 [thread overview]
Message-ID: <5508ED6E.7040408@daenzer.net> (raw)
In-Reply-To: <5508E89C.9040107@daenzer.net>
On 18.03.2015 11:53, Michel Dänzer wrote:
> On 18.03.2015 00:44, Chris Wilson wrote:
>> When userspace queries the current vblank for the CRTC, we can reply
>> with the cached value (using atomic reads to serialise with the vblank
>> interrupt as necessary) without having to touch registers. In the
>> instant disable case, this saves us from enabling/disabling the vblank
>> around every query, greatly reducing the number of registers read and
>> written.
>>
>> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
>> Cc: Imre Deak <imre.deak@intel.com>
>> Cc: Daniel Vetter <daniel.vetter@intel.com>
>> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
>> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>> Cc: Dave Airlie <airlied@redhat.com>
>> ---
>> drivers/gpu/drm/drm_irq.c | 15 ++++++++++++++-
>> 1 file changed, 14 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
>> index c8a34476570a..6c4570082b65 100644
>> --- a/drivers/gpu/drm/drm_irq.c
>> +++ b/drivers/gpu/drm/drm_irq.c
>> @@ -1585,7 +1585,18 @@ int drm_wait_vblank(struct drm_device *dev, void *data,
>> if (crtc >= dev->num_crtcs)
>> return -EINVAL;
>>
>> - vblank = &dev->vblank[crtc];
>> + /* Fast-path the query for the current value (without an event)
>> + * to avoid having to enable/disable the vblank interrupts.
>> + */
>> + if ((vblwait->request.type & (_DRM_VBLANK_TYPES_MASK | _DRM_VBLANK_FLAGS_MASK)) == _DRM_VBLANK_RELATIVE &&
>> + vblwait->request.sequence == 0) {
>> + struct timeval now;
>> +
>> + vblwait->reply.sequence = drm_vblank_count_and_time(dev, crtc, &now);
>> + vblwait->reply.tval_sec = now.tv_sec;
>> + vblwait->reply.tval_usec = now.tv_usec;
>> + return 0;
>> + }
>
> drm_vblank_count_and_time() doesn't return the correct sequence number
> while the vblank interrupt is disabled, does it? It returns the sequence
> number from the last time vblank_disable_and_save() was called (when the
> vblank interrupt was disabled). That's why drm_vblank_get() is needed here.
It might be possible to avoid drm_vblank_get() and use
drm_update_vblank_count() before (or in) drm_vblank_count_and_time()
instead when the vblank interrupt is disabled, but then you'd first need
to make it safe to call drm_update_vblank_count() several times while
the vblank interrupt is disabled, by making it update vblank->last at least.
--
Earthling Michel Dänzer | http://www.amd.com
Libre software enthusiast | Mesa and X developer
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2015-03-18 3:13 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-17 15:44 [PATCH] drm: Return current vblank value for drmWaitVBlank queries Chris Wilson
2015-03-18 2:53 ` Michel Dänzer
2015-03-18 3:13 ` Michel Dänzer [this message]
2015-03-18 9:30 ` Chris Wilson
2015-03-18 14:52 ` Mario Kleiner
2015-03-19 14:33 ` Daniel Vetter
2015-03-19 15:04 ` Ville Syrjälä
2015-03-19 15:13 ` Chris Wilson
2015-03-19 15:36 ` [Intel-gfx] " Chris Wilson
2015-03-19 16:43 ` Mario Kleiner
2015-03-18 17:57 ` shuang.he
2015-04-02 11:34 ` [PATCH] drm: Defer disabling the vblank IRQ until the next interrupt (for instant-off) Chris Wilson
2015-04-02 19:01 ` shuang.he
2015-04-03 2:20 ` Michel Dänzer
2015-04-03 9:06 ` Chris Wilson
2015-04-15 1:03 ` Mario Kleiner
2015-05-04 5:25 ` Mario Kleiner
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=5508ED6E.7040408@daenzer.net \
--to=michel@daenzer.net \
--cc=airlied@redhat.com \
--cc=chris@chris-wilson.co.uk \
--cc=daniel.vetter@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=laurent.pinchart@ideasonboard.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox