From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794047597; b=PGwvxO4HvlitenWIdP6nzK/t16s0y3vz+nDcSO8Fv9zPHEEpYakriJF0loi6ltryohu4 tuKTL66zWUkN7J8VJhngvj0JO6KaUepC5X0zh1Q9ToB8ygD0GFyUE6oHRYOOz+p+PZlmX qPSd0VZaRpI+w4kb6ESNnfmNwU1IWS3SmU2xnxNMzGcDsXcnwnM+0OwYfvXcE9kdyUmkD ML58am8edxRrCYqNjDU+c3eaW5dGnen93Pd3zEvfrTmauROxzMrdveBM/84cub8J5Kwg0 2HxHJnbT7sq3LCNnYt1S+Y+PNV8vY7/oaMxqG2Pnrrs3DpunS07Oi/J1w2KhLR3tnqw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794047597; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=2TV9iEyw/zodHr/+Hz2+UXOEWEYib3iXoXPotsm3RHM=; b=mpTdiOoK0/yTWautJ6PB/cGWp5P+DECXh2EDoBDsj7oftDbudXBMWc3YWiRg2b/8CSGF lUNgzUMvQJ/GGc29uCMQhfFWY34qdmA/J2eL8raGizkLk7fo/UdDoj+In/P/I7MznC3Cz 5Gcouc6vHMUtCHgnBkDslbl2YmVpf4VfBNYCINtBxUZgC5/eOpDL2l+xwWST9lGOX4PI+ HCBijjIDDNNP9GA4jTamXljE6j2dwmpck+8kJcf/43TdpDnuodT9XagZXbe1P36hWgdNU IAJKGzsiRaRE5uST9DLH+917gYNzYjrz7Zx5J0kzAWox+PLiNiUYj8kP5SPkz8h8BmA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Ixe5bmoB; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 11E3B606A326 for ; Sat, 7 Nov 2026 10:33:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Ixe5bmoB Received: by smtp.kernel.org (Postfix) with ESMTPSA id 564C71F0089F; Sat, 7 Nov 2026 10:33:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794047596; bh=2TV9iEyw/zodHr/+Hz2+UXOEWEYib3iXoXPotsm3RHM=; h=From:To:Cc:Subject:Date; b=Ixe5bmoB1i2wtdckO5mYvkGcTHrnm4VB6xUUG+ixkfjPOu+0Z015evUEbknzkOxs9 yRmh7WQkByO8t7BYxh0PMpPpqwdEBjfJCPgL+XQfWhuX5GJ3G0wAJldXUPbz53b/Xh rtactahs2aezRZRkIdvxoTl+wQ/1IIK4RTtCbq7FRMtOAz7cEE6PkuLbFpRxlO0MQu /ErY4X5Rk/Nh9GHBvSWjkZUWhxlqgNDGjK/XZX5u8m7cA2BII8GkLkDMoepC1vJl+g pSlkfKU8SOC4wqItyGB786+2T8CnKZCxxghn5MW+UO4wz3e5a6v5/eTiBBFmvYTA8f Yo/35wFUIxjkQ== From: Sasha Levin To: alchark@flipper.net, miquel.raynal@bootlin.com, srini@kernel.org, gregkh@linuxfoundation.org Cc: stable@vger.kernel.org Subject: FAILED: patch "[PATCH] nvmem: rockchip-otp: Serialize reads" failed to apply to 6.6-stable tree Date: Sat, 7 Nov 2026 05:33:15 -0500 Message-ID: <20261107053315-failed-6.6-9fc6a1592d84@kernel.org> X-Mailer: git-send-email 2.53.0 X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.6-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y git checkout FETCH_HEAD git cherry-pick -x 9fc6a1592d844c0397f115ee8cbd935169b9a71e # git commit -s git send-email --to '' --in-reply-to '20261107053315-failed-6.6-9fc6a1592d84@kernel.org' --subject-prefix 'PATCH 6.6.y' 'HEAD^..' Thanks, Sasha ------------------ original commit in Linus's tree ------------------ >From 9fc6a1592d844c0397f115ee8cbd935169b9a71e Mon Sep 17 00:00:00 2001 From: Alexey Charkov Date: Fri, 2 Oct 2026 11:13:26 +0100 Subject: [PATCH] nvmem: rockchip-otp: Serialize reads The OTP controller is driven through a single set of registers holding a state machine which has to be stepped through for every word read, yet nothing keeps two readers out of each other's way. Concurrent reads interleave, and the outcome is either a reader bailing out: rockchip-otp 2a580000.otp: timeout during read setup or, worse, one of them silently taking delivery of the other's data. Reading two cells in parallel from userspace on RK3576 reproduces both within 150 iterations - 53 read errors and 9 corrupted results, the latter either losing their first word or, in one case, ending in the two bytes which belong to the other reader's cell - whereas the same reads issued sequentially never fail. Concurrency is not hypothetical here, as six thermal sensors source their trim values from the OTP and reach the driver straight from asynchronous driver probing. Guard the read path with a mutex. Reads are the only way into the hardware, as the driver registers no write callback, and they always run in process context, so a plain mutex spanning the whole clock-enable, read, clock-disable sequence is enough. Fixes: 755864feb729 ("nvmem: add Rockchip OTP driver") Cc: stable@vger.kernel.org Reviewed-by: Miquel Raynal Signed-off-by: Alexey Charkov Signed-off-by: Srinivas Kandagatla Link: https://patch.msgid.link/20261002101329.1084348-2-srini@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/nvmem/rockchip-otp.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/nvmem/rockchip-otp.c b/drivers/nvmem/rockchip-otp.c index 2c0feb036f3fd..f8a8c7cece98d 100644 --- a/drivers/nvmem/rockchip-otp.c +++ b/drivers/nvmem/rockchip-otp.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -80,6 +81,8 @@ struct rockchip_otp { void __iomem *base; struct reset_control *rst; const struct rockchip_data *data; + /* Serializes access to the OTP controller state machine */ + struct mutex mutex; struct clk_bulk_data clks[]; }; @@ -272,10 +275,12 @@ static int rockchip_otp_read(void *context, unsigned int offset, if (!otp->data || !otp->data->reg_read) return -EINVAL; + mutex_lock(&otp->mutex); + ret = clk_bulk_prepare_enable(otp->data->num_clks, otp->clks); if (ret < 0) { dev_err(otp->dev, "failed to prepare/enable clks\n"); - return ret; + goto unlock; } offset += otp->data->read_offset; @@ -308,6 +313,9 @@ static int rockchip_otp_read(void *context, unsigned int offset, err: clk_bulk_disable_unprepare(otp->data->num_clks, otp->clks); +unlock: + mutex_unlock(&otp->mutex); + return ret; } @@ -431,6 +439,11 @@ static int rockchip_otp_probe(struct platform_device *pdev) otp->data = data; otp->dev = dev; + + ret = devm_mutex_init(dev, &otp->mutex); + if (ret) + return ret; + otp->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(otp->base)) return dev_err_probe(dev, PTR_ERR(otp->base), -- 2.53.0