linux-stable/drivers/mtd
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
..
chips mtd: gen_probe: Use bitmap_zalloc() when applicable 2021-12-09 17:52:29 +01:00
devices mtd: spear_smi: use GFP_KERNEL 2022-02-18 15:14:01 +01:00
hyperbus MTD core changes: 2022-01-11 11:35:28 -08:00
lpddr
maps MIPS: TXX9: Remove rbtx4939 board support 2022-01-02 14:10:40 +01:00
nand Topic branch bringing-in changes related to the support of ECC engines 2022-02-18 15:11:12 +01:00
parsers mtd: parsers: trx: allow to use on MediaTek MIPS SoCs 2022-02-18 15:14:05 +01:00
spi-nor mtd: aspeed-smc: improve probe resilience 2022-01-23 16:37:59 +01:00
tests mtd: tests: Fix eraseblock read speed miscalculation for lower partition sizes 2022-03-14 17:01:47 +01:00
ubi for-5.17/block-2022-01-11 2022-01-12 10:26:52 -08:00
ftl.c mtd/ftl: don't cast away the type when calling add_mtd_blktrans_dev 2021-08-23 10:01:04 +02:00
inftlcore.c
inftlmount.c
Kconfig mtdblock: Add comment about UBI block devices 2021-08-06 22:05:13 +02:00
Makefile
mtd_blkdevs.c mtd_blkdevs: avoid soft lockups with some mtd/spi devices 2022-01-26 11:43:02 +01:00
mtdblock.c mtdblock: Warn if added for a NAND device 2021-08-17 18:41:59 +02:00
mtdblock_ro.c mtdblock: Warn if added for a NAND device 2021-08-17 18:41:59 +02:00
mtdchar.c mtdchar: prevent unbounded allocation in MEMWRITE ioctl 2021-12-09 17:52:29 +01:00
mtdconcat.c mtd: mtdconcat: Check _read, _write callbacks existence before assignment 2021-08-17 18:43:33 +02:00
mtdcore.c mtd: Replace the expert mode symbols with a single helper 2022-02-07 16:36:11 +01:00
mtdcore.h
mtdoops.c
mtdpart.c mtd: Fixed breaking list in __mtd_del_partition. 2021-12-03 14:27:18 +01:00
mtdpstore.c
mtdsuper.c mm: don't include <linux/blkdev.h> in <linux/backing-dev.h> 2021-10-18 06:17:01 -06:00
mtdswap.c mtd: mtdswap: Remove redundant assignment of pointer eb 2021-09-14 19:36:34 +02:00
nftlcore.c
nftlmount.c
rfd_ftl.c mtd/rfd_ftl: don't cast away the type when calling add_mtd_blktrans_dev 2021-08-23 10:01:06 +02:00
sm_ftl.c
sm_ftl.h
ssfdc.c