[Intel-gfx] [PATCH v7 09/11] drm: uevent for connector status change

Daniel Vetter daniel.vetter at ffwll.ch
Tue May 14 14:34:01 UTC 2019


On Tue, May 14, 2019 at 3:36 PM Pekka Paalanen <ppaalanen at gmail.com> wrote:
>
> On Tue, 14 May 2019 13:02:09 +0200
> Daniel Vetter <daniel.vetter at ffwll.ch> wrote:
>
> > On Tue, May 14, 2019 at 10:18 AM Ser, Simon <simon.ser at intel.com> wrote:
> > >
> > > On Tue, 2019-05-14 at 11:02 +0300, Pekka Paalanen wrote:
> > > > On Mon, 13 May 2019 11:34:58 +0200
> > > > Daniel Vetter <daniel.vetter at ffwll.ch> wrote:
> > > >
> > > > > On Mon, May 13, 2019 at 11:02 AM Paul Kocialkowski
> > > > > <paul.kocialkowski at bootlin.com> wrote:
> > > > > > Hi,
> > > > > >
> > > > > > On Fri, 2019-05-10 at 16:54 +0200, Daniel Vetter wrote:
> > > > > > > On Fri, May 10, 2019 at 2:12 PM Paul Kocialkowski
> > > > > > > <paul.kocialkowski at bootlin.com> wrote:
> > > > > > > > Hi,
> > > > > > > >
> > > > > > > > On Tue, 2019-05-07 at 21:57 +0530, Ramalingam C wrote:
> > > > > > > > > DRM API for generating uevent for a status changes of connector's
> > > > > > > > > property.
> > > > > > > > >
> > > > > > > > > This uevent will have following details related to the status change:
> > > > > > > > >
> > > > > > > > >   HOTPLUG=1, CONNECTOR=<connector_id> and PROPERTY=<property_id>
> > > > > > > > >
> > > > > > > > > Need ACK from this uevent from userspace consumer.
> > > > > > > >
> > > > > > > > So we just had some discussions over on IRC and at about the hotplug
> > > > > > > > issue and came up with similar ideas:
> > > > > > > > https://lists.freedesktop.org/archives/dri-devel/2019-May/217408.html
> > > > > > > >
> > > > > > > > The conclusions of these discussions so far would be to have a more or
> > > > > > > > less fine grain of uevent reporting depending on what happened. The
> > > > > > > > point is that we need to cover different cases:
> > > > > > > > - one or more properties changed;
> > > > > > > > - the connector status changed;
> > > > > > > > - something else about the connector changed (e.g. EDID/modes)
> > > > > > > >
> > > > > > > > For the first case, we can send out:
> > > > > > > > HOTPLUG=1
> > > > > > > > CONNECTOR=<id>
> > > > > > > > PROPERTY=<id>
> > > > > > > >
> > > > > > > > and no reprobe is required.
> > > > > > > >
> > > > > > > > For the second one, something like:
> > > > > > > > HOTPLUG=1
> > > > > > > > CONNECTOR=<id>
> > > > > > > > STATUS=Connected/Disconnected
> > > > > > > >
> > > > > > > > and a connector probe is needed for connected, but not for
> > > > > > > > disconnected;
> > > > > > > >
> > > > > > > > For the third one, we can only indicate the connector:
> > > > > > > > HOTPLUG=1
> > > > > > > > CONNECTOR=<id>
> > > > > > > >
> > > > > > > > and a reprobe of the connector is always needed
> > > > > > >
> > > > > > > There's no material difference between this one and the previous one.
> > > > > > > Plus there's no beenfit in supplying the actual value of the property,
> > > > > > > i.e. we can reuse the same PROPERTY=<id-of-status-property> trick.
> > > > > >
> > > > > > That's the idea, but we need to handle status changes differently than
> > > > > > properties, since as far as I know, connected/unconnected status is not
> > > > > > exposed as a prop for the connector.
> > > > >
> > > > > Oops, totally missed that. "Everything is a property" is kinda
> > > > > new-ish, at least compared to kms. Kinda tempted to just make status
> > > > > into a property. Or another excuse why we should expose the epoch
> > > > > property :-)
> > > >
> > > > 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"

Furthermore different property can indicate different kind of updates,
e.g. hdcp vs general sink change vs. whatever else might come in the
future.

> 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).

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.

> 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.

> 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.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


More information about the Intel-gfx mailing list