All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel.vetter@ffwll.ch>
To: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Cc: David Airlie <airlied@linux.ie>,
	Maxime Ripard <maxime.ripard@bootlin.com>,
	intel-gfx <intel-gfx@lists.freedesktop.org>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	Gwan-gyeong Mun <gwan-gyeong.mun@intel.com>,
	"Ser, Simon" <simon.ser@intel.com>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	Daniel Vetter <daniel.vetter@intel.com>,
	Sean Paul <sean@poorly.run>
Subject: Re: [PATCH v7 09/11] drm: uevent for connector status change
Date: Fri, 10 May 2019 16:54:10 +0200	[thread overview]
Message-ID: <CAKMK7uEwHZ=As3B4z+WZ1fyd2yP5Krg3hVzfCcCAtv3jOxmTrA@mail.gmail.com> (raw)
In-Reply-To: <31dad9a323382628911c5301a6eec179855aa815.camel@bootlin.com>

On Fri, May 10, 2019 at 2:12 PM Paul Kocialkowski
<paul.kocialkowski@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.
Here's why:
- A side effect of forcing a probe on a connector is that you get to
read all the properties, so supplying them is kinda pointless.
- You can read STATUS without forcing a reprobe, if you want to avoid
the reprobe for disconnected. I'd kinda not recommend that though,
feels a bit like overoptimizing. And for reasonable connectors (i.e.
dp) reprobing a disconnected output is fast. HDMI is ... less
reasonable unfortunately, but oh well.
- There's no way to only reprobe status, you can only ever reprobe
everything with the current ioctl and implementations. Having an
option to reprobe only parts of it doesn't seem useful to me (we need
to read the EDID anyway, and that's the expensive part of reprobing in
almost all cases).

In a way PROPERTY=<status-prop-id> simply tells userspace that it
needs to reprobe this connector.

At that point we need to figure out whether this is a good uapi or
not, and that's where the epoch comes in. There's two reasons for an
epoch:
- We need it internally because I'm not goinig to wire a new return
value through hundreds of connector probe functions. It's much easier
to have an epoch counter which we set from e.g. drm_set_edid and
similar functions that update probe state.
- If userspace misses an event and there's no epoch, we're forcing
userspace to reprobe everything. Use case would be if a compositor is
switched away we probably don't want to piss of the current compositor
by blocking it's own probe kernel calls by doing our own (probe is
single-threaded in the kernel through the dev->mode_config.mutex). If
it can read the epoch property (which it can do without forcing a
reprobe) userspace would know which connectors it needs to check and
reprobe.

Hence why epoch, it's a bit more robust userspace api. Ofc you could
also require that userspace needs to keep parsing all uevents and make
a list of all connectors it needs to reprobe when it's back to being
the active compositor. But just comparing a current epoch with the one
you cached from the last full probe is much easier.

Another thing: None of this we can for connectors with unreliable hdp.
Or at least you'll piss of users if you cache always. The sad thing is
that HDMI is unreliable, at least on some machines/screen combos (you
never get a hpd irq if you plug in/unplug). So real compositors still
need to reprobe when the user asks for it. igt can probably get away
without reprobing.
-Daniel

