linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/sysfs: Expose DRM connector id in each connector sysfs
@ 2023-03-29  1:44 Won Chung
  2023-04-17 22:52 ` Manasi Navare
  0 siblings, 1 reply; 3+ messages in thread
From: Won Chung @ 2023-03-29  1:44 UTC (permalink / raw)
  To: wonchung, bleung, pmalani, heikki.krogerus, imre.deak,
	maarten.lankhorst, mripard, tzimmermann, airlied, daniel,
	jani.nikula, gildekel, seanpaul, dri-devel, linux-kernel

Expose DRM connector id in device sysfs so that we can map the connector
id to the connector syspath. Currently, even if we can derive the
connector id from modeset, we do not have a way to find the
corresponding connector's syspath.

This is helpful when determining the root connector of MST tree. When a
tree of multiple MST hub is connected to the system, modeset describes
the tree in the PATH blob. For example, consider the following scenario.

+-------------+
| Source      |    +-------------+
| (Device)    |    | BranchX     |
|             |    | (MST)       |
|       [conn6]--->|       [port1]--->DisplayA
+-------------+    |             |
                   |             |    +-------------+
                   |             |    | BranchY     |
                   |             |    | (MST)       |
                   |       [port2]--->|       [port1]----->DisplayB
                   +-------------+    |             |
                                      |       [port2]----->DisplayC
                                      +-------------+

DPMST connector of DisplayA would have "mst:6-1" PATH.
DPMST connector of DisplayB would have "mst:6-2-1" PATH.
DPMST connector of DisplayC would have "mst:6-2-2" PATH.

Given that connector id of 6 is the root of the MST connector tree, we
can utilize this patch to parse through DRM connectors sysfs and find
which connector syspath corresponds to the root connector (id == 6).

ChromeOS intend to use this information for metrics collection. For
example, we want to tell which port is deriving which displays even with
a MST hub. Chromium patch for parsing DRM connector id from the kernel
is at http://crrev.com/c/4317207.

Signed-off-by: Won Chung <wonchung@google.com>
---
 drivers/gpu/drm/drm_sysfs.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index 183130355997..11f98c5d6103 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -282,16 +282,27 @@ static ssize_t modes_show(struct device *device,
 	return written;
 }
 
+static ssize_t connector_id_show(struct device *device,
+				 struct device_attribute *attr,
+				 char *buf)
+{
+	struct drm_connector *connector = to_drm_connector(device);
+
+	return sysfs_emit(buf, "%d\n", connector->base.id);
+}
+
 static DEVICE_ATTR_RW(status);
 static DEVICE_ATTR_RO(enabled);
 static DEVICE_ATTR_RO(dpms);
 static DEVICE_ATTR_RO(modes);
+static DEVICE_ATTR_RO(connector_id);
 
 static struct attribute *connector_dev_attrs[] = {
 	&dev_attr_status.attr,
 	&dev_attr_enabled.attr,
 	&dev_attr_dpms.attr,
 	&dev_attr_modes.attr,
+	&dev_attr_connector_id.attr,
 	NULL
 };
 
-- 
2.40.0.348.gf938b09366-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/sysfs: Expose DRM connector id in each connector sysfs
  2023-03-29  1:44 [PATCH] drm/sysfs: Expose DRM connector id in each connector sysfs Won Chung
@ 2023-04-17 22:52 ` Manasi Navare
  2023-04-28 20:31   ` Manasi Navare
  0 siblings, 1 reply; 3+ messages in thread
From: Manasi Navare @ 2023-04-17 22:52 UTC (permalink / raw)
  To: Won Chung
  Cc: bleung, pmalani, heikki.krogerus, imre.deak, maarten.lankhorst,
	mripard, tzimmermann, airlied, daniel, jani.nikula, gildekel,
	seanpaul, dri-devel, linux-kernel

On Tue, Mar 28, 2023 at 6:45 PM Won Chung <wonchung@google.com> wrote:
>
> Expose DRM connector id in device sysfs so that we can map the connector
> id to the connector syspath. Currently, even if we can derive the
> connector id from modeset, we do not have a way to find the
> corresponding connector's syspath.
>
> This is helpful when determining the root connector of MST tree. When a
> tree of multiple MST hub is connected to the system, modeset describes
> the tree in the PATH blob. For example, consider the following scenario.
>
> +-------------+
> | Source      |    +-------------+
> | (Device)    |    | BranchX     |
> |             |    | (MST)       |
> |       [conn6]--->|       [port1]--->DisplayA
> +-------------+    |             |
>                    |             |    +-------------+
>                    |             |    | BranchY     |
>                    |             |    | (MST)       |
>                    |       [port2]--->|       [port1]----->DisplayB
>                    +-------------+    |             |
>                                       |       [port2]----->DisplayC
>                                       +-------------+
>
> DPMST connector of DisplayA would have "mst:6-1" PATH.
> DPMST connector of DisplayB would have "mst:6-2-1" PATH.
> DPMST connector of DisplayC would have "mst:6-2-2" PATH.
>
> Given that connector id of 6 is the root of the MST connector tree, we
> can utilize this patch to parse through DRM connectors sysfs and find
> which connector syspath corresponds to the root connector (id == 6).
>
> ChromeOS intend to use this information for metrics collection. For
> example, we want to tell which port is deriving which displays even with
> a MST hub. Chromium patch for parsing DRM connector id from the kernel
> is at http://crrev.com/c/4317207.
>
> Signed-off-by: Won Chung <wonchung@google.com>

Exposing connector id in device sysfs looks good to me.

Reviewed-by: Manasi Navare <navaremanasi@chromium.org>

Manasi

> ---
>  drivers/gpu/drm/drm_sysfs.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
> index 183130355997..11f98c5d6103 100644
> --- a/drivers/gpu/drm/drm_sysfs.c
> +++ b/drivers/gpu/drm/drm_sysfs.c
> @@ -282,16 +282,27 @@ static ssize_t modes_show(struct device *device,
>         return written;
>  }
>
> +static ssize_t connector_id_show(struct device *device,
> +                                struct device_attribute *attr,
> +                                char *buf)
> +{
> +       struct drm_connector *connector = to_drm_connector(device);
> +
> +       return sysfs_emit(buf, "%d\n", connector->base.id);
> +}
> +
>  static DEVICE_ATTR_RW(status);
>  static DEVICE_ATTR_RO(enabled);
>  static DEVICE_ATTR_RO(dpms);
>  static DEVICE_ATTR_RO(modes);
> +static DEVICE_ATTR_RO(connector_id);
>
>  static struct attribute *connector_dev_attrs[] = {
>         &dev_attr_status.attr,
>         &dev_attr_enabled.attr,
>         &dev_attr_dpms.attr,
>         &dev_attr_modes.attr,
> +       &dev_attr_connector_id.attr,
>         NULL
>  };
>
> --
> 2.40.0.348.gf938b09366-goog
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/sysfs: Expose DRM connector id in each connector sysfs
  2023-04-17 22:52 ` Manasi Navare
