From patchwork Thu Sep 28 11:36:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 13402847 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A425AE732C8 for ; Thu, 28 Sep 2023 11:37:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=aGO5iDDLWmIps4DozqqLEF7M9Eyx4hTzddCOqXB3B8o=; b=nANopksmjKLC7A fDcw1XonWrJ3Z2M6JXKvR/aQde8cuAROgF3TB4eny2AYsIpRCAQoPEk0QSkAtdMYfHE5aQcnFhYEd dqsKe4S7bLKDgEkx6nji+g0K0Nv2dzJv/mT7eyXy83aV/HKHYhXdYEX6tHMYFcflFWN960fvjrIWB ZamTFOg2Ad9PjcXi8bBn7hR5A0etKHjR7LCfBsA3pvmly1y1IxZigOc6Jh9kz8BNuXS7Uml/4inH1 UAsJiWE0cf15V5pZGkb0n12/m8EIYo2jXDLSPMi5uuhbdM+I3FKJxHnNdtQees32SfcZjhaBub4C2 KJgmCadOm97wBxjIsl9Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qlpJt-003Gmw-2c; Thu, 28 Sep 2023 11:36:37 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qlpJq-003GhJ-21 for linux-arm-kernel@lists.infradead.org; Thu, 28 Sep 2023 11:36:36 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qlpJm-0001ry-1h; Thu, 28 Sep 2023 13:36:30 +0200 Received: from [2a0a:edc0:0:1101:1d::28] (helo=dude02.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1qlpJl-009Z8S-Hw; Thu, 28 Sep 2023 13:36:29 +0200 From: Lucas Stach To: Marek Vasut , Liu Ying Cc: Pengutronix Kernel Team , NXP Linux Team , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, patchwork-lst@pengutronix.de Subject: [PATCH v3 1/8] drm: lcdif: improve burst size configuration comment Date: Thu, 28 Sep 2023 13:36:22 +0200 Message-Id: <20230928113629.103188-1-l.stach@pengutronix.de> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230928_043634_688428_3B396A83 X-CRM114-Status: GOOD ( 12.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The comment regarding AXI bust size configuration is a bit hard to read. Improve the wording somewhat. Signed-off-by: Lucas Stach Reviewed-by: Marco Felsch Reviewed-by: Marek Vasut --- v3: no changes v2: Some more rewording. --- drivers/gpu/drm/mxsfb/lcdif_kms.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/mxsfb/lcdif_kms.c b/drivers/gpu/drm/mxsfb/lcdif_kms.c index 2541d2de4e45..07e343e01f3e 100644 --- a/drivers/gpu/drm/mxsfb/lcdif_kms.c +++ b/drivers/gpu/drm/mxsfb/lcdif_kms.c @@ -329,12 +329,12 @@ static void lcdif_set_mode(struct lcdif_drm_private *lcdif, u32 bus_flags) lcdif->base + LCDC_V8_CTRLDESCL0_1); /* - * Undocumented P_SIZE and T_SIZE register but those written in the - * downstream kernel those registers control the AXI burst size. As of - * now there are two known values: + * The P_SIZE and T_SIZE bitfields are only documented in the + * downstream driver. Those bitfields control the AXI burst size. + * As of now there are two known values: * 1 - 128Byte * 2 - 256Byte - * Downstream set it to 256B burst size to improve the memory + * Downstream sets this to 256B burst size to improve the memory access * efficiency so set it here too. */ ctrl = CTRLDESCL0_3_P_SIZE(2) | CTRLDESCL0_3_T_SIZE(2) | From patchwork Thu Sep 28 11:36:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 13402846 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 64746E732C5 for ; Thu, 28 Sep 2023 11:37:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4nw+C6Wvg423pLJT6wDXLxd35AF9Vhlwsc537Aiif7I=; b=fWusAXZ07cK/gU SJWiAuH+Vb5C/ixCvr32+KFnHmDk0SRnZxRmJQkksSYFqs8806Yq3ifhsSN70xrdCrvBoJ11dOGMK na9yhq5+MlwFJAWqxbNj0LQsehGyywzfTOjffxbszw2CO0zv1+fczBObyMgdFI9Mf9jon7qROjEy3 scjShx4/bFfl2yYiPNROkQbxVibXMEuPPFsVFF4pKDNG2xtiAvKO9zC6xSgc1/J33wDbyvCCKjjVR cbXLDpFk3dY6+Ee8WaYYuInK7xYsEaaDNJ+jbURCKWV2XZBjHrRlnRPr2z70KUoSjKPxorLvBXk1a bwMFUNP/LnfnqFh2dxbg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qlpJv-003GoQ-20; Thu, 28 Sep 2023 11:36:39 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qlpJq-003Ghc-2X for linux-arm-kernel@lists.infradead.org; Thu, 28 Sep 2023 11:36:36 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qlpJm-0001rz-1h; Thu, 28 Sep 2023 13:36:30 +0200 Received: from [2a0a:edc0:0:1101:1d::28] (helo=dude02.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1qlpJl-009Z8S-JD; Thu, 28 Sep 2023 13:36:29 +0200 From: Lucas Stach To: Marek Vasut , Liu Ying Cc: Pengutronix Kernel Team , NXP Linux Team , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, patchwork-lst@pengutronix.de Subject: [PATCH v3 2/8] drm: lcdif: don't clear unrelated bits in CTRLDESCL0_5 when setting up format Date: Thu, 28 Sep 2023 13:36:23 +0200 Message-Id: <20230928113629.103188-2-l.stach@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230928113629.103188-1-l.stach@pengutronix.de> References: <20230928113629.103188-1-l.stach@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230928_043634_833430_554457D0 X-CRM114-Status: GOOD ( 13.00 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The CTRLDESCL0_5 register also holds other bits that are not related to the format, which should not be overwritten when the format is set up. Use a proper RMW access in lcdif_set_formats(). Signed-off-by: Lucas Stach --- v3: no changes v2: new patch --- drivers/gpu/drm/mxsfb/lcdif_kms.c | 40 +++++++++++++++---------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/mxsfb/lcdif_kms.c b/drivers/gpu/drm/mxsfb/lcdif_kms.c index 07e343e01f3e..e277592e5fa5 100644 --- a/drivers/gpu/drm/mxsfb/lcdif_kms.c +++ b/drivers/gpu/drm/mxsfb/lcdif_kms.c @@ -166,6 +166,7 @@ static void lcdif_set_formats(struct lcdif_drm_private *lcdif, const u32 format = plane_state->fb->format->format; bool in_yuv = false; bool out_yuv = false; + u32 ctrl_desc_5; switch (bus_format) { case MEDIA_BUS_FMT_RGB565_1X16: @@ -186,52 +187,49 @@ static void lcdif_set_formats(struct lcdif_drm_private *lcdif, break; } + ctrl_desc_5 = readl(lcdif->base + LCDC_V8_CTRLDESCL0_5) & + ~(CTRLDESCL0_5_BPP_MASK | CTRLDESCL0_5_YUV_FORMAT_MASK); + switch (format) { /* RGB Formats */ case DRM_FORMAT_RGB565: - writel(CTRLDESCL0_5_BPP_16_RGB565, - lcdif->base + LCDC_V8_CTRLDESCL0_5); + ctrl_desc_5 |= CTRLDESCL0_5_BPP_16_RGB565; break; case DRM_FORMAT_RGB888: - writel(CTRLDESCL0_5_BPP_24_RGB888, - lcdif->base + LCDC_V8_CTRLDESCL0_5); + ctrl_desc_5 |= CTRLDESCL0_5_BPP_24_RGB888; break; case DRM_FORMAT_XRGB1555: - writel(CTRLDESCL0_5_BPP_16_ARGB1555, - lcdif->base + LCDC_V8_CTRLDESCL0_5); + ctrl_desc_5 |= CTRLDESCL0_5_BPP_16_ARGB1555; break; case DRM_FORMAT_XRGB4444: - writel(CTRLDESCL0_5_BPP_16_ARGB4444, - lcdif->base + LCDC_V8_CTRLDESCL0_5); + ctrl_desc_5 |= CTRLDESCL0_5_BPP_16_ARGB4444; break; case DRM_FORMAT_XBGR8888: - writel(CTRLDESCL0_5_BPP_32_ABGR8888, - lcdif->base + LCDC_V8_CTRLDESCL0_5); + ctrl_desc_5 |= CTRLDESCL0_5_BPP_32_ABGR8888; break; case DRM_FORMAT_XRGB8888: - writel(CTRLDESCL0_5_BPP_32_ARGB8888, - lcdif->base + LCDC_V8_CTRLDESCL0_5); + ctrl_desc_5 |= CTRLDESCL0_5_BPP_32_ARGB8888; break; /* YUV Formats */ case DRM_FORMAT_YUYV: - writel(CTRLDESCL0_5_BPP_YCbCr422 | CTRLDESCL0_5_YUV_FORMAT_VY2UY1, - lcdif->base + LCDC_V8_CTRLDESCL0_5); + ctrl_desc_5 |= CTRLDESCL0_5_BPP_YCbCr422 | + CTRLDESCL0_5_YUV_FORMAT_VY2UY1; in_yuv = true; break; case DRM_FORMAT_YVYU: - writel(CTRLDESCL0_5_BPP_YCbCr422 | CTRLDESCL0_5_YUV_FORMAT_UY2VY1, - lcdif->base + LCDC_V8_CTRLDESCL0_5); + ctrl_desc_5 |= CTRLDESCL0_5_BPP_YCbCr422 | + CTRLDESCL0_5_YUV_FORMAT_UY2VY1; in_yuv = true; break; case DRM_FORMAT_UYVY: - writel(CTRLDESCL0_5_BPP_YCbCr422 | CTRLDESCL0_5_YUV_FORMAT_Y2VY1U, - lcdif->base + LCDC_V8_CTRLDESCL0_5); + ctrl_desc_5 |= CTRLDESCL0_5_BPP_YCbCr422 | + CTRLDESCL0_5_YUV_FORMAT_Y2VY1U; in_yuv = true; break; case DRM_FORMAT_VYUY: - writel(CTRLDESCL0_5_BPP_YCbCr422 | CTRLDESCL0_5_YUV_FORMAT_Y2UY1V, - lcdif->base + LCDC_V8_CTRLDESCL0_5); + ctrl_desc_5 |= CTRLDESCL0_5_BPP_YCbCr422 | + CTRLDESCL0_5_YUV_FORMAT_Y2UY1V; in_yuv = true; break; @@ -240,6 +238,8 @@ static void lcdif_set_formats(struct lcdif_drm_private *lcdif, break; } + writel(ctrl_desc_5, lcdif->base + LCDC_V8_CTRLDESCL0_5); + /* * The CSC differentiates between "YCbCr" and "YUV", but the reference * manual doesn't detail how they differ. Experiments showed that the From patchwork Thu Sep 28 11:36:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 13402848 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6674FE732C5 for ; Thu, 28 Sep 2023 11:37:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Wy/Lu6e1tL7CTBhgGtp9xYQ+bMCGtNUUEXmCsDGXUds=; b=LvDithKliJ+T5Y Wn8sRdqDFFSKqGQGwqkKlN6MC2uiVcOjnhhEVGXJp4Y8M+b2fC7ni3Py3dkA/6kaurRPbJqrEFsP/ 4YpcQqPG2YKQUs+4i4hujhzUPIkQCGbTywYZSOfmmaZ172Qy6ZZ7gR+lbtcGChA2E+2YgnVKD9GG1 KCDNtti9VEpAMD7W5eVMrGw5dvIgSU3xWyYsqVQTOjU/cB80tksfZ6O3OzmdzRXN2Ws5SUavi7Ice e78npAbyyYrptSxYwmxfiHT6ABX1jYHBVY0WfJSosuESHND1eVZlgt53b1T6/6ADqMOToeG0mtjcW mwX9JHXNRTYOqSD51/8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qlpKE-003H31-2T; Thu, 28 Sep 2023 11:36:58 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qlpJr-003GhO-01 for linux-arm-kernel@lists.infradead.org; Thu, 28 Sep 2023 11:36:37 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qlpJm-0001s0-1z; Thu, 28 Sep 2023 13:36:30 +0200 Received: from [2a0a:edc0:0:1101:1d::28] (helo=dude02.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1qlpJl-009Z8S-KS; Thu, 28 Sep 2023 13:36:29 +0200 From: Lucas Stach To: Marek Vasut , Liu Ying Cc: Pengutronix Kernel Team , NXP Linux Team , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, patchwork-lst@pengutronix.de Subject: [PATCH v3 3/8] drm: lcdif: enable DMA before display Date: Thu, 28 Sep 2023 13:36:24 +0200 Message-Id: <20230928113629.103188-3-l.stach@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230928113629.103188-1-l.stach@pengutronix.de> References: <20230928113629.103188-1-l.stach@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230928_043635_080345_824C8303 X-CRM114-Status: GOOD ( 12.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Otherwise the DMA enable races with the fetch start, which causes wrong or no data to be scanned out on the first frame. Also there is no point in waiting for the DMA disable when the controller is going to shut down. Simply disable the display first so no further fetches are triggered and then shut down DMA. Signed-off-by: Lucas Stach --- v3: new patch --- drivers/gpu/drm/mxsfb/lcdif_kms.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/mxsfb/lcdif_kms.c b/drivers/gpu/drm/mxsfb/lcdif_kms.c index e277592e5fa5..6a292f4b332b 100644 --- a/drivers/gpu/drm/mxsfb/lcdif_kms.c +++ b/drivers/gpu/drm/mxsfb/lcdif_kms.c @@ -358,34 +358,27 @@ static void lcdif_enable_controller(struct lcdif_drm_private *lcdif) writel(INT_ENABLE_D1_PLANE_PANIC_EN, lcdif->base + LCDC_V8_INT_ENABLE_D1); - reg = readl(lcdif->base + LCDC_V8_DISP_PARA); - reg |= DISP_PARA_DISP_ON; - writel(reg, lcdif->base + LCDC_V8_DISP_PARA); - reg = readl(lcdif->base + LCDC_V8_CTRLDESCL0_5); reg |= CTRLDESCL0_5_EN; writel(reg, lcdif->base + LCDC_V8_CTRLDESCL0_5); + + reg = readl(lcdif->base + LCDC_V8_DISP_PARA); + reg |= DISP_PARA_DISP_ON; + writel(reg, lcdif->base + LCDC_V8_DISP_PARA); } static void lcdif_disable_controller(struct lcdif_drm_private *lcdif) { u32 reg; - int ret; - - reg = readl(lcdif->base + LCDC_V8_CTRLDESCL0_5); - reg &= ~CTRLDESCL0_5_EN; - writel(reg, lcdif->base + LCDC_V8_CTRLDESCL0_5); - - ret = readl_poll_timeout(lcdif->base + LCDC_V8_CTRLDESCL0_5, - reg, !(reg & CTRLDESCL0_5_EN), - 0, 36000); /* Wait ~2 frame times max */ - if (ret) - drm_err(lcdif->drm, "Failed to disable controller!\n"); reg = readl(lcdif->base + LCDC_V8_DISP_PARA); reg &= ~DISP_PARA_DISP_ON; writel(reg, lcdif->base + LCDC_V8_DISP_PARA); + reg = readl(lcdif->base + LCDC_V8_CTRLDESCL0_5); + reg &= ~CTRLDESCL0_5_EN; + writel(reg, lcdif->base + LCDC_V8_CTRLDESCL0_5); + /* Disable FIFO Panic NoC priority booster. */ writel(0, lcdif->base + LCDC_V8_INT_ENABLE_D1); } From patchwork Thu Sep 28 11:36:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 13402853 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0E409E732C8 for ; Thu, 28 Sep 2023 11:37:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FvtjdDz9m/QS8gEwMu4hKZk52BxzkdIoTBWNsNBCIy4=; b=yg548aIkB243xT wWXyMNPU7ChzcwVMmHVzj9aVBiNMBPuwig6KRAmcOAVqaK3WO5hvXys8+t7fzLXh9M6dekHzRa28i DzOJ8oC1xMLsJLtV6NMvJL6g9pKcZHMGKDWnx5/RmK0VkJWa0YZumEH7ImV2f2G+oDxxBGeJfrtPm 8UpCkrACow8mM0+cg0pB45BaH3dlUn0FrzaCV+OYkhZyqEZeWupx6AWEmYzb3ruRLTtdaGC6MHc2X own0LkYz/tCZKA7/RLRNB0fs1+h23oybaFMHcJxbcJcOZ0nX2F5oxkBaRQzgMMw7uucti8K7gT5J3 Hxq3HxL0Xn1hiGretdbQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qlpKF-003H48-2W; Thu, 28 Sep 2023 11:36:59 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qlpJq-003GhS-2v for linux-arm-kernel@lists.infradead.org; Thu, 28 Sep 2023 11:36:37 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qlpJm-0001s1-4n; Thu, 28 Sep 2023 13:36:30 +0200 Received: from [2a0a:edc0:0:1101:1d::28] (helo=dude02.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1qlpJl-009Z8S-N2; Thu, 28 Sep 2023 13:36:29 +0200 From: Lucas Stach To: Marek Vasut , Liu Ying Cc: Pengutronix Kernel Team , NXP Linux Team , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, patchwork-lst@pengutronix.de Subject: [PATCH v3 4/8] drm: lcdif: control display clock from CRTC enable/disable Date: Thu, 28 Sep 2023 13:36:25 +0200 Message-Id: <20230928113629.103188-4-l.stach@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230928113629.103188-1-l.stach@pengutronix.de> References: <20230928113629.103188-1-l.stach@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230928_043634_945003_639DE304 X-CRM114-Status: GOOD ( 12.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The display clock only required to be running when the CRTC is enabled, so we have well defined points in the DRM atomic sequence when this clock should be enabled or disabled. Signed-off-by: Lucas Stach --- v3: new patch --- drivers/gpu/drm/mxsfb/lcdif_drv.c | 4 ---- drivers/gpu/drm/mxsfb/lcdif_kms.c | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/mxsfb/lcdif_drv.c b/drivers/gpu/drm/mxsfb/lcdif_drv.c index 18de2f17e249..38dfd307adc1 100644 --- a/drivers/gpu/drm/mxsfb/lcdif_drv.c +++ b/drivers/gpu/drm/mxsfb/lcdif_drv.c @@ -306,8 +306,6 @@ static int __maybe_unused lcdif_rpm_suspend(struct device *dev) struct drm_device *drm = dev_get_drvdata(dev); struct lcdif_drm_private *lcdif = drm->dev_private; - /* These clock supply the DISPLAY CLOCK Domain */ - clk_disable_unprepare(lcdif->clk); /* These clock supply the System Bus, AXI, Write Path, LFIFO */ clk_disable_unprepare(lcdif->clk_disp_axi); /* These clock supply the Control Bus, APB, APBH Ctrl Registers */ @@ -325,8 +323,6 @@ static int __maybe_unused lcdif_rpm_resume(struct device *dev) clk_prepare_enable(lcdif->clk_axi); /* These clock supply the System Bus, AXI, Write Path, LFIFO */ clk_prepare_enable(lcdif->clk_disp_axi); - /* These clock supply the DISPLAY CLOCK Domain */ - clk_prepare_enable(lcdif->clk); return 0; } diff --git a/drivers/gpu/drm/mxsfb/lcdif_kms.c b/drivers/gpu/drm/mxsfb/lcdif_kms.c index 6a292f4b332b..d43e3633bce0 100644 --- a/drivers/gpu/drm/mxsfb/lcdif_kms.c +++ b/drivers/gpu/drm/mxsfb/lcdif_kms.c @@ -545,6 +545,9 @@ static void lcdif_crtc_atomic_enable(struct drm_crtc *crtc, writel(CTRLDESCL_HIGH0_4_ADDR_HIGH(upper_32_bits(paddr)), lcdif->base + LCDC_V8_CTRLDESCL_HIGH0_4); } + + clk_prepare_enable(lcdif->clk); + lcdif_enable_controller(lcdif); drm_crtc_vblank_on(crtc); @@ -561,6 +564,8 @@ static void lcdif_crtc_atomic_disable(struct drm_crtc *crtc, lcdif_disable_controller(lcdif); + clk_disable_unprepare(lcdif->clk); + spin_lock_irq(&drm->event_lock); event = crtc->state->event; if (event) { From patchwork Thu Sep 28 11:36:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 13402852 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B4BB1E732C7 for ; Thu, 28 Sep 2023 11:37:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=GT7qRzbo4WlcMb+mwIPu2a5/oyvBMmoZi9RCx9ZSh7I=; b=bDlNqNHDUmJJOi 5/uWArcfL/I8HTV0KXjOmmzW/KRrv30hqzGHgWMm0IoHplQCCXzIc/ecjaG4f4DSFqCJcqCJD56kx SiQCn16/qhOCPd4MtcdvfpcdvSD+41iZvIRfGlqhd6PKcEbvMKQE0/k76iza1w2I9Wr8nKlcrRm6V 1AqMyHIdBNqK6QV/aLV27YCDg06OtK/KndNQWifC2gTrQjmXHXJJbnI9GcygBwjMM/0rlo7HalcgG QXAEUyqrcXyPUPS0o6GX9Ja4g/MgrzoFZHNiFXn4/46JugOx73lTSev8W/8YMuSferwoanVDCYxcC pdmjx6xSzcoHLKpXOzCg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qlpKE-003H2M-06; Thu, 28 Sep 2023 11:36:58 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qlpJq-003GhL-2q for linux-arm-kernel@lists.infradead.org; Thu, 28 Sep 2023 11:36:37 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qlpJm-0001s2-6t; Thu, 28 Sep 2023 13:36:30 +0200 Received: from [2a0a:edc0:0:1101:1d::28] (helo=dude02.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1qlpJl-009Z8S-Pe; Thu, 28 Sep 2023 13:36:29 +0200 From: Lucas Stach To: Marek Vasut , Liu Ying Cc: Pengutronix Kernel Team , NXP Linux Team , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, patchwork-lst@pengutronix.de Subject: [PATCH v3 5/8] drm: lcdif: rework runtime PM handling in the atomic commit Date: Thu, 28 Sep 2023 13:36:26 +0200 Message-Id: <20230928113629.103188-5-l.stach@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230928113629.103188-1-l.stach@pengutronix.de> References: <20230928113629.103188-1-l.stach@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230928_043634_922783_A9F8947A X-CRM114-Status: GOOD ( 14.18 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org drm_atomic_helper_commit_tail_rpm makes it hard for drivers to follow the documented encoder/bridge enable flow, as it commits all CRTC enables before the planes are fully set up, so drivers that can't enable the display link without valid plane setup either need to do the plane setup in the CRTC enable or violate the flow by enabling the display link after the planes have been set up. Neither of those options seem like a good idea. For devices that only do coarse-grained runtime PM for the whole display controller and not per CRTC, like the i.MX LCDIF, we can handle hardware wakeup and suspend in the atomic_commit_tail. Add a commit tail which follows the more conventional atomic commit flow of first diabling any unused CRTCs, setting up all the active plane state, then enable all active display pipes and also handles the device runtime PM at the appropriate times. Signed-off-by: Lucas Stach --- v3: add static qualifier v2: new patch --- drivers/gpu/drm/mxsfb/lcdif_drv.c | 22 +++++++++++++++++++++- drivers/gpu/drm/mxsfb/lcdif_kms.c | 12 ++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/mxsfb/lcdif_drv.c b/drivers/gpu/drm/mxsfb/lcdif_drv.c index 38dfd307adc1..9df278adf3e8 100644 --- a/drivers/gpu/drm/mxsfb/lcdif_drv.c +++ b/drivers/gpu/drm/mxsfb/lcdif_drv.c @@ -36,8 +36,28 @@ static const struct drm_mode_config_funcs lcdif_mode_config_funcs = { .atomic_commit = drm_atomic_helper_commit, }; +static void lcdif_commit_tail(struct drm_atomic_state *old_state) +{ + struct drm_device *drm = old_state->dev; + + pm_runtime_get_sync(drm->dev); + + drm_atomic_helper_commit_modeset_disables(drm, old_state); + drm_atomic_helper_commit_planes(drm, old_state, + DRM_PLANE_COMMIT_ACTIVE_ONLY); + drm_atomic_helper_commit_modeset_enables(drm, old_state); + + drm_atomic_helper_fake_vblank(old_state); + drm_atomic_helper_commit_hw_done(old_state); + drm_atomic_helper_wait_for_vblanks(drm, old_state); + + pm_runtime_put(drm->dev); + + drm_atomic_helper_cleanup_planes(drm, old_state); +} + static const struct drm_mode_config_helper_funcs lcdif_mode_config_helpers = { - .atomic_commit_tail = drm_atomic_helper_commit_tail_rpm, + .atomic_commit_tail = lcdif_commit_tail, }; static const struct drm_encoder_funcs lcdif_encoder_funcs = { diff --git a/drivers/gpu/drm/mxsfb/lcdif_kms.c b/drivers/gpu/drm/mxsfb/lcdif_kms.c index d43e3633bce0..1b90014d055a 100644 --- a/drivers/gpu/drm/mxsfb/lcdif_kms.c +++ b/drivers/gpu/drm/mxsfb/lcdif_kms.c @@ -533,7 +533,11 @@ static void lcdif_crtc_atomic_enable(struct drm_crtc *crtc, clk_set_rate(lcdif->clk, m->crtc_clock * 1000); - pm_runtime_get_sync(drm->dev); + /* + * Update the RPM usage count, actual resume already happened in + * lcdif_commit_tail wrapping all the atomic update. + */ + pm_runtime_get_noresume(drm->dev); lcdif_crtc_mode_set_nofb(new_cstate, new_pstate); @@ -574,7 +578,11 @@ static void lcdif_crtc_atomic_disable(struct drm_crtc *crtc, } spin_unlock_irq(&drm->event_lock); - pm_runtime_put_sync(drm->dev); + /* + * Update the RPM usage count, actual suspend happens in + * lcdif_commit_tail wrapping all the atomic update. + */ + pm_runtime_put(drm->dev); } static void lcdif_crtc_atomic_destroy_state(struct drm_crtc *crtc, From patchwork Thu Sep 28 11:36:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 13402850 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CE050E732C8 for ; Thu, 28 Sep 2023 11:37:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2MccLNdS564Dg4mW9rY1Fw89wBV0Otwh5sIZjHgD8+8=; b=yrJUu9brLvJKD4 k1cfXM/SROzhpam90yVGwDFn2j3PNJu5ddyUOYs1qUV9s7CLs+TOD8Edz+l0V/diSWlkHJMrO9Ksz IntJ2/DU4UeAa6DGlVUi9lG5w3UuBiJVN2WlAXsAnPQgyuRCzmaoKMUmEFvdQsuFyw/JIVA7pHHjO 1UamNiU4zC8IAgro7EGIx4aix+/Wi3BvJePVYiBB0FG1St6yqkOvGT/okZuZ1J3nIML+Z7l5+igdp 8/celCxvNHytPsMf2W4qVrUGH7LxNNXAcMOesdrXcfylj6bo4Uze41k0QKac8E2wY0pS1gyTcFKE6 WLcmVuvjJ1dir+v5+bqQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qlpKH-003H5z-1m; Thu, 28 Sep 2023 11:37:01 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qlpJr-003Gi2-0Y for linux-arm-kernel@lists.infradead.org; Thu, 28 Sep 2023 11:36:41 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qlpJm-0001s3-8f; Thu, 28 Sep 2023 13:36:30 +0200 Received: from [2a0a:edc0:0:1101:1d::28] (helo=dude02.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1qlpJl-009Z8S-R3; Thu, 28 Sep 2023 13:36:29 +0200 From: Lucas Stach To: Marek Vasut , Liu Ying Cc: Pengutronix Kernel Team , NXP Linux Team , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, patchwork-lst@pengutronix.de Subject: [PATCH v3 6/8] drm: lcdif: remove superfluous setup of framebuffer DMA address Date: Thu, 28 Sep 2023 13:36:27 +0200 Message-Id: <20230928113629.103188-6-l.stach@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230928113629.103188-1-l.stach@pengutronix.de> References: <20230928113629.103188-1-l.stach@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230928_043635_235874_77DA275C X-CRM114-Status: GOOD ( 10.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Now that the plane state is fully programmed into the hardware before the scanout is started there is no need to program the plane framebuffer DMA address from the CRTC atomic_enable anymore. Signed-off-by: Lucas Stach Reviewed-by: Marek Vasut --- v2/3: no changes --- drivers/gpu/drm/mxsfb/lcdif_kms.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/gpu/drm/mxsfb/lcdif_kms.c b/drivers/gpu/drm/mxsfb/lcdif_kms.c index 1b90014d055a..a5859c83fe08 100644 --- a/drivers/gpu/drm/mxsfb/lcdif_kms.c +++ b/drivers/gpu/drm/mxsfb/lcdif_kms.c @@ -529,7 +529,6 @@ static void lcdif_crtc_atomic_enable(struct drm_crtc *crtc, crtc->primary); struct drm_display_mode *m = &lcdif->crtc.state->adjusted_mode; struct drm_device *drm = lcdif->drm; - dma_addr_t paddr; clk_set_rate(lcdif->clk, m->crtc_clock * 1000); @@ -541,15 +540,6 @@ static void lcdif_crtc_atomic_enable(struct drm_crtc *crtc, lcdif_crtc_mode_set_nofb(new_cstate, new_pstate); - /* Write cur_buf as well to avoid an initial corrupt frame */ - paddr = drm_fb_dma_get_gem_addr(new_pstate->fb, new_pstate, 0); - if (paddr) { - writel(lower_32_bits(paddr), - lcdif->base + LCDC_V8_CTRLDESCL_LOW0_4); - writel(CTRLDESCL_HIGH0_4_ADDR_HIGH(upper_32_bits(paddr)), - lcdif->base + LCDC_V8_CTRLDESCL_HIGH0_4); - } - clk_prepare_enable(lcdif->clk); lcdif_enable_controller(lcdif); From patchwork Thu Sep 28 11:36:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 13402849 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3DE70E732C7 for ; Thu, 28 Sep 2023 11:37:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=GKuJw+TPBvepgGHrrWxVfLcz8zbHCBbW349EcOw1slo=; b=gzMywcJ28PGTFD oheV0OewIXYzcFXBkizpLGAwvZjMxmB1rjsMUyXlDXVNpoFqRjKL2dH+In0+08fKhPba5iib2S0cy WNdLu0I0TQ+yv5zGf/l313LMELU2igjj+ybnSuVdHIXKNBDp8Pj7afS3XFiMVPIz2UWr+SPOqnYrt v0/x/u+H1mN+HqYJAb4NKevRe3H1eNZyE9eUen0OaVwKdh9i8DO5GJWM4jfYcajj4Za+ntP9Qc6pK B4Y++zp4Rxv6+I6PrNMHGOojounQHfFEDDQvtU6UFoV6IdPtCnvCu3hjta2FvVYB0dCHNU5JhXWY9 TeZebZdkQi6zcFaZjy7g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qlpKG-003H50-20; Thu, 28 Sep 2023 11:37:00 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qlpJq-003Ghe-34 for linux-arm-kernel@lists.infradead.org; Thu, 28 Sep 2023 11:36:38 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qlpJm-0001sM-Dv; Thu, 28 Sep 2023 13:36:30 +0200 Received: from [2a0a:edc0:0:1101:1d::28] (helo=dude02.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1qlpJl-009Z8S-SW; Thu, 28 Sep 2023 13:36:29 +0200 From: Lucas Stach To: Marek Vasut , Liu Ying Cc: Pengutronix Kernel Team , NXP Linux Team , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, patchwork-lst@pengutronix.de Subject: [PATCH v3 7/8] drm: lcdif: move pitch setup to plane atomic update Date: Thu, 28 Sep 2023 13:36:28 +0200 Message-Id: <20230928113629.103188-7-l.stach@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230928113629.103188-1-l.stach@pengutronix.de> References: <20230928113629.103188-1-l.stach@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230928_043634_999963_922E9366 X-CRM114-Status: GOOD ( 13.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The buffer pitch may change when switching the buffer on a atomic update. As the register is double buffered it can be safely changed while the display is active. Signed-off-by: Lucas Stach Reviewed-by: Marek Vasut --- v2/3: no changes --- drivers/gpu/drm/mxsfb/lcdif_kms.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/mxsfb/lcdif_kms.c b/drivers/gpu/drm/mxsfb/lcdif_kms.c index a5859c83fe08..c3e31fa0335e 100644 --- a/drivers/gpu/drm/mxsfb/lcdif_kms.c +++ b/drivers/gpu/drm/mxsfb/lcdif_kms.c @@ -327,19 +327,6 @@ static void lcdif_set_mode(struct lcdif_drm_private *lcdif, u32 bus_flags) writel(CTRLDESCL0_1_HEIGHT(m->vdisplay) | CTRLDESCL0_1_WIDTH(m->hdisplay), lcdif->base + LCDC_V8_CTRLDESCL0_1); - - /* - * The P_SIZE and T_SIZE bitfields are only documented in the - * downstream driver. Those bitfields control the AXI burst size. - * As of now there are two known values: - * 1 - 128Byte - * 2 - 256Byte - * Downstream sets this to 256B burst size to improve the memory access - * efficiency so set it here too. - */ - ctrl = CTRLDESCL0_3_P_SIZE(2) | CTRLDESCL0_3_T_SIZE(2) | - CTRLDESCL0_3_PITCH(lcdif->crtc.primary->state->fb->pitches[0]); - writel(ctrl, lcdif->base + LCDC_V8_CTRLDESCL0_3); } static void lcdif_enable_controller(struct lcdif_drm_private *lcdif) @@ -691,6 +678,19 @@ static void lcdif_plane_primary_atomic_update(struct drm_plane *plane, writel(CTRLDESCL_HIGH0_4_ADDR_HIGH(upper_32_bits(paddr)), lcdif->base + LCDC_V8_CTRLDESCL_HIGH0_4); } + + /* + * The P_SIZE and T_SIZE bitfields are only documented in the + * downstream driver. Those bitfields control the AXI burst size. + * As of now there are two known values: + * 1 - 128Byte + * 2 - 256Byte + * Downstream sets this to 256B burst size to improve the memory access + * efficiency so set it here too. + */ + writel(CTRLDESCL0_3_P_SIZE(2) | CTRLDESCL0_3_T_SIZE(2) | + CTRLDESCL0_3_PITCH(new_pstate->fb->pitches[0]), + lcdif->base + LCDC_V8_CTRLDESCL0_3); } static bool lcdif_format_mod_supported(struct drm_plane *plane, From patchwork Thu Sep 28 11:36:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 13402851 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BECBFE732C5 for ; Thu, 28 Sep 2023 11:37:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=yoS0v4wFiYSEQL0NnxRpFLECaRmIdpbwCApA0M2WiHM=; b=NJ2tDthkwdHyDM gK8d5smRhNl8w+I0HgsamIsP0OzF93KqUCAidfallBpNrssnqH7/rLuEJblPqJSwr1Y1NHYVTu7xk 9iiHVRMjS2isJ7VOlIJLeMcs4SKDLtM7c0JBpaTscxToo4z7kTzGIY9IOzUa7EVJ/z4C/mYFF1Fcl dCcHxhl3PC0tPyKoKc4XuqKBoY9+cKEcnBI8vnUp9FcNuj2V6GcCaGT2Gu6NJIZ6TZlIUomOr+BRd u4/BNUKnw7sz++iC4K9PYpMpIzb8tF0OAheJg0+P2+b08ExFOYjv01hh/U7i4ZfOdqJnfOFJqtGAs MmRdw6Po8cNv/a9cM7ug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qlpKD-003H1i-11; Thu, 28 Sep 2023 11:36:57 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qlpJq-003Gha-2X for linux-arm-kernel@lists.infradead.org; Thu, 28 Sep 2023 11:36:37 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qlpJm-0001sZ-Ei; Thu, 28 Sep 2023 13:36:30 +0200 Received: from [2a0a:edc0:0:1101:1d::28] (helo=dude02.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1qlpJl-009Z8S-VA; Thu, 28 Sep 2023 13:36:30 +0200 From: Lucas Stach To: Marek Vasut , Liu Ying Cc: Pengutronix Kernel Team , NXP Linux Team , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, patchwork-lst@pengutronix.de Subject: [PATCH v3 8/8] drm: lcdif: force modeset when FB format changes Date: Thu, 28 Sep 2023 13:36:29 +0200 Message-Id: <20230928113629.103188-8-l.stach@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230928113629.103188-1-l.stach@pengutronix.de> References: <20230928113629.103188-1-l.stach@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230928_043634_838604_5AB77494 X-CRM114-Status: GOOD ( 17.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Force a modeset if the new FB has a different format than the currently active one. While it might be possible to change between compatible formats without a full modeset as the format control is also supposed to be double buffered, the colorspace conversion is not, so when the CSC changes we need a modeset. For now just always force a modeset when the FB format changes to properly reconfigure all parts of the device for the new format. Signed-off-by: Lucas Stach Reviewed-by: Marek Vasut --- v3: no changes v2: fix indentation --- drivers/gpu/drm/mxsfb/lcdif_drv.c | 18 +++++++++++++++++- drivers/gpu/drm/mxsfb/lcdif_kms.c | 26 ++++++++++++++++++++------ 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/mxsfb/lcdif_drv.c b/drivers/gpu/drm/mxsfb/lcdif_drv.c index 9df278adf3e8..667d3a4716b0 100644 --- a/drivers/gpu/drm/mxsfb/lcdif_drv.c +++ b/drivers/gpu/drm/mxsfb/lcdif_drv.c @@ -30,9 +30,25 @@ #include "lcdif_drv.h" #include "lcdif_regs.h" +static int lcdif_atomic_check(struct drm_device *dev, + struct drm_atomic_state *state) +{ + int ret; + + ret = drm_atomic_helper_check(dev, state); + if (ret) + return ret; + + /* + * Check modeset again in case crtc_state->mode_changed is + * updated in plane's ->atomic_check callback. + */ + return drm_atomic_helper_check_modeset(dev, state); +} + static const struct drm_mode_config_funcs lcdif_mode_config_funcs = { .fb_create = drm_gem_fb_create, - .atomic_check = drm_atomic_helper_check, + .atomic_check = lcdif_atomic_check, .atomic_commit = drm_atomic_helper_commit, }; diff --git a/drivers/gpu/drm/mxsfb/lcdif_kms.c b/drivers/gpu/drm/mxsfb/lcdif_kms.c index c3e31fa0335e..f98b9d8e3aa4 100644 --- a/drivers/gpu/drm/mxsfb/lcdif_kms.c +++ b/drivers/gpu/drm/mxsfb/lcdif_kms.c @@ -649,18 +649,32 @@ static const struct drm_crtc_funcs lcdif_crtc_funcs = { static int lcdif_plane_atomic_check(struct drm_plane *plane, struct drm_atomic_state *state) { - struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, - plane); + struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state, + plane); + struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state, + plane); struct lcdif_drm_private *lcdif = to_lcdif_drm_private(plane->dev); struct drm_crtc_state *crtc_state; + int ret; + + /* always okay to disable the plane */ + if (!new_state->fb) + return 0; crtc_state = drm_atomic_get_new_crtc_state(state, &lcdif->crtc); - return drm_atomic_helper_check_plane_state(plane_state, crtc_state, - DRM_PLANE_NO_SCALING, - DRM_PLANE_NO_SCALING, - false, true); + ret = drm_atomic_helper_check_plane_state(new_state, crtc_state, + DRM_PLANE_NO_SCALING, + DRM_PLANE_NO_SCALING, + false, true); + if (ret) + return ret; + + if (old_state->fb && new_state->fb->format != old_state->fb->format) + crtc_state->mode_changed = true; + + return 0; } static void lcdif_plane_primary_atomic_update(struct drm_plane *plane,