dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 0/2] drm: Add detection of changing of edid on between suspend and resume
@ 2019-04-11 14:36 Gwan-gyeong Mun
  2019-04-11 14:36 ` [PATCH v5 1/2] " Gwan-gyeong Mun
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Gwan-gyeong Mun @ 2019-04-11 14:36 UTC (permalink / raw)
  To: intel-gfx; +Cc: dri-devel

This patch series fix missed detection of changing of edid on between
suspend and resume.
First patch fixes drm_helper_hdp_irq_event() in order to fix a below use
case.

 Following scenario requires detection of changing of edid.
    
  1) plug display device to a connector
  2) system suspend
  3) unplug 1)'s display device and plug the other display device to a
     connector
  4) system resume

It adds edid check routine when a connector status still remains as
"connector_status_connected".

Second patch adds a missed update of edid property of drm connector on i915.
  
v2: Add NULL check before comparing of EDIDs.
v3: Make it as part of existing drm_helper_hpd_irq_event() (Stan, Mika)
v4: Rebased
v5: Use a cached edid property blob data of connector instead of adding
    a new detected_edid variable. (Maarten)
    Add an using of reference count for getting a cached edid property
    blob data. (Maarten)

Testcase: igt/kms_chamelium/hdmi-edid-change-during-hibernate
Testcase: igt/kms_chamelium/hdmi-edid-change-during-suspend
Testcase: igt/kms_chamelium/dp-edid-change-during-hibernate
Testcase: igt/kms_chamelium/dp-edid-change-during-suspend

v1, v2: https://patchwork.freedesktop.org/series/47680/
v3: https://patchwork.freedesktop.org/series/49298/
v4: https://patchwork.freedesktop.org/series/57397/

Gwan-gyeong Mun (2):
  drm: Add detection of changing of edid on between suspend and resume
  drm/i915: Add a missed update of edid property of drm connector

 drivers/gpu/drm/drm_probe_helper.c | 34 +++++++++++++++++++++++++++++-
 drivers/gpu/drm/i915/intel_dp.c    |  1 +
 drivers/gpu/drm/i915/intel_hdmi.c  |  1 +
 3 files changed, 35 insertions(+), 1 deletion(-)

-- 
2.21.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* [PATCH v5 1/2] drm: Add detection of changing of edid on between suspend and resume
  2019-04-11 14:36 [PATCH v5 0/2] drm: Add detection of changing of edid on between suspend and resume Gwan-gyeong Mun
@ 2019-04-11 14:36 ` Gwan-gyeong Mun
  2019-04-11 16:00   ` Lisovskiy, Stanislav
  2019-04-11 14:36 ` [PATCH v5 2/2] drm/i915: Add a missed update of edid property of drm connector Gwan-gyeong Mun
  2019-04-15 16:32 ` [PATCH v5 0/2] drm: Add detection of changing of edid on between suspend and resume Daniel Vetter
  2 siblings, 1 reply; 7+ messages in thread
From: Gwan-gyeong Mun @ 2019-04-11 14:36 UTC (permalink / raw)
  To: intel-gfx; +Cc: dri-devel

The hotplug detection routine of drm_helper_hpd_irq_event() can detect
changing of status of connector, but it can not detect changing of edid.

Following scenario requires detection of changing of edid.

 1) plug display device to a connector
 2) system suspend
 3) unplug 1)'s display device and plug the other display device to a
    connector
 4) system resume

It adds edid check routine when a connector status still remains as
"connector_status_connected".

v2: Add NULL check before comparing of EDIDs.
v3: Make it as part of existing drm_helper_hpd_irq_event() (Stan, Mika)
v4: Rebased
v5: Use a cached edid property blob data of connector instead of adding
    a new detected_edid variable. (Maarten)
    Add an using of reference count for getting a cached edid property
    blob data. (Maarten)

Testcase: igt/kms_chamelium/hdmi-edid-change-during-hibernate
Testcase: igt/kms_chamelium/hdmi-edid-change-during-suspend
Testcase: igt/kms_chamelium/dp-edid-change-during-hibernate
Testcase: igt/kms_chamelium/dp-edid-change-during-suspend

Signed-off-by: Gwan-gyeong Mun <gwan-gyeong.mun@intel.com>
---
 drivers/gpu/drm/drm_probe_helper.c | 34 +++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c
index 6fd08e04b323..27ad7f3dabb7 100644
--- a/drivers/gpu/drm/drm_probe_helper.c
+++ b/drivers/gpu/drm/drm_probe_helper.c
@@ -742,7 +742,16 @@ EXPORT_SYMBOL(drm_kms_helper_poll_fini);
  * panels.
  *
  * This helper function is useful for drivers which can't or don't track hotplug
- * interrupts for each connector.
+ * interrupts for each connector. And it also supports a detection of changing
+ * of edid on between suspend and resume when a connector status still remains
+ * as "connector_status_connected".
+ *
+ * Following scenario requires detection of changing of edid.
+ *  1) plug display device to a connector
+ *  2) system suspend
+ *  3) unplug 1)'s display device and plug the other display device to a
+ *     connector
+ *  4) system resume
  *
  * Drivers which support hotplug interrupts for each connector individually and
  * which have a more fine-grained detect logic should bypass this code and
@@ -760,6 +769,7 @@ bool drm_helper_hpd_irq_event(struct drm_device *dev)
 	struct drm_connector *connector;
 	struct drm_connector_list_iter conn_iter;
 	enum drm_connector_status old_status;
+	struct drm_property_blob *old_edid_blob_ptr;
 	bool changed = false;
 
 	if (!dev->mode_config.poll_enabled)
@@ -774,6 +784,11 @@ bool drm_helper_hpd_irq_event(struct drm_device *dev)
 
 		old_status = connector->status;
 
+		if (connector->edid_blob_ptr)
+			old_edid_blob_ptr = drm_property_blob_get(connector->edid_blob_ptr);
+		else
+			old_edid_blob_ptr = NULL;
+
 		connector->status = drm_helper_probe_detect(connector, NULL, false);
 		DRM_DEBUG_KMS("[CONNECTOR:%d:%s] status updated from %s to %s\n",
 			      connector->base.id,
@@ -782,6 +797,23 @@ bool drm_helper_hpd_irq_event(struct drm_device *dev)
 			      drm_get_connector_status_name(connector->status));
 		if (old_status != connector->status)
 			changed = true;
+
+		/* Check changing of edid when a connector status still remains
+		 * as "connector_status_connected".
+		 */
+		if (old_edid_blob_ptr && connector->edid_blob_ptr &&
+		    old_status == connector->status &&
+		    old_status == connector_status_connected) {
+			if (memcmp(old_edid_blob_ptr->data,
+				connector->edid_blob_ptr->data,
+				old_edid_blob_ptr->length)) {
+				changed = true;
+				DRM_DEBUG_KMS("[CONNECTOR:%d:%s] edid updated\n",
+					      connector->base.id,
+					      connector->name);
+			}
+		}
+		drm_property_blob_put(old_edid_blob_ptr);
 	}
 	drm_connector_list_iter_end(&conn_iter);
 	mutex_unlock(&dev->mode_config.mutex);
-- 
2.21.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* [PATCH v5 2/2] drm/i915: Add a missed update of edid property of drm connector
  2019-04-11 14:36 [PATCH v5 0/2] drm: Add detection of changing of edid on between suspend and resume Gwan-gyeong Mun
  2019-04-11 14:36 ` [PATCH v5 1/2] " Gwan-gyeong Mun
