From patchwork Mon Oct 21 14:07:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13844244 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 DA9CED15D96 for ; Mon, 21 Oct 2024 14:08:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 37CC310E527; Mon, 21 Oct 2024 14:08:28 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="dyJ9w6Ot"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9141710E520 for ; Mon, 21 Oct 2024 14:08:18 +0000 (UTC) Received: from [127.0.1.1] (91-157-155-49.elisa-laajakaista.fi [91.157.155.49]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A51D11775; Mon, 21 Oct 2024 16:06:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1729519591; bh=VBitCg4mmzcbGyGk6q4vLoLZGA6NGjSGxDJCUaNRvRA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=dyJ9w6Oty908otkRxZOKWO1PS3cEDZdAKt2iIRMvLHuGuuCX/0JwLMK7d6NWRnI/j qjbgEVn9R6ktyaVu93CSVA1IglJPShVcR/OSXw0dD190svCH3FldrVTZbfN+Xsmj9w wa/8z2popAW6glKGFqdfmy0/dOgsZcijA39X0TZM= From: Tomi Valkeinen Date: Mon, 21 Oct 2024 17:07:45 +0300 Subject: [PATCH 1/7] drm/tidss: Fix issue in irq handling causing irq-flood issue MIME-Version: 1.0 Message-Id: <20241021-tidss-irq-fix-v1-1-82ddaec94e4a@ideasonboard.com> References: <20241021-tidss-irq-fix-v1-0-82ddaec94e4a@ideasonboard.com> In-Reply-To: <20241021-tidss-irq-fix-v1-0-82ddaec94e4a@ideasonboard.com> To: Devarsh Thakkar , Jyri Sarha Cc: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Jonathan Cormier , Tomi Valkeinen , Bin Liu , stable@vger.kernel.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3147; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=VBitCg4mmzcbGyGk6q4vLoLZGA6NGjSGxDJCUaNRvRA=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnFmBMHTozIfIAbjm5ocXIG5ei/8JY10fx5WH+c u6fVWtNOfuJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZxZgTAAKCRD6PaqMvJYe 9YSIEACmQz+oDjXeahJ5zI+JsbI5Ax7kejJ0nkUwa25a2Xm+kcbrjRgR6iJJs93GyuccBI/d9iB 865nFZO4QQNUe8zVxy1AoftrDQMGrephfAXmMhg+dy9QPD+OBj9dHfoZwzX9tOM8ZgxOAH6qYpp czJ1xC/IWbZZcjmm1+/hn9KmLSyEAYntDr1qd5SloR0jcn3dQBz+F3LoQPyR+P2aH2uXBYMWIYc 76ZEN+/PD/bAk49yLxcfAEPk7yqE2bquxoiCjDliokSxEH6gkJgI2Vn6yGx9lNpJazjm0AOzcz1 SYUK2d7GU1HjtGcsylsHT5e3PJ6J7+U7dhjEtq8NuyqqqkLtL729rh5tPGyOP01KFum83ugAXBO 5iW+fXI9RTiILT5nBLpuJWFJyKtR5KU0dbDYIDIO48VLr4LlcwX0LpuJh71yIFeUo+lAZRx+FuE +riqBc9puFiw+U8DzR9lXenUWfaxicMPhVz/VQ1CmlDIds+0J3ypwH4U4hSl+nYCeIM6vkxHMpg UDPb1msyY9VquNeuIG/FAN9ShOdvmApZtU+iUKH4gdcyPOb0b4AWOR/YwKyUVJNQN4Ki1CWrTJ4 dpPTU+C04jDQmr1AiOwSeUlawYGMm1mna8uuJed5FY4kyZc9BfBYf4UZOXGnD/SNc0lTYBYy0x/ FDag+XhxTw7HC/w== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 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" It has been observed that sometimes DSS will trigger an interrupt and the top level interrupt (DISPC_IRQSTATUS) is not zero, but the VP and VID level interrupt-statuses are zero. As the top level irqstatus is supposed to tell whether we have VP/VID interrupts, the thinking of the driver authors was that this particular case could never happen. Thus the driver only clears the DISPC_IRQSTATUS bits which has corresponding interrupts in VP/VID status. So when this issue happens, the driver will not clear DISPC_IRQSTATUS, and we get an interrupt flood. It is unclear why the issue happens. It could be a race issue in the driver, but no such race has been found. It could also be an issue with the HW. However a similar case can be easily triggered by manually writing to DISPC_IRQSTATUS_RAW. This will forcibly set a bit in the DISPC_IRQSTATUS and trigger an interrupt, and as the driver never clears the bit, we get an interrupt flood. To fix the issue, always clear DISPC_IRQSTATUS. The concern with this solution is that if the top level irqstatus is the one that triggers the interrupt, always clearing DISPC_IRQSTATUS might leave some interrupts unhandled if VP/VID interrupt statuses have bits set. However, testing shows that if any of the irqstatuses is set (i.e. even if DISPC_IRQSTATUS == 0, but a VID irqstatus has a bit set), we will get an interrupt. Signed-off-by: Tomi Valkeinen Co-developed-by: Bin Liu Signed-off-by: Bin Liu Co-developed-by: Devarsh Thakkar Signed-off-by: Devarsh Thakkar Co-developed-by: Jonathan Cormier Signed-off-by: Jonathan Cormier Fixes: 32a1795f57ee ("drm/tidss: New driver for TI Keystone platform Display SubSystem") Cc: stable@vger.kernel.org Tested-by: Jonathan Cormier Tested-by: Jonathan Cormier --- drivers/gpu/drm/tidss/tidss_dispc.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/tidss/tidss_dispc.c b/drivers/gpu/drm/tidss/tidss_dispc.c index 1ad711f8d2a8..f81111067578 100644 --- a/drivers/gpu/drm/tidss/tidss_dispc.c +++ b/drivers/gpu/drm/tidss/tidss_dispc.c @@ -780,24 +780,20 @@ static void dispc_k3_clear_irqstatus(struct dispc_device *dispc, dispc_irq_t clearmask) { unsigned int i; - u32 top_clear = 0; for (i = 0; i < dispc->feat->num_vps; ++i) { - if (clearmask & DSS_IRQ_VP_MASK(i)) { + if (clearmask & DSS_IRQ_VP_MASK(i)) dispc_k3_vp_write_irqstatus(dispc, i, clearmask); - top_clear |= BIT(i); - } } for (i = 0; i < dispc->feat->num_planes; ++i) { - if (clearmask & DSS_IRQ_PLANE_MASK(i)) { + if (clearmask & DSS_IRQ_PLANE_MASK(i)) dispc_k3_vid_write_irqstatus(dispc, i, clearmask); - top_clear |= BIT(4 + i); - } } if (dispc->feat->subrev == DISPC_K2G) return; - dispc_write(dispc, DISPC_IRQSTATUS, top_clear); + /* always clear the top level irqstatus */ + dispc_write(dispc, DISPC_IRQSTATUS, dispc_read(dispc, DISPC_IRQSTATUS)); /* Flush posted writes */ dispc_read(dispc, DISPC_IRQSTATUS); From patchwork Mon Oct 21 14:07:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13844241 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 49FECD15D98 for ; Mon, 21 Oct 2024 14:08:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5B2A510E52B; Mon, 21 Oct 2024 14:08:22 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="TBlze24y"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by gabe.freedesktop.org (Postfix) with ESMTPS id F3B1610E524 for ; Mon, 21 Oct 2024 14:08:18 +0000 (UTC) Received: from [127.0.1.1] (91-157-155-49.elisa-laajakaista.fi [91.157.155.49]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7A05C17D6; Mon, 21 Oct 2024 16:06:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1729519592; bh=350svTouqCIMYauO1zF9sxUQfeZoXKejVvPzh3lweDI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=TBlze24yHdB+GbFvSJ/ta+JIv/NeZs9S/J2cq5gbrelXj7vStwUGyUcNDzRGM5wyK FS2PWFh/SvR5rmCziL3Ou/RELIkWKSt3DnStTyoickQOkY/QDV68wdPdVQS1XeKrMe rx6LlWp/XAhW/dDr84THGT10qJP2qCNs+Tv/YD4Y= From: Tomi Valkeinen Date: Mon, 21 Oct 2024 17:07:46 +0300 Subject: [PATCH 2/7] drm/tidss: Remove unused OCP error flag MIME-Version: 1.0 Message-Id: <20241021-tidss-irq-fix-v1-2-82ddaec94e4a@ideasonboard.com> References: <20241021-tidss-irq-fix-v1-0-82ddaec94e4a@ideasonboard.com> In-Reply-To: <20241021-tidss-irq-fix-v1-0-82ddaec94e4a@ideasonboard.com> To: Devarsh Thakkar , Jyri Sarha Cc: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Jonathan Cormier , Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1930; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=350svTouqCIMYauO1zF9sxUQfeZoXKejVvPzh3lweDI=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnFmBNsgrP8qGufXs4zHnZF5Q2pRBIcxHuB7Kjj clhLaP/ggqJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZxZgTQAKCRD6PaqMvJYe 9Qy0D/49SO1ruUUf7vq4nt97FHX1gbimghNP9szatVeaOuAM+DDbfCYpvPAs+xAtSxoyb0qZc2G ykekOU7vSafkJUlhQH4mgM8GerqMT+6Fi/Aj6fMJ3Yb3BTP1W0eDgoLMIv1fFGhFClVHYtCQ/Xm otkqwUYJouZBZ2t3v5IMi+BbxDOtJmSjw/O8pkQkfK6wWXhwa3aSOMhsxQqT+ftgSbXecgVUrAk 4csNf+mbzWNK/vAh3ZN+cYoyGAlNNgRNpj6TBAhS6I7FCNcsnw/kfgPzSIW+5XE8ESQMslKgDKw vczJT/Z3OpiW4hKcY6qUkuRQpbdIMeg41621AKGeu3kukuM1RiRC6MsSXutD3T4DfKyb2wBr7uq mozdH9rkN4jZAy9Dj7d6ul302lFBQahVChW6dUuPGQqQ4VnrvWULARG+X/NhOSOsh01nqCS6Xjf uUCEMUhihTgtq8NCLTDQ9ZvwxiteTyxVBgPJ58jEdCRbwRWxxW6k1YZLWQ/xVAr8t/ZYfBQwAog 1ll7wGDvzCMjv5KKpvyyIWY64+Q+EWFDAF1eO+F3zcVBY3cNneWfEl+lL4MO5FiomWgvoTYCxpo kvaWAPLv/9fSpFIfoZfNWRdITa+qPY6JmKZfTLaQx7D65YcCcpBzM5m4hEJH4oKXvMM9a3AzBIv Fvsq4sv6dyBiTAg== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 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" We never use the DSS_IRQ_DEVICE_OCP_ERR flag, and the HW doesn't even have such a bit... So remove it. Signed-off-by: Tomi Valkeinen Reviewed-by: Devarsh Thakkar --- drivers/gpu/drm/tidss/tidss_irq.c | 5 +---- drivers/gpu/drm/tidss/tidss_irq.h | 4 +--- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/tidss/tidss_irq.c b/drivers/gpu/drm/tidss/tidss_irq.c index 604334ef526a..91498ff664a2 100644 --- a/drivers/gpu/drm/tidss/tidss_irq.c +++ b/drivers/gpu/drm/tidss/tidss_irq.c @@ -78,9 +78,6 @@ static irqreturn_t tidss_irq_handler(int irq, void *arg) tidss_crtc_error_irq(crtc, irqstatus); } - if (irqstatus & DSS_IRQ_DEVICE_OCP_ERR) - dev_err_ratelimited(tidss->dev, "OCP error\n"); - return IRQ_HANDLED; } @@ -105,7 +102,7 @@ int tidss_irq_install(struct drm_device *ddev, unsigned int irq) if (ret) return ret; - tidss->irq_mask = DSS_IRQ_DEVICE_OCP_ERR; + tidss->irq_mask = 0; for (unsigned int i = 0; i < tidss->num_crtcs; ++i) { struct tidss_crtc *tcrtc = to_tidss_crtc(tidss->crtcs[i]); diff --git a/drivers/gpu/drm/tidss/tidss_irq.h b/drivers/gpu/drm/tidss/tidss_irq.h index b512614d5863..dd61f645f662 100644 --- a/drivers/gpu/drm/tidss/tidss_irq.h +++ b/drivers/gpu/drm/tidss/tidss_irq.h @@ -19,15 +19,13 @@ * bit use |D |fou|FEOL|FEOL|FEOL|FEOL| UUUU | | * bit number|0 |1-3|4-7 |8-11| 12-19 | 20-23 | 24-31 | * - * device bits: D = OCP error + * device bits: D = Unused * WB bits: f = frame done wb, o = wb buffer overflow, * u = wb buffer uncomplete * vp bits: F = frame done, E = vsync even, O = vsync odd, L = sync lost * plane bits: U = fifo underflow */ -#define DSS_IRQ_DEVICE_OCP_ERR BIT(0) - #define DSS_IRQ_DEVICE_FRAMEDONEWB BIT(1) #define DSS_IRQ_DEVICE_WBBUFFEROVERFLOW BIT(2) #define DSS_IRQ_DEVICE_WBUNCOMPLETEERROR BIT(3) From patchwork Mon Oct 21 14:07:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13844245 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 8E58DD15D9A for ; Mon, 21 Oct 2024 14:08:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1414B10E529; Mon, 21 Oct 2024 14:08:31 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="XBikVcUv"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by gabe.freedesktop.org (Postfix) with ESMTPS id 97B9610E524 for ; Mon, 21 Oct 2024 14:08:19 +0000 (UTC) Received: from [127.0.1.1] (91-157-155-49.elisa-laajakaista.fi [91.157.155.49]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3A5AC18B9; Mon, 21 Oct 2024 16:06:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1729519592; bh=1q9cAD7VxRnLeVa0WQH1ibBnEmicIHZOce8e+2t9JMA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=XBikVcUvALTtM6eoMckNqaCTTcFD7snAw0RbAWIX797OJ4rHtYCUJ2xCmKRAQje9u juKiQpG6fFleh4lgl4CH7er0JDBRcdnTxF+1kjoqMFIPKva52n0V0dTwXSMmh6YNAQ xifn0vI50z67VV2kos32QQdUzK2fbF6a3CiapJZ4= From: Tomi Valkeinen Date: Mon, 21 Oct 2024 17:07:47 +0300 Subject: [PATCH 3/7] drm/tidss: Remove extra K2G check MIME-Version: 1.0 Message-Id: <20241021-tidss-irq-fix-v1-3-82ddaec94e4a@ideasonboard.com> References: <20241021-tidss-irq-fix-v1-0-82ddaec94e4a@ideasonboard.com> In-Reply-To: <20241021-tidss-irq-fix-v1-0-82ddaec94e4a@ideasonboard.com> To: Devarsh Thakkar , Jyri Sarha Cc: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Jonathan Cormier , Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=963; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=1q9cAD7VxRnLeVa0WQH1ibBnEmicIHZOce8e+2t9JMA=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnFmBNB8YAVBBsW9C7Qu3rJKCDj7kd7zVLgXUGj o7J2z31cFqJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZxZgTQAKCRD6PaqMvJYe 9eouD/0UpgWjIbRmVs4qd9KM4zU+ULBEJ1Zah+myAQaDWAqNB2FCrKjqbXfkP3rkqskfXXpfCwv tM81LZ3PQ8fn3XTuiMNnS49iBJt3qL6DZ5vkXNZ2Jfpmz69R6n+fTptq4Bkz8F7vE2KAojRKWMb bsCmlqm0hqzkNXw2RPT9NZyqvhLMT0fgwIuig5aEuTxBpgvIp0/St9CpH7SNXOXNM9XKL6uGlDQ tmLUsagaO9mVI/7O2ojjLqRGM4s9QpgovpJRqzKO0pjklJJDB71gz7BzpTTE3l8yGkwATR6JF7D TE5EFazPcrq3qsJx+5ldHeRf6Ud7jY2PE4isme00GhRMkvCRCicYbn9rY8L8Bad60+cfViSfLSc 4EkMNeH1tIVO3APaxSw+7l1TEmCwxYZPSFnyCK3Vly6VvbW7o3SZPBSnlbGsDLFkA+MeUj3bsZR SFlFCv6O4DpkVEvIBU5bsGvEsvO9ciNUF8xHs3rpPsLOAlUi0dpax3QSwtfscagfF0i+nHm4FmP HA4TdCUKVHk5WKDj31cj+t57JZiRV44vNctuVRXNsOKTHu1CO/RBPlqMUXM2beX2kfibQzimU3p BbQKmCM/+iK+uZh886gjm6kcaItvjvyVyLnXtPlo7gBs0B1OA/tODR//CLg0b0LHGcihJ1JLZgQ CbC1728dvCllzNA== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 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" We check if the platform is K2G in dispc_k3_clear_irqstatus(), and return early if so. This cannot happen, as the _k3_ functions are never called on K2G in the first place. So remove the check. Signed-off-by: Tomi Valkeinen Reviewed-by: Devarsh Thakkar --- drivers/gpu/drm/tidss/tidss_dispc.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/gpu/drm/tidss/tidss_dispc.c b/drivers/gpu/drm/tidss/tidss_dispc.c index f81111067578..99a1138f3e69 100644 --- a/drivers/gpu/drm/tidss/tidss_dispc.c +++ b/drivers/gpu/drm/tidss/tidss_dispc.c @@ -789,8 +789,6 @@ void dispc_k3_clear_irqstatus(struct dispc_device *dispc, dispc_irq_t clearmask) if (clearmask & DSS_IRQ_PLANE_MASK(i)) dispc_k3_vid_write_irqstatus(dispc, i, clearmask); } - if (dispc->feat->subrev == DISPC_K2G) - return; /* always clear the top level irqstatus */ dispc_write(dispc, DISPC_IRQSTATUS, dispc_read(dispc, DISPC_IRQSTATUS)); From patchwork Mon Oct 21 14:07:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13844240 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 68924D15D96 for ; Mon, 21 Oct 2024 14:08:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ABEFB10E525; Mon, 21 Oct 2024 14:08:21 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="SlEDc8Bm"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3A78F10E524 for ; Mon, 21 Oct 2024 14:08:20 +0000 (UTC) Received: from [127.0.1.1] (91-157-155-49.elisa-laajakaista.fi [91.157.155.49]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id EAB5E19F8; Mon, 21 Oct 2024 16:06:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1729519593; bh=3lKvoJyc5GCASmOzrHd7zuyVDvlv3n+wB5AYfd2tH3M=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=SlEDc8Bm5JwReBKKhmIzf2Kpaj0X8qJs80rKRIEuEAf9vGmx6ePxD7ulrdqdm9A7P CY+FwHJuQPjVz57xAARYkPS5n+GZi+V44nqe85cL4SDiS0aCOqjzrISfKQ5eFRuzn5 NpXGIG8jJbCJ8ZaJoK9z0Xq/pj6LbTiEEV+E11D8= From: Tomi Valkeinen Date: Mon, 21 Oct 2024 17:07:48 +0300 Subject: [PATCH 4/7] drm/tidss: Add printing of underflows MIME-Version: 1.0 Message-Id: <20241021-tidss-irq-fix-v1-4-82ddaec94e4a@ideasonboard.com> References: <20241021-tidss-irq-fix-v1-0-82ddaec94e4a@ideasonboard.com> In-Reply-To: <20241021-tidss-irq-fix-v1-0-82ddaec94e4a@ideasonboard.com> To: Devarsh Thakkar , Jyri Sarha Cc: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Jonathan Cormier , Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2501; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=3lKvoJyc5GCASmOzrHd7zuyVDvlv3n+wB5AYfd2tH3M=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnFmBN0uzdnlnXgYBoLHvewlQcuKZ2YjzxIEHo8 l6U4vEbzheJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZxZgTQAKCRD6PaqMvJYe 9d/DEACsWQSvvw1DFMNhDBKPKC5ATHWGCl/HqMpfy+YZxFiI9QM0r0HNAa6cujKt+NM0Oie6CE0 +FEgyfyH73S5QNNTGASLx2WbE9WxzlolHN6+ROSSunNaaxMOvuZ3uhmSGLIArH9C5REpd2N4giz SAGxlQ0zP5V7RvXCpDlEV5oX6iFLLSIHjzaDwJ78WXzayJuekZJ0fwFWA47a96nAGxFxsG7YaoI BlAH+EtecDH9+zIo1yuBmTyntIGO9Zh8yTUmUtz3FNiycpu77UNW3DsimyjBmhU109H55YBqaL4 7Y+CFOYz4XIWaYK4MOYkmke4nD8naZQSAgfYDxrLTE/SGFI2Ue2QeRZ3kIa6ktt/i/zrP5b+4fx r59RyYffgkdOqN8PABzSHkKFZFztF8FGkrCUn4Zj/wCHubaxNKNU9I1A8+4Q7au2dXyQFC7MJiC 8y2W4Zt61lVWqbnO/YzPFuuOvCnGe3nSoIihw52eoArceKrQXtO7ZX4dInzXqwjBgE9TI0D4mjx Y29cf03a7RNHQ+2y2kquAANHR2OJW88qv4bm0SD7uMWyHH7sIKOpFYnJQaB1RDERNrKC73luO/B TZ9UYPUJvOiOKJ2/1kr35+1dGj+L+KGkJpMWVWaxAz9s2z4YIEqXx5QBv72h4XHruCChyD9hTUW Xn9DL2e7CixOdQw== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 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 printing of underflows the same way as we handle sync losts. Signed-off-by: Tomi Valkeinen Reviewed-by: Devarsh Thakkar --- drivers/gpu/drm/tidss/tidss_irq.c | 14 ++++++++++++++ drivers/gpu/drm/tidss/tidss_plane.c | 8 ++++++++ drivers/gpu/drm/tidss/tidss_plane.h | 2 ++ 3 files changed, 24 insertions(+) diff --git a/drivers/gpu/drm/tidss/tidss_irq.c b/drivers/gpu/drm/tidss/tidss_irq.c index 91498ff664a2..3cc4024ec7ff 100644 --- a/drivers/gpu/drm/tidss/tidss_irq.c +++ b/drivers/gpu/drm/tidss/tidss_irq.c @@ -78,6 +78,14 @@ static irqreturn_t tidss_irq_handler(int irq, void *arg) tidss_crtc_error_irq(crtc, irqstatus); } + for (unsigned int i = 0; i < tidss->num_planes; ++i) { + struct drm_plane *plane = tidss->planes[i]; + struct tidss_plane *tplane = to_tidss_plane(plane); + + if (irqstatus & DSS_IRQ_PLANE_FIFO_UNDERFLOW(tplane->hw_plane_id)) + tidss_plane_error_irq(plane, irqstatus); + } + return IRQ_HANDLED; } @@ -112,6 +120,12 @@ int tidss_irq_install(struct drm_device *ddev, unsigned int irq) tidss->irq_mask |= DSS_IRQ_VP_FRAME_DONE(tcrtc->hw_videoport); } + for (unsigned int i = 0; i < tidss->num_planes; ++i) { + struct tidss_plane *tplane = to_tidss_plane(tidss->planes[i]); + + tidss->irq_mask |= DSS_IRQ_PLANE_FIFO_UNDERFLOW(tplane->hw_plane_id); + } + return 0; } diff --git a/drivers/gpu/drm/tidss/tidss_plane.c b/drivers/gpu/drm/tidss/tidss_plane.c index a5d86822c9e3..116de124bddb 100644 --- a/drivers/gpu/drm/tidss/tidss_plane.c +++ b/drivers/gpu/drm/tidss/tidss_plane.c @@ -18,6 +18,14 @@ #include "tidss_drv.h" #include "tidss_plane.h" +void tidss_plane_error_irq(struct drm_plane *plane, u64 irqstatus) +{ + struct tidss_plane *tplane = to_tidss_plane(plane); + + dev_err_ratelimited(plane->dev->dev, "Plane%u underflow (irq %llx)\n", + tplane->hw_plane_id, irqstatus); +} + /* drm_plane_helper_funcs */ static int tidss_plane_atomic_check(struct drm_plane *plane, diff --git a/drivers/gpu/drm/tidss/tidss_plane.h b/drivers/gpu/drm/tidss/tidss_plane.h index e933e158b617..aecaf2728406 100644 --- a/drivers/gpu/drm/tidss/tidss_plane.h +++ b/drivers/gpu/drm/tidss/tidss_plane.h @@ -22,4 +22,6 @@ struct tidss_plane *tidss_plane_create(struct tidss_device *tidss, u32 crtc_mask, const u32 *formats, u32 num_formats); +void tidss_plane_error_irq(struct drm_plane *plane, u64 irqstatus); + #endif From patchwork Mon Oct 21 14:07:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13844242 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 ADEBED15D96 for ; Mon, 21 Oct 2024 14:08:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8967710E533; Mon, 21 Oct 2024 14:08:22 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="EDpDAXaJ"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0137010E524 for ; Mon, 21 Oct 2024 14:08:20 +0000 (UTC) Received: from [127.0.1.1] (91-157-155-49.elisa-laajakaista.fi [91.157.155.49]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A96A01A37; Mon, 21 Oct 2024 16:06:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1729519594; bh=IUMNEAvo290khRZh9z7VJP/IFs8nq3LUEXQk5ge19vg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=EDpDAXaJKRLnbe1mHspqU8ZHw4u79YMPYDN4+ed/4NF5AppC4vdKqOOaqcqIl3hzQ lPXdgY5vrZK0snIxRD0TeQpKpObT7keeKroUPpoh87l5p/u56y5qTt2KBn8hp6jmZ9 owhNhCKF5+6FtxbpZK9UqLt4bbDlKkziFRdf4L2s= From: Tomi Valkeinen Date: Mon, 21 Oct 2024 17:07:49 +0300 Subject: [PATCH 5/7] drm/tidss: Clear the interrupt status for interrupts being disabled MIME-Version: 1.0 Message-Id: <20241021-tidss-irq-fix-v1-5-82ddaec94e4a@ideasonboard.com> References: <20241021-tidss-irq-fix-v1-0-82ddaec94e4a@ideasonboard.com> In-Reply-To: <20241021-tidss-irq-fix-v1-0-82ddaec94e4a@ideasonboard.com> To: Devarsh Thakkar , Jyri Sarha Cc: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Jonathan Cormier , Tomi Valkeinen , stable@vger.kernel.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2574; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=6GwpZAEtux7Bj7g4mSltZcfqft3v17bYy0VmOFldnf0=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnFmBODQnh5GB565MHl21A3bV188NxrRKELGA+w iKNyiRnU1mJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZxZgTgAKCRD6PaqMvJYe 9XDuD/9bhlDfWWlSRHjmPYpcwrqbB6WCgpk35PnSJvY5NBPD7Q8787LL9qoFne+VIQRgldrTTVi dvzbIPZEbv5OLIVeck5+JnR6bQSsdO+3QdiFXHAQo6JRgsIcWi/LmmQzqqhWONHgikqsJpb7YyI H6+s/1UwliotxpWCm5+waN3pqUvMbqQlTUm2Gc9KEDPlBwh410tW+zH9YtMTaM7GuINJZxn4iMS hA7a1rsZeU7n8zGH1UwyZCJ0WDniX6SitrwtyKMDaWu2HBcPXet8fLGy6chdZbqPVRdYZBx0zJN D5xKs20pUCU3qDHoMK2iXfJkNXCk5ttcZvg8k0LFiz/xWSdH5AkHIJWiSoSqrM7OwIvu/sY4cAJ +ns9J51IKBoDWkUPGtYn3X2a/GrPoW8HFsM1oOKXydbg3HaG+Ds6IHKqJt6GzaSUjYn18D22/CM gVtPqGqf+3i5wyEDz3IXmkNHph1etIG3o32lYFjbkDkkpywL65BEUY/nDKvsvwYkfV65FepZ12p V2vHf/5L/pAYKrSuMSpQQhZH/1IkdfteZO7df87bI3BHxdPi+0zoJyKdUCsKWshlklmBdnJAB00 hjP/EwkI4IL+aP4y7Os7Xaw7Nnoko9qx+NhKGFihixwlsxeJnsb7EtO/EsbxeMae5OxdmfwbOqX 7kfP6QvxzfjryrA== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 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" From: Devarsh Thakkar The driver does not touch the irqstatus register when it is disabling interrupts. This might cause an interrupt to trigger for an interrupt that was just disabled. To fix the issue, clear the irqstatus registers right after disabling the interrupts. Fixes: 32a1795f57ee ("drm/tidss: New driver for TI Keystone platform Display SubSystem") Cc: stable@vger.kernel.org Reported-by: Jonathan Cormier Closes: https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1394222/am625-issue-about-tidss-rcu_preempt-self-detected-stall-on-cpu/5424479#5424479 Signed-off-by: Devarsh Thakkar [Tomi: mostly rewrote the patch] Signed-off-by: Tomi Valkeinen Reviewed-by: Jonathan Cormier Tested-by: Jonathan Cormier --- drivers/gpu/drm/tidss/tidss_dispc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/tidss/tidss_dispc.c b/drivers/gpu/drm/tidss/tidss_dispc.c index 99a1138f3e69..515f82e8a0a5 100644 --- a/drivers/gpu/drm/tidss/tidss_dispc.c +++ b/drivers/gpu/drm/tidss/tidss_dispc.c @@ -700,7 +700,7 @@ void dispc_k2g_set_irqenable(struct dispc_device *dispc, dispc_irq_t mask) { dispc_irq_t old_mask = dispc_k2g_read_irqenable(dispc); - /* clear the irqstatus for newly enabled irqs */ + /* clear the irqstatus for irqs that will be enabled */ dispc_k2g_clear_irqstatus(dispc, (mask ^ old_mask) & mask); dispc_k2g_vp_set_irqenable(dispc, 0, mask); @@ -708,6 +708,9 @@ void dispc_k2g_set_irqenable(struct dispc_device *dispc, dispc_irq_t mask) dispc_write(dispc, DISPC_IRQENABLE_SET, (1 << 0) | (1 << 7)); + /* clear the irqstatus for irqs that were disabled */ + dispc_k2g_clear_irqstatus(dispc, (mask ^ old_mask) & old_mask); + /* flush posted write */ dispc_k2g_read_irqenable(dispc); } @@ -837,7 +840,7 @@ static void dispc_k3_set_irqenable(struct dispc_device *dispc, old_mask = dispc_k3_read_irqenable(dispc); - /* clear the irqstatus for newly enabled irqs */ + /* clear the irqstatus for irqs that will be enabled */ dispc_k3_clear_irqstatus(dispc, (old_mask ^ mask) & mask); for (i = 0; i < dispc->feat->num_vps; ++i) { @@ -862,6 +865,9 @@ static void dispc_k3_set_irqenable(struct dispc_device *dispc, if (main_disable) dispc_write(dispc, DISPC_IRQENABLE_CLR, main_disable); + /* clear the irqstatus for irqs that were disabled */ + dispc_k3_clear_irqstatus(dispc, (old_mask ^ mask) & old_mask); + /* Flush posted writes */ dispc_read(dispc, DISPC_IRQENABLE_SET); } From patchwork Mon Oct 21 14:07:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13844243 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 63919D15D98 for ; Mon, 21 Oct 2024 14:08:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D88F310E524; Mon, 21 Oct 2024 14:08:27 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="PxDSWj1W"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by gabe.freedesktop.org (Postfix) with ESMTPS id C52CE10E526 for ; Mon, 21 Oct 2024 14:08:21 +0000 (UTC) Received: from [127.0.1.1] (91-157-155-49.elisa-laajakaista.fi [91.157.155.49]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6F4DB1A40; Mon, 21 Oct 2024 16:06:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1729519595; bh=ENDFVzRG/cSHhohHXAlrlu8X8vbG5ayt/Jz55IYFLDg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=PxDSWj1W2hRRX6/76+mP/nye+oe6R1f6chkMM+fq6dLMYNQTSaK72ISZ7DJLhY9R4 8EgDc1vJVC2+bmbGtD4anOJmLazMkU517fAV+/SHtXKlO+XgaGOmMYiQYJgMjXg+bl WDZFelNbWIhIE5dvbT+6AxXMcGVRY5ONpBdchrmU= From: Tomi Valkeinen Date: Mon, 21 Oct 2024 17:07:50 +0300 Subject: [PATCH 6/7] drm/tidss: Fix race condition while handling interrupt registers MIME-Version: 1.0 Message-Id: <20241021-tidss-irq-fix-v1-6-82ddaec94e4a@ideasonboard.com> References: <20241021-tidss-irq-fix-v1-0-82ddaec94e4a@ideasonboard.com> In-Reply-To: <20241021-tidss-irq-fix-v1-0-82ddaec94e4a@ideasonboard.com> To: Devarsh Thakkar , Jyri Sarha Cc: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Jonathan Cormier , Tomi Valkeinen , stable@vger.kernel.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1922; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=bGZXTG+tLmXBnXVPFsIwwNa8R3k06EXefciByMbofqM=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnFmBOTwVF0bOBCbZHVN0m7QT4O92wtEguXJm7B m7b+yARrGWJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZxZgTgAKCRD6PaqMvJYe 9egHD/9Lo9BOhehfjhPUQCcW290RdFSEMHDIAgFsTTmDduhcRjjHCntIlVzwBsX/VQjcx1DPuam DuNxqbhoKoo+xrbPfbdV38+mEZglw3IxIjha0U8DrrUCazbxdO96fnbCMHUcf/B8kgt9TGDDo9s G6RybrCb9SW5kQ8FJoXVyaIC5e8hrV4PF6cn6DEHrzyxYrENcwJRzgvUKiO6acID0VAFmeYP71h TpeRScI8C1CFC8UIkR5lqTBIzsj7sDP2Lv0B0x24iLSamA2AK6MHe4Y8VXPlIfYCH+vJYHTl0IM EPNW2Bo6T6Ih0m99g/K/SUPNr/uRLjWSwz4Xq8j65w92ZUPq0UZZRas5GxVRU2wSphp2BULgUQ/ tPud9VxLEVSENWY1nY9t5Z+EJ4KGNo39DS49CLpOs0+uu5mvMjbTbfp0ocyeZ1tK7c2MKNxsztR k1EUPY7tDRWPjqhjia9xh4FfIhWnawdMcRWiw/vSaKC563vvJf+IsOaqG0vH24kZQSDQveNJ6Hq MC/tYWEwBH+mDihu7eCYnZdmbZMGkuMiY2M+D+thYUGAYLMH4Xxe1p4aYPq7wsMuv9Sq82BpZIN vtbPDkpf4tvBZae/V/uoNqBSer5joVTZ0XhMZZ2NLRnXwf63IdkyEf+yYgM2dghgCebLwaiB+PO oxTpogasEpFpLEQ== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 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" From: Devarsh Thakkar The driver has a spinlock for protecting the irq_masks field and irq enable registers. However, the driver misses protecting the irq status registers which can lead to races. Take the spinlock when accessing irqstatus too. Fixes: 32a1795f57ee ("drm/tidss: New driver for TI Keystone platform Display SubSystem") Cc: stable@vger.kernel.org Signed-off-by: Devarsh Thakkar [Tomi: updated the desc] Signed-off-by: Tomi Valkeinen Reviewed-by: Jonathan Cormier Tested-by: Jonathan Cormier --- drivers/gpu/drm/tidss/tidss_dispc.c | 4 ++++ drivers/gpu/drm/tidss/tidss_irq.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/drivers/gpu/drm/tidss/tidss_dispc.c b/drivers/gpu/drm/tidss/tidss_dispc.c index 515f82e8a0a5..07f5c26cfa26 100644 --- a/drivers/gpu/drm/tidss/tidss_dispc.c +++ b/drivers/gpu/drm/tidss/tidss_dispc.c @@ -2767,8 +2767,12 @@ static void dispc_init_errata(struct dispc_device *dispc) */ static void dispc_softreset_k2g(struct dispc_device *dispc) { + unsigned long flags; + + spin_lock_irqsave(&dispc->tidss->wait_lock, flags); dispc_set_irqenable(dispc, 0); dispc_read_and_clear_irqstatus(dispc); + spin_unlock_irqrestore(&dispc->tidss->wait_lock, flags); for (unsigned int vp_idx = 0; vp_idx < dispc->feat->num_vps; ++vp_idx) VP_REG_FLD_MOD(dispc, vp_idx, DISPC_VP_CONTROL, 0, 0, 0); diff --git a/drivers/gpu/drm/tidss/tidss_irq.c b/drivers/gpu/drm/tidss/tidss_irq.c index 3cc4024ec7ff..8af4682ba56b 100644 --- a/drivers/gpu/drm/tidss/tidss_irq.c +++ b/drivers/gpu/drm/tidss/tidss_irq.c @@ -60,7 +60,9 @@ static irqreturn_t tidss_irq_handler(int irq, void *arg) unsigned int id; dispc_irq_t irqstatus; + spin_lock(&tidss->wait_lock); irqstatus = dispc_read_and_clear_irqstatus(tidss->dispc); + spin_unlock(&tidss->wait_lock); for (id = 0; id < tidss->num_crtcs; id++) { struct drm_crtc *crtc = tidss->crtcs[id]; From patchwork Mon Oct 21 14:07:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13844246 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 7EF94D15D98 for ; Mon, 21 Oct 2024 14:08:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E178810E526; Mon, 21 Oct 2024 14:08:31 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="aykD1+wt"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7BE1C10E52F for ; Mon, 21 Oct 2024 14:08:22 +0000 (UTC) Received: from [127.0.1.1] (91-157-155-49.elisa-laajakaista.fi [91.157.155.49]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3A12E1A42; Mon, 21 Oct 2024 16:06:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1729519595; bh=jpnOTkj0fNXVQ3yCGYsDhuDxmQz1B6JkpFLaV5xXSec=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=aykD1+wt8oby67aKd/vaulNKzqy7EPtkzQ4YMfPCB/SrjmHdrZbijZDI4humbwkln 8nWDkqwesIbYovnixKBbgXyG0vSJP7Ax8DRxL1yEgt1kUGoyCNJ5hkuMWvtv9NWgtH X+/Vmjmo2Scyu5m0m01HPvm14+DwhIAAsbGm2+3o= From: Tomi Valkeinen Date: Mon, 21 Oct 2024 17:07:51 +0300 Subject: [PATCH 7/7] drm/tidss: Rename 'wait_lock' to 'irq_lock' MIME-Version: 1.0 Message-Id: <20241021-tidss-irq-fix-v1-7-82ddaec94e4a@ideasonboard.com> References: <20241021-tidss-irq-fix-v1-0-82ddaec94e4a@ideasonboard.com> In-Reply-To: <20241021-tidss-irq-fix-v1-0-82ddaec94e4a@ideasonboard.com> To: Devarsh Thakkar , Jyri Sarha Cc: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Jonathan Cormier , Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4886; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=jpnOTkj0fNXVQ3yCGYsDhuDxmQz1B6JkpFLaV5xXSec=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBnFmBOko8rk+qt7zvORjAV6I1uMYTrQb18qr0eW sWkT9HwM4CJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZxZgTgAKCRD6PaqMvJYe 9U68D/0eolU7amxwxfeLI2ElMHOnplqY+Z42Bf4cHt1sCvjG7FTh1apr/vprUD/a1xxIaBXp0Nj Otf6Vh6nvmOFj4TJt7y9Oh7wYyYr2x7nilhKZoVvIg7MGdN+M/LX6JR1u/Jf7SJaw9hkcm66Vwt XTDgUoAT0bIGURsdSFcrPeirXn4pddVevssWUqwUrTHOF3RcupAOyMmAEGARW8mL76Eb86Oi54S cLjqyI9hl2ePoVB9bCEBoO3gjTd7/PO/I9jkXyZdnKIRyM7UVvydwv1i8jfbV7gI1EBvRondZ63 PO9xD2WGgA2wSJViu+ojDF+F768eqFZhbnQrmEs7hrmhUCOr8KBjXUNmJOhm/Qbzhf9l+kRCJxe DGdlo/vo6wEDTq9g0HdtM6pG96qXor/cCgAsdqbNEkHjr7hGqYxedwlJ+s8McqocAWQk77El0fT kIqVnkSya1dGOHeTPbBBX1jEO2RX3u4LwzXMVD3acQIv85WzmzEQJt44I4+VBFREoiufX+RJ+2o wYe5qRdy+prCX34imZ8OcBU59BYLP5sqja0F8wuYLD3gQm3rODQ1/EaYFw7Dt3POz0Dy852Zed2 EkywHKtTU48z8Tnm5SmqBHzDzWO6xq8AGZZGgVKSNBxGIQ0kHDwV88mL5mgmVZnz4ckbBbFJx0R 5n+rzgKFjcrrVrQ== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 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 'wait_lock' name seems to be a copy-paste from omapdrm, and makes no sense here. Rename it to 'irq_lock'. Also clarify the related comment to make it clear what it protects, and drop any comments related to 'wait_list' which doesn't exist in tidss. Signed-off-by: Tomi Valkeinen Reviewed-by: Devarsh Thakkar --- drivers/gpu/drm/tidss/tidss_dispc.c | 4 ++-- drivers/gpu/drm/tidss/tidss_drv.c | 2 +- drivers/gpu/drm/tidss/tidss_drv.h | 5 +++-- drivers/gpu/drm/tidss/tidss_irq.c | 19 +++++++++---------- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/tidss/tidss_dispc.c b/drivers/gpu/drm/tidss/tidss_dispc.c index 07f5c26cfa26..cacb5f3d8085 100644 --- a/drivers/gpu/drm/tidss/tidss_dispc.c +++ b/drivers/gpu/drm/tidss/tidss_dispc.c @@ -2769,10 +2769,10 @@ static void dispc_softreset_k2g(struct dispc_device *dispc) { unsigned long flags; - spin_lock_irqsave(&dispc->tidss->wait_lock, flags); + spin_lock_irqsave(&dispc->tidss->irq_lock, flags); dispc_set_irqenable(dispc, 0); dispc_read_and_clear_irqstatus(dispc); - spin_unlock_irqrestore(&dispc->tidss->wait_lock, flags); + spin_unlock_irqrestore(&dispc->tidss->irq_lock, flags); for (unsigned int vp_idx = 0; vp_idx < dispc->feat->num_vps; ++vp_idx) VP_REG_FLD_MOD(dispc, vp_idx, DISPC_VP_CONTROL, 0, 0, 0); diff --git a/drivers/gpu/drm/tidss/tidss_drv.c b/drivers/gpu/drm/tidss/tidss_drv.c index d15f836dca95..c7de8c9fa12e 100644 --- a/drivers/gpu/drm/tidss/tidss_drv.c +++ b/drivers/gpu/drm/tidss/tidss_drv.c @@ -138,7 +138,7 @@ static int tidss_probe(struct platform_device *pdev) platform_set_drvdata(pdev, tidss); - spin_lock_init(&tidss->wait_lock); + spin_lock_init(&tidss->irq_lock); ret = dispc_init(tidss); if (ret) { diff --git a/drivers/gpu/drm/tidss/tidss_drv.h b/drivers/gpu/drm/tidss/tidss_drv.h index d7f27b0b0315..7f4f4282bc04 100644 --- a/drivers/gpu/drm/tidss/tidss_drv.h +++ b/drivers/gpu/drm/tidss/tidss_drv.h @@ -29,8 +29,9 @@ struct tidss_device { unsigned int irq; - spinlock_t wait_lock; /* protects the irq masks */ - dispc_irq_t irq_mask; /* enabled irqs in addition to wait_list */ + /* protects the irq masks field and irqenable/irqstatus registers */ + spinlock_t irq_lock; + dispc_irq_t irq_mask; /* enabled irqs */ }; #define to_tidss(__dev) container_of(__dev, struct tidss_device, ddev) diff --git a/drivers/gpu/drm/tidss/tidss_irq.c b/drivers/gpu/drm/tidss/tidss_irq.c index 8af4682ba56b..5abc788781f4 100644 --- a/drivers/gpu/drm/tidss/tidss_irq.c +++ b/drivers/gpu/drm/tidss/tidss_irq.c @@ -15,10 +15,9 @@ #include "tidss_irq.h" #include "tidss_plane.h" -/* call with wait_lock and dispc runtime held */ static void tidss_irq_update(struct tidss_device *tidss) { - assert_spin_locked(&tidss->wait_lock); + assert_spin_locked(&tidss->irq_lock); dispc_set_irqenable(tidss->dispc, tidss->irq_mask); } @@ -31,11 +30,11 @@ void tidss_irq_enable_vblank(struct drm_crtc *crtc) u32 hw_videoport = tcrtc->hw_videoport; unsigned long flags; - spin_lock_irqsave(&tidss->wait_lock, flags); + spin_lock_irqsave(&tidss->irq_lock, flags); tidss->irq_mask |= DSS_IRQ_VP_VSYNC_EVEN(hw_videoport) | DSS_IRQ_VP_VSYNC_ODD(hw_videoport); tidss_irq_update(tidss); - spin_unlock_irqrestore(&tidss->wait_lock, flags); + spin_unlock_irqrestore(&tidss->irq_lock, flags); } void tidss_irq_disable_vblank(struct drm_crtc *crtc) @@ -46,11 +45,11 @@ void tidss_irq_disable_vblank(struct drm_crtc *crtc) u32 hw_videoport = tcrtc->hw_videoport; unsigned long flags; - spin_lock_irqsave(&tidss->wait_lock, flags); + spin_lock_irqsave(&tidss->irq_lock, flags); tidss->irq_mask &= ~(DSS_IRQ_VP_VSYNC_EVEN(hw_videoport) | DSS_IRQ_VP_VSYNC_ODD(hw_videoport)); tidss_irq_update(tidss); - spin_unlock_irqrestore(&tidss->wait_lock, flags); + spin_unlock_irqrestore(&tidss->irq_lock, flags); } static irqreturn_t tidss_irq_handler(int irq, void *arg) @@ -60,9 +59,9 @@ static irqreturn_t tidss_irq_handler(int irq, void *arg) unsigned int id; dispc_irq_t irqstatus; - spin_lock(&tidss->wait_lock); + spin_lock(&tidss->irq_lock); irqstatus = dispc_read_and_clear_irqstatus(tidss->dispc); - spin_unlock(&tidss->wait_lock); + spin_unlock(&tidss->irq_lock); for (id = 0; id < tidss->num_crtcs; id++) { struct drm_crtc *crtc = tidss->crtcs[id]; @@ -95,9 +94,9 @@ void tidss_irq_resume(struct tidss_device *tidss) { unsigned long flags; - spin_lock_irqsave(&tidss->wait_lock, flags); + spin_lock_irqsave(&tidss->irq_lock, flags); tidss_irq_update(tidss); - spin_unlock_irqrestore(&tidss->wait_lock, flags); + spin_unlock_irqrestore(&tidss->irq_lock, flags); } int tidss_irq_install(struct drm_device *ddev, unsigned int irq)