@ 2023-04-28 20:31   ` Manasi Navare
  0 siblings, 0 replies; 3+ messages in thread
From: Manasi Navare @ 2023-04-28 20:31 UTC (permalink / raw)
  To: Won Chung
  Cc: bleung, pmalani, heikki.krogerus, imre.deak, maarten.lankhorst,
	mripard, tzimmermann, airlied, daniel, jani.nikula, gildekel,
	seanpaul, dri-devel, linux-kernel

Hi Won,

Thanks for the patch, I have now merged to drm-misc-next

Regards
Manasi

On Mon, Apr 17, 2023 at 3:52 PM Manasi Navare <navaremanasi@google.com> wrote:
>
> On Tue, Mar 28, 2023 at 6:45 PM Won Chung <wonchung@google.com> wrote:
> >
> > Expose DRM connector id in device sysfs so that we can map the connector
> > id to the connector syspath. Currently, even if we can derive the
> > connector id from modeset, we do not have a way to find the
> > corresponding connector's syspath.
> >
> > This is helpful when determining the root connector of MST tree. When a
> > tree of multiple MST hub is connected to the system, modeset describes
> > the tree in the PATH blob. For example, consider the following scenario.
> >
> > +-------------+
> > | Source      |    +-------------+
> > | (Device)    |    | BranchX     |
> > |             |    | (MST)       |
> > |       [conn6]--->|       [port1]--->DisplayA
> > +-------------+    |             |
> >                    |             |    +-------------+
> >                    |             |    | BranchY     |
> >                    |             |    | (MST)       |
> >                    |       [port2]--->|       [port1]----->DisplayB
> >                    +-------------+    |             |
> >                                       |       [port2]----->DisplayC
> >                                       +-------------+
> >
> > DPMST connector of DisplayA would have "mst:6-1" PATH.
> > DPMST connector of DisplayB would have "mst:6-2-1" PATH.
> > DPMST connector of DisplayC would have "mst:6-2-2" PATH.
> >
> > Given that connector id of 6 is the root of the MST connector tree, we
> > can utilize this patch to parse through DRM connectors sysfs and find
> > which connector syspath corresponds to the root connector (id == 6).
> >
> > ChromeOS intend to use this information for metrics collection. For
> > example, we want to tell which port is deriving which displays even with
> > a MST hub. Chromium patch for parsing DRM connector id from the kernel
> > is at http://crrev.com/c/4317207.
> >
> > Signed-off-by: Won Chung <wonchung@google.com>
>
> Exposing connector id in device sysfs looks good to me.
>
> Reviewed-by: Manasi Navare <navaremanasi@chromium.org>
>
> Manasi
>
> > ---
> >  drivers/gpu/drm/drm_sysfs.c | 11 +++++++++++
> >  1 file changed, 11 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
> > index 183130355997..11f98c5d6103 100644
> > --- a/drivers/gpu/drm/drm_sysfs.c
> > +++ b/drivers/gpu/drm/drm_sysfs.c
> > @@ -282,16 +282,27 @@ static ssize_t modes_show(struct device *device,
> >         return written;
> >  }
> >
> > +static ssize_t connector_id_show(struct device *device,
> > +                                struct device_attribute *attr,
> > +                                char *buf)
> > +{
> > +       struct drm_connector *connector = to_drm_connector(device);
> > +
> > +       return sysfs_emit(buf, "%d\n", connector->base.id);
> > +}
> > +
> >  static DEVICE_ATTR_RW(status);
> >  static DEVICE_ATTR_RO(enabled);
> >  static DEVICE_ATTR_RO(dpms);
> >  static DEVICE_ATTR_RO(modes);
> > +static DEVICE_ATTR_RO(connector_id);
> >
> >  static struct attribute *connector_dev_attrs[] = {
> >         &dev_attr_status.attr,
> >         &dev_attr_enabled.attr,
> >         &dev_attr_dpms.attr,
> >         &dev_attr_modes.attr,
> > +       &dev_attr_connector_id.attr,
> >         NULL
> >  };
> >
> > --
> > 2.40.0.348.gf938b09366-goog
> >

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-04-28 20:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-29  1:44 [PATCH] drm/sysfs: Expose DRM connector id in each connector sysfs Won Chung
2023-04-17 22:52 ` Manasi Navare
2023-04-28 20:31   ` Manasi Navare

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).