@ 2019-04-11 14:36 ` Gwan-gyeong Mun
  2019-04-15 16:32 ` [PATCH v5 0/2] drm: Add detection of changing of edid on between suspend and resume Daniel Vetter
  2 siblings, 0 replies; 7+ messages in thread
From: Gwan-gyeong Mun @ 2019-04-11 14:36 UTC (permalink / raw)
  To: intel-gfx; +Cc: stanislav.lisovskiy, mika.kahola, dri-devel

After suspend/resume process, hotplug detection is handled by
i915_hpd_poll_init_work() workqueue. While intel_hdmi_detect() or
intel_dp_detect() are called, intel_hdmi_set_edid() or intel_dp_set_edid()
only update an internal detect_edid variable of intel_connector.
A missed update of edid property of drm_connector leads incorrect behavior
of drm_helper_hpd_irq_event() on below testcases.
It adds a missed update of edid property of drm connector and updates
drm edid modes, while i915_hpd_poll_init_work() workqueue works.

Testcase: igt/kms_chamelium/hdmi-edid-change-during-hibernate
Testcase: igt/kms_chamelium/hdmi-edid-change-during-suspend
Testcase: igt/kms_chamelium/dp-edid-change-during-hibernate
Testcase: igt/kms_chamelium/dp-edid-change-during-suspend

