On Tue, 14 May 2019 16:34:01 +0200 Daniel Vetter daniel.vetter@ffwll.ch wrote:
On Tue, May 14, 2019 at 3:36 PM Pekka Paalanen ppaalanen@gmail.com wrote:
On Tue, 14 May 2019 13:02:09 +0200 Daniel Vetter daniel.vetter@ffwll.ch wrote:
On Tue, May 14, 2019 at 10:18 AM Ser, Simon simon.ser@intel.com wrote:
On Tue, 2019-05-14 at 11:02 +0300, Pekka Paalanen wrote:
...
Hi Daniel,
just to clarify the first case, specific to one very particular property:
With HDCP, there is a property that may change dynamically at runtime (the undesired/desired/enabled tristate). Userspace must be notified when it changes, I do not want userspace have to poll that property with a timer.
When that property alone changes, and userspace is prepared to handle that property changing alone, it must not trigger a reprobe of the connector. There is no reason to reprobe at that point AFAIU.
How do you ensure that userspace can avoid triggering a reprobe with the epoch approach or with any alternate uevent design?
We need an event to userspace that indicates that re-reading the properties is enough and reprobe of the connector is not necessary. This is complementary to indicating to userspace that only some connectors need to be reprobed instead of everything.
Can't you use the PROPERTY hint? If PROPERTY is the HDCP one, skip the reprobing. Would that work?
Hi,
yes, that would work, if it was acceptable to DRM upstream. The replies to Paul seemed to be going south so fast that I thought we wouldn't get any new uevent fields in favour of "epoch counters".
Yes that's the idea, depending upon which property you get you know it's a sink change (needs full reprobe) or something else like hdcp state machinery update.
Right.
Wrt avoiding the full reprobe for sink changes: I think we should indeed decouple that from the per-connector event for sink changes. That along is a good win already, since you know for which connector you need to call drmGetConnector (which forces the reprobe). It would be nice to only call drmGetConnectorCurrent (avoids the reprobe), but historically speaking every time we tried to rely on this we ended up regretting things.
What changed? This sounds very much what Paul suggested. Looking at it from userspace side:
This sounds solid, some refinements below:
HOTPLUG=1 CONNECTOR=xx PROPERTY=yy
If yy is "Content Protection", no need to drmModeGetConnector(), just re-get the connector properties.
Kernel probably shouldn't bother sending this for properties where re-probe could be necessary, and send the below instead.
I think we should assert that the kernel can get the new property values using drmModeGetConnectorCurrent for this case, i.e. the kernel does not expect a full reprobe. I.e. upgrade your idea from "should" to "must"
Hi Daniel,
ok, that's good.
Furthermore different property can indicate different kind of updates, e.g. hdcp vs general sink change vs. whatever else might come in the future.
What do you mean by different kinds of updates?
Btw. I started thinking, maybe we should completely leave out the "If yy is "Content Protection"" and require the kernel to guarantee, that if PROPERTY is set, then drmModeGetConnector() (probing) must not be necessary based on this event alone.
Writing it down again:
HOTPLUG=1 CONNECTOR=xx PROPERTY=yy
- yy denotes which connector xx property changed.
- Userspace does not need to do drmModeGetConnector(), it only needs to drmModeObjectGetProperties() on the connector to receive the new updated property values.
- Kernel must not send this event for changes that may require probing for correct results, exceptional conditions (buggy hardware, etc.) included. Instead, the kernel must send one of the below events.
Is there actually anything interesting that drmModeGetConnectorCurrent() could guaranteed correctly return that is not a property already? I'd probably leave this consideration out completely, and just say do one of the needs-probing events if anything there changed.
HOTPLUG=1 CONNECTOR=xx
- Needs to drmModeGetConnector() on the one connector, no need to probe others. Implies that one needs to re-get the connector properties as well.
Sounds good.
HOTPLUG=1
- Need to do drmModeGetResouces() to discover new/disappeared connectors, and need to drmModeGetConnector to re-probe every connector. (As always.)
Maybe we should clarify that this is also what you get when an entire connector appears/disappears (for dp mst hotplug).
Yes, that's what I wrote. :-)
Weston implements the discovery of appearing/disappearing connectors (as opposed to connecting/disconnecting connectors). Not sure anyone has ever tested it though...
Maybe we could make an additional rule that if a connector has the EPOCH property, then it does _not_ need to be reprobe for the global events. For that case userspace should only check whether there's new/removed connectors, and then probe the new ones (and disable the removed ones as needed). We can also use some other flag to indicate this if we don't add the epoch proprty.
Sounds fine to me, though I'm not too clear what the epoch property is designed to achieve. Is it about avoiding re-probing when re-gaining DRM master after having let it go, e.g. VT-switching back from another VT? That would be nice.
That should be also backwards-compatible: any userspace that doesn't understand CONNECTOR will see HOTPLUG=1 and re-probe everything. Any userspace that doesn't understand PROPERTY or the property it refers to will fall back to probing either the connector or everything.
Agreed, that should work.
Cool. The epoch exception you worded seems to fit backward-compatible as well.
I would be happy to get that behaviour into Weston, particularly as the HDCP feature is brewing for Weston too.
When discussing this in IRC, I had the concern about how uevents are delivered in userspace. Is there a possibility that they might be overwritten, contain stale attributes, or get squashed together?
Particularly if a display server is current on the VT and active and monitoring udev, but stuck doing something and cannot service uevents very fast, and the kernel sends more than one event before the process gets back to dispatching. The terminology in libudev API confused me as an event is a device. Squashing together would make sense if the uevent were just updating a device attribute list. Previously when we had just a single kind of uevent, that would not have made a difference, but if we gain different kinds of uevents like here, it starts to matter.
However, Paul came to the conclusion that we will be ok as long as the events come via netlink.
Yeah netlink shouldn't drop events on the floor I think. It might still happen, but then I think you should get an indication of that error, and you just treat it as a general hotplug event like on older kernels.
Alright, although reading Paul it sounds like there is another (fallback?) method as well that wouldn't work. Should userspace worry about that?
Hmm, get an indication of an error... I don't know how that would be presented in libudev API and I can't point to any code in Weston that would deal with it. Does anyone have a clue about that?
Userspace cannot really start taking advantage of any new fine-grained hotplug events until it can rely on the event delivery. Granted, this seems purely a userspace issue, but I bet it could be formulated as a kernel regression: things stop working after upgrading the kernel while having always used new userspace which was ready for detailed hotplug events but didn't ensure the delivery in userspace.
Thanks, pq