All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tomi Valkeinen <tomi.valkeinen@ti.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 01/42] drm/omap: fix suspend/resume handling
Date: Mon, 7 Mar 2016 10:04:34 +0200	[thread overview]
Message-ID: <56DD3612.8050207@ti.com> (raw)
In-Reply-To: <2736448.dXU553MJfV@avalon>


[-- Attachment #1.1.1: Type: text/plain, Size: 6849 bytes --]


On 07/03/16 09:52, Laurent Pinchart wrote:
> Hi Tomi,
> 
> Thank you for the patch.
> 
> On Monday 22 February 2016 19:10:07 Tomi Valkeinen wrote:
>> For legacy reasons omapdss handles system suspend/resume via PM notifier
>> callback, where the driver disables/resumes all the outputs.
>>
>> This doesn't work well with omapdrm. What happens on suspend is that the
>> omapdss disables the displays while omapdrm is still happily continuing
>> its work, possibly waiting for an vsync irq, which will never come if
>> the display output is disabled, leading to timeouts and errors sent to
>> userspace.
>>
>> This patch moves the suspend/resume handling to omapdrm, and the
>> suspend/resume is now done safely inside modeset lock.
>>
>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
>> ---
>>  drivers/gpu/drm/omapdrm/dss/core.c    | 29 -----------------------
>>  drivers/gpu/drm/omapdrm/dss/display.c | 36 ----------------------------
>>  drivers/gpu/drm/omapdrm/dss/dss.h     |  2 --
>>  drivers/gpu/drm/omapdrm/omap_drv.c    | 44 ++++++++++++++++++++++++++++++++
>>  4 files changed, 44 insertions(+), 67 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/omapdrm/dss/core.c
>> b/drivers/gpu/drm/omapdrm/dss/core.c index 54eeb507f9b3..1f55d0aae03d
>> 100644
>> --- a/drivers/gpu/drm/omapdrm/dss/core.c
>> +++ b/drivers/gpu/drm/omapdrm/dss/core.c
>> @@ -165,31 +165,6 @@ int dss_debugfs_create_file(const char *name, void
>> (*write)(struct seq_file *)) #endif /* CONFIG_OMAP2_DSS_DEBUGFS */
>>
>>  /* PLATFORM DEVICE */
>> -static int omap_dss_pm_notif(struct notifier_block *b, unsigned long v,
>> void *d) -{
>> -	DSSDBG("pm notif %lu\n", v);
>> -
>> -	switch (v) {
>> -	case PM_SUSPEND_PREPARE:
>> -	case PM_HIBERNATION_PREPARE:
>> -	case PM_RESTORE_PREPARE:
>> -		DSSDBG("suspending displays\n");
>> -		return dss_suspend_all_devices();
>> -
>> -	case PM_POST_SUSPEND:
>> -	case PM_POST_HIBERNATION:
>> -	case PM_POST_RESTORE:
>> -		DSSDBG("resuming displays\n");
>> -		return dss_resume_all_devices();
>> -
>> -	default:
>> -		return 0;
>> -	}
>> -}
>> -
>> -static struct notifier_block omap_dss_pm_notif_block = {
>> -	.notifier_call = omap_dss_pm_notif,
>> -};
>>
>>  static int __init omap_dss_probe(struct platform_device *pdev)
>>  {
>> @@ -211,8 +186,6 @@ static int __init omap_dss_probe(struct platform_device
>> *pdev) else if (pdata->default_device)
>>  		core.default_display_name = pdata->default_device->name;
>>
>> -	register_pm_notifier(&omap_dss_pm_notif_block);
>> -
>>  	return 0;
>>
>>  err_debugfs:
>> @@ -222,8 +195,6 @@ err_debugfs:
>>
>>  static int omap_dss_remove(struct platform_device *pdev)
>>  {
>> -	unregister_pm_notifier(&omap_dss_pm_notif_block);
>> -
>>  	dss_uninitialize_debugfs();
>>
>>  	return 0;
>> diff --git a/drivers/gpu/drm/omapdrm/dss/display.c
>> b/drivers/gpu/drm/omapdrm/dss/display.c index ef5b9027985d..24c2bffa0036
>> 100644
>> --- a/drivers/gpu/drm/omapdrm/dss/display.c
>> +++ b/drivers/gpu/drm/omapdrm/dss/display.c
>> @@ -78,42 +78,6 @@ void omapdss_default_get_timings(struct omap_dss_device
>> *dssdev, }
>>  EXPORT_SYMBOL(omapdss_default_get_timings);
>>
>> -int dss_suspend_all_devices(void)
>> -{
>> -	struct omap_dss_device *dssdev = NULL;
>> -
>> -	for_each_dss_dev(dssdev) {
>> -		if (!dssdev->driver)
>> -			continue;
>> -
>> -		if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE) {
>> -			dssdev->driver->disable(dssdev);
>> -			dssdev->activate_after_resume = true;
>> -		} else {
>> -			dssdev->activate_after_resume = false;
>> -		}
>> -	}
>> -
>> -	return 0;
>> -}
>> -
>> -int dss_resume_all_devices(void)
>> -{
>> -	struct omap_dss_device *dssdev = NULL;
>> -
>> -	for_each_dss_dev(dssdev) {
>> -		if (!dssdev->driver)
>> -			continue;
>> -
>> -		if (dssdev->activate_after_resume) {
>> -			dssdev->driver->enable(dssdev);
>> -			dssdev->activate_after_resume = false;
>> -		}
>> -	}
>> -
>> -	return 0;
>> -}
>> -
>>  void dss_disable_all_devices(void)
>>  {
>>  	struct omap_dss_device *dssdev = NULL;
>> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h
>> b/drivers/gpu/drm/omapdrm/dss/dss.h index 9a6453235585..a974d46672db 100644
>> --- a/drivers/gpu/drm/omapdrm/dss/dss.h
>> +++ b/drivers/gpu/drm/omapdrm/dss/dss.h
>> @@ -206,8 +206,6 @@ int dss_set_min_bus_tput(struct device *dev, unsigned
>> long tput); int dss_debugfs_create_file(const char *name, void
>> (*write)(struct seq_file *));
>>
>>  /* display */
>> -int dss_suspend_all_devices(void);
>> -int dss_resume_all_devices(void);
>>  void dss_disable_all_devices(void);
>>
>>  int display_init_sysfs(struct platform_device *pdev);
>> diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c
>> b/drivers/gpu/drm/omapdrm/omap_drv.c index dfafdb602ad2..e21433c3fda4
>> 100644
>> --- a/drivers/gpu/drm/omapdrm/omap_drv.c
>> +++ b/drivers/gpu/drm/omapdrm/omap_drv.c
>> @@ -900,12 +900,52 @@ static int pdev_remove(struct platform_device *device)
>> }
>>
>>  #ifdef CONFIG_PM_SLEEP
>> +static int omap_drm_suspend_all_displays(void)
>> +{
>> +	struct omap_dss_device *dssdev = NULL;
>> +
>> +	for_each_dss_dev(dssdev) {
>> +		if (!dssdev->driver)
>> +			continue;
>> +
>> +		if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE) {
>> +			dssdev->driver->disable(dssdev);
>> +			dssdev->activate_after_resume = true;
>> +		} else {
>> +			dssdev->activate_after_resume = false;
>> +		}
>> +	}
>> +
>> +	return 0;
>> +}
>> +
>> +static int omap_drm_resume_all_displays(void)
>> +{
>> +	struct omap_dss_device *dssdev = NULL;
>> +
>> +	for_each_dss_dev(dssdev) {
>> +		if (!dssdev->driver)
>> +			continue;
>> +
>> +		if (dssdev->activate_after_resume) {
>> +			dssdev->driver->enable(dssdev);
>> +			dssdev->activate_after_resume = false;
>> +		}
>> +	}
>> +
>> +	return 0;
>> +}
>> +
>>  static int omap_drm_suspend(struct device *dev)
>>  {
>>  	struct drm_device *drm_dev = dev_get_drvdata(dev);
>>
>>  	drm_kms_helper_poll_disable(drm_dev);
>>
>> +	drm_modeset_lock_all(drm_dev);
> 
> The omapdss implementation of the suspend and resume handlers didn't take the 
> modeset locks. I wonder what we're trying to protect against here, what other 
> concurrent task(s) could race us ?

The description explains at least one case I was encountering. To be
honest, the new code doesn't feel very good either, but at least the
entry point is now in omapdrm, and protected with a lock, so it should
be much safer.

As for what else is there... I hope not much. The panel/encoder drivers
can execute code in an interrupt or possibly even via a sysfs file if
someone would add things like that, and at the moment we don't have
means to properly deal with it. But afaik the current drivers don't do
any of those.

 Tomi


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

  reply	other threads:[~2016-03-07  8:04 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-22 17:10 [PATCH 00/42] drm/omap: patches for v4.6 part 2 Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 01/42] drm/omap: fix suspend/resume handling Tomi Valkeinen
2016-03-07  7:52   ` Laurent Pinchart
2016-03-07  8:04     ` Tomi Valkeinen [this message]
2016-02-22 17:10 ` [PATCH 02/42] drm/omap: move dss_suspend/resume_all to core.c Tomi Valkeinen
2016-03-07  7:53   ` Laurent Pinchart
2016-02-22 17:10 ` [PATCH 03/42] drm/omap: omapdss.h: remove unused struct omap_dss_hdmi_data Tomi Valkeinen
2016-03-07  7:55   ` Laurent Pinchart
2016-02-22 17:10 ` [PATCH 04/42] drm/omap: omapdss.h: remove omap_hdmi_init Tomi Valkeinen
2016-03-07  7:56   ` Laurent Pinchart
2016-02-22 17:10 ` [PATCH 05/42] drm/omap: panel-dsi-cm: remove pdata support Tomi Valkeinen
2016-03-07  8:04   ` Laurent Pinchart
2016-03-07  8:07     ` Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 06/42] drm/omap: encoder-tfp410: " Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 07/42] drm/omap: connector-dvi: " Tomi Valkeinen
2016-03-07  8:16   ` Laurent Pinchart
2016-03-07  8:24     ` Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 08/42] drm/omap: connector-hdmi: " Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 09/42] drm/omap: panel-lgphilips-lb035q02: " Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 10/42] drm/omap: panel-sharp-ls037v7dw01: " Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 11/42] drm/omap: panel-nec-nl8048hl11: " Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 12/42] drm/omap: panel-tpo-td028ttec1: " Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 13/42] drm/omap: panel-tpo-td043mtea1: " Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 14/42] drm/omap, omapfb: move exported dispc function declarations to omapdrm/omapfb Tomi Valkeinen
2016-03-07  8:42   ` Laurent Pinchart
2016-03-07  8:54     ` Tomi Valkeinen
2016-03-07  9:53       ` Laurent Pinchart
2016-02-22 17:10 ` [PATCH 15/42] drm/omap: move struct dss_mgr_ops " Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 16/42] drm/omap: move dss_mgr_* declarations " Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 17/42] drm/omap: Add dispc_mgr_get_supported_outputs() Tomi Valkeinen
2016-03-07  8:47   ` Laurent Pinchart
2016-03-07  9:08     ` Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 18/42] drm/omap: remove crtc->mgr field Tomi Valkeinen
2016-03-07  8:52   ` Laurent Pinchart
2016-03-07  9:19     ` Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 19/42] drm/omap: remove use of omapdss_find_mgr_from_display() Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 20/42] drm/omap: convert dss_mgr_ops to use omap_channel Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 21/42] drm/omap: add dispc_channel_connected field to omap_dss_device Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 22/42] drm/omap: use dispc_channel_connected in output drivers Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 23/42] drm/omap: convert dss_mgr_connect to accept omap_channel Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 24/42] drm/omap: convert dss_mgr_disconnect " Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 25/42] drm/omap: convert dss_mgr_set_timings " Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 26/42] drm/omap: convert dss_mgr_set_lcd_config " Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 27/42] drm/omap: convert dss_mgr_enable " Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 28/42] drm/omap: convert dss_mgr_disable " Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 29/42] drm/omap: convert dss_mgr_start_update " Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 30/42] drm/omap: convert dss_mgr_register_framedone_handler " Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 31/42] drm/omap: convert dss_mgr_unregister_framedone_handler " Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 32/42] drm/omap: remove extra check in dpi and sdi Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 33/42] drm/omap: remove extra manager checks on disconnect Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 34/42] drm/omap: DPI: remove uses of omap_overlay_manager Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 35/42] drm/omap: HDMI5: " Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 36/42] drm/omap: HDMI4: " Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 37/42] drm/omap: SDI: " Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 38/42] drm/omap: VENC: " Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 39/42] drm/omap: DSI: " Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 40/42] drm/omap: remove last " Tomi Valkeinen
2016-03-07  9:01   ` Laurent Pinchart
2016-03-07  9:10     ` Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 41/42] drm/omap: remove dss compat code Tomi Valkeinen
2016-02-22 17:10 ` [PATCH 42/42] drm/omap: remove dispc_ovl_check() Tomi Valkeinen

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=56DD3612.8050207@ti.com \
    --to=tomi.valkeinen@ti.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=laurent.pinchart@ideasonboard.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.