From patchwork Mon Aug 27 11:10:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonard Crestez X-Patchwork-Id: 10576979 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 02BE5920 for ; Mon, 27 Aug 2018 11:12:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E72CC2965C for ; Mon, 27 Aug 2018 11:12:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D99E6296B9; Mon, 27 Aug 2018 11:12:24 +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=-2.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E930429668 for ; Mon, 27 Aug 2018 11:12:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KRJsANGUtJqAKdrJz9VQ9oiYVAI6sM2WO0/9cp/iF+I=; b=CsfgKMyfElGHTw HAni7+7QqUhhYQxTtvVr5QIQmjlXhPsIec4K0rBM8lKWWwn4yGpff/8UltBEztae4vDqTmtHHhLp/ fgATjb7mdOyecWWeZYcjs8YaMe3YjfduKPuEz1gF3mI5zrn51dbj6xSombU4p4wwDlxhDbKUUIWrF 8b0xMkSJScYYgGWoApTQebpfS3i9IDMhwVo/EJASAeVqfiignid8g+aEePX/tJiy2VHlGNAsNo5US kDmsAdC9qtcE/3382dalLJoNp5NE5Ku0/E/7mtKCtFH7zXugddMMEDtR1dFx2PSgthx0uH23F/lD3 W13zOikwkWLarsJP+iIg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fuFRP-00082s-FB; Mon, 27 Aug 2018 11:12:15 +0000 Received: from mail-he1eur01on0088.outbound.protection.outlook.com ([104.47.0.88] helo=EUR01-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fuFQZ-0007gC-5P for linux-arm-kernel@lists.infradead.org; Mon, 27 Aug 2018 11:11:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=x29FxP6cx8gNBjbFoOrq6u20hsJpDEHgdSSA4sSCqBc=; b=d0m+TiTJaOiziPwLue0z2/PMsQQulUwEE4kLAdiX9FXNwaPGJPMbwIUAotwy7VCnLyTduRyx25tgkXeh6GX3Gg9cy69h4bij7PHu8vP/sbRLe2cOIK0sJFuwFTVIao5fL6PBQO1X1RDJ4IwStt6OLcATwXr+sJTpAjQ0TdKFhFQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=leonard.crestez@nxp.com; Received: from localhost.localdomain (95.76.156.53) by DB7PR04MB4297.eurprd04.prod.outlook.com (2603:10a6:5:28::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.17; Mon, 27 Aug 2018 11:11:07 +0000 From: Leonard Crestez To: Marek Vasut , Philipp Zabel Subject: [RESEND 2/5] drm/mxsfb: Fix initial corrupt frame when activating display Date: Mon, 27 Aug 2018 14:10:38 +0300 Message-Id: <7ce983379410b6c29a16c9f394b382ec16c16ba9.1535367027.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: HE1PR0802CA0012.eurprd08.prod.outlook.com (2603:10a6:3:bd::22) To DB7PR04MB4297.eurprd04.prod.outlook.com (2603:10a6:5:28::11) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 188589d1-dc43-457e-de99-08d60c0dca8d 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:DB7PR04MB4297; X-Microsoft-Exchange-Diagnostics: 1; DB7PR04MB4297; 3:Tm7rFa3LMN9cZMlQ6Ui0AQJgQHUAqV1PBHsTAp55ajvXksNoq6PDBvdWQTIwWG/6KORG7KRwYeIxw3ZbInzBaEP5WdytxVEV/fbe+eya3ogNcSTJjiyeCXvB2bONP4JEvLo5apwWGoD8TltJcY1uAompgVJTOxlw9SK8M45rZNDYuiUqCZ4pg0vMTjyKZF4CK9MotYIjQm4PAGp4ObqCmpE1NbX7pbq01gekJnCnHUi+swmEWhYTbkxQhSs6n9c/; 25:yjE7kVu8IkiRSqkpjaitqEYXhcgIwkAGslomYzaQyd1U18Vxj/EJAht9IqOHqRgfP2XBERaAREhImIu3hsJyCeiS/SFsttO0nYMcdpu1OZcofrcpnUCzCl+K80WQ7g8q6Mf5VOjx2V4WvgDPtYj+MtBpjUUAfWGUoGO5+G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zgbn2Ou3QM7bYe5Zn3NoGDb+oubYdZawBV9a8lkUQR4NdF6E891SR5ZmUQCIKQ4+etbLkJK6tXlU6mnAiRXvmSBfQJwfqxdgPfxj+G4Xi9bfgkxbAFACjMCLY8nMTrRH9dwrh2sG8vV17sa/jn06OhXjkvpYxmyVOC6OEmAS3+JYErugQ4whrVT+jsSudsM2WT8cOKu3UJc2T42E43hb4igkFVtQQGs7tClrGKP26ksVr 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)(823301075)(3231311)(944501410)(52105095)(93006095)(93001095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699016); SRVR:DB7PR04MB4297; BCL:0; PCL:0; RULEID:; SRVR:DB7PR04MB4297; X-Forefront-PRVS: 07778E4001 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(396003)(376002)(136003)(366004)(346002)(39860400002)(199004)(189003)(4326008)(305945005)(478600001)(6666003)(2906002)(36756003)(446003)(476003)(2616005)(956004)(81166006)(8676002)(81156014)(14444005)(44832011)(7736002)(486006)(11346002)(3846002)(6116002)(47776003)(6486002)(66066001)(97736004)(575784001)(86362001)(54906003)(5660300001)(53936002)(6512007)(16586007)(110136005)(316002)(50466002)(48376002)(50226002)(118296001)(105586002)(8936002)(106356001)(51416003)(186003)(26005)(52116002)(16526019)(6506007)(386003)(68736007)(25786009)(76176011)(69590400005); DIR:OUT; SFP:1101; SCL:1; SRVR:DB7PR04MB4297; 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-Diag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QEQwMmuEp7i8mLkCyFJgKZb2oKpQzjXYJpMEmA1I0KQCz/Vgd1y7OSb7Xtc8v84+oz1DdPaTIGdosm+fBqn+1WScVyEHQyR1zapEvz201/sC0OCIWNaPhNZQ05klNerg==; 5:nHNDBeFrb0If6/q+4A69eYyO+S9OrGPWjHCX33GCCHet/9a4B++ODXuFPLhplYiQOrhSY2vN7zDQzU8JZ2j/0nqjmcPI7NzQCa5bPDn27+Xcn0p84XokhEchIUBgQ3SjQ4GQCUqraK07Y384gU6KaNeyQ4T2wgmYr8MGZXXDd5o=; 7:/l5w+P52KtAG6sH17K+tJAVeymUlpIAvTDN5sIk15mH5nfWkZ/7nhDs3AkVCSkhCVFovuhP+WvjmkoE1vK8FqFAMhHNnpdKVMVaGa8NUF/HLQX45HE25cSzVHKhfI0Adio5UcSBRbP+F29XUaZhAsKSyrQ8Z8FQXz374XO20cPaTIFkSN3Zi3vvZnTMe+YqGWnZMxUU/g3Qq0fVIbxTLGSEK6C6n4mLITqtuv7hIeZbjtGBy+uItdwOmR2LOW/Z8 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2018 11:11:07.3824 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 188589d1-dc43-457e-de99-08d60c0dca8d X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4297 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180827_041123_234743_4A3D4361 X-CRM114-Status: GOOD ( 12.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dong Aisheng , David Airlie , linux-kernel@vger.kernel.org, Stefan Agner , Robert Chiras , dri-devel@lists.freedesktop.org, kernel@pengutronix.de, Fabio Estevam , Marco Franchi , Shawn Guo , linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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); + } }