From patchwork Wed Aug 8 16:08:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonard Crestez X-Patchwork-Id: 10563429 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 86D7913B4 for ; Sat, 11 Aug 2018 12:05:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 602652A2B8 for ; Sat, 11 Aug 2018 12:05:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 526332A532; Sat, 11 Aug 2018 12:05:44 +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 D7BF02A2B8 for ; Sat, 11 Aug 2018 12:05:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 28CAE6E1A7; Sat, 11 Aug 2018 12:05:14 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40045.outbound.protection.outlook.com [40.107.4.45]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2E0A289E08 for ; Wed, 8 Aug 2018 16:09:33 +0000 (UTC) Received: from localhost.localdomain (95.76.156.53) by VI1PR04MB4301.eurprd04.prod.outlook.com (2603:10a6:803:3f::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1017.15; Wed, 8 Aug 2018 16:09:30 +0000 From: Leonard Crestez To: Stefan Agner , Marek Vasut , Shawn Guo Subject: [PATCH v4 2/5] drm/mxsfb: Fix initial corrupt frame when activating display Date: Wed, 8 Aug 2018 19:08:59 +0300 Message-Id: <056bd70ef7bf4d66d636cf7869a489e8c743aaf3.1533743954.git.leonard.crestez@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [95.76.156.53] X-ClientProxiedBy: DB6PR02CA0004.eurprd02.prod.outlook.com (2603:10a6:6:15::17) To VI1PR04MB4301.eurprd04.prod.outlook.com (2603:10a6:803:3f::28) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 737d53ab-a6a2-4911-dfa7-08d5fd49533c X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR04MB4301; X-Microsoft-Exchange-Diagnostics: 1; VI1PR04MB4301; 3:GHqLgIRLZ8yM3HjRDgsGd4mCn2bKIXzTunpZSKp0nxWoY8mm2uYuQFrIgBL85cE2HzLkd+GXT+Tnu6YmCx1dL9WR4MCrhtW/uK1OEaf7UTDUlfN0Cw5KnkEmPXPkSRtz63yuhUPRPBGXb+/U/WvpRUZp9SNDrmaSV+WjFP8HEbCMqCnCl2S7n3P5/qqnCpwIVuCUwiY5dIrhE8MHpPMwzPUGJ0QVeIbzk/LW/oNWoi/U1Xf0ALmw3NqvSmSrZyk9; 25:OTyoWBFmP1CDP0TAA1+p/ZpWNMU8xpbbREptaGE+6mg3LgJBwq+nM0xpengoXw/qLBVVUD+ruf9YrhKVjQ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dvQEvdDdjNh8t0kx/Duj; 4:SwqgO+yDCqeFaCHZSf1/A2g3lyMUCXXBuADD+soF34jupon+cFhMdTBBWbLe6T7G+mL2wItSQr7uUZ6uY8M3AGCWsZIbkqR2VVpGxZsYiI68u4+Z9D5KW/8IUQguNUrIIFSR8U9mAj+1DUQq9ZeJWse75mKzqvAOoIVfyCnckzgRuOphTtBUA0Eu0FMn19FCz51N2BpRycCCI4ym2FPYCvIjikVrUpCmKMXMh4YbBhGWk3ycWPpjcZ4ty0LFLZU2Sm+pWLU41WVneX/9u4kv5W2o+tXwNdab+Nx1JDoe6iojC7MjQkhRhzZYICF+e/pK 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)(8121501046)(5005006)(3231311)(944501410)(52105095)(10201501046)(93006095)(93001095)(3002001)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123564045)(20161123562045)(6072148)(201708071742011)(7699016); SRVR:VI1PR04MB4301; BCL:0; PCL:0; RULEID:; SRVR:VI1PR04MB4301; X-Forefront-PRVS: 07584EDBCD X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(39850400004)(376002)(396003)(346002)(366004)(136003)(199004)(189003)(66066001)(7736002)(76176011)(47776003)(6512007)(81166006)(68736007)(81156014)(25786009)(8676002)(6666003)(110136005)(54906003)(36756003)(14444005)(305945005)(106356001)(105586002)(53936002)(50466002)(6486002)(97736004)(48376002)(86362001)(4326008)(575784001)(3846002)(5660300001)(26005)(486006)(16526019)(186003)(316002)(2906002)(16586007)(6116002)(6506007)(44832011)(478600001)(8936002)(956004)(11346002)(2616005)(50226002)(386003)(446003)(476003)(51416003)(52116002)(118296001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR04MB4301; 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; VI1PR04MB4301; 23:mcnipxJWYD0RphA7Pvbm6dbRq7oxUInNFfz9lif91?= FZU54zospCZDeYA89PVRT+yQD1FizEM361qLqZdbPo8xjV77eUhUnpDYD6XJH+C/UmLgp6Y7FB8FMc+9cx6UXUI0rjp8A7PnDRnFXRkwoHB/IxOjM7fiomAeLwaE/3zR/v3jOHUnxCa2UvMAfhnROVaVfHR978n7hRGeAXXSO/iand6p9oZj+Ced6FlOZXaX7PAkujawJVgzzs2ZejcM6CvYng0EBY1iFi79s9NYpB2DCM/TghMwujPh54Sk7/F2CpCMarFwTqlyw2TLeLITPQ1MUVpYlyATmohpX72AI4O8Pbu50QryY+WWHNMZQ1aqkB/zYnTmhV44W40LDGQs71aE53hufPB63hwtZgpVDtni2GtqtvPor8gpv3DPbpf3kqP+BANi/xAAqznL1cNGULDD1frYi7Ee06LE009VP3aevnAmLf59M3qvx5vm49NVO7QHcpnNhmj1KREq4SOXMQs7PFRq5QY7DFQ+fKquFgwq7r5o3NSqTcVurCO5v3sJZM4/WyH2kVGzPwLhBg1PqPE0MCJADrxQoKsWGB4KX/gF/haWEPW4rHRu0Z8hN9qiovxzVEem7C0Achq40LOKQdk1VbsHd8Q/PickDS/eQkiXbacN/8gU4FyqhZ+rUH8gP+AO+ebh1BLTBWq2z6lISFAoWLBRPwhNfbskssN/e/7KrO6v1/p3Lo0EW6CMHkRJFWf0mam/ve+f6TnubfBp800poLaa279aMvWGnplihFFvCq+aQEPhJCQZux69kqUBF688Y1K21t6MWjyyePcqntE/h/b1yCc3cCxrPpoEtNmQmACpMkkMYDMKjDLWQE3GUKBpZnum1IDFbXppd+2znwDNqDBy4V0qwdGUMCC//Q+mosWUopyr3GDy/DYRKHZQQ7/kGOGMLyQiaxbVnYKctrTMDpFeWh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wV15w+I5L7dgSC0IyN1wJXAbmyThxxuPGQniSMQPIJRFeSf1dKvFBXZ2blwv5WbdpwBU7D2lmWmHpxqj3FuDaRz/sdX61I6vahBA2H5eENKj33J+eedzxx7lC7ww2ce2r/2QGPheI3+CP6w==; 5:XWGcNnaLRaldHfzmST9EC3HelZ/zUAr3kaW3UoJztt5S/8mO5EeCkLP5NOHQkBEC839coUBeiDW87oUou6LbVbpe0DWdQSnaLinz3j8BJW9VfvfyFHL5wt0CfJvyZCsCuLbvbkGJYaDy3dapxtw6DtZKmYxulvZE4auWQbS52vA=; 7:iaPmnkpKQOzzssjS5aS+AQyI1vbWAemz17gZ83i2AbXyWKZFn+QRjrltR25ep9pqDBBcZwcNhVaZip6Wmf2sqqkfiEdpocW+97jaMRfKH+Jj7llufZy9bf01jfwl+k5OWjLWYedC70f6EowfWJAGBC3ENWQLHSAX1oEVu8Cilti3fC39zHwmOeHnLPNATOcyHBWJA3HxxJlpT3nXk6i99lHS24s+K6ysAl3da3WklbxhrpnM7fDlywoNbvtAnsnF SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Aug 2018 16:09:30.0606 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 737d53ab-a6a2-4911-dfa7-08d5fd49533c X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4301 X-Mailman-Approved-At: Sat, 11 Aug 2018 12:05:13 +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: Dong Aisheng , kernel@pengutronix.de, Anson Huang , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Fabio Estevam , linux-imx@nxp.com, Robert Chiras Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP LCDIF will repeatedly display data from CUR_BUF and set CUR_BUF to NEXT_BUF when done. Since we are only ever writing to NEXT_BUF the display will show an initial corrupt frame. Fix by writing the FB paddr to both CUR_BUF and NEXT_BUF when activating the CRTC. Signed-off-by: Leonard Crestez Tested-by: Philipp Zabel --- drivers/gpu/drm/mxsfb/mxsfb_crtc.c | 45 +++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/mxsfb/mxsfb_crtc.c b/drivers/gpu/drm/mxsfb/mxsfb_crtc.c index e4fcbb65b969..24b1f0c1432e 100644 --- a/drivers/gpu/drm/mxsfb/mxsfb_crtc.c +++ b/drivers/gpu/drm/mxsfb/mxsfb_crtc.c @@ -191,10 +191,25 @@ 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; @@ -267,12 +282,22 @@ static void mxsfb_crtc_mode_set_nofb(struct mxsfb_drm_private *mxsfb) mxsfb->base + LCDC_VDCTRL4); } void mxsfb_crtc_enable(struct mxsfb_drm_private *mxsfb) { + dma_addr_t paddr; + mxsfb_enable_axi_clk(mxsfb); mxsfb_crtc_mode_set_nofb(mxsfb); + + /* Write 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_enable_controller(mxsfb); } void mxsfb_crtc_disable(struct mxsfb_drm_private *mxsfb) { @@ -283,16 +308,12 @@ void mxsfb_crtc_disable(struct mxsfb_drm_private *mxsfb) 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; @@ -303,14 +324,12 @@ 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) - 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); + } }