drm: clean cached display info

Submitted by Sharma, Shashank on Dec. 29, 2016, 12:28 p.m.

Details

Message ID 1483014530-27393-1-git-send-email-shashank.sharma@intel.com
State New
Headers show
Series "drm: clean cached display info" ( rev: 1 ) in DRI devel

Not browsing as part of any series.

Commit Message

Sharma, Shashank Dec. 29, 2016, 12:28 p.m.
This patch adds a small helper function, which clears the cached
information about a hot-pluggable display, from connector. On event
This will run on event of a hot-unplug, keeping the connector's display
info up-to-date, avoiding any errors due to invalid cached data.

Forking this patch out from the 3 patch series:
	https://patchwork.freedesktop.org/patch/128961/
(still under review) and sending as individual patch.

Cc: Jose Abreu <joabreu@synopsys.com>
Cc: Daniel Vetter <daniel@ffwll.ch>

Suggested-by: Jose Abreu <joabreu@synopsys.com>
Signed-off-by: Shashank Sharma <shashank.sharma@intel.com>
---
 drivers/gpu/drm/drm_probe_helper.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c
index 7cff91e..65a6a1f 100644
--- a/drivers/gpu/drm/drm_probe_helper.c
+++ b/drivers/gpu/drm/drm_probe_helper.c
@@ -164,6 +164,18 @@  void drm_kms_helper_poll_enable_locked(struct drm_device *dev)
 }
 
 /**
+ * drm_helper_clear_display_info - clean cached display information for
+ * hot pluggable displays, on event of hot-unplug
+ * @connector: connector under event
+ */
+void drm_helper_clear_display_info(struct drm_connector *connector)
+{
+	struct drm_display_info *info = &connector->display_info;
+
+	memset(info, 0, sizeof(*info));
+}
+
+/**
  * drm_helper_probe_single_connector_modes - get complete set of display modes
  * @connector: connector to probe
  * @maxX: max width for modes
@@ -288,6 +300,16 @@  int drm_helper_probe_single_connector_modes(struct drm_connector *connector,
 		DRM_DEBUG_KMS("[CONNECTOR:%d:%s] disconnected\n",
 			connector->base.id, connector->name);
 		drm_mode_connector_update_edid_property(connector, NULL);
+
+		/*
+		 * Connector status change to disconnected, time to clean
+		 * cached display information.
+		 * Any driver which doesn't use this probe_helper function
+		 * should implement update of EDID property and display_info
+		 * on its own.
+		 */
+		drm_helper_clear_display_info(connector);
+
 		verbose_prune = false;
 		goto prune;
 	}

Comments

Hi Shashank,


On 29-12-2016 12:28, Shashank Sharma wrote:
> This patch adds a small helper function, which clears the cached
> information about a hot-pluggable display, from connector. On event
> This will run on event of a hot-unplug, keeping the connector's display
> info up-to-date, avoiding any errors due to invalid cached data.
>
> Forking this patch out from the 3 patch series:
> 	https://urldefense.proofpoint.com/v2/url?u=https-3A__patchwork.freedesktop.org_patch_128961_&d=DgIBAg&c=DPL6_X_6JkXFx7AXWqB0tg&r=yaVFU4TjGY0gVF8El1uKcisy6TPsyCl9uN7Wsis-qhY&m=wGqvHYK00VvbUVGun4-ZhK6KZ4Ht_lHwPGfC6ajlzxE&s=7YpJD-fwUixHNz9SNn2B1ijuL5mEVeEUmolbf3NqWcs&e= 
> (still under review) and sending as individual patch.
>
> Cc: Jose Abreu <joabreu@synopsys.com>
> Cc: Daniel Vetter <daniel@ffwll.ch>
>
> Suggested-by: Jose Abreu <joabreu@synopsys.com>
> Signed-off-by: Shashank Sharma <shashank.sharma@intel.com>
> ---