Signed-off-by: Gwan-gyeong Mun <gwan-gyeong.mun@intel.com>
---
 drivers/gpu/drm/i915/intel_dp.c   | 1 +
 drivers/gpu/drm/i915/intel_hdmi.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index c4e36759a756..0301e58495b4 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -5379,6 +5379,7 @@ intel_dp_set_edid(struct intel_dp *intel_dp)
 
 	intel_dp->has_audio = drm_detect_monitor_audio(edid);
 	drm_dp_cec_set_edid(&intel_dp->aux, edid);
+	intel_connector_update_modes(&intel_connector->base, edid);
 }
 
 static void
diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
index e1005d7b75fd..b53360c4d0ef 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -2493,6 +2493,7 @@ intel_hdmi_set_edid(struct drm_connector *connector)
 	}
 
 	cec_notifier_set_phys_addr_from_edid(intel_hdmi->cec_notifier, edid);
+	intel_connector_update_modes(connector, edid);
 
 	return connected;
 }
-- 
2.21.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH v5 1/2] drm: Add detection of changing of edid on between suspend and resume
  2019-04-11 14:36 ` [PATCH v5 1/2] " Gwan-gyeong Mun
@ 2019-04-11 16:00   ` Lisovskiy, Stanislav
  2019-04-16 13:55     ` Mun, Gwan-gyeong
  0 siblings, 1 reply; 7+ messages in thread
From: Lisovskiy, Stanislav @ 2019-04-11 16:00 UTC (permalink / raw)
  To: intel-gfx, Mun, Gwan-gyeong; +Cc: dri-devel

On Thu, 2019-04-11 at 17:36 +0300, Gwan-gyeong Mun wrote:
> The hotplug detection routine of drm_helper_hpd_irq_event() can
> detect
> changing of status of connector, but it can not detect changing of
> edid.
> 
> Following scenario requires detection of changing of edid.
> 
>  1) plug display device to a connector
>  2) system suspend
>  3) unplug 1)'s display device and plug the other display device to a
>     connector
>  4) system resume
> 
> It adds edid check routine when a connector status still remains as
> "connector_status_connected".
> 
> v2: Add NULL check before comparing of EDIDs.
> v3: Make it as part of existing drm_helper_hpd_irq_event() (Stan,
> Mika)
> v4: Rebased
> v5: Use a cached edid property blob data of connector instead of
> adding
>     a new detected_edid variable. (Maarten)
>     Add an using of reference count for getting a cached edid
> property
>     blob data. (Maarten)
> 
> Testcase: igt/kms_chamelium/hdmi-edid-change-during-hibernate
> Testcase: igt/kms_chamelium/hdmi-edid-change-during-suspend
> Testcase: igt/kms_chamelium/dp-edid-change-during-hibernate
> Testcase: igt/kms_chamelium/dp-edid-change-during-suspend
> 
> Signed-off-by: Gwan-gyeong Mun <gwan-gyeong.mun@intel.com>
> ---
>  drivers/gpu/drm/drm_probe_helper.c | 34
> +++++++++++++++++++++++++++++-
>  1 file changed, 33 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_probe_helper.c
> b/drivers/gpu/drm/drm_probe_helper.c
> index 6fd08e04b323..27ad7f3dabb7 100644
> --- a/drivers/gpu/drm/drm_probe_helper.c
> +++ b/drivers/gpu/drm/drm_probe_helper.c
> @@ -742,7 +742,16 @@ EXPORT_SYMBOL(drm_kms_helper_poll_fini);
>   * panels.
>   *
>   * This helper function is useful for drivers which can't or don't
> track hotplug
> - * interrupts for each connector.
> + * interrupts for each connector. And it also supports a detection
> of changing
> + * of edid on between suspend and resume when a connector status
> still remains
> + * as "connector_status_connected".
> + *
> + * Following scenario requires detection of changing of edid.
> + *  1) plug display device to a connector
> + *  2) system suspend
> + *  3) unplug 1)'s display device and plug the other display device
> to a
> + *     connector
> + *  4) system resume
>   *
>   * Drivers which support hotplug interrupts for each connector
> individually and
>   * which have a more fine-grained detect logic should bypass this
> code and
> @@ -760,6 +769,7 @@ bool drm_helper_hpd_irq_event(struct drm_device
> *dev)
>  	struct drm_connector *connector;
>  	struct drm_connector_list_iter conn_iter;
>  	enum drm_connector_status old_status;
> +	struct drm_property_blob *old_edid_blob_ptr;
>  	bool changed = false;
>  
>  	if (!dev->mode_config.poll_enabled)
> @@ -774,6 +784,11 @@ bool drm_helper_hpd_irq_event(struct drm_device
> *dev)
>  
>  		old_status = connector->status;
>  
> +		if (connector->edid_blob_ptr)
> +			old_edid_blob_ptr =
> drm_property_blob_get(connector->edid_blob_ptr);
> +		else
> +			old_edid_blob_ptr = NULL;
> +
>  		connector->status = drm_helper_probe_detect(connector,
> NULL, false);
>  		DRM_DEBUG_KMS("[CONNECTOR:%d:%s] status updated from %s
> to %s\n",
>  			      connector->base.id,
> @@ -782,6 +797,23 @@ bool drm_helper_hpd_irq_event(struct drm_device
> *dev)
>  			      drm_get_connector_status_name(connector-
> >status));
>  		if (old_status != connector->status)
>  			changed = true;
> +
> +		/* Check changing of edid when a connector status still
> remains
> +		 * as "connector_status_connected".
> +		 */
> +		if (old_edid_blob_ptr && connector->edid_blob_ptr &&

I guess you don't need to check both old_edid_blob_ptr && connector-
>edid_blob_ptr here. Because if old_edid_blob_ptr is not NULL - it
means that connector->edid_blob_ptr was not NULL for sure. See the 
condition you have added above.
I mean this one:

> +		if (connector->edid_blob_ptr)
> +			old_edid_blob_ptr =
> drm_property_blob_get(connector->edid_blob_ptr);
> +		else
> +			old_edid_blob_ptr = NULL;

So I would check only old_edid_blob_ptr for not being NULL here.



> +		    old_status == connector->status &&
> +		    old_status == connector_status_connected) {
> +			if (memcmp(old_edid_blob_ptr->data,
> +				connector->edid_blob_ptr->data,
> +				old_edid_blob_ptr->length)) {
> +				changed = true;
> +				DRM_DEBUG_KMS("[CONNECTOR:%d:%s] edid
> updated\n",
> +					      connector->base.id,
> +					      connector->name);
> +			}
> +		}
> +		drm_property_blob_put(old_edid_blob_ptr);
>  	}
>  	drm_connector_list_iter_end(&conn_iter);
>  	mutex_unlock(&dev->mode_config.mutex);
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH v5 0/2] drm: Add detection of changing of edid on between suspend and resume
  2019-04-11 14:36 [PATCH v5 0/2] drm: Add detection of changing of edid on between suspend and resume Gwan-gyeong Mun
  2019-04-11 14:36 ` [PATCH v5 1/2] " Gwan-gyeong Mun
  2019-04-11 14:36 ` [PATCH v5 2/2] drm/i915: Add a missed update of edid property of drm connector Gwan-gyeong Mun
@ 2019-04-15 16:32 ` Daniel Vetter
  2019-04-17 19:40   ` [Intel-gfx] " Mun, Gwan-gyeong
  2 siblings, 1 reply; 7+ messages in thread
From: Daniel Vetter @ 2019-04-15 16:32 UTC (permalink / raw)
  To: Gwan-gyeong Mun; +Cc: intel-gfx, dri-devel

On Thu, Apr 11, 2019 at 05:36:30PM +0300, Gwan-gyeong Mun wrote:
> This patch series fix missed detection of changing of edid on between
> suspend and resume.
> First patch fixes drm_helper_hdp_irq_event() in order to fix a below use
> case.
> 
>  Following scenario requires detection of changing of edid.
>     
>   1) plug display device to a connector
>   2) system suspend
>   3) unplug 1)'s display device and plug the other display device to a
>      connector
>   4) system resume
> 
> It adds edid check routine when a connector status still remains as
> "connector_status_connected".
> 
> Second patch adds a missed update of edid property of drm connector on i915.
>   
> v2: Add NULL check before comparing of EDIDs.
> v3: Make it as part of existing drm_helper_hpd_irq_event() (Stan, Mika)
> v4: Rebased
> v5: Use a cached edid property blob data of connector instead of adding
>     a new detected_edid variable. (Maarten)
>     Add an using of reference count for getting a cached edid property
>     blob data. (Maarten)
> 
> Testcase: igt/kms_chamelium/hdmi-edid-change-during-hibernate
> Testcase: igt/kms_chamelium/hdmi-edid-change-during-suspend
> Testcase: igt/kms_chamelium/dp-edid-change-during-hibernate
> Testcase: igt/kms_chamelium/dp-edid-change-during-suspend
> 
> v1, v2: https://patchwork.freedesktop.org/series/47680/
> v3: https://patchwork.freedesktop.org/series/49298/
> v4: https://patchwork.freedesktop.org/series/57397/

I guess I missed this, but there's a few fundamental things here first
imo:

- patch 2 is fallout from the fairly abitrary split between ->detect and
  ->get_modes. There's not really any good reason for that, I think we can
  just always call ->get_modes if ->detect says the connector is
  connected. There's more than just dp and hdmi (that's simply the 2
  things we test in CI using chamelium).

- the problem is bigger than just the edid changing (e.g. when repeaters
  change, or when something else changes aside from the edid, e.g. in dp
  aux, like how many lanes the dp cable has). Plus we have this long-term
  idea to give userspace a better idea about which connector exactly has
  changed. Therefor:

  1. add a new drm_connector->detect_epoque counter.
  2. Increment that counter every time something has changed, i.e. from
  probe helpers (we can push this down into the detect wrappers) when
  connector->status has changed, or when we update the edid blob.
  3. probe helpers look for changes in ->detect_epoque to decided whether
  to fire the uevent or not.
  4. long term we could expose the ->detect_epoque as a read-only
  property, or at least supply information about which connector caused
  the uevent using the new drm_sysfs_connector_status_event() (see the
  patch from Ram "[PATCH v3 09/10] drm: uevent for connector status
  change").

I think that gives us a much better long term foundation than adding lots
of hacks.

Cheers, Daniel

> 
> Gwan-gyeong Mun (2):
>   drm: Add detection of changing of edid on between suspend and resume
>   drm/i915: Add a missed update of edid property of drm connector
> 
>  drivers/gpu/drm/drm_probe_helper.c | 34 +++++++++++++++++++++++++++++-
>  drivers/gpu/drm/i915/intel_dp.c    |  1 +
>  drivers/gpu/drm/i915/intel_hdmi.c  |  1 +
>  3 files changed, 35 insertions(+), 1 deletion(-)
> 
> -- 
> 2.21.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH v5 1/2] drm: Add detection of changing of edid on between suspend and resume
  2019-04-11 16:00   ` Lisovskiy, Stanislav
