From patchwork Mon Sep 17 13:42:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonard Crestez X-Patchwork-Id: 10604013 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 6840E913 for ; Tue, 18 Sep 2018 09:58:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0FA1329AE5 for ; Tue, 18 Sep 2018 09:58:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 037E529B11; Tue, 18 Sep 2018 09:58:06 +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 7769329AE5 for ; Tue, 18 Sep 2018 09:58:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D93026E3AB; Tue, 18 Sep 2018 09:57:53 +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-eopbgr30041.outbound.protection.outlook.com [40.107.3.41]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6A7BD891FB for ; Mon, 17 Sep 2018 13:43:04 +0000 (UTC) Received: from localhost.localdomain (95.76.156.53) by AM0PR04MB4290.eurprd04.prod.outlook.com (2603:10a6:208:67::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.18; Mon, 17 Sep 2018 13:43:00 +0000 From: Leonard Crestez To: Daniel Vetter , Philipp Zabel , Marek Vasut Subject: [RESEND 2/5] drm/mxsfb: Fix initial corrupt frame when activating display Date: Mon, 17 Sep 2018 16:42:12 +0300 Message-Id: <7cdac9c064cc2b8a3d237934f186da98cefe6cb3.1537191359.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: HE1P190CA0028.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:52::17) To AM0PR04MB4290.eurprd04.prod.outlook.com (2603:10a6:208:67::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b7d68a23-614f-40ea-5133-08d61ca37cdc X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM0PR04MB4290; X-Microsoft-Exchange-Diagnostics: 1; AM0PR04MB4290; 3:P0w6+Hbqn8Egi3B1+D8SdtjSPvh0lld4/5jnmouExS9xr4iB2noVgjh1IFSceEf66S5Kv4LIPb29kMUMCeauiBjp1ezWKUAlzEUXFGwSN2F+XZ0cDpk/IfsKrcxbCYQWwlRSp7zxd20siAHt6/QIvHvwdnR0Wp7/xxk/VJcG26kbmpWjQ6ffY/ZrDe4LnSlwUCB/wXpWf26vTsZEs540mOpC/Bmirx3M2tmEM80G4SsDHWTZrnuCfioFaaxwcHY0; 25:U2BOVg2HhmqLoSdGB5DHUVKhPYfGgMTpNDRgD48HFm0Lb1c9P8F7zaTzNvFYx3KdU6O1tQl0wH/FKRTXp5y7R7WNlqM5j5h4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4:eMSIhwv1Bq/j/3fhIVAr3Bxv05k99L878VI5xky5hWewdsvioJTZ8QfNeSTZD6XaHxY0XXZuQc4zTllW3Hvt2fb7tEaCVty+rcwDsGivY2fIc7qMe5QSITgwTJSEe2/Y+cmirBPEMvymQo0ZcyafjkANL+3PwezX6u/AnT01iaSg5mEo1T7X7bO06iZ2JpPlEpsAI1bInXpW7c6wpY2jpLHJQFrkjXOy8Gxpi1qTbswSP3Ab1crjIMzGvIzlcdPKQyevR/zmAbea8quSA8pmwl0CAvg0BlYWeKsRJN/LAgvj4Dgdzoww0fj9pbwjzKXY 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)(93006095)(93001095)(3231355)(944501410)(52105095)(10201501046)(3002001)(6055026)(149027)(150027)(6041310)(20161123560045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(201708071742011)(7699050); SRVR:AM0PR04MB4290; BCL:0; PCL:0; RULEID:; SRVR:AM0PR04MB4290; X-Forefront-PRVS: 0798146F16 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(376002)(396003)(346002)(136003)(39860400002)(366004)(199004)(189003)(6506007)(81166006)(81156014)(8936002)(14444005)(50226002)(478600001)(16526019)(186003)(106356001)(3846002)(6116002)(105586002)(97736004)(47776003)(26005)(68736007)(50466002)(48376002)(66066001)(6512007)(2906002)(5660300001)(118296001)(11346002)(446003)(386003)(110136005)(4326008)(7736002)(6666003)(476003)(956004)(2616005)(54906003)(51416003)(16586007)(575784001)(86362001)(305945005)(6486002)(44832011)(25786009)(53936002)(36756003)(8676002)(52116002)(486006)(69590400006)(76176011)(316002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR04MB4290; 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; AM0PR04MB4290; 23:02/P157LasJd3CT4sM44GXNMk67N4S7R9eGJRdXgk?= 5ZE+C24tJZ+IZ7QzQxBx+atqH/KpZa3RrkZ0sEKZr3FsYFRLhvksJFGp73C78BkC/uib/fvM7q4jLQSAwRXOAnl8le8kf8yJkPyAw0nDl8jesLJYoays5ENzMlYH/wOxZzgtRJRkO/YDzfajq8LaF0jRLIsS22NE/F8ZipcplQhg2JU5LYTPQxkEU4mHQKQa+X9qmengJzLPQuFyXkYdF4hdSpanof1HgUpZ2JD7EM41jeyImX3KB/GKM4x+WwLCpEcbM1gj1j/A4TQKgAnZ4Okf3d3ssLMPIew25kkNcCDFTlAmVZm5gMzTG91wnL7yFhucrlAGO4N9gywKGfm0qzkliFHjW/hbTj0mKGozXp0mmOWdTrT4AcTHgqjm0XDPXhA50eR97JNzPXBZ9iw3l/l53qh2jrteGrJcHVbbbPc6YpZt7P2yJpoIm4mCFoF88La1GaF8iNBMEtQankzU9AjRJkKhvr/hAH7GMMBl4eKPoRo4qdZHlVHBwj3zjMr0/QAx3cI86EqKqWr9Eba+I/TtEXJVehzHLfs4oFA5PObZI+/0S8PTaSdbyyKMn7eMvp/3LZy8VUCZlTga+HlOX4lxaIwEWQwyq18s5kfNqDBl5TKuQLPRWqMwf/plK+yLgSBxRnp3Ew0BtjiswIuc8NF4xl/QDJUuaTQrwO+M1fXbofLVsNtLQcVVo37tFiewkrjOSSn7GApIVn3V5xOmtxRqvIzfpxse7S+J7h0rdMmgl/9dSB0AJvE0xl5zL+Rs4JECwMbr+MMLFouHTEVx1nFefo1B41dvgTQ6TSV+XipTUfAI8kgSKH1HGXe71FNebeJjOM7QKMJDKEMnjS22rvnvwenrt9pKejGF44/127E5wI378j20b4uQBkNL4Djj6SbgiY7JyslJ03agXkHtbO7K3st5YW+omKNfkCc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gQFDOwSmA0MJTd0xz7ID/Emp0FiiynRXn54kmJP5BKHxO1E2plgo1lqiq2JaIhZXcKb1j/6SHJgpYamPSCA2ohXz5jr7l9WwvbTPe/H+rlh4Ue4+7ivIgSSZWMCdUmtGcYRzukNiOmRMKPNnpgXkTJHJuvw2s6HaW6o6XqCIG1DyA5g==; 5:Br10QKg9nVy9kfDiXA0ud6UDjXoJmpbBuB7JG11pnAQKfMEoI2IqY44XlbkvTUhHQ7rivXf+oWdBWfAwaG8fXoJ2qSzC9ggiED4kpyr2t/L8stUekZ5Az7QomaNN+X+IEjaPFDn+nE1iZ5agO15fiFXt8nTfSmMgLxnitzGcF1U=; 7:iWlbIZlr3+6KbcrplzcWeZRKp6beeZ54YbKbx/9oQY/BLvXNN7h5qAF6IejjDl25KF/uOhLBMGq0IwdzM7z51qHPbhNp+WMjUhbQKlivqElpyoBTH7yML4fJ9QZ5oDTElkkrzunIRH/lw0LIe332UQxSPOIp7vNU7oSv1ADKV4a1g8eQbgcQnp6JhxxR66y2XMh6RTT+kmsgBnDgYpgofMk68EJlScaIMFFCAxXLs9IEM35zta7nxzZiVI/pF3yS SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2018 13:43:00.5054 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b7d68a23-614f-40ea-5133-08d61ca37cdc X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4290 X-Mailman-Approved-At: Tue, 18 Sep 2018 09:57:51 +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, Robert Chiras , dri-devel@lists.freedesktop.org, kernel@pengutronix.de, Fabio Estevam , Shawn Guo , linux-imx@nxp.com 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 Reviewed-by: Stefan Agner --- 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); + } }