Reviewed-by: Jose Abreu <joabreu@synopsys.com>

Best regards,
Jose Miguel Abreu
>  drivers/gpu/drm/drm_probe_helper.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c
> index 7cff91e..65a6a1f 100644
> --- a/drivers/gpu/drm/drm_probe_helper.c
> +++ b/drivers/gpu/drm/drm_probe_helper.c
> @@ -164,6 +164,18 @@ void drm_kms_helper_poll_enable_locked(struct drm_device *dev)
>  }
>  
>  /**
> + * drm_helper_clear_display_info - clean cached display information for
> + * hot pluggable displays, on event of hot-unplug
> + * @connector: connector under event
> + */
> +void drm_helper_clear_display_info(struct drm_connector *connector)
> +{
> +	struct drm_display_info *info = &connector->display_info;
> +
> +	memset(info, 0, sizeof(*info));
> +}
> +
> +/**
>   * drm_helper_probe_single_connector_modes - get complete set of display modes
>   * @connector: connector to probe
>   * @maxX: max width for modes
> @@ -288,6 +300,16 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector,
>  		DRM_DEBUG_KMS("[CONNECTOR:%d:%s] disconnected\n",
>  			connector->base.id, connector->name);
>  		drm_mode_connector_update_edid_property(connector, NULL);
> +
> +		/*
> +		 * Connector status change to disconnected, time to clean
> +		 * cached display information.
> +		 * Any driver which doesn't use this probe_helper function
> +		 * should implement update of EDID property and display_info
> +		 * on its own.
> +		 */
> +		drm_helper_clear_display_info(connector);
> +
>  		verbose_prune = false;
>  		goto prune;
>  	}
Thanks for the review, Jose.

Regards
Shashank
-----Original Message-----
From: Jose Abreu [mailto:Jose.Abreu@synopsys.com] 
Sent: Thursday, December 29, 2016 11:05 PM
To: Sharma, Shashank <shashank.sharma@intel.com>; dri-devel@lists.freedesktop.org; intel-gfx@lists.freedesktop.org
Cc: Jose Abreu <Jose.Abreu@synopsys.com>; Daniel Vetter <daniel@ffwll.ch>
Subject: Re: [PATCH] drm: clean cached display info

Hi Shashank,


On 29-12-2016 12:28, Shashank Sharma wrote:
> This patch adds a small helper function, which clears the cached 
> information about a hot-pluggable display, from connector. On event 
> This will run on event of a hot-unplug, keeping the connector's 
> display info up-to-date, avoiding any errors due to invalid cached data.
>
> Forking this patch out from the 3 patch series:
> 	
> https://urldefense.proofpoint.com/v2/url?u=https-3A__patchwork.freedes
> ktop.org_patch_128961_&d=DgIBAg&c=DPL6_X_6JkXFx7AXWqB0tg&r=yaVFU4TjGY0
> gVF8El1uKcisy6TPsyCl9uN7Wsis-qhY&m=wGqvHYK00VvbUVGun4-ZhK6KZ4Ht_lHwPGf
> C6ajlzxE&s=7YpJD-fwUixHNz9SNn2B1ijuL5mEVeEUmolbf3NqWcs&e=
> (still under review) and sending as individual patch.
>
> Cc: Jose Abreu <joabreu@synopsys.com>
> Cc: Daniel Vetter <daniel@ffwll.ch>
>
> Suggested-by: Jose Abreu <joabreu@synopsys.com>
> Signed-off-by: Shashank Sharma <shashank.sharma@intel.com>
> ---

Reviewed-by: Jose Abreu <joabreu@synopsys.com>

