All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sam Ravnborg <sam@ravnborg.org>
To: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
Cc: Neil Armstrong <narmstrong@baylibre.com>,
	Maxime Ripard <maxime.ripard@bootlin.com>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
	Shawn Guo <shawnguo@kernel.org>,
	kernel@collabora.com, linux-samsung-soc@vger.kernel.org,
	Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>,
	Krzysztof Kozlowski <krzk@kernel.org>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	David Airlie <airlied@linux.ie>, Chen-Yu Tsai <wens@csie.org>,
	Kukjin Kim <kgene@kernel.org>, NXP Linux Team <linux-imx@nxp.com>,
	linux-rockchip@lists.infradead.org,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Jonas Karlman <jonas@kwiboo.se>,
	linux-arm-msm@vger.kernel.org, intel-gfx@lists.freedesktop.org,
	Jyri Sarha <jsarha@ti.com>,
	Alexios Zavras <alexios.zavras@intel.com>,
	Mamta Shukla <mamtashukla555@gmai>
Subject: Re: [PATCH v5 01/24] drm: Include ddc adapter pointer in struct drm_connector
Date: Fri, 26 Jul 2019 10:08:55 +0200	[thread overview]
Message-ID: <20190726080855.GA9143@ravnborg.org> (raw)
In-Reply-To: <20190726063759.GB6443@ravnborg.org>

Hi Andrzej.

After reading through the series a few more comments.

1) The subject of this patch could be improved.
   Consider something like:
   drm: add ddc link in sysfs created by drm_connector

   This spells out much better what the patch achieve.


2) The purpsoe of drm_connector.ddc is to provide drm_connector with
   info to create the symlink.
   Yet in many follow-up patches the drivers are changed so
   drm_connector.ddc is their only reference to struct i2c_adapter.

   But the ownership is not clear here.
   Who owns the reference to i2c_adapter - and who has the
   responsibility to call put() on the adapter.

   Looking at the conversions done then some drivers are converted
   so they only use drm_connector.ddc, and other drivers have their own
   reference to i2c_adapter.
   The latter looks like the correct solution as the ownership of the
   reference belongs to the driver and not drm_connector.

   In other words - a conversion where the drivers only assigned
   drm_connector.ddc (using drm_connector_init_with_ddc()),
   seems like a more clean design that does not mix up ownership.
   This is at least how I see it.
   I did not take this type of look at the patches before. Sorry
   for providing feedback this late.

	Sam