@ 2019-04-16 13:55     ` Mun, Gwan-gyeong
  0 siblings, 0 replies; 7+ messages in thread
From: Mun, Gwan-gyeong @ 2019-04-16 13:55 UTC (permalink / raw)
  To: Lisovskiy, Stanislav, intel-gfx; +Cc: Kahola, Mika, dri-devel

On Thu, 2019-04-11 at 17:00 +0100, Lisovskiy, Stanislav wrote:
> On Thu, 2019-04-11 at 17:36 +0300, Gwan-gyeong Mun wrote:
> > The hotplug detection routine of drm_helper_hpd_irq_event() can
> > detect
> > changing of status of connector, but it can not detect changing of
> > edid.
> > 
> > Following scenario requires detection of changing of edid.
> > 
> >  1) plug display device to a connector
> >  2) system suspend
> >  3) unplug 1)'s display device and plug the other display device to
> > a
> >     connector
> >  4) system resume
> > 
> > It adds edid check routine when a connector status still remains as
> > "connector_status_connected".
> > 
> > v2: Add NULL check before comparing of EDIDs.
> > v3: Make it as part of existing drm_helper_hpd_irq_event() (Stan,
> > Mika)
> > v4: Rebased
> > v5: Use a cached edid property blob data of connector instead of
> > adding
> >     a new detected_edid variable. (Maarten)
> >     Add an using of reference count for getting a cached edid
> > property
> >     blob data. (Maarten)
> > 
> > Testcase: igt/kms_chamelium/hdmi-edid-change-during-hibernate
> > Testcase: igt/kms_chamelium/hdmi-edid-change-during-suspend
> > Testcase: igt/kms_chamelium/dp-edid-change-during-hibernate
> > Testcase: igt/kms_chamelium/dp-edid-change-during-suspend
> > 
> > Signed-off-by: Gwan-gyeong Mun <gwan-gyeong.mun@intel.com>
> > ---
> >  drivers/gpu/drm/drm_probe_helper.c | 34
> > +++++++++++++++++++++++++++++-
> >  1 file changed, 33 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_probe_helper.c
> > b/drivers/gpu/drm/drm_probe_helper.c
> > index 6fd08e04b323..27ad7f3dabb7 100644
> > --- a/drivers/gpu/drm/drm_probe_helper.c
> > +++ b/drivers/gpu/drm/drm_probe_helper.c
> > @@ -742,7 +742,16 @@ EXPORT_SYMBOL(drm_kms_helper_poll_fini);
> >   * panels.
> >   *
> >   * This helper function is useful for drivers which can't or don't
> > track hotplug
> > - * interrupts for each connector.
> > + * interrupts for each connector. And it also supports a detection
> > of changing
> > + * of edid on between suspend and resume when a connector status
> > still remains
> > + * as "connector_status_connected".
> > + *
> > + * Following scenario requires detection of changing of edid.
> > + *  1) plug display device to a connector
> > + *  2) system suspend
> > + *  3) unplug 1)'s display device and plug the other display
> > device
> > to a
> > + *     connector
> > + *  4) system resume
> >   *
> >   * Drivers which support hotplug interrupts for each connector
> > individually and
> >   * which have a more fine-grained detect logic should bypass this
> > code and
> > @@ -760,6 +769,7 @@ bool drm_helper_hpd_irq_event(struct drm_device
> > *dev)
> >  	struct drm_connector *connector;
> >  	struct drm_connector_list_iter conn_iter;
> >  	enum drm_connector_status old_status;
> > +	struct drm_property_blob *old_edid_blob_ptr;
> >  	bool changed = false;
> >  
> >  	if (!dev->mode_config.poll_enabled)
> > @@ -774,6 +784,11 @@ bool drm_helper_hpd_irq_event(struct
> > drm_device
> > *dev)
> >  
> >  		old_status = connector->status;
> >  
> > +		if (connector->edid_blob_ptr)
> > +			old_edid_blob_ptr =
> > drm_property_blob_get(connector->edid_blob_ptr);
> > +		else
> > +			old_edid_blob_ptr = NULL;
> > +
> >  		connector->status = drm_helper_probe_detect(connector,
> > NULL, false);
> >  		DRM_DEBUG_KMS("[CONNECTOR:%d:%s] status updated from %s
> > to %s\n",
> >  			      connector->base.id,
> > @@ -782,6 +797,23 @@ bool drm_helper_hpd_irq_event(struct
> > drm_device
> > *dev)
> >  			      drm_get_connector_status_name(connector-
> > > status));
> >  		if (old_status != connector->status)
> >  			changed = true;
> > +
> > +		/* Check changing of edid when a connector status still
> > remains
> > +		 * as "connector_status_connected".
> > +		 */
> > +		if (old_edid_blob_ptr && connector->edid_blob_ptr &&
> 
> I guess you don't need to check both old_edid_blob_ptr && connector-
> > edid_blob_ptr here. Because if old_edid_blob_ptr is not NULL - it
> means that connector->edid_blob_ptr was not NULL for sure. See the 
> condition you have added above.
> I mean this one:
> 
> > +		if (connector->edid_blob_ptr)
> > +			old_edid_blob_ptr =
> > drm_property_blob_get(connector->edid_blob_ptr);
> > +		else
> > +			old_edid_blob_ptr = NULL;
> 
> So I would check only old_edid_blob_ptr for not being NULL here.
> 
> 
Hi Stan,

Thank you for checking it.

First, drivers could set edid_blob_ptr to NULL with
drm_connector_update_edid_property().
And drm_helper_probe_detect() could lead updating of an internal edid
of driver and if driver can not get EDID from I2C, it could call
drm_connector_update_edid_property() with NULL.

therefore I think that we should check old and new edid_blob_ptr are
NULL or not.
> 
> > +		    old_status == connector->status &&
> > +		    old_status == connector_status_connected) {
> > +			if (memcmp(old_edid_blob_ptr->data,
> > +				connector->edid_blob_ptr->data,
> > +				old_edid_blob_ptr->length)) {
> > +				changed = true;
> > +				DRM_DEBUG_KMS("[CONNECTOR:%d:%s] edid
> > updated\n",
> > +					      connector->base.id,
> > +					      connector->name);
> > +			}
> > +		}
> > +		drm_property_blob_put(old_edid_blob_ptr);
> >  	}
> >  	drm_connector_list_iter_end(&conn_iter);
> >  	mutex_unlock(&dev->mode_config.mutex);
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [Intel-gfx] [PATCH v5 0/2] drm: Add detection of changing of edid on between suspend and resume
  2019-04-15 16:32 ` [PATCH v5 0/2] drm: Add detection of changing of edid on between suspend and resume Daniel Vetter
