All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Keith Packard" <keithp@keithp.com>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: linux-kernel@vger.kernel.org, Dave Airlie <airlied@redhat.com>,
	Daniel Vetter <daniel@ffwll.ch>,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 3/3] drm: Add CRTC_GET_SEQUENCE and CRTC_QUEUE_SEQUENCE ioctls [v2]
Date: Sat, 05 Aug 2017 23:32:39 -0400	[thread overview]
Message-ID: <87r2wpfk14.fsf@keithp.com> (raw)
In-Reply-To: <20170802092505.ynlpy6dxf3lxziim@phenom.ffwll.local>

[-- Attachment #1: Type: text/plain, Size: 3974 bytes --]

Daniel Vetter <daniel@ffwll.ch> writes:

> Since I missed all the details Michel spotted, so I'll defer to his r-b.
> Also, before merging we need the userspace user. Do we have e.g.
> -modesetting patch for this, fully reviewed&ready for merging, just as
> demonstration?

Well, given that we'll have to keep the old API around for older
kernels, at least for a decade or so, I'm not sure why we'd actually
want that anytime soon, if ever? I guess it does provide 64-bit sequence
numbers, which Present wants?

> This way we could land this before the lease stuff for the
> vk extension is all solid&ready.

Do you think there's a pile more work to be done for the lease changes
in the kernel? Or are you just trying to separate the work flows?

I can go re-write the modesetting present support to use this new API
and use that for testing the kernel, if you think that would help move
the kernel bits along.

>> +	drm_modeset_lock(&crtc->mutex, NULL);
>> +	if (crtc->state)
>> +		get_seq->active = crtc->state->enable;
>> +	else
>> +		get_seq->active = crtc->enabled;
>> +	drm_modeset_unlock(&crtc->mutex);
>
> This is really heavywheight, given the lockless dance we attempt above.
> Also, when the crtc is off the vblank_get will fail, so you never get
> here. I guess my idea wasn't all that useful and well-thought out, or we
> need to be a bit more clever about this. To fix this we need to continue
> even when vblank_get fails (but only call vblank_put if ret == 0 ofc). And
> to avoid the locking you can use READ_ONCE(vblank->enabled) instead.

So, in reality, the client can more-or-less tell that the crtc is
disabled because the call fails? Sounds like I can just remove the
little dance to get the CRTC enabled state entirely. I don't understand
your comment about READ_ONCE(vblank->enabled); that doesn't relate to
the crtc enabled state, I don't think?

>> +
>> +/* Queue event to be delivered at specified sequence */
>> +
>> +#define DRM_CRTC_SEQUENCE_RELATIVE		0x00000001	/* sequence is relative to current */
>> +#define DRM_CRTC_SEQUENCE_NEXT_ON_MISS		0x00000002	/* Use next sequence if we've missed */
>> +#define DRM_CRTC_SEQUENCE_FIRST_PIXEL_OUT	0x00000004	/* Signal when first pixel is displayed */
>
> Note that right now vblank events are defined as:
> - The even will be delivered "somewhen" around vblank (right before up to
>   first pixel are all things current drivers implement).
> - An atomic update or pageflip ioctl call right after a vblank event will
>   hit (assuming no stalls) sequence + 1. radeon/amdgpu have some sw hacks
>   to handle this because their vblank event gets delivered before the last
>   possible time to update the next frame.
> - The timestamp is corrected to be top-of-frame.
>
> Would be a good time to document this a bit better, and might not exactly
> match what vk expects ...

(NEXT_ON_MISS is not used by the new Vulkan code; I added it only to keep
compatibility with the old API, in case we want to switch someday).

FIRST_PIXEL_OUT is an attempt to signal to the kernel that the
application really wants to see the event when the first pixel hits the
display. I assume the important thing here is the timestamp in the
event and not the actual delivery, but I don't actually know that.

If the timestamp is the only important thing, it sounds like the kernel
already satisfies that, which is cool.

If Vulkan really wants the event to be delivered when the first pixel is
displayed, then having this bit in the ioctl means we can let drivers
continue to do whatever they are now when the bit isn't set, but try
harder to deliver the event at first-pixel when requested.

So, I think what I want to do is leave the bit in the request so that
drivers can at least see what user space is asking for, and if we learn
that it's important to deliver the event at the requested time, we can
go fix drivers later.

-- 
-keith

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: "Keith Packard" <keithp@keithp.com>
To: Daniel Vetter <daniel@ffwll.ch>
Cc: Dave Airlie <airlied@redhat.com>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] drm: Add CRTC_GET_SEQUENCE and CRTC_QUEUE_SEQUENCE ioctls [v2]
Date: Sat, 05 Aug 2017 23:32:39 -0400	[thread overview]
Message-ID: <87r2wpfk14.fsf@keithp.com> (raw)
In-Reply-To: <20170802092505.ynlpy6dxf3lxziim@phenom.ffwll.local>


