From patchwork Wed Sep 10 14:43:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 4881941 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 96AA29F32F for ; Thu, 11 Sep 2014 02:25:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C63D1201C0 for ; Thu, 11 Sep 2014 02:25:29 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 021C22018E for ; Thu, 11 Sep 2014 02:25:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A412D6E4C7; Wed, 10 Sep 2014 19:25:25 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from na01-bl2-obe.outbound.protection.outlook.com (mail-bl2on0136.outbound.protection.outlook.com [65.55.169.136]) by gabe.freedesktop.org (Postfix) with ESMTP id 1FB866E463 for ; Wed, 10 Sep 2014 07:44:19 -0700 (PDT) Received: from BY2PR03CA055.namprd03.prod.outlook.com (10.141.249.28) by BY2PR03MB345.namprd03.prod.outlook.com (10.141.139.11) with Microsoft SMTP Server (TLS) id 15.0.1024.9; Wed, 10 Sep 2014 14:44:15 +0000 Received: from BL2FFO11FD017.protection.gbl (2a01:111:f400:7c09::145) by BY2PR03CA055.outlook.office365.com (2a01:111:e400:2c5d::28) with Microsoft SMTP Server (TLS) id 15.0.1024.12 via Frontend Transport; Wed, 10 Sep 2014 14:44:15 +0000 Received: from az84smr01.freescale.net (192.88.158.2) by BL2FFO11FD017.mail.protection.outlook.com (10.173.161.35) with Microsoft SMTP Server (TLS) id 15.0.1019.14 via Frontend Transport; Wed, 10 Sep 2014 14:44:14 +0000 Received: from dragon.ap.freescale.net ([10.192.185.80]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id s8AEi7bR006315; Wed, 10 Sep 2014 07:44:08 -0700 From: Shawn Guo To: Greg Kroah-Hartman Subject: [PATCH RESEND] imx-drm: imx-drm-core: add basic suspend/resume support Date: Wed, 10 Sep 2014 22:43:51 +0800 Message-ID: <1410360231-14837-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.158.2; CTRY:US; IPV:CAL; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019019)(6009001)(199003)(189002)(4396001)(50986999)(87936001)(62966002)(104016003)(36756003)(15975445006)(50226001)(85852003)(81342001)(88136002)(81156004)(81542001)(83072002)(106466001)(31966008)(86362001)(92726001)(89996001)(97736003)(19580405001)(15202345003)(79102001)(74662001)(44976005)(92566001)(48376002)(87286001)(19580395003)(74502001)(83322001)(95666004)(33646002)(68736004)(84676001)(20776003)(107046002)(6806004)(90102001)(47776003)(99396002)(21056001)(77156001)(110136001)(104166001)(76482001)(77982001)(50466002)(230783001)(102836001)(85306004)(105606002)(80022001)(64706001)(69596002)(93916002)(26826002)(229853001)(46102001); DIR:OUT; SFP:1102; SCL:1; SRVR:BY2PR03MB345; H:az84smr01.freescale.net; FPR:; MLV:ovrnspm; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;UriScan:; X-Forefront-PRVS: 033054F29A Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=Shawn.Guo@freescale.com; X-OriginatorOrg: freescale.com X-Mailman-Approved-At: Wed, 10 Sep 2014 19:25:24 -0700 Cc: devel@driverdev.osuosl.org, Russell King , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de, Shawn Guo X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 --- Greg, This is a resend of '[PATCH v3] imx-drm: imx-drm-core: add suspend/resume support' [1], with a tiny change on the subject only. Shawn [1] http://thread.gmane.org/gmane.linux.ports.arm.kernel/349360 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, }, };