@ 2019-04-17 19:40   ` Mun, Gwan-gyeong
  0 siblings, 0 replies; 7+ messages in thread
From: Mun, Gwan-gyeong @ 2019-04-17 19:40 UTC (permalink / raw)
  To: daniel; +Cc: intel-gfx, dri-devel

On Mon, 2019-04-15 at 18:32 +0200, Daniel Vetter wrote:
> On Thu, Apr 11, 2019 at 05:36:30PM +0300, Gwan-gyeong Mun wrote:
> > This patch series fix missed detection of changing of edid on
> > between
> > suspend and resume.
> > First patch fixes drm_helper_hdp_irq_event() in order to fix a
> > below use
> > case.
> > 
> >  Following scenario requires detection of changing of edid.
> >     
> >   1) plug display device to a connector
> >   2) system suspend
> >   3) unplug 1)'s display device and plug the other display device
> > to a
> >      connector
> >   4) system resume
> > 
> > It adds edid check routine when a connector status still remains as
> > "connector_status_connected".
> > 
> > Second patch adds a missed update of edid property of drm connector
> > on i915.
> >   
> > v2: Add NULL check before comparing of EDIDs.
> > v3: Make it as part of existing drm_helper_hpd_irq_event() (Stan,
> > Mika)
> > v4: Rebased
> > v5: Use a cached edid property blob data of connector instead of
> > adding
> >     a new detected_edid variable. (Maarten)
> >     Add an using of reference count for getting a cached edid
> > property
> >     blob data. (Maarten)
> > 
> > Testcase: igt/kms_chamelium/hdmi-edid-change-during-hibernate
> > Testcase: igt/kms_chamelium/hdmi-edid-change-during-suspend
> > Testcase: igt/kms_chamelium/dp-edid-change-during-hibernate
> > Testcase: igt/kms_chamelium/dp-edid-change-during-suspend
> > 
> > v1, v2: https://patchwork.freedesktop.org/series/47680/
> > v3: https://patchwork.freedesktop.org/series/49298/
> > v4: https://patchwork.freedesktop.org/series/57397/
> 
> I guess I missed this, but there's a few fundamental things here
> first
> imo:
> 
> - patch 2 is fallout from the fairly abitrary split between ->detect
> and
>   ->get_modes. There's not really any good reason for that, I think
> we can
>   just always call ->get_modes if ->detect says the connector is
>   connected. There's more than just dp and hdmi (that's simply the 2
>   things we test in CI using chamelium).
> 
Thank you for checking it.

I agree. I'll modify first patch with your guide and will resend it.
> - the problem is bigger than just the edid changing (e.g. when
> repeaters
>   change, or when something else changes aside from the edid, e.g. in
> dp
>   aux, like how many lanes the dp cable has). Plus we have this long-
> term
>   idea to give userspace a better idea about which connector exactly
> has
>   changed. Therefor:
> 
Yes, you pointed an essential problem.

>   1. add a new drm_connector->detect_epoque counter.
>   2. Increment that counter every time something has changed, i.e.
> from
>   probe helpers (we can push this down into the detect wrappers) when
>   connector->status has changed, or when we update the edid blob.
>   3. probe helpers look for changes in ->detect_epoque to decided
> whether
>   to fire the uevent or not.
>   4. long term we could expose the ->detect_epoque as a read-only
>   property, or at least supply information about which connector
> caused
>   the uevent using the new drm_sysfs_connector_status_event() (see
> the
>   patch from Ram "[PATCH v3 09/10] drm: uevent for connector status
>   change").
> 
I'll make new patches which followes your guide.
Thanks for reviewing it and giving me a new approach.

Br,
G.G.

> I think that gives us a much better long term foundation than adding
> lots
> of hacks.
> 
> Cheers, Daniel
> 
> > Gwan-gyeong Mun (2):
> >   drm: Add detection of changing of edid on between suspend and
> > resume
> >   drm/i915: Add a missed update of edid property of drm connector
> > 
> >  drivers/gpu/drm/drm_probe_helper.c | 34
> > +++++++++++++++++++++++++++++-
> >  drivers/gpu/drm/i915/intel_dp.c    |  1 +
> >  drivers/gpu/drm/i915/intel_hdmi.c  |  1 +
> >  3 files changed, 35 insertions(+), 1 deletion(-)
> > 
> > -- 
> > 2.21.0
> > 
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2019-04-17 19:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-11 14:36 [PATCH v5 0/2] drm: Add detection of changing of edid on between suspend and resume Gwan-gyeong Mun
2019-04-11 14:36 ` [PATCH v5 1/2] " Gwan-gyeong Mun
2019-04-11 16:00   ` Lisovskiy, Stanislav
2019-04-16 13:55     ` Mun, Gwan-gyeong
2019-04-11 14:36 ` [PATCH v5 2/2] drm/i915: Add a missed update of edid property of drm connector Gwan-gyeong Mun
2019-04-15 16:32 ` [PATCH v5 0/2] drm: Add detection of changing of edid on between suspend and resume Daniel Vetter
2019-04-17 19:40   ` [Intel-gfx] " Mun, Gwan-gyeong

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