From patchwork Thu Sep 19 15:11:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaustabh Chakraborty X-Patchwork-Id: 13808167 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 9603BCF58E1 for ; Fri, 20 Sep 2024 07:23:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 10DA110E7BD; Fri, 20 Sep 2024 07:23:03 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; secure) header.d=disroot.org header.i=@disroot.org header.b="Z8QZNb6p"; dkim-atps=neutral Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) by gabe.freedesktop.org (Postfix) with ESMTPS id 389C510E722 for ; Thu, 19 Sep 2024 15:19:47 +0000 (UTC) Received: from mail01.disroot.lan (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 5E2BA23C84; Thu, 19 Sep 2024 17:11:29 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id C22g_44K2jCi; Thu, 19 Sep 2024 17:11:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1726758688; bh=vtqJW4WoUdJcxU3RW65FntLJKHSrz+r77iQWDTkRUAg=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=Z8QZNb6p6RID89WXQnJeGWWbD9a9lgxAaXxrg3vO+S9gRVFSvO1j88l+7OTuvqBNa leX1+EguSnOiHgsB2G/SxQAd5kx/eVtcwLPKJxwVfQ0x/qs/d4GiHj2eui1r/cb/tQ 2H7foP02Jy0PRTUqkLrrDCN3pFs4uqehqt5Nwqt40clxUghJy1gFvI8h0O5lgxCVyj WznF6VnhNUEBCd/V572JzsGzB6HqsDJ8MiUNIr3pEsWqFl8jyjLq0+gDpP6ahvwbV3 UdlhQVwMOp2dH2RmBM/gVs9LgZ+jbHDI87yEF9hhtJIZGMMyyONYl7L7xqUIe96/Zi PNl777QQ66hpQ== From: Kaustabh Chakraborty Date: Thu, 19 Sep 2024 20:41:00 +0530 Subject: [PATCH 1/6] drm/exynos: exynos7_drm_decon: fix uninitialized crtc reference in functions MIME-Version: 1.0 Message-Id: <20240919-exynosdrm-decon-v1-1-6c5861c1cb04@disroot.org> References: <20240919-exynosdrm-decon-v1-0-6c5861c1cb04@disroot.org> In-Reply-To: <20240919-exynosdrm-decon-v1-0-6c5861c1cb04@disroot.org> To: Inki Dae , Seung-Woo Kim , Kyungmin Park , David Airlie , Simona Vetter , Krzysztof Kozlowski , Alim Akhtar , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Rob Herring , Conor Dooley Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Kaustabh Chakraborty X-Mailman-Approved-At: Fri, 20 Sep 2024 07:22:50 +0000 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" decon_clear_channels() and decon_wait_for_vblank() accept a pointer to struct exynos_drm_crtc. However, these functions are called when the crtc is still uninitialized. Moreover, both functions use the pointer to retrieve and use struct decon_context, which is initialized. Modify the functions to accept a pointer to struct decon_context instead. Signed-off-by: Kaustabh Chakraborty --- drivers/gpu/drm/exynos/exynos7_drm_decon.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c b/drivers/gpu/drm/exynos/exynos7_drm_decon.c index 0d185c0564b9..e994779694f0 100644 --- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c +++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c @@ -81,10 +81,8 @@ static const enum drm_plane_type decon_win_types[WINDOWS_NR] = { DRM_PLANE_TYPE_CURSOR, }; -static void decon_wait_for_vblank(struct exynos_drm_crtc *crtc) +static void decon_wait_for_vblank(struct decon_context *ctx) { - struct decon_context *ctx = crtc->ctx; - if (ctx->suspended) return; @@ -100,9 +98,8 @@ static void decon_wait_for_vblank(struct exynos_drm_crtc *crtc) DRM_DEV_DEBUG_KMS(ctx->dev, "vblank wait timed out.\n"); } -static void decon_clear_channels(struct exynos_drm_crtc *crtc) +static void decon_clear_channels(struct decon_context *ctx) { - struct decon_context *ctx = crtc->ctx; unsigned int win, ch_enabled = 0; /* Check if any channel is enabled. */ @@ -118,7 +115,7 @@ static void decon_clear_channels(struct exynos_drm_crtc *crtc) /* Wait for vsync, as disable channel takes effect at next vsync */ if (ch_enabled) - decon_wait_for_vblank(ctx->crtc); + decon_wait_for_vblank(ctx); } static int decon_ctx_initialize(struct decon_context *ctx, @@ -126,7 +123,7 @@ static int decon_ctx_initialize(struct decon_context *ctx, { ctx->drm_dev = drm_dev; - decon_clear_channels(ctx->crtc); + decon_clear_channels(ctx); return exynos_drm_register_dma(drm_dev, ctx->dev, &ctx->dma_priv); } From patchwork Thu Sep 19 15:11:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaustabh Chakraborty X-Patchwork-Id: 13808160 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 991A5CF58E1 for ; Fri, 20 Sep 2024 07:22:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C942E10E7C3; Fri, 20 Sep 2024 07:22:51 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; secure) header.d=disroot.org header.i=@disroot.org header.b="d4a12F3o"; dkim-atps=neutral Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) by gabe.freedesktop.org (Postfix) with ESMTPS id 59B0F10E725 for ; Thu, 19 Sep 2024 15:19:47 +0000 (UTC) Received: from mail01.disroot.lan (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id E438521B06; Thu, 19 Sep 2024 17:11:35 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id BqxMisKfJAsW; Thu, 19 Sep 2024 17:11:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1726758695; bh=W9NCakkUrBU6rZgTcjvry5F2W8keaA/67v1TEQpKKeQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=d4a12F3oc0//7xbMft44unULEDptgyZ8hdZsHJlcawbcBix+0C+teeomT+TQazSR7 SOksXV3EVD937F1dSYO19M5XUN17GvEzjOLK4FKngNBfaJYdLzc15b+wTnR/HJ357o E1aVNVLV6v9m2OStYcGw2/oFeuxqapya0gsURwvrRkNlczUhFiQPeeLAkfD16qebIT Preyv5iXYzQQD0LLiZot9ukE+IB/aLsBrDQzAwRKJLUFx5z+ZNk1A6UnP7Amuv7Xxt u5ZDzpfXXVbfEbl4BpsJpI/OZaLM70BBqdWikkdjLjRtZUi8gLc8BGXAfjJBDKjk10 zhAg/u/3bWK8g== From: Kaustabh Chakraborty Date: Thu, 19 Sep 2024 20:41:01 +0530 Subject: [PATCH 2/6] drm/exynos: exynos7_drm_decon: fix suspended condition in decon_commit() MIME-Version: 1.0 Message-Id: <20240919-exynosdrm-decon-v1-2-6c5861c1cb04@disroot.org> References: <20240919-exynosdrm-decon-v1-0-6c5861c1cb04@disroot.org> In-Reply-To: <20240919-exynosdrm-decon-v1-0-6c5861c1cb04@disroot.org> To: Inki Dae , Seung-Woo Kim , Kyungmin Park , David Airlie , Simona Vetter , Krzysztof Kozlowski , Alim Akhtar , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Rob Herring , Conor Dooley Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Kaustabh Chakraborty X-Mailman-Approved-At: Fri, 20 Sep 2024 07:22:50 +0000 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" decon_commit() gets called during atomic_enable. At this stage, DECON is suspended, and thus the function refuses to run. Fix the suspended condition checking in decon_commit(). Signed-off-by: Kaustabh Chakraborty --- drivers/gpu/drm/exynos/exynos7_drm_decon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c b/drivers/gpu/drm/exynos/exynos7_drm_decon.c index e994779694f0..2c4ee87ae6ec 100644 --- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c +++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c @@ -152,7 +152,7 @@ static void decon_commit(struct exynos_drm_crtc *crtc) struct drm_display_mode *mode = &crtc->base.state->adjusted_mode; u32 val, clkdiv; - if (ctx->suspended) + if (!ctx->suspended) return; /* nothing to do if we haven't set the mode yet */ From patchwork Thu Sep 19 15:11:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaustabh Chakraborty X-Patchwork-Id: 13808165 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 34455CF58E2 for ; Fri, 20 Sep 2024 07:23:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EEB6510E7C5; Fri, 20 Sep 2024 07:22:52 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; secure) header.d=disroot.org header.i=@disroot.org header.b="j1RU2oUi"; dkim-atps=neutral Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4F28C10E723 for ; Thu, 19 Sep 2024 15:19:47 +0000 (UTC) Received: from mail01.disroot.lan (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 26EBA2384D; Thu, 19 Sep 2024 17:11:42 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id jdkrb6ejJlZP; Thu, 19 Sep 2024 17:11:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1726758701; bh=GP7vulBylMtNMk0x+Curx74hl3PAursdsxiHeXQyGIc=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=j1RU2oUifgRfrDVJQxO5RYwZI3+S9p3yFuP19csagm0z4pTVEaXm8Gd7hIpcKPMPt ZIBH2f/A50JsqmhZZrmSkXN+RhjYYi4URKZDg3jV3d/oF/IOc7q+lkRSEWjcOD1NlZ g3ir59c/YHCO1WXX8HBTmmQVH+bPgbwI2oRquA7jbCLJXuuSAQjsAZXRDedzpsGU8R 0Tj84BcIBVZjJZuZ6bsib1xq5p+GhTqtrSpWAz3+Ysp80o+GIlcVJVOyb6j84XzIwq JjouLksHiEeK0NeUFcpL1Ydcsl23Gu316L0EhSiiIBzwsS64ySJLd/KHUjOZBNIDo2 /NCwekO55hZ4g== From: Kaustabh Chakraborty Date: Thu, 19 Sep 2024 20:41:02 +0530 Subject: [PATCH 3/6] drm/exynos: exynos7_drm_decon: fix ideal_clk by converting it to Hz MIME-Version: 1.0 Message-Id: <20240919-exynosdrm-decon-v1-3-6c5861c1cb04@disroot.org> References: <20240919-exynosdrm-decon-v1-0-6c5861c1cb04@disroot.org> In-Reply-To: <20240919-exynosdrm-decon-v1-0-6c5861c1cb04@disroot.org> To: Inki Dae , Seung-Woo Kim , Kyungmin Park , David Airlie , Simona Vetter , Krzysztof Kozlowski , Alim Akhtar , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Rob Herring , Conor Dooley Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Kaustabh Chakraborty X-Mailman-Approved-At: Fri, 20 Sep 2024 07:22:50 +0000 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The clkdiv values are incorrect as ideal_clk is in kHz and the clock rate of vclk is in Hz. Multiply 1000 to ideal_clk to bring it to Hz. Signed-off-by: Kaustabh Chakraborty --- drivers/gpu/drm/exynos/exynos7_drm_decon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c b/drivers/gpu/drm/exynos/exynos7_drm_decon.c index 2c4ee87ae6ec..4e4ced50ff15 100644 --- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c +++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c @@ -137,7 +137,7 @@ static void decon_ctx_remove(struct decon_context *ctx) static u32 decon_calc_clkdiv(struct decon_context *ctx, const struct drm_display_mode *mode) { - unsigned long ideal_clk = mode->clock; + unsigned long ideal_clk = mode->clock * 1000; u32 clkdiv; /* Find the clock divider value that gets us closest to ideal_clk */ From patchwork Thu Sep 19 15:11:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaustabh Chakraborty X-Patchwork-Id: 13808161 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 23FF7CF58E2 for ; Fri, 20 Sep 2024 07:22:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AE10B10E7BF; Fri, 20 Sep 2024 07:22:51 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; secure) header.d=disroot.org header.i=@disroot.org header.b="Ysj/aRL1"; dkim-atps=neutral Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) by gabe.freedesktop.org (Postfix) with ESMTPS id 12D6410E040 for ; Thu, 19 Sep 2024 15:24:47 +0000 (UTC) Received: from mail01.disroot.lan (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id CF3BA23DFD; Thu, 19 Sep 2024 17:11:48 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id n1VxGGLcqtJu; Thu, 19 Sep 2024 17:11:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1726758708; bh=8o85bus/0rE9Cesf9JRpcxZtGUE4BpUrbgAzVXQTVc8=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=Ysj/aRL1u62Gn0awDl+2XPfKVS13f8EXYghIEeMliIlwn5jzVVvdCuysWvDE+uQCQ 67/TQICD+TqkPLwscbpSQg1zSyi1QUq0Zzk3JnCnQfLQLz983c9WTdI7Y0XepMi8mq hoPzjWXqpQTFTUgf8sERtWD5OZs8tzk/cGvA//Wj1w+f8DO2dUDjs/1sKxWQFKgPu/ U8lWt06vJ+kLzq7EEHCM3hvDPmopftnN9hR/NBPDmXSUi/S7IT49y1+GF1uVbTetJA UT8twdv64OwFRzTwLWyN9zw6AtywymqtajFXrv/dwauDFXgTCEu6OCb05LSH2YAPWH iaWxXRetkRTGA== From: Kaustabh Chakraborty Date: Thu, 19 Sep 2024 20:41:03 +0530 Subject: [PATCH 4/6] drm/exynos: exynos7_drm_decon: properly clear channels during bind MIME-Version: 1.0 Message-Id: <20240919-exynosdrm-decon-v1-4-6c5861c1cb04@disroot.org> References: <20240919-exynosdrm-decon-v1-0-6c5861c1cb04@disroot.org> In-Reply-To: <20240919-exynosdrm-decon-v1-0-6c5861c1cb04@disroot.org> To: Inki Dae , Seung-Woo Kim , Kyungmin Park , David Airlie , Simona Vetter , Krzysztof Kozlowski , Alim Akhtar , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Rob Herring , Conor Dooley Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Kaustabh Chakraborty X-Mailman-Approved-At: Fri, 20 Sep 2024 07:22:50 +0000 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The DECON channels are not cleared properly as the windows aren't shadow protected. When accompanied with an IOMMU, it pagefaults, and the kernel panics. Implement shadow protect/unprotect, along with a standalone update, for channel clearing to properly take effect. Signed-off-by: Kaustabh Chakraborty --- drivers/gpu/drm/exynos/exynos7_drm_decon.c | 55 +++++++++++++++++------------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c b/drivers/gpu/drm/exynos/exynos7_drm_decon.c index 4e4ced50ff15..7f0985eb216e 100644 --- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c +++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c @@ -81,6 +81,28 @@ static const enum drm_plane_type decon_win_types[WINDOWS_NR] = { DRM_PLANE_TYPE_CURSOR, }; +/** + * decon_shadow_protect_win() - disable updating values from shadow registers at vsync + * + * @ctx: display and enhancement controller context + * @win: window to protect registers for + * @protect: 1 to protect (disable updates) + */ +static void decon_shadow_protect_win(struct decon_context *ctx, + unsigned int win, bool protect) +{ + u32 bits, val; + + bits = SHADOWCON_WINx_PROTECT(win); + + val = readl(ctx->regs + SHADOWCON); + if (protect) + val |= bits; + else + val &= ~bits; + writel(val, ctx->regs + SHADOWCON); +} + static void decon_wait_for_vblank(struct decon_context *ctx) { if (ctx->suspended) @@ -101,18 +123,27 @@ static void decon_wait_for_vblank(struct decon_context *ctx) static void decon_clear_channels(struct decon_context *ctx) { unsigned int win, ch_enabled = 0; + u32 val; /* Check if any channel is enabled. */ for (win = 0; win < WINDOWS_NR; win++) { - u32 val = readl(ctx->regs + WINCON(win)); + val = readl(ctx->regs + WINCON(win)); if (val & WINCONx_ENWIN) { + decon_shadow_protect_win(ctx, win, true); + val &= ~WINCONx_ENWIN; writel(val, ctx->regs + WINCON(win)); ch_enabled = 1; + + decon_shadow_protect_win(ctx, win, false); } } + val = readl(ctx->regs + DECON_UPDATE); + val |= DECON_UPDATE_STANDALONE_F; + writel(val, ctx->regs + DECON_UPDATE); + /* Wait for vsync, as disable channel takes effect at next vsync */ if (ch_enabled) decon_wait_for_vblank(ctx); @@ -340,28 +371,6 @@ static void decon_win_set_colkey(struct decon_context *ctx, unsigned int win) writel(keycon1, ctx->regs + WKEYCON1_BASE(win)); } -/** - * decon_shadow_protect_win() - disable updating values from shadow registers at vsync - * - * @ctx: display and enhancement controller context - * @win: window to protect registers for - * @protect: 1 to protect (disable updates) - */ -static void decon_shadow_protect_win(struct decon_context *ctx, - unsigned int win, bool protect) -{ - u32 bits, val; - - bits = SHADOWCON_WINx_PROTECT(win); - - val = readl(ctx->regs + SHADOWCON); - if (protect) - val |= bits; - else - val &= ~bits; - writel(val, ctx->regs + SHADOWCON); -} - static void decon_atomic_begin(struct exynos_drm_crtc *crtc) { struct decon_context *ctx = crtc->ctx; From patchwork Thu Sep 19 15:19:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaustabh Chakraborty X-Patchwork-Id: 13808162 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 58D77CF58E0 for ; Fri, 20 Sep 2024 07:22:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C425610E7C2; Fri, 20 Sep 2024 07:22:51 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; secure) header.d=disroot.org header.i=@disroot.org header.b="A55hCsmd"; dkim-atps=neutral Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) by gabe.freedesktop.org (Postfix) with ESMTPS id CE9B610E040 for ; Thu, 19 Sep 2024 15:20:15 +0000 (UTC) Received: from mail01.disroot.lan (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id A959620454; Thu, 19 Sep 2024 17:20:14 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id Qo0bG5SzFI2j; Thu, 19 Sep 2024 17:20:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1726759213; bh=OGLUCgDWH562twCZsYpJURmvO0GqslL15kZSjFqgcgY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=A55hCsmdEO8Gznbzp2FRJwmJjccXj+GTJF6zPvzNisXBEsznw9wdjCwIQI166AcPo kIlEko3sMTln1yqa2b1Za3GTR5vGdGxbmnuJg2f8en3Nup9x+isUhs/IRV5pTH0Ynt u+2pdEmp5NHsOrDKIJlx8SYiCnhmyyby3o3E2P6gZZdtT1uhtvtzd1GKFHgsy3XmnK AEK+8+nzGAf8l5C+MbfkqSlMMMr1xiFqB3xB+dVL1uInlA13sT8rKg2ZzZyFnX5kfm +baHz/b17dQj2fwTqdKwNKPDHAL7wxLx7RLOAIEXi6XAeLjxeeTjhwnwa2RVxeIf0x rHvLk+VwG0r4Q== From: Kaustabh Chakraborty To: kauschluss@disroot.org Cc: airlied@gmail.com, alim.akhtar@samsung.com, conor@kernel.org, devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, inki.dae@samsung.com, krzk@kernel.org, kyungmin.park@samsung.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, maarten.lankhorst@linux.intel.com, mripard@kernel.org, robh@kernel.org, simona@ffwll.ch, sw0312.kim@samsung.com, tzimmermann@suse.de Subject: [PATCH 5/6] drm/exynos: exynos7_drm_decon: add driver data and support for Exynos7870 Date: Thu, 19 Sep 2024 20:49:39 +0530 Message-ID: <20240919-exynosdrm-decon-v1-5-8c3e3ccffad5@disroot.org> In-Reply-To: <20240919-exynosdrm-decon-v1-0-6c5861c1cb04@disroot.org> References: <20240919-exynosdrm-decon-v1-0-6c5861c1cb04@disroot.org> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 20 Sep 2024 07:22:50 +0000 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add support for Exynos 7870 DECON in the Exynos 7 DECON driver. Some Exynos 7 series SoCs (Exynos 7580 onwards) have different register values. In order to address such changes, include a driver data struct (named decon_data) so that correct base addresses and shift values can be provided. Signed-off-by: Kaustabh Chakraborty --- drivers/gpu/drm/exynos/exynos7_drm_decon.c | 58 ++++++++++++++++++++++-------- drivers/gpu/drm/exynos/regs-decon7.h | 15 ++++---- 2 files changed, 51 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c b/drivers/gpu/drm/exynos/exynos7_drm_decon.c index 7f0985eb216e..4d93d2d7959f 100644 --- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c +++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c @@ -37,6 +37,24 @@ #define WINDOWS_NR 2 +struct decon_data { + unsigned int vidw_buf_start_base; + unsigned int shadowcon_win_protect_shift; + unsigned int wincon_burstlen_shift; +}; + +static struct decon_data exynos7_decon_data = { + .vidw_buf_start_base = 0x80, + .shadowcon_win_protect_shift = 10, + .wincon_burstlen_shift = 11, +}; + +static struct decon_data exynos7870_decon_data = { + .vidw_buf_start_base = 0x880, + .shadowcon_win_protect_shift = 8, + .wincon_burstlen_shift = 10, +}; + struct decon_context { struct device *dev; struct drm_device *drm_dev; @@ -55,11 +73,19 @@ struct decon_context { wait_queue_head_t wait_vsync_queue; atomic_t wait_vsync_event; + const struct decon_data *data; struct drm_encoder *encoder; }; static const struct of_device_id decon_driver_dt_match[] = { - {.compatible = "samsung,exynos7-decon"}, + { + .compatible = "samsung,exynos7-decon", + .data = &exynos7_decon_data, + }, + { + .compatible = "samsung,exynos7870-decon", + .data = &exynos7870_decon_data, + }, {}, }; MODULE_DEVICE_TABLE(of, decon_driver_dt_match); @@ -92,8 +118,9 @@ static void decon_shadow_protect_win(struct decon_context *ctx, unsigned int win, bool protect) { u32 bits, val; + unsigned int shift = ctx->data->shadowcon_win_protect_shift; - bits = SHADOWCON_WINx_PROTECT(win); + bits = SHADOWCON_WINx_PROTECT(shift, win); val = readl(ctx->regs + SHADOWCON); if (protect) @@ -291,6 +318,7 @@ static void decon_win_set_pixfmt(struct decon_context *ctx, unsigned int win, { unsigned long val; int padding; + unsigned int shift = ctx->data->wincon_burstlen_shift; val = readl(ctx->regs + WINCON(win)); val &= ~WINCONx_BPPMODE_MASK; @@ -298,44 +326,44 @@ static void decon_win_set_pixfmt(struct decon_context *ctx, unsigned int win, switch (fb->format->format) { case DRM_FORMAT_RGB565: val |= WINCONx_BPPMODE_16BPP_565; - val |= WINCONx_BURSTLEN_16WORD; + val |= WINCONx_BURSTLEN_16WORD(shift); break; case DRM_FORMAT_XRGB8888: val |= WINCONx_BPPMODE_24BPP_xRGB; - val |= WINCONx_BURSTLEN_16WORD; + val |= WINCONx_BURSTLEN_16WORD(shift); break; case DRM_FORMAT_XBGR8888: val |= WINCONx_BPPMODE_24BPP_xBGR; - val |= WINCONx_BURSTLEN_16WORD; + val |= WINCONx_BURSTLEN_16WORD(shift); break; case DRM_FORMAT_RGBX8888: val |= WINCONx_BPPMODE_24BPP_RGBx; - val |= WINCONx_BURSTLEN_16WORD; + val |= WINCONx_BURSTLEN_16WORD(shift); break; case DRM_FORMAT_BGRX8888: val |= WINCONx_BPPMODE_24BPP_BGRx; - val |= WINCONx_BURSTLEN_16WORD; + val |= WINCONx_BURSTLEN_16WORD(shift); break; case DRM_FORMAT_ARGB8888: val |= WINCONx_BPPMODE_32BPP_ARGB | WINCONx_BLD_PIX | WINCONx_ALPHA_SEL; - val |= WINCONx_BURSTLEN_16WORD; + val |= WINCONx_BURSTLEN_16WORD(shift); break; case DRM_FORMAT_ABGR8888: val |= WINCONx_BPPMODE_32BPP_ABGR | WINCONx_BLD_PIX | WINCONx_ALPHA_SEL; - val |= WINCONx_BURSTLEN_16WORD; + val |= WINCONx_BURSTLEN_16WORD(shift); break; case DRM_FORMAT_RGBA8888: val |= WINCONx_BPPMODE_32BPP_RGBA | WINCONx_BLD_PIX | WINCONx_ALPHA_SEL; - val |= WINCONx_BURSTLEN_16WORD; + val |= WINCONx_BURSTLEN_16WORD(shift); break; case DRM_FORMAT_BGRA8888: default: val |= WINCONx_BPPMODE_32BPP_BGRA | WINCONx_BLD_PIX | WINCONx_ALPHA_SEL; - val |= WINCONx_BURSTLEN_16WORD; + val |= WINCONx_BURSTLEN_16WORD(shift); break; } @@ -351,8 +379,8 @@ static void decon_win_set_pixfmt(struct decon_context *ctx, unsigned int win, padding = (fb->pitches[0] / fb->format->cpp[0]) - fb->width; if (fb->width + padding < MIN_FB_WIDTH_FOR_16WORD_BURST) { - val &= ~WINCONx_BURSTLEN_MASK; - val |= WINCONx_BURSTLEN_8WORD; + val &= ~WINCONx_BURSTLEN_MASK(shift); + val |= WINCONx_BURSTLEN_8WORD(shift); } writel(val, ctx->regs + WINCON(win)); @@ -397,6 +425,7 @@ static void decon_update_plane(struct exynos_drm_crtc *crtc, unsigned int win = plane->index; unsigned int cpp = fb->format->cpp[0]; unsigned int pitch = fb->pitches[0]; + unsigned int vidw_addr0_base = ctx->data->vidw_buf_start_base; if (ctx->suspended) return; @@ -413,7 +442,7 @@ static void decon_update_plane(struct exynos_drm_crtc *crtc, /* buffer start address */ val = (unsigned long)exynos_drm_fb_dma_addr(fb, 0); - writel(val, ctx->regs + VIDW_BUF_START(win)); + writel(val, ctx->regs + VIDW_BUF_START(vidw_addr0_base, win)); padding = (pitch / cpp) - fb->width; @@ -695,6 +724,7 @@ static int decon_probe(struct platform_device *pdev) ctx->dev = dev; ctx->suspended = true; + ctx->data = of_device_get_match_data(dev); i80_if_timings = of_get_child_by_name(dev->of_node, "i80-if-timings"); if (i80_if_timings) diff --git a/drivers/gpu/drm/exynos/regs-decon7.h b/drivers/gpu/drm/exynos/regs-decon7.h index 5bc5f1db5196..216c106dac8f 100644 --- a/drivers/gpu/drm/exynos/regs-decon7.h +++ b/drivers/gpu/drm/exynos/regs-decon7.h @@ -48,7 +48,7 @@ /* SHADOWCON */ #define SHADOWCON 0x30 -#define SHADOWCON_WINx_PROTECT(_win) (1 << (10 + (_win))) +#define SHADOWCON_WINx_PROTECT(_shf, _win) (1 << ((_shf) + (_win))) /* WINCONx */ #define WINCON(_win) (0x50 + ((_win) * 4)) @@ -58,10 +58,9 @@ #define WINCONx_BUFSEL_SHIFT 28 #define WINCONx_TRIPLE_BUF_MODE (0x1 << 18) #define WINCONx_DOUBLE_BUF_MODE (0x0 << 18) -#define WINCONx_BURSTLEN_16WORD (0x0 << 11) -#define WINCONx_BURSTLEN_8WORD (0x1 << 11) -#define WINCONx_BURSTLEN_MASK (0x1 << 11) -#define WINCONx_BURSTLEN_SHIFT 11 +#define WINCONx_BURSTLEN_16WORD(_shf) (0x0 << (_shf)) +#define WINCONx_BURSTLEN_8WORD(_shf) (0x1 << (_shf)) +#define WINCONx_BURSTLEN_MASK(_shf) (0x1 << (_shf)) #define WINCONx_BLD_PLANE (0 << 8) #define WINCONx_BLD_PIX (1 << 8) #define WINCONx_ALPHA_MUL (1 << 7) @@ -89,9 +88,9 @@ #define VIDOSD_H(_x) (0x80 + ((_x) * 4)) /* Frame buffer start addresses: VIDWxxADD0n */ -#define VIDW_BUF_START(_win) (0x80 + ((_win) * 0x10)) -#define VIDW_BUF_START1(_win) (0x84 + ((_win) * 0x10)) -#define VIDW_BUF_START2(_win) (0x88 + ((_win) * 0x10)) +#define VIDW_BUF_START(_base, _win) ((_base) + ((_win) * 0x10)) +#define VIDW_BUF_START1(_base, _win) ((_base) + ((_win) * 0x10)) +#define VIDW_BUF_START2(_base, _win) ((_base) + ((_win) * 0x10)) #define VIDW_WHOLE_X(_win) (0x0130 + ((_win) * 8)) #define VIDW_WHOLE_Y(_win) (0x0134 + ((_win) * 8)) From patchwork Thu Sep 19 15:20:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaustabh Chakraborty X-Patchwork-Id: 13808168 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 743B8CF58E0 for ; Fri, 20 Sep 2024 07:23:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CD9C410E7C8; Fri, 20 Sep 2024 07:23:03 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=disroot.org header.i=@disroot.org header.b="gwuMj+Rw"; dkim-atps=neutral Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8442910E040 for ; Thu, 19 Sep 2024 15:21:05 +0000 (UTC) Received: from mail01.disroot.lan (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 6C96323D4F; Thu, 19 Sep 2024 17:21:04 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id pNWoonSMiFBj; Thu, 19 Sep 2024 17:21:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1726759263; bh=nvVtJPZU+6i/0iKiXxq0eINrojPz7dYMmz/1raiBwfw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=gwuMj+RwZMpwd6/9vwtYGrppumnTO+qGQlMpTtJ1TVudHFNR/ZjqUykKTazDdSSXz WZBRnt4N4d2HGJ00vXRCFsvZ9i4YZ0tV1yZy5VyHrQtv9nYa7GnQB420X0RhkWMzUU 4wqRg474W28Rvd6bTlCFGIAiACDItLBxzW6wCC6VJU15NHyyGq2FJS11lNkJM73rAF yzwCjsiLzPCTk54W2k+WZkhtM40ZK5t4LXk1G7Yrfnc2vkoZf4SgvSYC+tmo3ILv0c Nh6w1djHuKjpyRww3NTODoSKuiwOomoiCNczoMNqv/GH1VvaCIr//Z6dwgPMpUcDSk NiPAhJ0wIPRvA== From: Kaustabh Chakraborty To: kauschluss@disroot.org Cc: airlied@gmail.com, alim.akhtar@samsung.com, conor@kernel.org, devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, inki.dae@samsung.com, krzk@kernel.org, kyungmin.park@samsung.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, maarten.lankhorst@linux.intel.com, mripard@kernel.org, robh@kernel.org, simona@ffwll.ch, sw0312.kim@samsung.com, tzimmermann@suse.de Subject: [PATCH 6/6] dt-bindings: display: samsung, exynos7-decon: add exynos7870 compatible Date: Thu, 19 Sep 2024 20:50:42 +0530 Message-ID: <20240919-exynosdrm-decon-v1-6-8c3e3ccffad5@disroot.org> In-Reply-To: <20240919-exynosdrm-decon-v1-0-6c5861c1cb04@disroot.org> References: <20240919-exynosdrm-decon-v1-0-6c5861c1cb04@disroot.org> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 20 Sep 2024 07:22:50 +0000 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add the compatible string of Exynos7870 to the existing list. Signed-off-by: Kaustabh Chakraborty Acked-by: Krzysztof Kozlowski --- .../devicetree/bindings/display/samsung/samsung,exynos7-decon.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/display/samsung/samsung,exynos7-decon.yaml b/Documentation/devicetree/bindings/display/samsung/samsung,exynos7-decon.yaml index 992c23ca7a4e..53916e4c95d8 100644 --- a/Documentation/devicetree/bindings/display/samsung/samsung,exynos7-decon.yaml +++ b/Documentation/devicetree/bindings/display/samsung/samsung,exynos7-decon.yaml @@ -19,7 +19,9 @@ description: | properties: compatible: - const: samsung,exynos7-decon + enum: + - samsung,exynos7-decon + - samsung,exynos7870-decon clocks: maxItems: 4