From patchwork Thu Sep 21 20:03:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 13394465 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 4C797E7D0A8 for ; Thu, 21 Sep 2023 20:03:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 07F6010E617; Thu, 21 Sep 2023 20:03:18 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3FE5110E610 for ; Thu, 21 Sep 2023 20:03:15 +0000 (UTC) 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 1qjPtI-0000P1-Pe; Thu, 21 Sep 2023 22:03:12 +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 1qjPtI-00804q-71; Thu, 21 Sep 2023 22:03:12 +0200 From: Lucas Stach To: Marek Vasut , Liu Ying Subject: [PATCH v2 1/6] drm: lcdif: improve burst size configuration comment Date: Thu, 21 Sep 2023 22:03:07 +0200 Message-Id: <20230921200312.3989073-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: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, NXP Linux Team , Pengutronix Kernel Team , patchwork-lst@pengutronix.de Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 --- 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 21 20:03:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 13394462 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 5DDC6E7D0A2 for ; Thu, 21 Sep 2023 20:03:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B5B5F10E60F; Thu, 21 Sep 2023 20:03:16 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by gabe.freedesktop.org (Postfix) with ESMTPS id 407B810E611 for ; Thu, 21 Sep 2023 20:03:15 +0000 (UTC) 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 1qjPtI-0000P2-Pe; Thu, 21 Sep 2023 22:03:12 +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 1qjPtI-00804q-9s; Thu, 21 Sep 2023 22:03:12 +0200 From: Lucas Stach To: Marek Vasut , Liu Ying Subject: [PATCH v2 2/6] drm: lcdif: don't clear unrelated bits in CTRLDESCL0_5 when setting up format Date: Thu, 21 Sep 2023 22:03:08 +0200 Message-Id: <20230921200312.3989073-2-l.stach@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230921200312.3989073-1-l.stach@pengutronix.de> References: <20230921200312.3989073-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: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, NXP Linux Team , Pengutronix Kernel Team , patchwork-lst@pengutronix.de Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 --- 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 21 20:03:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 13394463 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 2CF44E7D0A6 for ; Thu, 21 Sep 2023 20:03:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D152110E610; Thu, 21 Sep 2023 20:03:16 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3F41610E60E for ; Thu, 21 Sep 2023 20:03:15 +0000 (UTC) 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 1qjPtI-0000PB-Ps; Thu, 21 Sep 2023 22:03:12 +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 1qjPtI-00804q-Cn; Thu, 21 Sep 2023 22:03:12 +0200 From: Lucas Stach To: Marek Vasut , Liu Ying Subject: [PATCH v2 3/6] drm: lcdif: rework runtime PM handling in the atomic commit Date: Thu, 21 Sep 2023 22:03:09 +0200 Message-Id: <20230921200312.3989073-3-l.stach@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230921200312.3989073-1-l.stach@pengutronix.de> References: <20230921200312.3989073-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: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, NXP Linux Team , Pengutronix Kernel Team , patchwork-lst@pengutronix.de Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 --- 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 18de2f17e249..205f6855fb1b 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, }; +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 e277592e5fa5..ccee5e28f236 100644 --- a/drivers/gpu/drm/mxsfb/lcdif_kms.c +++ b/drivers/gpu/drm/mxsfb/lcdif_kms.c @@ -540,7 +540,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); @@ -576,7 +580,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 21 20:03:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 13394464 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 696B7E7D0A2 for ; Thu, 21 Sep 2023 20:03:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7F5E810E611; Thu, 21 Sep 2023 20:03:17 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3F84D10E60F for ; Thu, 21 Sep 2023 20:03:15 +0000 (UTC) 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 1qjPtI-0000PH-R6; Thu, 21 Sep 2023 22:03:12 +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 1qjPtI-00804q-EE; Thu, 21 Sep 2023 22:03:12 +0200 From: Lucas Stach To: Marek Vasut , Liu Ying Subject: [PATCH v2 4/6] drm: lcdif: remove superfluous setup of framebuffer DMA address Date: Thu, 21 Sep 2023 22:03:10 +0200 Message-Id: <20230921200312.3989073-4-l.stach@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230921200312.3989073-1-l.stach@pengutronix.de> References: <20230921200312.3989073-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: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, NXP Linux Team , Pengutronix Kernel Team , patchwork-lst@pengutronix.de Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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: no changes --- drivers/gpu/drm/mxsfb/lcdif_kms.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/gpu/drm/mxsfb/lcdif_kms.c b/drivers/gpu/drm/mxsfb/lcdif_kms.c index ccee5e28f236..4e9284b0d12e 100644 --- a/drivers/gpu/drm/mxsfb/lcdif_kms.c +++ b/drivers/gpu/drm/mxsfb/lcdif_kms.c @@ -536,7 +536,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); @@ -548,14 +547,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); - } lcdif_enable_controller(lcdif); drm_crtc_vblank_on(crtc); From patchwork Thu Sep 21 20:03:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 13394466 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 23B3FE7D0A7 for ; Thu, 21 Sep 2023 20:03:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8B01410E613; Thu, 21 Sep 2023 20:03:18 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4D97D10E613 for ; Thu, 21 Sep 2023 20:03:15 +0000 (UTC) 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 1qjPtI-0000PI-U5; Thu, 21 Sep 2023 22:03:12 +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 1qjPtI-00804q-FX; Thu, 21 Sep 2023 22:03:12 +0200 From: Lucas Stach To: Marek Vasut , Liu Ying Subject: [PATCH v2 5/6] drm: lcdif: move pitch setup to plane atomic update Date: Thu, 21 Sep 2023 22:03:11 +0200 Message-Id: <20230921200312.3989073-5-l.stach@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230921200312.3989073-1-l.stach@pengutronix.de> References: <20230921200312.3989073-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: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, NXP Linux Team , Pengutronix Kernel Team , patchwork-lst@pengutronix.de Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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: 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 4e9284b0d12e..daf54ff2b7bd 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) @@ -694,6 +681,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 21 20:03:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 13394461 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 7B096E7D0A2 for ; Thu, 21 Sep 2023 20:03:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8D49E10E60E; Thu, 21 Sep 2023 20:03:16 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4366710E612 for ; Thu, 21 Sep 2023 20:03:15 +0000 (UTC) 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 1qjPtJ-0000Pc-1E; Thu, 21 Sep 2023 22:03:13 +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 1qjPtI-00804q-II; Thu, 21 Sep 2023 22:03:12 +0200 From: Lucas Stach To: Marek Vasut , Liu Ying Subject: [PATCH v2 6/6] drm: lcdif: force modeset when FB format changes Date: Thu, 21 Sep 2023 22:03:12 +0200 Message-Id: <20230921200312.3989073-6-l.stach@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230921200312.3989073-1-l.stach@pengutronix.de> References: <20230921200312.3989073-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: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, NXP Linux Team , Pengutronix Kernel Team , patchwork-lst@pengutronix.de Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 --- 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 205f6855fb1b..69a2a9323257 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 daf54ff2b7bd..34386e4b31c4 100644 --- a/drivers/gpu/drm/mxsfb/lcdif_kms.c +++ b/drivers/gpu/drm/mxsfb/lcdif_kms.c @@ -652,18 +652,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,