qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Christian Speich <c.speich@avm.de>, qemu-devel@nongnu.org
Cc: Bin Meng <bmeng.cn@gmail.com>, qemu-block@nongnu.org
Subject: Re: [PATCH 3/4] hw/sd/sdcard: Erase blocks to zero
Date: Mon, 24 Nov 2025 05:09:03 +0100	[thread overview]
Message-ID: <a289ad27-20f2-46f1-bd33-a08cf8f1a14e@linaro.org> (raw)
In-Reply-To: <20250919-sdcard-performance-b4-v1-3-e1037e481a19@avm.de>

On 19/9/25 14:34, Christian Speich wrote:
> 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.

You are right, we don't set DATA_STAT_AFTER_ERASE correctly.

> 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);
>       }
>   }

I'm OK with this change, but I'd rather having a device boolean property
so we can keep the old behavior for backward compatibility. Maybe
'erase-block-as-zero'? Do you mind updating this patch?

Regards,

Phil.


  reply	other threads:[~2025-11-24  4:09 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 ` [PATCH 3/4] hw/sd/sdcard: Erase blocks to zero Christian Speich
2025-11-24  4:09   ` Philippe Mathieu-Daudé [this message]
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=a289ad27-20f2-46f1-bd33-a08cf8f1a14e@linaro.org \
    --to=philmd@linaro.org \
    --cc=bmeng.cn@gmail.com \
    --cc=c.speich@avm.de \
    --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).