Hi Christian,
On 19/5/26 10:58, Christian Speich wrote:
Hey Phil,
On Tue, May 12, 2026 at 10:37:34PM +0200, Philippe Mathieu-Daudé wrote:
On 12/5/26 08:21, Philippe Mathieu-Daudé wrote:
From: Christian Speich <[email protected]>
Paths that use sd_generic_write/read_data can now write/read multiple
bytes with one call.
Signed-off-by: Christian Speich <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
---
hw/sd/sd.c | 62 ++++++++++++++++++++++++++++++------------------------
1 file changed, 35 insertions(+), 27 deletions(-)
-static bool sd_generic_write_byte(SDState *sd, uint8_t value)
+static bool sd_generic_write_data(SDState *sd, const void *buf, size_t *len)
{
- sd->data[sd->data_offset] = value;
+ size_t to_write = MIN(sd->data_size - sd->data_offset, *len);
- if (++sd->data_offset >= sd->data_size) {
+ memcpy(sd->data, buf, to_write);
Always writing beginning of buffer.
+ sd->data_offset += to_write;
+ *len = to_write;
+
+ if (sd->data_offset >= sd->data_size) {
sd->state = sd_transfer_state;
return true;
}
@@ -2627,11 +2631,15 @@ static bool sd_generic_write_byte(SDState *sd, uint8_t
value)
}
/* Return true when buffer is consumed. Configured by
sd_cmd_to_sendingdata() */
-static bool sd_generic_read_byte(SDState *sd, uint8_t *value)
+static bool sd_generic_read_data(SDState *sd, void *buf, size_t *len)
{
- *value = sd->data[sd->data_offset];
+ size_t to_read = MIN(sd->data_size - sd->data_offset, *len);
- if (++sd->data_offset >= sd->data_size) {
+ memcpy(buf, sd->data, to_read);
Always reading beginning of buffer.
Oh, good find! Thanks!
I see that only 3 of 7 patches from my series made it into this PULL, are there
any
problems with the others I can help with?
This series is the last thing I wanted to get in for the next release
but unfortunately I don't feel having having enough energy to do that
in time tonight :/ Sigh.
Per my notes from May 12, there is a problem in "hw/sd/sd: Use
multi-byte/block writes for block path"
case 18: /* CMD18: READ_MULTIPLE_BLOCK */
...
+ else if (length >= io_len
+ && partition_access != EXT_CSD_PART_CONFIG_ACC_RPMB) {
+ length = QEMU_ALIGN_DOWN(length, io_len);
+
+ /* For limited reads, only read the requested block count. */
+ if (sd->multi_blk_cnt != 0) {
+ length = MIN(length, sd->multi_blk_cnt * io_len);
+ }
+
+ sd_blk_read(sd, buf, sd->data_start, length);
^^^ at this line.
Too long passed and I don't remember neither the problem or how I was
testing your series, so I'll have to restart from scratch. (Maybe a
short read from the host backend?) Nothing to be done on your side,
I'm at fault here for not updating what happened (why I didn't merged
the whole series) when it was time. I apologize for the delays...
Regards,
Phil.
Greetings,
Christian