summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorNishanth Menon <nm@ti.com>2022-06-15 20:32:11 -0500
committerAnand Gadiyar <gadiyar@ti.com>2022-06-27 15:37:23 -0500
commit3722fd49d49337868d3756e52df5f4f5b9744146 (patch)
treedd6e410a25eada8cdb681caaa974fa49cbcd4464 /board
parentd30d4edc0102e8b9f3c2df0e6f7c4157eabab147 (diff)
board: ti: common: Optimize boot when detecting consecutive bad records
The eeprom data area is much bigger than the data we intend to store, however, with bad programming, we might end up reading bad records over and over till we run out of eeprom space. instead just exit when 10 consecutive records are read. Signed-off-by: Nishanth Menon <nm@ti.com>
Diffstat (limited to 'board')
-rw-r--r--board/ti/common/board_detect.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/board/ti/common/board_detect.c b/board/ti/common/board_detect.c
index 8b3b4bc8253..242dfd38af1 100644
--- a/board/ti/common/board_detect.c
+++ b/board/ti/common/board_detect.c
@@ -434,6 +434,7 @@ int __maybe_unused ti_i2c_eeprom_am6_get(int bus_addr, int dev_addr,
struct ti_am6_eeprom_record_board_id board_id;
struct ti_am6_eeprom_record record;
int rc;
+ int consecutive_bad_records = 0;
/* Initialize with a known bad marker for i2c fails.. */
memset(ep, 0, sizeof(*ep));
@@ -470,7 +471,7 @@ int __maybe_unused ti_i2c_eeprom_am6_get(int bus_addr, int dev_addr,
*/
eeprom_addr = sizeof(board_id);
- while (true) {
+ while (consecutive_bad_records < 10) {
rc = dm_i2c_read(dev, eeprom_addr, (uint8_t *)&record.header,
sizeof(record.header));
if (rc)
@@ -506,6 +507,7 @@ int __maybe_unused ti_i2c_eeprom_am6_get(int bus_addr, int dev_addr,
pr_err("%s: EEPROM parsing error!\n", __func__);
return rc;
}
+ consecutive_bad_records = 0;
} else {
/*
* We may get here in case of larger records which
@@ -513,6 +515,7 @@ int __maybe_unused ti_i2c_eeprom_am6_get(int bus_addr, int dev_addr,
*/
pr_err("%s: Ignoring record id %u\n", __func__,
record.header.id);
+ consecutive_bad_records++;
}
eeprom_addr += record.header.len;