From patchwork Tue Aug 19 07:26:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 4741071 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 84EA8C0338 for ; Tue, 19 Aug 2014 07:32:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B5EC620149 for ; Tue, 19 Aug 2014 07:32:03 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A23CD20148 for ; Tue, 19 Aug 2014 07:32:01 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XJdos-0002ea-F5; Tue, 19 Aug 2014 07:27:02 +0000 Received: from mail-bn1lp0142.outbound.protection.outlook.com ([207.46.163.142] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XJdop-0002Zk-3l for linux-arm-kernel@lists.infradead.org; Tue, 19 Aug 2014 07:26:59 +0000 Received: from CH1PR03CA012.namprd03.prod.outlook.com (10.255.156.157) by BL2PR03MB339.namprd03.prod.outlook.com (10.141.68.23) with Microsoft SMTP Server (TLS) id 15.0.1015.9; Tue, 19 Aug 2014 07:26:35 +0000 Received: from BY2FFO11FD022.protection.gbl (10.255.156.132) by CH1PR03CA012.outlook.office365.com (10.255.156.157) with Microsoft SMTP Server (TLS) id 15.0.1010.18 via Frontend Transport; Tue, 19 Aug 2014 07:26:34 +0000 Received: from tx30smr01.am.freescale.net (192.88.168.50) by BY2FFO11FD022.mail.protection.outlook.com (10.1.15.211) with Microsoft SMTP Server (TLS) id 15.0.1010.11 via Frontend Transport; Tue, 19 Aug 2014 07:26:34 +0000 Received: from dragon.ap.freescale.net ([10.192.185.207]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id s7J7QSAA001836; Tue, 19 Aug 2014 00:26:29 -0700 From: Shawn Guo To: Russell King Subject: [PATCH v3] imx-drm: imx-drm-core: add suspend/resume support Date: Tue, 19 Aug 2014 15:26:25 +0800 Message-ID: <1408433185-14702-1-git-send-email-shawn.guo@freescale.com> X-Mailer: git-send-email 1.9.1 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:CAL; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019006)(6009001)(189002)(199003)(85852003)(104166001)(50986999)(46102001)(89996001)(62966002)(87286001)(79102001)(77982001)(97736001)(80022001)(76482001)(102836001)(85306004)(92566001)(104016003)(36756003)(50466002)(92726001)(110136001)(230783001)(86362001)(93916002)(33646002)(74502001)(83072002)(50226001)(95666004)(106466001)(74662001)(26826002)(6806004)(105606002)(4396001)(19580395003)(31966008)(44976005)(81342001)(83322001)(48376002)(19580405001)(229853001)(47776003)(99396002)(77156001)(68736004)(88136002)(21056001)(20776003)(87936001)(107046002)(81542001)(84676001)(64706001); DIR:OUT; SFP:1102; SCL:1; SRVR:BL2PR03MB339; H:tx30smr01.am.freescale.net; FPR:; MLV:ovrnspm; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;UriScan:; X-Forefront-PRVS: 0308EE423E Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=Shawn.Guo@freescale.com; X-OriginatorOrg: freescale.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140819_002659_302088_501EAFDD X-CRM114-Status: GOOD ( 12.25 ) X-Spam-Score: -0.7 (/) Cc: Daniel Vetter , David Airlie , dri-devel@lists.freedesktop.org, Andrzej Hajda , Shawn Guo , kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP HDMI currently stops working after a system suspend/resume cycle. The cause is that the mode setting states in hardware gets lost and isn't restored across the suspend/resume cycle. The patch adds a very basic suspend/resume support to imx-drm driver, and calls drm_helper_resume_force_mode() in .resume hook to restore the mode setting states, so that HDMI can continue working after a system suspend/resume cycle. Since the suspend/resume hook can be called with drm_device pointer being NULL from driver data, we need a check on the pointer in the hooks. And to avoid using a stale pointer from driver data, it also clears driver data in .unload hook. Signed-off-by: Shawn Guo --- Changes since v2: - Check NULL pointer of drm_dev in suspend/resume hook - Clear driver data in .unload hook drivers/staging/imx-drm/imx-drm-core.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c index 6b22106534d8..41ff896d2ca9 100644 --- a/drivers/staging/imx-drm/imx-drm-core.c +++ b/drivers/staging/imx-drm/imx-drm-core.c @@ -87,6 +87,8 @@ static int imx_drm_driver_unload(struct drm_device *drm) drm_vblank_cleanup(drm); drm_mode_config_cleanup(drm); + platform_set_drvdata(drm->platformdev, NULL); + return 0; } @@ -647,6 +649,36 @@ 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); + + /* The drm_dev is NULL before .load hook is called */ + if (drm_dev == NULL) + return 0; + + drm_kms_helper_poll_disable(drm_dev); + + return 0; +} + +static int imx_drm_resume(struct device *dev) +{ + struct drm_device *drm_dev = dev_get_drvdata(dev); + + if (drm_dev == NULL) + return 0; + + drm_helper_resume_force_mode(drm_dev); + drm_kms_helper_poll_enable(drm_dev); + + return 0; +} +#endif + +static SIMPLE_DEV_PM_OPS(imx_drm_pm_ops, imx_drm_suspend, imx_drm_resume); + static const struct of_device_id imx_drm_dt_ids[] = { { .compatible = "fsl,imx-display-subsystem", }, { /* sentinel */ }, @@ -659,6 +691,7 @@ static struct platform_driver imx_drm_pdrv = { .driver = { .owner = THIS_MODULE, .name = "imx-drm", + .pm = &imx_drm_pm_ops, .of_match_table = imx_drm_dt_ids, }, };