Skip to contentSkip to conversation

sf: fix timebase data type in _wait_ready()

PATCH In review Stephen Warren 3 participants 9 messages Apr 4, 2016 – Apr 26, 2016 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sf: fix timebase data type in _wait_ready()

From: Stephen Warren <[email protected]>

get_timer() returns an unsigned 64-bit value, but is currently assigned to a signed 32-bit variable. Due to sign extension and data truncation, this causes the timeout loop in spi_flash_cmd_wait_ready() to immediately (and incorrectly) fire for about 50% of all time values, based on whether bit 31 is set. In sandbox at least, this causes the test to pass or fail based on system uptime, as opposed to time since the U-Boot binary was started.

Fixes 4efad20a1751 ("sf: Update status reg check in spi_flash_cmd_wait_ready")
---
 drivers/mtd/spi/spi_flash.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mtd/spi/spi_flash.c +2 -1
index 44d9e9ba0105..545172568949 100644
@@ -265,7 +265,8 @@ static int spi_flash_ready(struct spi_flash *flash)
 static int spi_flash_cmd_wait_ready(struct spi_flash *flash,
 					unsigned long timeout)
 {
-	int timebase, ret;
+	unsigned long timebase;
+	int ret;
 
 	timebase = get_timer(0);
 
Signature · 1 line
2.8.1
#1 lore raw

PATCH 1/1 sf: fix timebase data type in _wait_ready()

Quoted 11 lines · Stephen Warren

From: Stephen Warren <[email protected]>

get_timer() returns an unsigned 64-bit value, but is currently assigned to a signed 32-bit variable. Due to sign extension and data truncation, this causes the timeout loop in spi_flash_cmd_wait_ready() to immediately (and incorrectly) fire for about 50% of all time values, based on whether bit 31 is set. In sandbox at least, this causes the test to pass or fail based on system uptime, as opposed to time since the U-Boot binary was started.

Fixes 4efad20a1751 ("sf: Update status reg check in spi_flash_cmd_wait_ready")
Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160404/3bea6f8f/attachment.sig>
#2 lore raw

PATCH 1/1 sf: fix timebase data type in _wait_ready()

Quoted 11 lines · Tom Rini
Quoted 9 lines · Stephen Warren

From: Stephen Warren <[email protected]>

get_timer() returns an unsigned 64-bit value, but is currently assigned to a signed 32-bit variable. Due to sign extension and data truncation, this causes the timeout loop in spi_flash_cmd_wait_ready() to immediately (and incorrectly) fire for about 50% of all time values, based on whether bit 31 is set. In sandbox at least, this causes the test to pass or fail based on system uptime, as opposed to time since the U-Boot binary was started.

Quoted 4 lines
Quoted 2 lines
Fixes 4efad20a1751 ("sf: Update status reg check in spi_flash_cmd_wait_ready")
Signature · 1 line
Jagan.
#3 lore raw

PATCH 1/1 sf: fix timebase data type in _wait_ready()

Quoted 12 lines · Jagan Teki
Quoted 11 lines · Tom Rini
Quoted 9 lines · Stephen Warren

From: Stephen Warren <[email protected]>

get_timer() returns an unsigned 64-bit value, but is currently assigned to a signed 32-bit variable. Due to sign extension and data truncation, this causes the timeout loop in spi_flash_cmd_wait_ready() to immediately (and incorrectly) fire for about 50% of all time values, based on whether bit 31 is set. In sandbox at least, this causes the test to pass or fail based on system uptime, as opposed to time since the U-Boot binary was started.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Fixes 4efad20a1751 ("sf: Update status reg check in spi_flash_cmd_wait_ready")

It'd be great if this could be applied to fix the final test/py failure on sandbox.

#4 lore raw

PATCH 1/1 sf: fix timebase data type in _wait_ready()

Quoted 16 lines · Stephen Warren
Quoted 15 lines · Jagan Teki
Quoted 14 lines · Tom Rini
Quoted 11 lines · Stephen Warren

From: Stephen Warren <[email protected]>

get_timer() returns an unsigned 64-bit value, but is currently assigned to a signed 32-bit variable. Due to sign extension and data truncation, this causes the timeout loop in spi_flash_cmd_wait_ready() to immediately (and incorrectly) fire for about 50% of all time values, based on whether bit 31 is set. In sandbox at least, this causes the test to pass or fail based on system uptime, as opposed to time since the U-Boot binary was started.

Fixes 4efad20a1751 ("sf: Update status reg check in spi_flash_cmd_wait_ready")
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

It'd be great if this could be applied to fix the final test/py failure on sandbox.

Yes, please, lets get some PRs with fixes in now :) Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160412/e256fec9/attachment.sig>
#5 lore raw

