Skip to content

Commit 4dae3c1

Browse files
committed
u-boot: v2026.04: helios64: retry OTP read on transient SPI failure
The previous commit preserved has_been_read = 0 on SPI I/O failure so a later call could retry. But in the actual boot flow no retry happens: board_early_init_r() ignores the return of read_otp_data(), and the later consumers (set_board_info, mac_read_from_otp) bail out early with 'if (!is_data_valid()) return;' — so a single transient SPI failure leaves board_rev / serial# / ethaddr unset for the whole boot. Add an ensure_otp_data_ready() helper that re-invokes read_otp_data() when the cached data is not yet valid, and use it in both consumers. Valid/invalid-data behavior is unchanged; only the retry path is now actually exercised. Addresses a CodeRabbit review comment on PR armbian#9675.
1 parent 560ee3b commit 4dae3c1

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

  • patch/u-boot/v2026.04/board_helios64/board

patch/u-boot/v2026.04/board_helios64/board/sys_otp.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,21 @@ static inline int is_data_valid(void)
4343
return data_valid;
4444
}
4545

46+
static int read_otp_data(void);
47+
48+
/*
49+
* Ensure OTP data is cached and valid. If a previous read failed (for example
50+
* on a transient SPI error during board_early_init_r()), retry here so
51+
* consumers don't silently skip using OTP-provided values for the whole boot.
52+
*/
53+
static int ensure_otp_data_ready(void)
54+
{
55+
if (is_data_valid())
56+
return 0;
57+
58+
return read_otp_data();
59+
}
60+
4661
/*
4762
* Decode the 6-byte serial number into a u64. Doing a casted *(uint64_t *)
4863
* read on otp.serial_num would over-read into otp.mfg_year and is unaligned
@@ -231,7 +246,7 @@ void set_board_info(void)
231246
{
232247
char env_str[13];
233248

234-
if (!is_data_valid())
249+
if (ensure_otp_data_ready())
235250
return;
236251

237252
snprintf(env_str, sizeof(env_str), "%i.%i", (otp.revision & 0xf0) >> 4, otp.revision & 0x0f);
@@ -246,7 +261,7 @@ int mac_read_from_otp(void)
246261
{
247262
unsigned int i;
248263

249-
if (!is_data_valid())
264+
if (ensure_otp_data_ready())
250265
return -1;
251266

252267
for (i = 0; i < MAX_NUM_PORTS; i++) {

0 commit comments

Comments
 (0)