This patch series improves the performance of read/write/erase operations
on sdcards.
This is done by increasing the maximum buffer size that is worked on.
>From 1 byte (master) to 512 bytes (commit 1-3) to larger than 512
(adma commit).
Testing on my system with fio I see the following rough performance
values in MiB/s.
read write readwrite
master: 6 6 3/ 3
first commit: 51 43 23/ 23
second commit: 392 180 144/143
Tested on a 2GiB raw image with:
fio --filename=/dev/mmcblk0 --direct=1 --runtime=60 --time_based --bs=128k
--rw={mode}
The adma values are somewhat unstable but always >100MiB/s, I'm not sure
why but I guess it has something to do with the host side caching.
The fifth commit fixes the DATA_STAT_AFTER_ERASE bit in SCR and
introduces an option to allow to erase blocks to 0x00.
The sixth commit optimizes block erase when erase-blocks-as-zero=true
is used, by passing the zeroing request down the to the block device.
Erasing 2GiB now takes 0.1s instead of 26s.
Signed-off-by: Christian Speich <[email protected]>
I'm picking up this series with the changes indicated in v5 below. Please let
me know how I could improve attribution to Christian in case I missed something.
The last two patches are new and are small cleanups.
---
Changes in v5:
- Rebase onto master
- Split patch "hw/sd/sd: Use multi-byte/block writes for block path" into three
(first three patches)
- Use sd_blk_{read,write} with additional parameter directly rather than having
sd_blk_{read,write}_bounce_buffer
- Drive limits and write protect groups are preserved to be checked on block
boundaries only since these checks are redundant in case the SD host
transfers one byte at a time.
- WP_VIOLATION is only raised once the first protected block shall be written,
rather than immediately at the beginning of a multiple block write which
starts with allowed blocks.
- An off-by-one error has been fixed in the same case where one bye too less
had been written if a write protected block had been detected.
- There are only two rather than three code paths each handling the multiple
block optimization.
Changes in v4:
- Rebase onto master, no changes needed.
- Renames:
- sd_blk_{read,write} -> sd_blk_{read,write}_bounce_buffer
- sd_blk_{read,write}_direct -> sd_blk_{read,write}
- to_erase -> erase_len
- Extract erase logic into sd_blk_erase helper
- Enable erase-blocks-as-zero by default. Add compat for 11.0 and below
to keep it disabled.
- Add cleanup commit to update trace events.
- Link to v3:
https://lore.kernel.org/qemu-devel/[email protected]
Changes in v3:
- Rebase onto master, updating read/write path for newly added RBMP
- Split up commit 1 into multiple commits
- change interface to allow "short" read/writes that are continued
by the core later by calling again
- Link to v2:
https://lore.kernel.org/qemu-devel/[email protected]
Changes in v2:
- Properly set DATA_STAT_AFTER_ERASE in SCR
- Add erase-blocks-as-zero option to allow the user to switch between
0x00 and 0xFF for erased blocks.
- Link to v1:
https://lore.kernel.org/qemu-devel/[email protected]
Bernhard Beschow (5):
hw/sd/sd: Transfer up to one block in case of multi-block commands
hw/sd/sd: Add buffer argument to sd_blk_{read,write}
hw/sd/sd: Use multi-byte/block writes for block path
hw/sd/sd: Retype state attribute to SDCardStates
hw/sd/sd: Remove unneeded forward declaration
Christian Speich (3):
hw/sd/sdhci: Don't use bounce buffer for ADMA
hw/sd/sd: Add erase-blocks-as-zero option.
hw/sd/sd: Optimize erase blocks as zero.
hw/core/machine.c | 1 +
hw/sd/sd.c | 230 ++++++++++++++++++++++++++++++++++------------
hw/sd/sdhci.c | 102 ++++++++++----------
3 files changed, 225 insertions(+), 108 deletions(-)
--
2.56.0