From: Christian Speich <c.speich@avm.de>
To: qemu-devel@nongnu.org
Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Bin Meng" <bmeng.cn@gmail.com>,
qemu-block@nongnu.org, "Christian Speich" <c.speich@avm.de>
Subject: [PATCH 3/4] hw/sd/sdcard: Erase blocks to zero
Date: Fri, 19 Sep 2025 14:34:42 +0200 [thread overview]
Message-ID: <20250919-sdcard-performance-b4-v1-3-e1037e481a19@avm.de> (raw)
In-Reply-To: <20250919-sdcard-performance-b4-v1-0-e1037e481a19@avm.de>
Currently, erased blocks are filled with 0xFF. However SCR Bit 55
(DATA_STAT_AFTER_ERASE) indicates that an erase produces zeros. One of
them is wrong.
As erasing to zero is more performant and allows block devices to
use optimizations, we the erase to produce 0x00.
Signed-off-by: Christian Speich <c.speich@avm.de>
---
hw/sd/sd.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 23764ed99f36cf39ee7abe02f08e51897c05e718..94ef3cc62582717ee044c4b114b7f22bd1b4a256 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -1115,7 +1115,6 @@ static void sd_erase(SDState *sd)
sd->erase_end = INVALID_ADDRESS;
sd->csd[14] |= 0x40;
- memset(sd->data, 0xff, erase_len);
for (erase_addr = erase_start; erase_addr <= erase_end;
erase_addr += erase_len) {
if (sdsc) {
@@ -1127,7 +1126,8 @@ static void sd_erase(SDState *sd)
continue;
}
}
- sd_blk_write(sd, erase_addr, erase_len);
+ blk_pwrite_zeroes(sd->blk, erase_addr + sd_part_offset(sd),
+ erase_len, 0);
}
}
--
2.43.0
next prev parent reply other threads:[~2025-09-19 13:59 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-19 12:34 [PATCH 0/4] hw/sd: Improve performance of read/write/erase Christian Speich
2025-09-19 12:34 ` [PATCH 1/4] hw/sd: Switch from byte-wise to buf+len read/writes Christian Speich
2025-09-19 12:34 ` [PATCH 2/4] hw/sd/sdhci: Don't use bounce buffer for ADMA Christian Speich
2025-09-19 12:34 ` Christian Speich [this message]
2025-11-24 4:09 ` [PATCH 3/4] hw/sd/sdcard: Erase blocks to zero Philippe Mathieu-Daudé
2025-11-25 9:47 ` Christian Speich
2025-09-19 12:34 ` [PATCH 4/4] hw/sd/sdcard: Erase in large blocks Christian Speich
2025-11-07 9:08 ` [PATCH 0/4] hw/sd: Improve performance of read/write/erase Christian Speich
2025-11-24 4:05 ` Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250919-sdcard-performance-b4-v1-3-e1037e481a19@avm.de \
--to=c.speich@avm.de \
--cc=bmeng.cn@gmail.com \
--cc=philmd@linaro.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).