[-- Attachment #1.1: Type: text/plain, Size: 3974 bytes --]

Daniel Vetter <daniel@ffwll.ch> writes:

> Since I missed all the details Michel spotted, so I'll defer to his r-b.
> Also, before merging we need the userspace user. Do we have e.g.
> -modesetting patch for this, fully reviewed&ready for merging, just as
> demonstration?

Well, given that we'll have to keep the old API around for older
kernels, at least for a decade or so, I'm not sure why we'd actually
want that anytime soon, if ever? I guess it does provide 64-bit sequence
numbers, which Present wants?

> This way we could land this before the lease stuff for the
> vk extension is all solid&ready.

Do you think there's a pile more work to be done for the lease changes
in the kernel? Or are you just trying to separate the work flows?

I can go re-write the modesetting present support to use this new API
and use that for testing the kernel, if you think that would help move
the kernel bits along.

>> +	drm_modeset_lock(&crtc->mutex, NULL);
>> +	if (crtc->state)
>> +		get_seq->active = crtc->state->enable;
>> +	else
>> +		get_seq->active = crtc->enabled;
>> +	drm_modeset_unlock(&crtc->mutex);
>
> This is really heavywheight, given the lockless dance we attempt above.
> Also, when the crtc is off the vblank_get will fail, so you never get
> here. I guess my idea wasn't all that useful and well-thought out, or we
> need to be a bit more clever about this. To fix this we need to continue
> even when vblank_get fails (but only call vblank_put if ret == 0 ofc). And
> to avoid the locking you can use READ_ONCE(vblank->enabled) instead.

So, in reality, the client can more-or-less tell that the crtc is
disabled because the call fails? Sounds like I can just remove the
little dance to get the CRTC enabled state entirely. I don't understand
your comment about READ_ONCE(vblank->enabled); that doesn't relate to
the crtc enabled state, I don't think?

>> +
>> +/* Queue event to be delivered at specified sequence */
>> +
>> +#define DRM_CRTC_SEQUENCE_RELATIVE		0x00000001	/* sequence is relative to current */
>> +#define DRM_CRTC_SEQUENCE_NEXT_ON_MISS		0x00000002	/* Use next sequence if we've missed */
>> +#define DRM_CRTC_SEQUENCE_FIRST_PIXEL_OUT	0x00000004	/* Signal when first pixel is displayed */
>
> Note that right now vblank events are defined as:
> - The even will be delivered "somewhen" around vblank (right before up to
>   first pixel are all things current drivers implement).
> - An atomic update or pageflip ioctl call right after a vblank event will
>   hit (assuming no stalls) sequence + 1. radeon/amdgpu have some sw hacks
>   to handle this because their vblank event gets delivered before the last
>   possible time to update the next frame.
> - The timestamp is corrected to be top-of-frame.
>
> Would be a good time to document this a bit better, and might not exactly
> match what vk expects ...

(NEXT_ON_MISS is not used by the new Vulkan code; I added it only to keep
compatibility with the old API, in case we want to switch someday).

FIRST_PIXEL_OUT is an attempt to signal to the kernel that the
application really wants to see the event when the first pixel hits the
display. I assume the important thing here is the timestamp in the
event and not the actual delivery, but I don't actually know that.

If the timestamp is the only important thing, it sounds like the kernel
already satisfies that, which is cool.

If Vulkan really wants the event to be delivered when the first pixel is
displayed, then having this bit in the ioctl means we can let drivers
continue to do whatever they are now when the bit isn't set, but try
harder to deliver the event at first-pixel when requested.

So, I think what I want to do is leave the bit in the request so that
drivers can at least see what user space is asking for, and if we learn
that it's important to deliver the event at the requested time, we can
go fix drivers later.

-- 
-keith

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

  reply	other threads:[~2017-08-06  5:42 UTC|newest]

Thread overview: 82+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-05 22:10 [PATCH 0/3] drm: Add CRTC-id based ioctls for vblank query/event Keith Packard
2017-07-05 22:10 ` Keith Packard
2017-07-05 22:10 ` [PATCH 1/3] drm: Widen vblank count to 64 bits. Change vblank time precision to ns Keith Packard
2017-07-05 22:10   ` Keith Packard
2017-07-06  7:19   ` Daniel Vetter
2017-07-06  7:19     ` Daniel Vetter
2017-07-06 14:59     ` Keith Packard
2017-07-06 14:59       ` Keith Packard
2017-07-07 12:16       ` Daniel Vetter
2017-07-07 12:16         ` Daniel Vetter
2017-07-25 20:54         ` Keith Packard
2017-07-25 20:54           ` Keith Packard
2017-07-06  7:45   ` Michel Dänzer
2017-07-06  7:45     ` Michel Dänzer
2017-07-06  8:05     ` Michel Dänzer
2017-07-06  8:05       ` Michel Dänzer
2017-07-06 15:11       ` Keith Packard
2017-07-06 15:04     ` Keith Packard
2017-07-06 15:04       ` Keith Packard
2017-07-07  1:34       ` Michel Dänzer
2017-07-07  1:34         ` Michel Dänzer
2017-07-07  2:05         ` Michel Dänzer
2017-07-07  2:05           ` Michel Dänzer
2017-07-05 22:10 ` [PATCH 2/3] drm: Reorganize drm_pending_event to support future event types Keith Packard
2017-07-05 22:10   ` Keith Packard
2017-07-06  7:30   ` Daniel Vetter
2017-07-06 15:36     ` Keith Packard
2017-07-06 15:36       ` Keith Packard
2017-07-07 12:05       ` Daniel Vetter
2017-07-07 12:05         ` Daniel Vetter
2017-07-05 22:10 ` [PATCH 3/3] drm: Add CRTC_GET_SEQUENCE and CRTC_QUEUE_SEQUENCE ioctls Keith Packard
2017-07-05 22:10   ` Keith Packard
2017-07-06  7:53   ` Daniel Vetter
2017-07-06 10:16     ` Ville Syrjälä
2017-07-06 10:16       ` Ville Syrjälä
2017-07-06 11:04       ` Daniel Vetter
2017-07-06 14:08         ` Ville Syrjälä
2017-07-06 16:28           ` Keith Packard
2017-07-06 16:28             ` Keith Packard
2017-07-06 17:59             ` Ville Syrjälä
2017-07-06 17:59               ` Ville Syrjälä
2017-07-06 18:22               ` Keith Packard
2017-07-06 18:22                 ` Keith Packard
2017-07-06 18:59                 ` Ville Syrjälä
2017-07-06 18:59                   ` Ville Syrjälä
2017-07-06 19:46                   ` Keith Packard
2017-07-06 19:46                     ` Keith Packard
2017-07-06 16:27     ` Keith Packard
2017-07-06 16:27       ` Keith Packard
2017-07-06 21:49       ` Daniel Vetter
2017-07-06 21:49         ` Daniel Vetter
2017-08-01  5:03 ` [PATCH 0/3] drm: Add CRTC-id based ioctls for vblank query/event Keith Packard
2017-08-01  5:03   ` Keith Packard
2017-08-01  5:03   ` [PATCH 1/3] drm: Widen vblank UAPI to 64 bits. Change vblank time to ktime_t [v2] Keith Packard
2017-08-01  5:03     ` Keith Packard
2017-08-02  8:53     ` Daniel Vetter
2017-08-02  8:53       ` Daniel Vetter
2017-08-02  9:41       ` Michel Dänzer
2017-08-02  9:41         ` Michel Dänzer
2017-08-06 17:35       ` Keith Packard
2017-08-06 17:35         ` Keith Packard
2017-08-01  5:03   ` [PATCH 2/3] drm: Reorganize drm_pending_event to support future event types [v2] Keith Packard
2017-08-02  9:05     ` Daniel Vetter
2017-08-01  5:03   ` [PATCH 3/3] drm: Add CRTC_GET_SEQUENCE and CRTC_QUEUE_SEQUENCE ioctls [v2] Keith Packard
2017-08-01  5:03     ` Keith Packard
2017-08-02  9:25     ` Daniel Vetter
2017-08-02  9:25       ` Daniel Vetter
2017-08-06  3:32       ` Keith Packard [this message]
2017-08-06  3:32         ` Keith Packard
2017-08-07  3:02         ` Michel Dänzer
2017-08-07  3:02           ` Michel Dänzer
2017-08-07  8:34         ` Daniel Vetter
2017-08-07  8:34           ` Daniel Vetter
2017-10-09 17:18           ` Keith Packard
2017-10-09 17:18             ` Keith Packard
2017-10-10  8:55             ` Daniel Vetter
2017-10-10  8:55               ` Daniel Vetter
2017-08-02  9:45     ` Michel Dänzer
2017-08-06  3:42       ` Keith Packard
2017-08-06  3:42         ` Keith Packard
2017-08-07  3:03         ` Michel Dänzer
2017-08-07  3:03           ` Michel Dänzer

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=87r2wpfk14.fsf@keithp.com \
    --to=keithp@keithp.com \
    --cc=airlied@redhat.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    /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.