Best regards,
Jose Miguel Abreu
>  drivers/gpu/drm/drm_probe_helper.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_probe_helper.c 
> b/drivers/gpu/drm/drm_probe_helper.c
> index 7cff91e..65a6a1f 100644
> --- a/drivers/gpu/drm/drm_probe_helper.c
> +++ b/drivers/gpu/drm/drm_probe_helper.c
> @@ -164,6 +164,18 @@ void drm_kms_helper_poll_enable_locked(struct 
> drm_device *dev)  }
>  
>  /**
> + * drm_helper_clear_display_info - clean cached display information 
> +for
> + * hot pluggable displays, on event of hot-unplug
> + * @connector: connector under event
> + */
> +void drm_helper_clear_display_info(struct drm_connector *connector) {
> +	struct drm_display_info *info = &connector->display_info;
> +
> +	memset(info, 0, sizeof(*info));
> +}
> +
> +/**
>   * drm_helper_probe_single_connector_modes - get complete set of display modes
>   * @connector: connector to probe
>   * @maxX: max width for modes
> @@ -288,6 +300,16 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector,
>  		DRM_DEBUG_KMS("[CONNECTOR:%d:%s] disconnected\n",
>  			connector->base.id, connector->name);
>  		drm_mode_connector_update_edid_property(connector, NULL);
> +
> +		/*
> +		 * Connector status change to disconnected, time to clean
> +		 * cached display information.
> +		 * Any driver which doesn't use this probe_helper function
> +		 * should implement update of EDID property and display_info
> +		 * on its own.
> +		 */
> +		drm_helper_clear_display_info(connector);
> +
>  		verbose_prune = false;
>  		goto prune;
>  	}
On Thu, Dec 29, 2016 at 05:58:50PM +0530, Shashank Sharma wrote:
> This patch adds a small helper function, which clears the cached
> information about a hot-pluggable display, from connector. On event
> This will run on event of a hot-unplug, keeping the connector's display
> info up-to-date, avoiding any errors due to invalid cached data.
> 
> Forking this patch out from the 3 patch series:
> 	https://patchwork.freedesktop.org/patch/128961/
> (still under review) and sending as individual patch.
> 
> Cc: Jose Abreu <joabreu@synopsys.com>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> 
> Suggested-by: Jose Abreu <joabreu@synopsys.com>
> Signed-off-by: Shashank Sharma <shashank.sharma@intel.com>
> ---
>  drivers/gpu/drm/drm_probe_helper.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c
> index 7cff91e..65a6a1f 100644
> --- a/drivers/gpu/drm/drm_probe_helper.c
> +++ b/drivers/gpu/drm/drm_probe_helper.c
> @@ -164,6 +164,18 @@ void drm_kms_helper_poll_enable_locked(struct drm_device *dev)
>  }
>  
>  /**
> + * drm_helper_clear_display_info - clean cached display information for
> + * hot pluggable displays, on event of hot-unplug
> + * @connector: connector under event
> + */
> +void drm_helper_clear_display_info(struct drm_connector *connector)
> +{
> +	struct drm_display_info *info = &connector->display_info;
> +
> +	memset(info, 0, sizeof(*info));
> +}
> +
> +/**
>   * drm_helper_probe_single_connector_modes - get complete set of display modes
>   * @connector: connector to probe
>   * @maxX: max width for modes
> @@ -288,6 +300,16 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector,
>  		DRM_DEBUG_KMS("[CONNECTOR:%d:%s] disconnected\n",
>  			connector->base.id, connector->name);
>  		drm_mode_connector_update_edid_property(connector, NULL);
> +
> +		/*
> +		 * Connector status change to disconnected, time to clean
> +		 * cached display information.
> +		 * Any driver which doesn't use this probe_helper function
> +		 * should implement update of EDID property and display_info
> +		 * on its own.
> +		 */
> +		drm_helper_clear_display_info(connector);

This isn't really the only place where you can switch to disconnected. I
think something along the lines of some of Jani's recent RFC where we try
to make this functions dtrt thing for a NULL edid would be much more
robust.
-Daniel

> +
>  		verbose_prune = false;
>  		goto prune;
>  	}
> -- 
> 1.9.1
>