> Then we still have the legacy case:
> HOTPLUG=1
>
> where userspace is expected to reprobe all the connectors.
>
> I think this would deserve to be a separate series on its own. So I am
> proposing to take this one off your plate and come up with another
> seres implementing this proposal. What do you think?
>
> Cheers,
>
> Paul
>
> > v2:
> >   Minor fixes at KDoc comments [Daniel]
> > v3:
> >   Check the property is really attached with connector [Daniel]
> >
> > Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
> > Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> > ---
> >  drivers/gpu/drm/drm_sysfs.c | 35 +++++++++++++++++++++++++++++++++++
> >  include/drm/drm_sysfs.h     |  5 ++++-
> >  2 files changed, 39 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
> > index 18b1ac442997..63fa951a20db 100644
> > --- a/drivers/gpu/drm/drm_sysfs.c
> > +++ b/drivers/gpu/drm/drm_sysfs.c
> > @@ -21,6 +21,7 @@
> >  #include <drm/drm_sysfs.h>
> >  #include <drm/drmP.h>
> >  #include "drm_internal.h"
> > +#include "drm_crtc_internal.h"
> >
> >  #define to_drm_minor(d) dev_get_drvdata(d)
> >  #define to_drm_connector(d) dev_get_drvdata(d)
> > @@ -320,6 +321,9 @@ void drm_sysfs_lease_event(struct drm_device *dev)
> >   * Send a uevent for the DRM device specified by @dev.  Currently we only
> >   * set HOTPLUG=1 in the uevent environment, but this could be expanded to
> >   * deal with other types of events.
> > + *
> > + * Any new uapi should be using the drm_sysfs_connector_status_event()
> > + * for uevents on connector status change.
> >   */
> >  void drm_sysfs_hotplug_event(struct drm_device *dev)
> >  {
> > @@ -332,6 +336,37 @@ void drm_sysfs_hotplug_event(struct drm_device *dev)
> >  }
> >  EXPORT_SYMBOL(drm_sysfs_hotplug_event);
> >
> > +/**
> > + * drm_sysfs_connector_status_event - generate a DRM uevent for connector
> > + * property status change
> > + * @connector: connector on which property status changed
> > + * @property: connector property whoes status changed.
> > + *
> > + * Send a uevent for the DRM device specified by @dev.  Currently we
> > + * set HOTPLUG=1 and connector id along with the attached property id
> > + * related to the status change.
> > + */
> > +void drm_sysfs_connector_status_event(struct drm_connector *connector,
> > +                                   struct drm_property *property)
> > +{
> > +     struct drm_device *dev = connector->dev;
> > +     char hotplug_str[] = "HOTPLUG=1", conn_id[30], prop_id[30];
> > +     char *envp[4] = { hotplug_str, conn_id, prop_id, NULL };
> > +
> > +     WARN_ON(!drm_mode_obj_find_prop_id(&connector->base,
> > +                                        property->base.id));
> > +
> > +     snprintf(conn_id, ARRAY_SIZE(conn_id),
> > +              "CONNECTOR=%u", connector->base.id);
> > +     snprintf(prop_id, ARRAY_SIZE(prop_id),
> > +              "PROPERTY=%u", property->base.id);
> > +
> > +     DRM_DEBUG("generating connector status event\n");
> > +
> > +     kobject_uevent_env(&dev->primary->kdev->kobj, KOBJ_CHANGE, envp);
> > +}
> > +EXPORT_SYMBOL(drm_sysfs_connector_status_event);
> > +
> >  static void drm_sysfs_release(struct device *dev)
> >  {
> >       kfree(dev);
> > diff --git a/include/drm/drm_sysfs.h b/include/drm/drm_sysfs.h
> > index 4f311e836cdc..d454ef617b2c 100644
> > --- a/include/drm/drm_sysfs.h
> > +++ b/include/drm/drm_sysfs.h
> > @@ -4,10 +4,13 @@
> >
> >  struct drm_device;
> >  struct device;
> > +struct drm_connector;
> > +struct drm_property;
> >
> >  int drm_class_device_register(struct device *dev);
> >  void drm_class_device_unregister(struct device *dev);
> >
> >  void drm_sysfs_hotplug_event(struct drm_device *dev);
> > -
> > +void drm_sysfs_connector_status_event(struct drm_connector *connector,
> > +                                   struct drm_property *property);
> >  #endif
> --
> Paul Kocialkowski, Bootlin
> Embedded Linux and kernel engineering
> https://bootlin.com
>


-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2019-05-10 14:54 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-07 16:27 [PATCH v7 00/11] HDCP2.2 Phase II Ramalingam C
2019-05-07 16:27 ` [PATCH v7 01/11] drm: move content protection property to mode_config Ramalingam C
2019-05-07 16:27 ` [PATCH v7 02/11] drm/i915: debugfs: HDCP2.2 capability read Ramalingam C
2019-05-07 16:27 ` [PATCH v7 03/11] drm: generic fn converting be24 to cpu and vice versa Ramalingam C
2019-05-07 16:27 ` [PATCH v7 04/11] drm: revocation check at drm subsystem Ramalingam C
2019-07-04 10:53   ` Pekka Paalanen
2019-09-12  0:15   ` Harry Wentland
2019-09-12  1:14     ` Deucher, Alexander
2019-09-12  6:54     ` Ramalingam C
2019-09-12 15:49       ` Harry Wentland
2019-05-07 16:27 ` [PATCH v7 05/11] drm/i915: SRM revocation check for HDCP1.4 and 2.2 Ramalingam C
2019-05-07 16:27 ` [PATCH v7 06/11] drm/hdcp: gathering hdcp related code into drm_hdcp.c Ramalingam C
2019-05-07 16:27 ` [PATCH v7 07/11] drm: Add Content protection type property Ramalingam C
2019-07-04 11:11   ` Pekka Paalanen
2019-07-04 10:36     ` Ramalingam C
2019-07-05 13:00       ` Pekka Paalanen
2019-07-05  6:33         ` Ramalingam C
2019-07-05 14:12           ` Pekka Paalanen
2019-05-07 16:27 ` [PATCH v7 08/11] drm/i915: Attach content " Ramalingam C
2019-05-07 16:27 ` [PATCH v7 09/11] drm: uevent for connector status change Ramalingam C
2019-05-10 12:12   ` Paul Kocialkowski
2019-05-10 14:54     ` Daniel Vetter [this message]
2019-05-13  9:02       ` Paul Kocialkowski
2019-05-13  9:34         ` Daniel Vetter
2019-05-13 10:11           ` Ser, Simon
2019-05-13 15:04             ` Daniel Vetter
2019-05-14  6:18               ` Ser, Simon
2019-05-13 17:14           ` Paul Kocialkowski
2019-05-14 11:09             ` Daniel Vetter
2019-05-14 14:12               ` Paul Kocialkowski
2019-05-14 14:28                 ` Daniel Vetter
2019-05-15  7:43                   ` Paul Kocialkowski
2019-05-15  7:48                     ` Daniel Vetter
2019-05-14  8:02           ` Pekka Paalanen
2019-05-14  8:18             ` Ser, Simon
2019-05-14 11:02               ` Daniel Vetter
2019-05-14 13:36                 ` Pekka Paalanen
2019-05-14 13:58                   ` Paul Kocialkowski
2019-05-14 14:34                   ` Daniel Vetter
2019-05-15  7:37                     ` Pekka Paalanen
2019-05-15  7:49                       ` Paul Kocialkowski
2019-05-15  8:24                       ` Daniel Vetter
2019-05-16  8:22                         ` Pekka Paalanen
2019-05-16 12:24                           ` Daniel Vetter
2019-05-17 10:08                             ` Pekka Paalanen
2019-05-20 16:11                               ` Daniel Vetter
2019-05-20 16:24                                 ` Paul Kocialkowski
2019-05-21  6:55                                 ` Pekka Paalanen
2019-05-21  7:52                                   ` Daniel Vetter
2019-05-21  9:01                                     ` Pekka Paalanen
2019-05-21  9:42                                       ` Daniel Vetter
2019-06-03  9:50                                     ` Michel Dänzer
2019-06-03 15:08                                       ` Daniel Vetter
2019-06-03 15:19                                         ` Ser, Simon
2019-06-04  7:06                                           ` Pekka Paalanen
2019-05-13 21:20     ` Lyude Paul
2019-05-14 11:12       ` Daniel Vetter
2019-07-04 11:12   ` Pekka Paalanen
2019-07-04 10:42     ` Ramalingam C
2019-07-05 13:36       ` Pekka Paalanen
2019-05-07 16:27 ` [PATCH v7 10/11] drm/hdcp: update content protection property with uevent Ramalingam C
2019-07-04 11:14   ` Pekka Paalanen
2019-07-04 11:11     ` Ramalingam C
2019-07-05 13:59       ` Pekka Paalanen
2019-07-04 23:51     ` Ramalingam C
2019-05-07 16:27 ` [PATCH v7 11/11] drm/i915: update the hdcp state " Ramalingam C
2019-05-07 16:45 ` ✗ Fi.CI.CHECKPATCH: warning for HDCP2.2 Phase II (rev9) Patchwork
2019-05-07 16:52 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-05-07 17:37 ` ✓ Fi.CI.BAT: success " Patchwork
2019-05-08  0:41 ` ✓ Fi.CI.IGT: " Patchwork

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='CAKMK7uEwHZ=As3B4z+WZ1fyd2yP5Krg3hVzfCcCAtv3jOxmTrA@mail.gmail.com' \
    --to=daniel.vetter@ffwll.ch \
    --cc=airlied@linux.ie \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gwan-gyeong.mun@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=maxime.ripard@bootlin.com \
    --cc=paul.kocialkowski@bootlin.com \
    --cc=sean@poorly.run \
    --cc=simon.ser@intel.com \
    --cc=thomas.petazzoni@bootlin.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 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.