diff mbox series

[4/6] stm32mp: stm32prog: fix OTP read/write error management

Message ID 20230427153632.4.I8515a57201b19ed2af357f96106ede4b4cf078b7@changeid
State Accepted
Commit 09f50c75a18da5a6d949b8bc5510f8ec5693a5b0
Delegated to: Patrice Chotard
Headers show
Series stm32mp: soome changes and fixes for STM32MP13 and STM32MP15 boards | expand

Commit Message

Patrick Delaunay April 27, 2023, 1:36 p.m. UTC
Avoid to ignore the OTP read/write error and transmits the error
to STM32CubeProgrammer.

Today the error is only displayed in log error:
so the user on HOST thinks the OTP operation is performed.

Reported-by: Mickael GARDET <m.gardet@overkiz.com>
Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Fixes: 75ea9e75931c ("stm32mp: stm32prog: add TEE support in stm32prog command")
---

 arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Patrice CHOTARD May 3, 2023, 6:28 a.m. UTC | #1
On 4/27/23 15:36, Patrick Delaunay wrote:
> Avoid to ignore the OTP read/write error and transmits the error
> to STM32CubeProgrammer.
> 
> Today the error is only displayed in log error:
> so the user on HOST thinks the OTP operation is performed.
> 
> Reported-by: Mickael GARDET <m.gardet@overkiz.com>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> Fixes: 75ea9e75931c ("stm32mp: stm32prog: add TEE support in stm32prog command")
> ---
> 
>  arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
> index 6f3641ccf57b..c85217f6d61e 100644
> --- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
> +++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
> @@ -1439,8 +1439,11 @@ int stm32prog_otp_write(struct stm32prog_data *data, u32 offset, u8 *buffer,
>  
>  	if (!data->otp_part) {
>  		data->otp_part = memalign(CONFIG_SYS_CACHELINE_SIZE, otp_size);
> -		if (!data->otp_part)
> +		if (!data->otp_part) {
> +			stm32prog_err("OTP write issue %d", -ENOMEM);
> +
>  			return -ENOMEM;
> +		}
>  	}
>  
>  	if (!offset)
> @@ -1503,6 +1506,8 @@ int stm32prog_otp_read(struct stm32prog_data *data, u32 offset, u8 *buffer,
>  	memcpy(buffer, (void *)((uintptr_t)data->otp_part + offset), *size);
>  
>  end_otp_read:
> +	if (result)
> +		stm32prog_err("OTP read issue %d", result);
>  	log_debug("%s: result %i\n", __func__, result);
>  
>  	return result;
> @@ -1556,6 +1561,8 @@ int stm32prog_otp_start(struct stm32prog_data *data)
>  
>  	free(data->otp_part);
>  	data->otp_part = NULL;
> +	if (result)
> +		stm32prog_err("OTP write issue %d", result);
>  	log_debug("%s: result %i\n", __func__, result);
>  
>  	return result;
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>

Thanks
Patrice
diff mbox series

Patch

diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
index 6f3641ccf57b..c85217f6d61e 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
@@ -1439,8 +1439,11 @@  int stm32prog_otp_write(struct stm32prog_data *data, u32 offset, u8 *buffer,
 
 	if (!data->otp_part) {
 		data->otp_part = memalign(CONFIG_SYS_CACHELINE_SIZE, otp_size);
-		if (!data->otp_part)
+		if (!data->otp_part) {
+			stm32prog_err("OTP write issue %d", -ENOMEM);
+
 			return -ENOMEM;
+		}
 	}
 
 	if (!offset)
@@ -1503,6 +1506,8 @@  int stm32prog_otp_read(struct stm32prog_data *data, u32 offset, u8 *buffer,
 	memcpy(buffer, (void *)((uintptr_t)data->otp_part + offset), *size);
 
 end_otp_read:
+	if (result)
+		stm32prog_err("OTP read issue %d", result);
 	log_debug("%s: result %i\n", __func__, result);
 
 	return result;
@@ -1556,6 +1561,8 @@  int stm32prog_otp_start(struct stm32prog_data *data)
 
 	free(data->otp_part);
 	data->otp_part = NULL;
+	if (result)
+		stm32prog_err("OTP write issue %d", result);
 	log_debug("%s: result %i\n", __func__, result);
 
 	return result;