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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D02DBC5B543 for ; Sun, 1 Jun 2025 23:42:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=foN3wx/oF4Wkrf39+ThD1ZlqWStiAURx8dJZzAexlmY=; b=EqohpgFouSCwJe73KRVxTiezIp I9WC2lBkqZOOVezdVRwgD6pFhj9/BFDh3eE5cf4wqXTt5dVdigCF1o87YOy3j91wfi/8lzRVvmJo1 jRyt56vcfZUkh8pgEurkBN1hmP84leAY8MEimpEVfX0JIU3vhRY3mqWI+stQauA7OuCY1nBy6MF7l bJyjbIA6lqlFJfpW2mIMidIYe3nD211wGYTEmSxLb+pxzRQaj8j2TJqc+uUbQxez1pTBXA831BBwN 5b6rp7rFWfvQjKdjCWJFtkm3R8RDA3UeDn+/ntnZG7FWzXJ3T6HVPHy+K7I7ncWFFMCMrkIpmtRuV E35TgLSQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uLsJn-000000069dM-2Gig; Sun, 01 Jun 2025 23:42:19 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1uLs6D-000000066D4-200m for linux-arm-kernel@bombadil.infradead.org; Sun, 01 Jun 2025 23:28:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:Content-ID:Content-Description; bh=foN3wx/oF4Wkrf39+ThD1ZlqWStiAURx8dJZzAexlmY=; b=lc3dpERWk148dFNjrCw1d9L79P BqZ6rwDlUYmP7EFAQbs4UNXsZfNx5BkbheWsl5QF7DgWHK3Jnnw5+15M4Q7dxFjr1uz0ynktx8G9R ByNe/4c4u5eu/A9aOTAepRXdgdGceO1T+1xOtXj1kxYkFW31iuqnFD4gjZm+Lr7B2O3/o8CpKe4wG Y/1fDTs3OxuY8YMmXAJUc3I2cKBtjQXmGIDUEIKQ1ReT7B5h30DeiYRveTf4PnXvDW+wxUCnt/3Bz MgNnWvCMctoruYua/KuQX92FwF0sGiuKMn6m5BFf5dZtaFFUFbh2IP4nWNpMWzPL8qKZWbYwSOazx XWADh+/Q==; Received: from sea.source.kernel.org ([172.234.252.31]) by desiato.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1uLs6A-00000000XVV-29kJ for linux-arm-kernel@lists.infradead.org; Sun, 01 Jun 2025 23:28:16 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 47D04447C0; Sun, 1 Jun 2025 23:28:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF40EC4CEEE; Sun, 1 Jun 2025 23:28:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1748820492; bh=A48W80d/OvYkJUwQnKQg9w4xhc8rbidgZOgmvwELG1g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O7BzAQ1B1LZX/kxrhvTgcmSXd1zf/rY/vBE756LvkPJ1NxWthxQ95tXla3eZvU9bS ZwYRctcz3wml2+HYhsUgy9MuitS2J/6HeoGpGPr4Ymanj7vh0uq8lZith9rrHj5jMn zjCRoSLSk6bZrBCcBJa3GBE8rKrepexpImGqpw0GtegG7zYm/VJLhykx1zHBV2UsN7 O/4hax8WqX7HMCMst2Ow0jHa1lnsm8HjHnMIS7QIJ4UvOyj0dslGby76SDvALEeOzW igdI/i7yRacVanFJXMEKEd5fh4o3iRtOfbmKl92cnVFHt7R8g4G1j7bBg26sYcBmwI DjVbRlfSvDlJw== From: Sasha Levin To: patches@lists.linux.dev, stable@vger.kernel.org Cc: Wentao Liang , Hans Verkuil , Sasha Levin , s.nawrocki@samsung.com, mchehab@kernel.org, krzk@kernel.org, linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH AUTOSEL 6.15 071/110] media: platform: exynos4-is: Add hardware sync wait to fimc_is_hw_change_mode() Date: Sun, 1 Jun 2025 19:23:53 -0400 Message-Id: <20250601232435.3507697-71-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250601232435.3507697-1-sashal@kernel.org> References: <20250601232435.3507697-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.15 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250602_002814_876916_F532B599 X-CRM114-Status: GOOD ( 13.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Wentao Liang [ Upstream commit bd9f6ce7d512fa21249415c16af801a4ed5d97b6 ] In fimc_is_hw_change_mode(), the function changes camera modes without waiting for hardware completion, risking corrupted data or system hangs if subsequent operations proceed before the hardware is ready. Add fimc_is_hw_wait_intmsr0_intmsd0() after mode configuration, ensuring hardware state synchronization and stable interrupt handling. Signed-off-by: Wentao Liang Signed-off-by: Hans Verkuil Signed-off-by: Sasha Levin --- Based on my analysis of the commit and examination of the kernel code, here is my assessment: **YES** This commit should be backported to stable kernel trees for the following reasons: ## Analysis of the Code Change The commit adds a single line `fimc_is_hw_wait_intmsr0_intmsd0(is);` at line 167 in the `fimc_is_hw_change_mode()` function in `drivers/media/platform/samsung/exynos4-is/fimc-is-regs.c`. ## Why This Should Be Backported 1. **Clear Bug Fix**: The commit message explicitly states this fixes a race condition where "the function changes camera modes without waiting for hardware completion, risking corrupted data or system hangs if subsequent operations proceed before the hardware is ready." This is a classic hardware synchronization bug. 2. **Consistent Pattern**: Examining the surrounding code shows that ALL other similar hardware control functions (`fimc_is_hw_get_setfile_addr()`, `fimc_is_hw_load_setfile()`, `fimc_is_hw_stream_on()`, `fimc_is_hw_stream_off()`) already call `fimc_is_hw_wait_intmsr0_intmsd0()` before writing to hardware registers. The `fimc_is_hw_change_mode()` function was the only outlier missing this synchronization. 3. **Minimal and Safe**: The change is extremely small (one line) and uses an existing, well-tested synchronization primitive. The `fimc_is_hw_wait_intmsr0_intmsd0()` function implements a timeout-based wait with proper error handling. 4. **Critical Subsystem**: This affects camera hardware control in Samsung Exynos4 SoCs. Hardware synchronization issues in camera drivers can cause: - System hangs (as mentioned in commit message) - Data corruption - Unpredictable hardware state 5. **Runtime Safety**: The wait function has built-in timeout protection (2000 iterations with 1μs delay each), so it cannot cause infinite hangs even if hardware fails. 6. **Follows Hardware Protocol**: The pattern clearly shows the proper hardware protocol is: wait for ready state → write command → trigger interrupt. The missing wait was a protocol violation. ## Comparison with Historical References Looking at the provided similar commits marked "NO" for backporting, they were all: - Documentation/binding changes (commits #1, #2) - Code cleanup/feature removal (commit #3) - Architecture changes (commit #4) The one commit marked "YES" (commit #5) was a simple bug fix correcting a return value check, very similar in nature to this synchronization fix. This commit fits the stable tree criteria perfectly: it's a small, contained bug fix addressing a real hardware synchronization issue that could cause system instability, with minimal risk of regression. drivers/media/platform/samsung/exynos4-is/fimc-is-regs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/platform/samsung/exynos4-is/fimc-is-regs.c b/drivers/media/platform/samsung/exynos4-is/fimc-is-regs.c index 366e6393817d2..5f9c44e825a5f 100644 --- a/drivers/media/platform/samsung/exynos4-is/fimc-is-regs.c +++ b/drivers/media/platform/samsung/exynos4-is/fimc-is-regs.c @@ -164,6 +164,7 @@ int fimc_is_hw_change_mode(struct fimc_is *is) if (WARN_ON(is->config_index >= ARRAY_SIZE(cmd))) return -EINVAL; + fimc_is_hw_wait_intmsr0_intmsd0(is); mcuctl_write(cmd[is->config_index], is, MCUCTL_REG_ISSR(0)); mcuctl_write(is->sensor_index, is, MCUCTL_REG_ISSR(1)); mcuctl_write(is->setfile.sub_index, is, MCUCTL_REG_ISSR(2)); -- 2.39.5