On Fri, Jul 26, 2019 at 08:37:59AM +0200, Sam Ravnborg wrote:
> Hi Andrzej.
> 
> Patch looks good, but one kernel-doc detail.
> 
> On Wed, Jul 24, 2019 at 03:59:23PM +0200, Andrzej Pietrasiewicz wrote:
> > Add generic code which creates symbolic links in sysfs, pointing to ddc
> > interface used by a particular video output. For example:
> > 
> > ls -l /sys/class/drm/card0-HDMI-A-1/ddc
> > lrwxrwxrwx 1 root root 0 Jun 24 10:42 /sys/class/drm/card0-HDMI-A-1/ddc \
> > 	-> ../../../../soc/13880000.i2c/i2c-2
> > 
> > This makes it easy for user to associate a display with its ddc adapter
> > and use e.g. ddcutil to control the chosen monitor.
> > 
> > This patch adds an i2c_adapter pointer to struct drm_connector. Particular
> > drivers can then use it instead of using their own private instance. If a
> > connector contains a ddc, then create a symbolic link in sysfs.
> > 
> > Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
> > Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> > Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>
> > ---
> >  drivers/gpu/drm/drm_sysfs.c |  8 ++++++++
> >  include/drm/drm_connector.h | 11 +++++++++++
> >  2 files changed, 19 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
> > index ad10810bc972..e962a9d45f7e 100644
> > --- a/drivers/gpu/drm/drm_sysfs.c
> > +++ b/drivers/gpu/drm/drm_sysfs.c
> > @@ -14,6 +14,7 @@
> >  #include <linux/err.h>
> >  #include <linux/export.h>
> >  #include <linux/gfp.h>
> > +#include <linux/i2c.h>
> >  #include <linux/kdev_t.h>
> >  #include <linux/slab.h>
> >  
> > @@ -294,6 +295,9 @@ int drm_sysfs_connector_add(struct drm_connector *connector)
> >  	/* Let userspace know we have a new connector */
> >  	drm_sysfs_hotplug_event(dev);
> >  
> > +	if (connector->ddc)
> > +		return sysfs_create_link(&connector->kdev->kobj,
> > +				 &connector->ddc->dev.kobj, "ddc");
> >  	return 0;
> >  }
> >  
> > @@ -301,6 +305,10 @@ void drm_sysfs_connector_remove(struct drm_connector *connector)
> >  {
> >  	if (!connector->kdev)
> >  		return;
> > +
> > +	if (connector->ddc)
> > +		sysfs_remove_link(&connector->kdev->kobj, "ddc");
> > +
> >  	DRM_DEBUG("removing \"%s\" from sysfs\n",
> >  		  connector->name);
> >  
> > diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
> > index 4c30d751487a..33a6fff85fdb 100644
> > --- a/include/drm/drm_connector.h
> > +++ b/include/drm/drm_connector.h
> > @@ -41,6 +41,7 @@ struct drm_property;
> >  struct drm_property_blob;
> >  struct drm_printer;
> >  struct edid;
> > +struct i2c_adapter;
> >  
> >  enum drm_connector_force {
> >  	DRM_FORCE_UNSPECIFIED,
> > @@ -1311,6 +1312,16 @@ struct drm_connector {
> >  	 * [0]: progressive, [1]: interlaced
> >  	 */
> >  	int audio_latency[2];
> > +
> > +	/**
> > +	 * @ddc: associated ddc adapter.
> > +	 * A connector usually has its associated ddc adapter. If a driver uses
> > +	 * this field, then an appropriate symbolic link is created in connector
> > +	 * sysfs directory to make it easy for the user to tell which i2c
> > +	 * adapter is for a particular display.
> > +	 */
> > +	struct i2c_adapter *ddc;
> 
> To help the reader could you add in the above a reference to
> drm_connector_init_with_ddc() sp the reader is told how to init this
> field.
> 
> Either add it in PATCH 2 - or merge patch 1 and 2.
> 
> 	Sam
> 
> > +
> >  	/**
> >  	 * @null_edid_counter: track sinks that give us all zeros for the EDID.
> >  	 * Needed to workaround some HW bugs where we get all 0s
> > -- 
> > 2.17.1
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

WARNING: multiple messages have this Message-ID (diff)
From: Sam Ravnborg <sam@ravnborg.org>
To: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
Cc: "Neil Armstrong" <narmstrong@baylibre.com>,
	"Maxime Ripard" <maxime.ripard@bootlin.com>,
	"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	"Matthias Brugger" <matthias.bgg@gmail.com>,
	"Thierry Reding" <thierry.reding@gmail.com>,
	"Laurent Pinchart" <Laurent.pinchart@ideasonboard.com>,
	"Shawn Guo" <shawnguo@kernel.org>,
	kernel@collabora.com, linux-samsung-soc@vger.kernel.org,
	"Oleksandr Andrushchenko" <oleksandr_andrushchenko@epam.com>,
	"Sean Paul" <sean@poorly.run>,
	"Krzysztof Kozlowski" <krzk@kernel.org>,
	"Jonathan Hunter" <jonathanh@nvidia.com>,
	"David Airlie" <airlied@linux.ie>, "Chen-Yu Tsai" <wens@csie.org>,
	"Kukjin Kim" <kgene@kernel.org>,
	"NXP Linux Team" <linux-imx@nxp.com>,
	linux-rockchip@lists.infradead.org,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"Jonas Karlman" <jonas@kwiboo.se>,
	linux-arm-msm@vger.kernel.org, intel-gfx@lists.freedesktop.org,
	"Jyri Sarha" <jsarha@ti.com>,
	"Alexios Zavras" <alexios.zavras@intel.com>,
	"Mamta Shukla" <mamtashukla555@gmail.com>,
	linux-mediatek@lists.infradead.org,
	"Dave Airlie" <airlied@redhat.com>,
	linux-tegra@vger.kernel.org,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Vincent Abriou" <vincent.abriou@st.com>,
	linux-arm-kernel@lists.infradead.org,
	"Jernej Skrabec" <jernej.skrabec@siol.net>,
	amd-gfx@lists.freedesktop.org,
	"Tomi Valkeinen" <tomi.valkeinen@ti.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Seung-Woo Kim" <sw0312.kim@samsung.com>,
	"Douglas Anderson" <dianders@chromium.org>,
	"Todor Tomov" <todor.tomov@linaro.org>,
	"Kyungmin Park" <kyungmin.park@samsung.com>,
	"Huang Rui" <ray.huang@amd.com>,
	"Pengutronix Kernel Team" <kernel@pengutronix.de>,
	"Alex Deucher" <alexander.deucher@amd.com>,
	freedreno@lists.freedesktop.org,
	"Christian König" <christian.koenig@amd.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>
Subject: Re: [PATCH v5 01/24] drm: Include ddc adapter pointer in struct drm_connector
Date: Fri, 26 Jul 2019 10:08:55 +0200	[thread overview]
Message-ID: <20190726080855.GA9143@ravnborg.org> (raw)
In-Reply-To: <20190726063759.GB6443@ravnborg.org>

Hi Andrzej.

After reading through the series a few more comments.

1) The subject of this patch could be improved.
   Consider something like:
   drm: add ddc link in sysfs created by drm_connector

   This spells out much better what the patch achieve.


2) The purpsoe of drm_connector.ddc is to provide drm_connector with
   info to create the symlink.
   Yet in many follow-up patches the drivers are changed so
   drm_connector.ddc is their only reference to struct i2c_adapter.

   But the ownership is not clear here.
   Who owns the reference to i2c_adapter - and who has the
   responsibility to call put() on the adapter.

   Looking at the conversions done then some drivers are converted
   so they only use drm_connector.ddc, and other drivers have their own
   reference to i2c_adapter.
   The latter looks like the correct solution as the ownership of the
   reference belongs to the driver and not drm_connector.

   In other words - a conversion where the drivers only assigned
   drm_connector.ddc (using drm_connector_init_with_ddc()),
   seems like a more clean design that does not mix up ownership.
   This is at least how I see it.
   I did not take this type of look at the patches before. Sorry
   for providing feedback this late.

	Sam

On Fri, Jul 26, 2019 at 08:37:59AM +0200, Sam Ravnborg wrote:
> Hi Andrzej.
> 
> Patch looks good, but one kernel-doc detail.
> 
> On Wed, Jul 24, 2019 at 03:59:23PM +0200, Andrzej Pietrasiewicz wrote:
> > Add generic code which creates symbolic links in sysfs, pointing to ddc
> > interface used by a particular video output. For example:
> > 
> > ls -l /sys/class/drm/card0-HDMI-A-1/ddc
> > lrwxrwxrwx 1 root root 0 Jun 24 10:42 /sys/class/drm/card0-HDMI-A-1/ddc \
> > 	-> ../../../../soc/13880000.i2c/i2c-2
> > 
> > This makes it easy for user to associate a display with its ddc adapter
> > and use e.g. ddcutil to control the chosen monitor.
> > 
> > This patch adds an i2c_adapter pointer to struct drm_connector. Particular
> > drivers can then use it instead of using their own private instance. If a
> > connector contains a ddc, then create a symbolic link in sysfs.
> > 
> > Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
> > Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> > Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>
> > ---
> >  drivers/gpu/drm/drm_sysfs.c |  8 ++++++++
> >  include/drm/drm_connector.h | 11 +++++++++++
> >  2 files changed, 19 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
> > index ad10810bc972..e962a9d45f7e 100644
> > --- a/drivers/gpu/drm/drm_sysfs.c
> > +++ b/drivers/gpu/drm/drm_sysfs.c
> > @@ -14,6 +14,7 @@
> >  #include <linux/err.h>
> >  #include <linux/export.h>
> >  #include <linux/gfp.h>
> > +#include <linux/i2c.h>
> >  #include <linux/kdev_t.h>
> >  #include <linux/slab.h>
> >  
> > @@ -294,6 +295,9 @@ int drm_sysfs_connector_add(struct drm_connector *connector)
> >  	/* Let userspace know we have a new connector */
> >  	drm_sysfs_hotplug_event(dev);
> >  
> > +	if (connector->ddc)
> > +		return sysfs_create_link(&connector->kdev->kobj,
> > +				 &connector->ddc->dev.kobj, "ddc");
> >  	return 0;
> >  }
> >  
> > @@ -301,6 +305,10 @@ void drm_sysfs_connector_remove(struct drm_connector *connector)
> >  {
> >  	if (!connector->kdev)
> >  		return;
> > +
> > +	if (connector->ddc)
> > +		sysfs_remove_link(&connector->kdev->kobj, "ddc");
> > +
> >  	DRM_DEBUG("removing \"%s\" from sysfs\n",
> >  		  connector->name);
> >  
> > diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
> > index 4c30d751487a..33a6fff85fdb 100644
> > --- a/include/drm/drm_connector.h
> > +++ b/include/drm/drm_connector.h
> > @@ -41,6 +41,7 @@ struct drm_property;
> >  struct drm_property_blob;
> >  struct drm_printer;
> >  struct edid;
> > +struct i2c_adapter;
> >  
> >  enum drm_connector_force {
> >  	DRM_FORCE_UNSPECIFIED,
> > @@ -1311,6 +1312,16 @@ struct drm_connector {
> >  	 * [0]: progressive, [1]: interlaced
> >  	 */
> >  	int audio_latency[2];
> > +
> > +	/**
> > +	 * @ddc: associated ddc adapter.
> > +	 * A connector usually has its associated ddc adapter. If a driver uses
> > +	 * this field, then an appropriate symbolic link is created in connector
> > +	 * sysfs directory to make it easy for the user to tell which i2c
> > +	 * adapter is for a particular display.
> > +	 */
> > +	struct i2c_adapter *ddc;
> 
> To help the reader could you add in the above a reference to
> drm_connector_init_with_ddc() sp the reader is told how to init this
> field.
> 
> Either add it in PATCH 2 - or merge patch 1 and 2.
> 
> 	Sam
> 
> > +
> >  	/**
> >  	 * @null_edid_counter: track sinks that give us all zeros for the EDID.
> >  	 * Needed to workaround some HW bugs where we get all 0s
> > -- 
> > 2.17.1
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2019-07-26  8:08 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-24 13:59 [PATCH v5 00/24] Associate ddc adapters with connectors Andrzej Pietrasiewicz
2019-07-24 13:59 ` [PATCH v5 01/24] drm: Include ddc adapter pointer in struct drm_connector Andrzej Pietrasiewicz
     [not found]   ` <e82d6aca4f8abc95834c8a36c101d153518bb1ac.1563960855.git.andrzej.p-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
2019-07-26  6:37     ` Sam Ravnborg
2019-07-26  8:08       ` Sam Ravnborg [this message]
2019-07-26  8:08         ` Sam Ravnborg
2019-07-26 12:18       ` Andrzej Pietrasiewicz
2019-07-26 12:18         ` Andrzej Pietrasiewicz
2019-07-24 13:59 ` [PATCH v5 02/24] drm: Add drm_connector_init() variant with ddc Andrzej Pietrasiewicz
     [not found]   ` <53f5ded2971235e5b63c9a3ed4ed8bccf10c78f2.1563960855.git.andrzej.p-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
2019-07-24 17:16     ` Thomas Zimmermann
2019-07-24 17:16       ` Thomas Zimmermann
2019-07-24 17:16       ` Thomas Zimmermann
2019-07-26  6:35     ` Sam Ravnborg
2019-07-29  8:42   ` Jani Nikula
2019-07-24 13:59 ` [PATCH v5 03/24] drm/exynos: Provide ddc symlink in connector's sysfs Andrzej Pietrasiewicz
2019-07-24 13:59 ` [PATCH v5 04/24] drm: rockchip: Provide ddc symlink in rk3066_hdmi sysfs directory Andrzej Pietrasiewicz
2019-07-24 13:59 ` [PATCH v5 05/24] drm: rockchip: Provide ddc symlink in inno_hdmi " Andrzej Pietrasiewicz
2019-07-24 13:59 ` [PATCH v5 06/24] drm/msm/hdmi: Provide ddc symlink in hdmi connector " Andrzej Pietrasiewicz
2019-07-24 13:59 ` [PATCH v5 08/24] drm/mediatek: " Andrzej Pietrasiewicz
2019-07-24 13:59 ` [PATCH v5 09/24] drm/tegra: Provide ddc symlink in output " Andrzej Pietrasiewicz
2019-07-24 13:59 ` [PATCH v5 10/24] drm/imx: imx-ldb: Provide ddc symlink in connector's sysfs Andrzej Pietrasiewicz
2019-07-24 13:59 ` [PATCH v5 11/24] drm/imx: imx-tve: " Andrzej Pietrasiewicz
2019-07-24 13:59 ` [PATCH v5 12/24] drm/vc4: Provide ddc symlink in connector sysfs directory Andrzej Pietrasiewicz
2019-07-24 13:59 ` [PATCH v5 13/24] drm: zte: Provide ddc symlink in hdmi " Andrzej Pietrasiewicz
2019-07-24 13:59 ` [PATCH v5 14/24] drm: zte: Provide ddc symlink in vga " Andrzej Pietrasiewicz
2019-07-24 13:59 ` [PATCH v5 15/24] drm/tilcdc: Provide ddc symlink in " Andrzej Pietrasiewicz
2019-07-24 13:59 ` [PATCH v5 16/24] drm: sti: Provide ddc symlink in hdmi " Andrzej Pietrasiewicz
2019-07-24 13:59 ` [PATCH v5 17/24] drm/mgag200: Provide ddc symlink in " Andrzej Pietrasiewicz
     [not found]   ` <f86dfa1ed6e84ab8b36a0b2c24df897bdb957294.1563960855.git.andrzej.p-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
2019-07-24 17:17     ` Thomas Zimmermann
2019-07-24 13:59 ` [PATCH v5 18/24] drm/ast: " Andrzej Pietrasiewicz
2019-07-24 17:17   ` Thomas Zimmermann
2019-07-24 17:17     ` Thomas Zimmermann
2019-07-24 17:17     ` Thomas Zimmermann
2019-07-24 13:59 ` [PATCH v5 19/24] drm/bridge: dumb-vga-dac: " Andrzej Pietrasiewicz
2019-07-24 13:59 ` [PATCH v5 20/24] drm/bridge: dw-hdmi: " Andrzej Pietrasiewicz
2019-07-24 13:59 ` [PATCH v5 21/24] drm/bridge: ti-tfp410: " Andrzej Pietrasiewicz
2019-07-24 13:59 ` [PATCH v5 22/24] drm/amdgpu: " Andrzej Pietrasiewicz
     [not found] ` <cover.1563960855.git.andrzej.p-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
2019-07-24 13:59   ` [PATCH v5 07/24] drm/sun4i: hdmi: Provide ddc symlink in sun4i hdmi " Andrzej Pietrasiewicz
2019-07-24 13:59   ` [PATCH v5 23/24] drm/radeon: Provide ddc symlink in " Andrzej Pietrasiewicz
2019-07-24 13:59   ` [PATCH v5 24/24] drm/i915: Provide ddc symlink in hdmi " Andrzej Pietrasiewicz
2019-07-24 14:19 ` ✗ Fi.CI.CHECKPATCH: warning for Associate ddc adapters with connectors (rev2) Patchwork
2019-07-24 16:37 ` ✓ Fi.CI.BAT: success " Patchwork
2019-07-24 19:47 ` ✓ 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=20190726080855.GA9143@ravnborg.org \
    --to=sam@ravnborg.org \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=airlied@linux.ie \
    --cc=alexios.zavras@intel.com \
    --cc=andrzej.p@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jonas@kwiboo.se \
    --cc=jonathanh@nvidia.com \
    --cc=jsarha@ti.com \
    --cc=kernel@collabora.com \
    --cc=kgene@kernel.org \
    --cc=krzk@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=mamtashukla555@gmai \
    --cc=matthias.bgg@gmail.com \
    --cc=maxime.ripard@bootlin.com \
    --cc=narmstrong@baylibre.com \
    --cc=oleksandr_andrushchenko@epam.com \
    --cc=shawnguo@kernel.org \
    --cc=tzimmermann@suse.de \
    --cc=wens@csie.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.