linux/drivers/mtd/tests
Amit Kumar Mahapatra ceef4cf97b mtd: tests: Fix eraseblock read speed miscalculation for lower partition sizes
While calculating speed during  mtd_speedtest, the time interval
(i.e., start - finish) is rounded off to the nearest milliseconds by
ignoring the fractional part. This leads to miscalculation of speed.
The miscalculation is more visible while running speed test on small
partition sizes(i.e., when partition size is equal to eraseblock size or
twice the eraseblock size) at higher spi frequencies.

For e.g., while calculating eraseblock read speed for a mtd partition with
size equal to the eraseblock size(i.e., 64KiB) the eraseblock read time
interval comes out to be 966490 nanosecond. This is then converted to
millisecond(i.e., 0.966 msec.). The integer part (i.e., 0 msec) of the
value is considered and the fractional part (i.e., 0.966) is ignored,for
calculating the eraseblock read speed. So the reported eraseblock read
speed is 0 KiB/s, which is incorrect.

There are two approaches to fix this issue.

First approach will be to keep the time interval in millisecond. and round
up the integer value, with this approach the 0.966msec time interval in the
above example will be rounded up to 1msec and this value is used for
calculating the speed. Downside of this approach is that the reported speed
is still not accurate.

Second approach will be to convert the time interval to microseconds
instead of milliseconds, with this approach the 966490 nanosecond time
interval in the above example will be converted t0 966.490usec and this
value is used for calculating the speed. As compared to the current
implementation and the suggested First approach, this approach will report
a more accurate speed. Downside of this approach is that, in future if the
mtd size is too large then the u64 variable, that holds the number of
bytes, might overflow.

In this patch we have gone with the second approach as this reports a more
accurate speed. With this approach the eraseblock read speed in the above
example comes out to be 132505 KiB/s when the spi clock is configured at
150Mhz.

Signed-off-by: Amit Kumar Mahapatra <amit.kumar-mahapatra@xilinx.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20220208103905.13354-1-amit.kumar-mahapatra@xilinx.com
2022-03-14 17:01:47 +01:00
..
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
mtd_nandecctest.c mtd: nand: ecc-hamming: Rename the exported functions 2020-12-10 22:37:29 +01:00
mtd_test.c mtd: Unconditionally update ->fail_addr and ->addr in part_erase() 2018-03-15 18:22:26 +01:00
mtd_test.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
nandbiterrs.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 326 2019-06-05 17:37:06 +02:00
oobtest.c mtd: mtd_oobtest: Remove redundant assignment to err 2021-05-10 12:42:57 +02:00
pagetest.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 326 2019-06-05 17:37:06 +02:00
readtest.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 326 2019-06-05 17:37:06 +02:00
speedtest.c mtd: tests: Fix eraseblock read speed miscalculation for lower partition sizes 2022-03-14 17:01:47 +01:00
stresstest.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 326 2019-06-05 17:37:06 +02:00
subpagetest.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 326 2019-06-05 17:37:06 +02:00
torturetest.c mtd: tests: Remove redundant assignment to err 2021-05-10 12:48:35 +02:00