From patchwork Fri Oct 14 15:04:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Delaunay X-Patchwork-Id: 13007076 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 18185C433FE for ; Fri, 14 Oct 2022 15:06:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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:In-Reply-To:References: List-Owner; bh=oDjhpQl705ZiJ9SAw6uL3FVzjQcUnhDO3j/0yFqOacM=; b=o5sALFmrxtic8Q JSyf4eYMMb3oieKOVFrWjEroZSVjPbHyX01vxEHUbr8FfoQzHKiFEEys0CTOMpvP1d+snONmNDWWM ZhbA82euQvc++7tOywvzkLfWfiB34WIsYFtc84Gdbdn0Z3lkFvJhTdT3DOxA+SgbVEqmTOhsGoyxV 7R+9tUPAxmhnMvM1dIwekQgMtw+tSSQ2uonOzb907KzQtYWXnZSVpszPM15wQJNvtxUF6oNXaM4+m DkoLWPoQXTwbglvBi9uG/ASpvLt7e0c+eRq9lc25guKT2wibcbSYphw+ejlKw+pAQfcGCPeHK2q8y fJ5Eg04tcW3ugVRyaZEA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojMFc-00F7KK-E3; Fri, 14 Oct 2022 15:05:28 +0000 Received: from mx07-00178001.pphosted.com ([185.132.182.106]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ojMFZ-00F7I1-Ro for linux-arm-kernel@lists.infradead.org; Fri, 14 Oct 2022 15:05:27 +0000 Received: from pps.filterd (m0241204.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29EF5CUm031283; Fri, 14 Oct 2022 17:05:16 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=selector1; bh=wRlyGKw6VgdQ2d1sRB7WsBi1jFMUKA9qlH7Ogi8UJ3Q=; b=SZ3hTvda1/8mgXWADaxQc5uP+6m6EJSUGbwxAVUNdADrYqx97d75pK101tdOl5VJqH7M xeesK61F6zcZczXV1+Vfv+IysappYKZh54mMdnAUCVpnl0UHvr4fTiP4PQsQDmErhjSD FY3PXltu0Vgf2mPioCh9I88Ce8ZBm4Ba1J7ssZjfp8IeBGvnJzsIsNQAR+ISAfybjrSX 7j8oqipLlWInnojuDGd8M0fmRfU0nQ2UJj9QNa7dxc2krpP7fvNVpDQmugzP/JFj0Psy za9EIKOZMfQAxal7+K3yLRcsh3BL4425OrSi2ypNNoH5vmwsx0uQZmOZo0ai9yOq6Ie5 uQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3k64m7xbpe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 14 Oct 2022 17:05:16 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 292EA100038; Fri, 14 Oct 2022 17:05:13 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node3.st.com [10.75.129.71]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 23FC0233C75; Fri, 14 Oct 2022 17:05:13 +0200 (CEST) Received: from localhost (10.75.127.50) by SHFDAG1NODE3.st.com (10.75.129.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2375.31; Fri, 14 Oct 2022 17:05:10 +0200 From: Patrick Delaunay To: Srinivas Kandagatla , Maxime Coquelin , Alexandre Torgue CC: Patrick Delaunay , , , Subject: [PATCH 1/2] nvmem: stm32: add warning when upper OTPs are updated Date: Fri, 14 Oct 2022 17:04:28 +0200 Message-ID: <20221014170426.1.Ifa806ff30d7c669ba9a3df9c6b64698a2dcc073a@changeid> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.75.127.50] X-ClientProxiedBy: SFHDAG2NODE3.st.com (10.75.127.6) To SHFDAG1NODE3.st.com (10.75.129.71) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-14_08,2022-10-14_01,2022-06-22_01 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221014_080526_305674_0828CAA4 X-CRM114-Status: GOOD ( 15.63 ) 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 As the upper OTPs are ECC protected, they support only one 32 bits word programming. For a second modification of this word, these ECC become invalid and this OTP will be no more accessible, the shadowed value is invalid. This patch adds a warning to indicate an upper OTP update, because this operation is dangerous as OTP is not locked by the driver after the first update to avoid a second update. Signed-off-by: Patrick Delaunay --- drivers/nvmem/stm32-romem.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/nvmem/stm32-romem.c b/drivers/nvmem/stm32-romem.c index 354be526897f..e3c3c333b5d1 100644 --- a/drivers/nvmem/stm32-romem.c +++ b/drivers/nvmem/stm32-romem.c @@ -133,6 +133,9 @@ static int stm32_bsec_write(void *context, unsigned int offset, void *buf, } } + if (offset + bytes >= priv->lower * 4) + dev_warn(dev, "Update of upper OTPs with ECC protection (word programming, only once)\n"); + return 0; }