From patchwork Tue Jul 17 10:48:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonard Crestez X-Patchwork-Id: 10531481 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BCF68602CA for ; Wed, 18 Jul 2018 07:29:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A38FC290E8 for ; Wed, 18 Jul 2018 07:29:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 97A59290F1; Wed, 18 Jul 2018 07:29:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 15D1A290E8 for ; Wed, 18 Jul 2018 07:29:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 79E4A6E829; Wed, 18 Jul 2018 07:28:12 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-am5eur03on062c.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe08::62c]) by gabe.freedesktop.org (Postfix) with ESMTPS id 899CF892A9 for ; Tue, 17 Jul 2018 10:48:56 +0000 (UTC) Received: from localhost.localdomain (95.76.156.53) by VI1PR04MB4303.eurprd04.prod.outlook.com (2603:10a6:803:3f::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.952.19; Tue, 17 Jul 2018 10:48:52 +0000 From: Leonard Crestez To: Marek Vasut , Stefan Agner , Shawn Guo Subject: [PATCH v2] drm/mxsfb: Fix runtime PM for unpowering lcdif block Date: Tue, 17 Jul 2018 13:48:31 +0300 Message-Id: X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [95.76.156.53] X-ClientProxiedBy: AM5P189CA0023.EURP189.PROD.OUTLOOK.COM (2603:10a6:206:15::36) To VI1PR04MB4303.eurprd04.prod.outlook.com (2603:10a6:803:3f::30) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3ddf3674-116d-436b-4ebb-08d5ebd2e37e X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(48565401081)(2017052603328)(7153060)(7193020); SRVR:VI1PR04MB4303; X-Microsoft-Exchange-Diagnostics: 1; VI1PR04MB4303; 3:mAPymEfMFoAFFBqAbyRUi8apfyy255SzyFzkfgRvds0fxG21FBUEwlxdRtvGzqhzpFcdAuFgVzAhLtzr/r8hQTrB6Dv2Ib7QoPYt+FHM/5nrkVxDYaOAzJ3gs/UTohSHURmzh+Z91LzaiMCj2LUKPhqor7dBo+3fJ8QuMhwECWTEIsVet0T+9TyjcZCor1f1xHLKms/2htP2beUrW/pfqW08OlP7pZyPLJQhUeoVVC3IbrhsrvqPHH8KK1U3iOkC; 25:7oTRoLxTsy4KekokKkpNm0uY581VbnN7q8WD1aA4HqxI4isAybJ3fZsCX+jt7yQmVhUK4cEEktTQc++aRdOb3tQEIiCr8JZ346SYyxYjYdVrinvJyZ+u3bL9gKmwt9tdcXZjKZvut3brffeSpqs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iTR0x1Xq1/ldcN2AV5jHY2gKuJGwEgadGV8uUzVaoUYRkBB7w4Nu+l/qFGpHtXA2CdLAAi51bzgyNmbbMfhs26KaiZ4/xuy92Z9MhyOmQAuCswBfBYJjoeVRQpH14elvXQF5rKJi/vTxODzOn+r3q6v1Qz9u7wGCxw0+JxBO5oDWEn9nGs6e4cOm2m4RhMbO9lh8vTfXK7nMIex8ZV5ZeiYW8mvXuff3RufBUj45B1SEZx/9uJtLRX3QGBDH6XyTHskSoNl6 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(10201501046)(3231311)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123562045)(6072148)(201708071742011)(7699016); SRVR:VI1PR04MB4303; BCL:0; PCL:0; RULEID:; SRVR:VI1PR04MB4303; X-Forefront-PRVS: 073631BD3D X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(979002)(6069001)(39860400002)(396003)(366004)(376002)(346002)(136003)(199004)(189003)(51416003)(305945005)(476003)(8936002)(44832011)(956004)(110136005)(14444005)(47776003)(16586007)(486006)(7736002)(54906003)(6666003)(2616005)(52116002)(81156014)(5660300001)(8676002)(386003)(6506007)(316002)(81166006)(68736007)(118296001)(66066001)(50226002)(97736004)(6512007)(2906002)(26005)(105586002)(25786009)(4326008)(48376002)(6486002)(50466002)(53936002)(966005)(186003)(86362001)(6306002)(3846002)(6116002)(106356001)(478600001)(36756003)(16526019)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR04MB4303; H:localhost.localdomain; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR04MB4303; 23:s6fTyfD1dZee5wmshjwuoTP/QKokLx9SF0t/54Y7g?= =?us-ascii?Q?9Xnkyzw38Lj7bsIpkKoJg//KNy+bTYo4k+p9oH61E/kXK3Tyx1FZgInhlCfp?= =?us-ascii?Q?/wjCAPfT+oLdHGSzTRGPlQwfL8fMOkcfV/vtZob8PLIyU9oNoscJMGwUvHvt?= =?us-ascii?Q?hM+6X9BHUIaZWuIH08RFMoTlDbZKMF9YWGRFT1NK2NLM5kHKmf+ajveoT75H?= =?us-ascii?Q?ztL66wwnwymOQZNXrH7OPkpXxTQDIBg4DelTtikBjAdiIhkvlhvgiWiFMP+Y?= =?us-ascii?Q?2HEj7TP1WoiKJ2JLpLE8uWkP8v9C5dnihqKPLEhcCgaCUUx0+VL+IkYpK0zI?= =?us-ascii?Q?16m4fV5Enb3x9PH/m5ByEGR4S7LYrtlkx+FjY/61a8YLhgN0/exODVXFfEK8?= =?us-ascii?Q?T5jEtNSK7Oz5w7mt4aGsprJv/NqO1c0kKDuId6mybA5ZO+lJ6V576FdJqeFr?= =?us-ascii?Q?KI8va9j1xEI2QDwdiiljEXm2xQlk9jmc2bsiieWtJ7AnJVnb5kKsWo8WfzlN?= =?us-ascii?Q?GwKEcBmLwOVRDVmPMbsneajit11Ijgubtn+El9+I6B42t79ad0KtOeF7Ow1J?= =?us-ascii?Q?TCUqhvippIjS/4lb9Lnbb5xUksH0Y4aOC2y/bQTrBowyfY1Op3VNkOyNZmBl?= =?us-ascii?Q?z5xCuz+YI53WfUnlw9UimyFcemcAzL8wyUDnYu4B/j5SfMTRD5zerkmaOqX6?= =?us-ascii?Q?t0LiluP6p4eSK7h6b0j6knZSixk7YBSIAynS8/c3MwiDdYj2TRJDo2aW7YdT?= =?us-ascii?Q?CpLVbdwrgG7eVZCzw9PY8Myxhfm1065ifoQbbcfxvImCnmwQ8Q4bf9oZ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0LkyHXPQCyjsX4OE1NPIe6/nMmxbMBIH7JwU2dgxP3Dv5XdwwBhdH1DVeu8RYTZ6yMLw X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2018 10:48:52.6408 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3ddf3674-116d-436b-4ebb-08d5ebd2e37e X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4303 X-Mailman-Approved-At: Wed, 18 Jul 2018 07:28:03 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anson Huang , David Airlie , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Robert Chiras , linux-imx@nxp.com, kernel@pengutronix.de, Fabio Estevam Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Adding lcdif nodes to a power domain currently does work, it results in black/corrupted screens or hangs. While the driver does enable runtime pm it does not deal correctly with the block being unpowered. Ensure power is on when required by adding pm_runtime_get/put_sync to mxsfb_pipe_enable/disable. Since power is lost on suspend implement PM_SLEEP_OPS using drm_mode_config_helper_suspend/resume. The mxsfb_plane_atomic_update function can get called before mxsfb_pipe_enable while the block is not yet powered. When this happens the write to LCDIF_NEXT_BUF is lost causing corrupt display on unblank until a refresh. Fix this by not writing gem->paddr if the block is not enabled and instead delaying the write until the next mxsfb_crtc_mode_set_nofb call. At that point also update cur_buf to avoid an initial corrupt frame after resume. Signed-off-by: Leonard Crestez Tested-by: Philipp Zabel --- The purpose of this patch is to prepare for enabling power gating on DISPLAY power domains. Changes since v1: * Drop mxsfb_runtime_suspend/mxsfb_runtime_resume, calling pm_runtime_get/put in pipe enable/disable is enough. * Use drm_mode_config_helper_suspend/resume instead of attempting to track state manually. * Don't touch NEXT_BUF if atomic_update called with crtc disabled * Also update CUR_BUF on enable, this avoids initial corrupt frames. Previous discussion: https://lkml.org/lkml/2018/7/17/329 --- drivers/gpu/drm/mxsfb/mxsfb_crtc.c | 51 +++++++++++++++++++++++------- drivers/gpu/drm/mxsfb/mxsfb_drv.c | 25 +++++++++++++++ drivers/gpu/drm/mxsfb/mxsfb_drv.h | 2 ++ 3 files changed, 67 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/mxsfb/mxsfb_crtc.c b/drivers/gpu/drm/mxsfb/mxsfb_crtc.c index 0abe77675b76..10153da77c40 100644 --- a/drivers/gpu/drm/mxsfb/mxsfb_crtc.c +++ b/drivers/gpu/drm/mxsfb/mxsfb_crtc.c @@ -194,15 +194,31 @@ static int mxsfb_reset_block(void __iomem *reset_addr) return ret; return clear_poll_bit(reset_addr, MODULE_CLKGATE); } +static dma_addr_t mxsfb_get_fb_paddr(struct mxsfb_drm_private *mxsfb) +{ + struct drm_framebuffer *fb = mxsfb->pipe.plane.state->fb; + struct drm_gem_cma_object *gem; + + if (!fb) + return 0; + + gem = drm_fb_cma_get_gem_obj(fb, 0); + if (!gem) + return 0; + + return gem->paddr; +} + static void mxsfb_crtc_mode_set_nofb(struct mxsfb_drm_private *mxsfb) { struct drm_display_mode *m = &mxsfb->pipe.crtc.state->adjusted_mode; const u32 bus_flags = mxsfb->connector.display_info.bus_flags; u32 vdctrl0, vsync_pulse_len, hsync_pulse_len; + dma_addr_t paddr; int err; /* * It seems, you can't re-program the controller if it is still * running. This may lead to shifted pictures (FIFO issue?), so @@ -268,35 +284,47 @@ static void mxsfb_crtc_mode_set_nofb(struct mxsfb_drm_private *mxsfb) mxsfb->base + LCDC_VDCTRL3); writel(SET_DOTCLK_H_VALID_DATA_CNT(m->hdisplay), mxsfb->base + LCDC_VDCTRL4); + /* Update cur_buf as well to avoid an initial corrupt frame */ + paddr = mxsfb_get_fb_paddr(mxsfb); + if (paddr) { + writel(paddr, mxsfb->base + mxsfb->devdata->cur_buf); + writel(paddr, mxsfb->base + mxsfb->devdata->next_buf); + } mxsfb_disable_axi_clk(mxsfb); } void mxsfb_crtc_enable(struct mxsfb_drm_private *mxsfb) { + if (mxsfb->enabled) + return; + mxsfb_crtc_mode_set_nofb(mxsfb); mxsfb_enable_controller(mxsfb); + + mxsfb->enabled = true; } void mxsfb_crtc_disable(struct mxsfb_drm_private *mxsfb) { + if (!mxsfb->enabled) + return; + mxsfb_disable_controller(mxsfb); + + mxsfb->enabled = false; } void mxsfb_plane_atomic_update(struct mxsfb_drm_private *mxsfb, struct drm_plane_state *state) { struct drm_simple_display_pipe *pipe = &mxsfb->pipe; struct drm_crtc *crtc = &pipe->crtc; - struct drm_framebuffer *fb = pipe->plane.state->fb; struct drm_pending_vblank_event *event; - struct drm_gem_cma_object *gem; - - if (!crtc) - return; + dma_addr_t paddr; spin_lock_irq(&crtc->dev->event_lock); event = crtc->state->event; if (event) { crtc->state->event = NULL; @@ -307,14 +335,15 @@ void mxsfb_plane_atomic_update(struct mxsfb_drm_private *mxsfb, drm_crtc_send_vblank_event(crtc, event); } } spin_unlock_irq(&crtc->dev->event_lock); - if (!fb) + if (!mxsfb->enabled) return; - gem = drm_fb_cma_get_gem_obj(fb, 0); - - mxsfb_enable_axi_clk(mxsfb); - writel(gem->paddr, mxsfb->base + mxsfb->devdata->next_buf); - mxsfb_disable_axi_clk(mxsfb); + paddr = mxsfb_get_fb_paddr(mxsfb); + if (paddr) { + mxsfb_enable_axi_clk(mxsfb); + writel(paddr, mxsfb->base + mxsfb->devdata->next_buf); + mxsfb_disable_axi_clk(mxsfb); + } } diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c b/drivers/gpu/drm/mxsfb/mxsfb_drv.c index dd1dd58e4956..a5269fccbed9 100644 --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c @@ -101,23 +101,27 @@ static const struct drm_mode_config_funcs mxsfb_mode_config_funcs = { static void mxsfb_pipe_enable(struct drm_simple_display_pipe *pipe, struct drm_crtc_state *crtc_state, struct drm_plane_state *plane_state) { struct mxsfb_drm_private *mxsfb = drm_pipe_to_mxsfb_drm_private(pipe); + struct drm_device *drm = pipe->plane.dev; + pm_runtime_get_sync(drm->dev); drm_panel_prepare(mxsfb->panel); mxsfb_crtc_enable(mxsfb); drm_panel_enable(mxsfb->panel); } static void mxsfb_pipe_disable(struct drm_simple_display_pipe *pipe) { struct mxsfb_drm_private *mxsfb = drm_pipe_to_mxsfb_drm_private(pipe); + struct drm_device *drm = pipe->plane.dev; drm_panel_disable(mxsfb->panel); mxsfb_crtc_disable(mxsfb); drm_panel_unprepare(mxsfb->panel); + pm_runtime_put_sync(drm->dev); } static void mxsfb_pipe_update(struct drm_simple_display_pipe *pipe, struct drm_plane_state *plane_state) { @@ -412,17 +416,38 @@ static int mxsfb_remove(struct platform_device *pdev) drm_dev_unref(drm); return 0; } +#ifdef CONFIG_PM +static int mxsfb_suspend(struct device *dev) +{ + struct drm_device *drm = dev_get_drvdata(dev); + + return drm_mode_config_helper_suspend(drm); +} + +static int mxsfb_resume(struct device *dev) +{ + struct drm_device *drm = dev_get_drvdata(dev); + + return drm_mode_config_helper_resume(drm); +} +#endif + +static const struct dev_pm_ops mxsfb_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(mxsfb_suspend, mxsfb_resume) +}; + static struct platform_driver mxsfb_platform_driver = { .probe = mxsfb_probe, .remove = mxsfb_remove, .id_table = mxsfb_devtype, .driver = { .name = "mxsfb-drm", .of_match_table = mxsfb_dt_ids, + .pm = &mxsfb_pm_ops, }, }; module_platform_driver(mxsfb_platform_driver); diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.h b/drivers/gpu/drm/mxsfb/mxsfb_drv.h index 5d0883fc805b..e539d4b05c48 100644 --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.h +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.h @@ -36,10 +36,12 @@ struct mxsfb_drm_private { struct drm_simple_display_pipe pipe; struct drm_connector connector; struct drm_panel *panel; struct drm_fbdev_cma *fbdev; + + bool enabled; }; int mxsfb_setup_crtc(struct drm_device *dev); int mxsfb_create_output(struct drm_device *dev);