From mboxrd@z Thu Jan 1 00:00:00 1970 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 7B575FF886D for ; Wed, 29 Apr 2026 09:39:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2776C10EF25; Wed, 29 Apr 2026 09:39:03 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.b="LvU2zwhg"; dkim-atps=neutral Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) by gabe.freedesktop.org (Postfix) with ESMTPS id A295610EEFE for ; Wed, 29 Apr 2026 09:38:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1777455537; bh=YEXgj6Ay4Q/wh0v7MXHI8NL2Nbu+OEpLdioOx+8oNO8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=LvU2zwhgiC9f7XSx78xjmx+GBo+RsS4zFDd28XUwEuR9f33AJAf1axnzZQ6I4CJ5x W3gCGpc0VO1eji9AHuRFMAtFjJLQU2OU8b04gWjd+VppCGiit7VTZEYqGB9Vrq2edM k6M9vDtC0vlnLYpRZV+IPpgvHTFRShwyv0msIOaKARR1Of6u+ixgiqXw/0qywqHseJ BzcCEWV3ip3Tj/mxZ1YL8NjOp+Q76X0Ol58oRNHxK3v83zL5oU64bd600y7SgPfb0K Q+FVn9XXazZs5josJ2BTdrogHzT5ZFCHWu9XWX6OrUdMom+Z3ek8GC82bQ+EueUeJ0 yjo7JLs0EjoTA== Received: from [100.64.0.11] (unknown [100.64.0.11]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bbrezillon) by bali.collaboradmins.com (Postfix) with ESMTPSA id 1225F17E1553; Wed, 29 Apr 2026 11:38:57 +0200 (CEST) From: Boris Brezillon Date: Wed, 29 Apr 2026 11:38:32 +0200 Subject: [PATCH 05/10] drm/panthor: Make panthor_fw_{update,toggle}_reqs() callable from IRQ context MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260429-panthor-signal-from-irq-v1-5-4b92ae4142d2@collabora.com> References: <20260429-panthor-signal-from-irq-v1-0-4b92ae4142d2@collabora.com> In-Reply-To: <20260429-panthor-signal-from-irq-v1-0-4b92ae4142d2@collabora.com> To: Steven Price , Liviu Dudau Cc: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Boris Brezillon X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777455534; l=2195; i=boris.brezillon@collabora.com; s=20260429; h=from:subject:message-id; bh=YEXgj6Ay4Q/wh0v7MXHI8NL2Nbu+OEpLdioOx+8oNO8=; b=scJ7bM7R+tkKoMzuKWHjBmfyGImo5IKRuEv+Qn4rBFKNxGmid+aXq9ORO8BSyq/w5AAEwhB6W 2eu1EQmmF0HAsaXn9VQ8JaWc4AlW74jxIRk1L77XD/gOutT1XYkRdku X-Developer-Key: i=boris.brezillon@collabora.com; a=ed25519; pk=eN+ORdOgQY7d5U+0kA8h5bf67XdD8bhKbjD/TCHexSY= 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" If we want some FW events to be processed in the interrupt path, we need the helpers manipulating req regs to be IRQ-safe, which implies using spin_lock_irqsave instead of spinlock. While at it, use guards instead of plain spin_lock/unlock calls. Signed-off-by: Boris Brezillon --- drivers/gpu/drm/panthor/panthor_fw.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/panthor/panthor_fw.h b/drivers/gpu/drm/panthor/panthor_fw.h index a99a9b6f4825..e56b7fe15bb3 100644 --- a/drivers/gpu/drm/panthor/panthor_fw.h +++ b/drivers/gpu/drm/panthor/panthor_fw.h @@ -432,12 +432,11 @@ struct panthor_fw_global_iface { #define panthor_fw_toggle_reqs(__iface, __in_reg, __out_reg, __mask) \ do { \ u32 __cur_val, __new_val, __out_val; \ - spin_lock(&(__iface)->lock); \ + guard(spinlock_irqsave)(&(__iface)->lock); \ __cur_val = READ_ONCE((__iface)->input->__in_reg); \ __out_val = READ_ONCE((__iface)->output->__out_reg); \ __new_val = ((__out_val ^ (__mask)) & (__mask)) | (__cur_val & ~(__mask)); \ WRITE_ONCE((__iface)->input->__in_reg, __new_val); \ - spin_unlock(&(__iface)->lock); \ } while (0) /** @@ -458,21 +457,19 @@ struct panthor_fw_global_iface { #define panthor_fw_update_reqs(__iface, __in_reg, __val, __mask) \ do { \ u32 __cur_val, __new_val; \ - spin_lock(&(__iface)->lock); \ + guard(spinlock_irqsave)(&(__iface)->lock); \ __cur_val = READ_ONCE((__iface)->input->__in_reg); \ __new_val = (__cur_val & ~(__mask)) | ((__val) & (__mask)); \ WRITE_ONCE((__iface)->input->__in_reg, __new_val); \ - spin_unlock(&(__iface)->lock); \ } while (0) #define panthor_fw_update_reqs64(__iface, __in_reg, __val, __mask) \ do { \ u64 __cur_val, __new_val; \ - spin_lock(&(__iface)->lock); \ + guard(spinlock_irqsave)(&(__iface)->lock); \ __cur_val = READ_ONCE((__iface)->input->__in_reg); \ __new_val = (__cur_val & ~(__mask)) | ((__val) & (__mask)); \ WRITE_ONCE((__iface)->input->__in_reg, __new_val); \ - spin_unlock(&(__iface)->lock); \ } while (0) struct panthor_fw_global_iface * -- 2.53.0