Subject: [PATCH v2] imx-drm: imx-drm-core: add suspend/resume support

From: [email-masked] (Andrzej Hajda)
Date: Mon, 18 Aug 2014 14:58:14 +0200

On 08/18/2014 02:38 PM, Shawn Guo wrote:
> Hi Andrzej,
>
> On Mon, Aug 18, 2014 at 09:43:19AM +0200, Andrzej Hajda wrote:
>>> diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c
>>> index def8280d7ee6..ab41152089a3 100644
>>> --- a/drivers/staging/imx-drm/imx-drm-core.c
>>> +++ b/drivers/staging/imx-drm/imx-drm-core.c
>>> @@ -696,6 +696,29 @@ static int imx_drm_platform_remove(struct platform_device *pdev)
>>>  	return 0;
>>>  }
>>>  
>>> +#ifdef CONFIG_PM_SLEEP
>>> +static int imx_drm_suspend(struct device *dev)
>>> +{
>>> +	struct drm_device *drm_dev = dev_get_drvdata(dev);
>>> +
>>> +	drm_kms_helper_poll_disable(drm_dev);
>> drm_dev can be NULL here. You should add check before.
> The drvdata is set to drm_dev in drm_driver .load() hook.  So are you
> saying that .suspend() hook could possibly be called before the .load()
> hook gets called?

.load hook is called after all components are attached to the master.
So if suspend happen after probe of the master and before attaching the last
component you will have NULL here, I guess.

Regards
Andrzej

>
> Shawn
>
>>> +
>>> +	return 0;
>>> +}
>>> +
>>> +static int imx_drm_resume(struct device *dev)
>>> +{
>>> +	struct drm_device *drm_dev = dev_get_drvdata(dev);
>>> +
>>> +	drm_helper_resume_force_mode(drm_dev);
>> ditto