PATCH 1/1 sf: fix timebase data type in _wait_ready()

In reply to Jagan Teki
Quoted 12 lines · Jagan Teki
Quoted 11 lines · Tom Rini
Quoted 9 lines · Stephen Warren

From: Stephen Warren <[email protected]>

get_timer() returns an unsigned 64-bit value, but is currently assigned to a signed 32-bit variable. Due to sign extension and data truncation, this causes the timeout loop in spi_flash_cmd_wait_ready() to immediately (and incorrectly) fire for about 50% of all time values, based on whether bit 31 is set. In sandbox at least, this causes the test to pass or fail based on system uptime, as opposed to time since the U-Boot binary was started.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Fixes 4efad20a1751 ("sf: Update status reg check in spi_flash_cmd_wait_ready")

Jagan, are you going to apply this?

#6 lore raw

PATCH 1/1 sf: fix timebase data type in _wait_ready()

Quoted 23 lines · Stephen Warren
Quoted 22 lines · Jagan Teki
Quoted 21 lines · Tom Rini
Quoted 18 lines · Stephen Warren

From: Stephen Warren <[email protected]>

get_timer() returns an unsigned 64-bit value, but is currently assigned to
a signed 32-bit variable. Due to sign extension and data truncation, this
causes the timeout loop in spi_flash_cmd_wait_ready() to immediately (and
incorrectly) fire for about 50% of all time values, based on whether bit
31 is set. In sandbox at least, this causes the test to pass or fail based
on system uptime, as opposed to time since the U-Boot binary was started.

Fixes 4efad20a1751 ("sf: Update status reg check in

spi_flash_cmd_wait_ready")

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Jagan, are you going to apply this?

Tom, does it make sense for you to apply this?

#7 lore raw

PATCH 1/1 sf: fix timebase data type in _wait_ready()

Quoted 24 lines · Stephen Warren
Quoted 23 lines · Stephen Warren
Quoted 22 lines · Jagan Teki
Quoted 21 lines · Tom Rini
Quoted 18 lines · Stephen Warren

From: Stephen Warren <[email protected]>

get_timer() returns an unsigned 64-bit value, but is currently assigned to
a signed 32-bit variable. Due to sign extension and data truncation, this
causes the timeout loop in spi_flash_cmd_wait_ready() to immediately (and
incorrectly) fire for about 50% of all time values, based on whether bit
31 is set. In sandbox at least, this causes the test to pass or fail based
on system uptime, as opposed to time since the U-Boot binary was started.

Fixes 4efad20a1751 ("sf: Update status reg check in

spi_flash_cmd_wait_ready")

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Jagan, are you going to apply this?

Tom, does it make sense for you to apply this?

If Jagan doesn't want to make up a small PR for this, yes. And since I should do an rc3 today, yes, I should pick this up myself. Thanks for the reminder.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160425/3137f755/attachment.sig>
#8 lore raw
In reply to Stephen Warren
Quoted 9 lines · Stephen Warren

From: Stephen Warren <[email protected]>

get_timer() returns an unsigned 64-bit value, but is currently assigned to a signed 32-bit variable. Due to sign extension and data truncation, this causes the timeout loop in spi_flash_cmd_wait_ready() to immediately (and incorrectly) fire for about 50% of all time values, based on whether bit 31 is set. In sandbox at least, this causes the test to pass or fail based on system uptime, as opposed to time since the U-Boot binary was started.

Quoted 4 lines
Fixes 4efad20a1751 ("sf: Update status reg check in spi_flash_cmd_wait_ready")

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160425/3da6bf8a/attachment.sig>