Skip to contentSkip to conversation

board: ti: common: board_detect: Fix EEPROM offset read for 1-byte

PATCH RESEND Superseded Prasanth Babu Mantena 4 participants 6 messages Oct 20, 2023 – Oct 26, 2023

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 board: ti: common: board_detect: Fix EEPROM offset read for 1-byte

EEPROM detection logic in ti_i2c_eeprom_get() involves reading the total size followed by reading 1-byte size with an offset 1. This commit fixes the header matching issue in commit 9f393a2d7af8 ("board: ti: common:
board_detect: Fix EEPROM read quirk for 2-byte").

In the previous commit, the value with one offset is being read into offset_test, but the pointer used to match was still ep. After reading with an offset 1, the second byte of the header is compared with the 1-byte data read from EEPROM. This is taken care by comparing proper first byte value from the header.

Fixes 9f393a2d7af8 (board: ti: common: board_detect: Fix EEPROM read quirk for 2-byte)

---
Resending due to incorrect patch tag last time.

 board/ti/common/board_detect.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
board/ti/common/board_detect.c +1 -1
index 9a53884c98..17fe8f8069 100644
@@ -128,7 +128,7 @@ static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr,
 
 	rc = dm_i2c_read(dev, 0x1, &offset_test, sizeof(offset_test));
 
-	if (*((u32 *)ep) != (header & 0xFF))
+	if (offset_test != ((header >> 8) & 0xFF))
 		one_byte_addressing = false;
 
 	/* Corrupted data??? */
Signature · 1 line
2.39.0
#1 lore raw

Thanks Prasanth

Quoted 4 lines · Prasanth Babu Mantena

EEPROM detection logic in ti_i2c_eeprom_get() involves reading the total size followed by reading 1-byte size with an offset 1. This commit fixes the header matching issue in commit 9f393a2d7af8 ("board: ti: common:
board_detect: Fix EEPROM read quirk for 2-byte").

You can fixes below as well. I think you can avoid this in commit message

Quoted 6 lines

In the previous commit, the value with one offset is being read into offset_test, but the pointer used to match was still ep. After reading with an offset 1, the second byte of the header is compared with the 1-byte data read from EEPROM. This is taken care by comparing proper first byte value from the header.

Nice catch

Quoted 3 lines
Fixes 9f393a2d7af8 (board: ti: common: board_detect: Fix EEPROM read quirk for 2-byte)

Please consider Fixes line, first than Signed-off-by

Please copy Nishanth in patch as well .

Quoted 19 lines

---
Resending due to incorrect patch tag last time.

  board/ti/common/board_detect.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
board/ti/common/board_detect.c +1 -1
index 9a53884c98..17fe8f8069 100644
@@ -128,7 +128,7 @@ static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr,
 
  	rc = dm_i2c_read(dev, 0x1, &offset_test, sizeof(offset_test));
 
-	if (*((u32 *)ep) != (header & 0xFF))
+	if (offset_test != ((header >> 8) & 0xFF))
  		one_byte_addressing = false;
 
  	/* Corrupted data??? */
#2 lore raw
Quoted 7 lines · Udit

Thanks Prasanth

Quoted 4 lines · Prasanth Babu Mantena

EEPROM detection logic in ti_i2c_eeprom_get() involves reading the total size followed by reading 1-byte size with an offset 1. This commit fixes the header matching issue in commit 9f393a2d7af8 ("board: ti: common:
board_detect: Fix EEPROM read quirk for 2-byte").

Quoted 8 lines

You can fixes below as well. I think you can avoid this in commit message

Quoted 6 lines

In the previous commit, the value with one offset is being read into offset_test, but the pointer used to match was still ep. After reading with an offset 1, the second byte of the header is compared with the 1-byte data read from EEPROM. This is taken care by comparing proper first byte value from the header.

Nice catch

Yes indeed.. here is a possible improvement of commit message:

EEPROM detection logic in ti_i2c_eeprom_get() involves reading the total size and the 1-byte size with an offset 1.

The value with one offset is read into "offset_test," but the pointer used to match was still "ep". This results in comparing results against the previously read data while the intent is to ensure the detection of the bad 2-byte addressing eeproms that get stuck after responding initially to 1- byte accesses. This behavior was detected on BeagleBone-AI64.

Quoted 4 lines
Quoted 3 lines
Fixes 9f393a2d7af8 (board: ti: common: board_detect: Fix EEPROM read quirk for 2-byte)

Please consider Fixes line, first than Signed-off-by

Yup, fixes and SoB (checkpatch typically warns)

Quoted 10 lines

Please copy Nishanth in patch as well .

Quoted 6 lines

---
Resending due to incorrect patch tag last time.

  board/ti/common/board_detect.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 10 lines

board/ti/common/board_detect.c static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr, · line 131

Quoted 10 lines
board/ti/common/board_detect.c +1 -1
index 9a53884c98..17fe8f8069 100644
@@ -128,7 +128,7 @@ static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr,
  	rc = dm_i2c_read(dev, 0x1, &offset_test, sizeof(offset_test));
-	if (*((u32 *)ep) != (header & 0xFF))
+	if (offset_test != ((header >> 8) & 0xFF))
  		one_byte_addressing = false;
  	/* Corrupted data??? */

You missed the else CONFIG_IS_ENABLED(DM_I2C) case with the same bug?

Also please CC Matwey V. Kornilov <[email protected]> , Jason Kridner <[email protected]> and Robert Nelson <[email protected]>

So that we don't have regressions on their boards.

https://lore.kernel.org/all/CAJs94Ebdd4foOjhGFu9Bop0v=B1US9neDLxfhgcY23ukgLzFOQ@mail.gmail.com/

Signature · 3 lines
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 849D 1736 249D
#3 lore raw
Quoted 60 lines · Nishanth Menon
Quoted 7 lines · Udit

Thanks Prasanth

Quoted 4 lines · Prasanth Babu Mantena

EEPROM detection logic in ti_i2c_eeprom_get() involves reading the total size followed by reading 1-byte size with an offset 1. This commit fixes the header matching issue in commit 9f393a2d7af8 ("board: ti: common:
board_detect: Fix EEPROM read quirk for 2-byte").

Quoted 8 lines

You can fixes below as well. I think you can avoid this in commit message

Quoted 6 lines

In the previous commit, the value with one offset is being read into offset_test, but the pointer used to match was still ep. After reading with an offset 1, the second byte of the header is compared with the 1-byte data read from EEPROM. This is taken care by comparing proper first byte value from the header.

Nice catch

Yes indeed.. here is a possible improvement of commit message:

EEPROM detection logic in ti_i2c_eeprom_get() involves reading the total size and the 1-byte size with an offset 1.

The value with one offset is read into "offset_test," but the pointer used to match was still "ep". This results in comparing results against the previously read data while the intent is to ensure the detection of the bad 2-byte addressing eeproms that get stuck after responding initially to 1- byte accesses. This behavior was detected on BeagleBone-AI64.

Quoted 4 lines
Quoted 3 lines
Fixes 9f393a2d7af8 (board: ti: common: board_detect: Fix EEPROM read quirk for 2-byte)

Please consider Fixes line, first than Signed-off-by

Yup, fixes and SoB (checkpatch typically warns)

Quoted 10 lines

Please copy Nishanth in patch as well .

Quoted 6 lines

---
Resending due to incorrect patch tag last time.

  board/ti/common/board_detect.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 10 lines

board/ti/common/board_detect.c static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr, · line 131

Quoted 10 lines
board/ti/common/board_detect.c +1 -1
index 9a53884c98..17fe8f8069 100644
@@ -128,7 +128,7 @@ static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr,
  	rc = dm_i2c_read(dev, 0x1, &offset_test, sizeof(offset_test));
-	if (*((u32 *)ep) != (header & 0xFF))
+	if (offset_test != ((header >> 8) & 0xFF))
  		one_byte_addressing = false;
  	/* Corrupted data??? */

You missed the else CONFIG_IS_ENABLED(DM_I2C) case with the same bug?

Quoted 6 lines

Also please CC Matwey V. Kornilov <[email protected]> , Jason Kridner <[email protected]> and Robert Nelson <[email protected]>

So that we don't have regressions on their boards.

https://lore.kernel.org/all/CAJs94Ebdd4foOjhGFu9Bop0v=B1US9neDLxfhgcY23ukgLzFOQ@mail.gmail.com/

Thanks for the comments Nishanth.
Will send a v2 addressing them.

Regards,
Prasanth

Quoted 5 lines
Signature · 4 lines
-- 
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 849D 1736 249D
#4 lore raw
In reply to Kumar, Udit
Quoted 14 lines · Udit

Thanks Prasanth

Quoted 4 lines · Prasanth Babu Mantena

EEPROM detection logic in ti_i2c_eeprom_get() involves reading the total size followed by reading 1-byte size with an offset 1. This commit fixes the header matching issue in commit 9f393a2d7af8 ("board: ti: common:
board_detect: Fix EEPROM read quirk for 2-byte").

You can fixes below as well. I think you can avoid this in commit message

Quoted 6 lines

In the previous commit, the value with one offset is being read into offset_test, but the pointer used to match was still ep. After reading with an offset 1, the second byte of the header is compared with the 1-byte data read from EEPROM. This is taken care by comparing proper first byte value from the header.

Quoted 9 lines

Nice catch

Quoted 3 lines
Fixes 9f393a2d7af8 (board: ti: common: board_detect: Fix EEPROM read quirk for 2-byte)

Please consider Fixes line, first than Signed-off-by

Please copy Nishanth in patch as well .

Thanks for the review comments Udit.
Will send a v2 addressing them.

Regards,
Prasanth

Quoted 16 lines
Quoted 16 lines

---
Resending due to incorrect patch tag last time.

  board/ti/common/board_detect.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
board/ti/common/board_detect.c +1 -1
index 9a53884c98..17fe8f8069 100644
@@ -128,7 +128,7 @@ static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr,
  	rc = dm_i2c_read(dev, 0x1, &offset_test, sizeof(offset_test));
-	if (*((u32 *)ep) != (header & 0xFF))
+	if (offset_test != ((header >> 8) & 0xFF))
  		one_byte_addressing = false;
  	/* Corrupted data??? */
Reviewed-by on v1 1/1
#5 lore raw
In reply to Prasanth Babu Mantena

Hi Prasanth

Quoted 24 lines · Prasanth Babu Mantena

EEPROM detection logic in ti_i2c_eeprom_get() involves reading the total size followed by reading 1-byte size with an offset 1. This commit fixes the header matching issue in commit 9f393a2d7af8 ("board: ti: common:
board_detect: Fix EEPROM read quirk for 2-byte").

In the previous commit, the value with one offset is being read into offset_test, but the pointer used to match was still ep. After reading with an offset 1, the second byte of the header is compared with the 1-byte data read from EEPROM. This is taken care by comparing proper first byte value from the header.

Fixes 9f393a2d7af8 (board: ti: common: board_detect: Fix EEPROM read quirk for 2-byte)

---
Resending due to incorrect patch tag last time.

  board/ti/common/board_detect.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
board/ti/common/board_detect.c +0 -0
index 9a53884c98..17fe8f8069 100644

board/ti/common/board_detect.c static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr, · line 134

Quoted 8 lines
board/ti/common/board_detect.c +1 -1
@@ -128,7 +128,7 @@ static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr,
 
  	rc = dm_i2c_read(dev, 0x1, &offset_test, sizeof(offset_test));
 
-	if (*((u32 *)ep) != (header & 0xFF))
+	if (offset_test != ((header >> 8) & 0xFF))
  		one_byte_addressing = false;
 
  	/* Corrupted data??? */

Thanks for catching this!

Signature · 2 lines
Thanking You
Neha Malcom Francis