qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Luc Michel <luc.michel@amd.com>
Cc: qemu-devel@nongnu.org, "Bin Meng" <bmeng.cn@gmail.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Cédric Le Goater" <clg@kaod.org>,
	qemu-block@nongnu.org, "Cédric Le Goater" <clg@redhat.com>
Subject: Re: [PATCH v43 2/2] hw/sd/sdcard: Do not store vendor data on block drive (CMD56)
Date: Wed, 3 Jul 2024 10:08:06 +0200	[thread overview]
Message-ID: <4ee9fdea-369b-4aaf-a31b-249beaa58a6a@linaro.org> (raw)
In-Reply-To: <ZoUAREvcNtlgpK3r@XFR-LUMICHEL-L2.amd.com>

On 3/7/24 09:39, Luc Michel wrote:
> On 18:10 Tue 02 Jul     , Philippe Mathieu-Daudé wrote:
>> "General command" (GEN_CMD, CMD56) is described as:
>>
>>    GEN_CMD is the same as the single block read or write
>>    commands (CMD24 or CMD17). The difference is that [...]
>>    the data block is not a memory payload data but has a
>>    vendor specific format and meaning.
>>
>> Thus this block must not be stored overwriting data block
>> on underlying storage drive. Keep it in a dedicated
>> 'vendor_data[]' array.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> Tested-by: Cédric Le Goater <clg@redhat.com>
>> ---
>> v43: Do not re-use VMSTATE_UNUSED_V (danpb)
>> ---
>>   hw/sd/sd.c | 16 +++++++++-------
>>   1 file changed, 9 insertions(+), 7 deletions(-)
>>
>> diff --git a/hw/sd/sd.c b/hw/sd/sd.c
>> index 808dc1cea6..418ccb14a4 100644
>> --- a/hw/sd/sd.c
>> +++ b/hw/sd/sd.c
>> @@ -153,6 +153,8 @@ struct SDState {
>>       uint32_t data_offset;
>>       size_t data_size;
>>       uint8_t data[512];
>> +    uint8_t vendor_data[512];
>> +
>>       qemu_irq readonly_cb;
>>       qemu_irq inserted_cb;
>>       QEMUTimer *ocr_power_timer;
>> @@ -719,6 +721,7 @@ static void sd_reset(DeviceState *dev)
>>       sd->wp_switch = sd->blk ? !blk_is_writable(sd->blk) : false;
>>       sd->wp_group_bits = sect;
>>       sd->wp_group_bmap = bitmap_new(sd->wp_group_bits);
>> +    memset(sd->vendor_data, 0xec, sizeof(sd->vendor_data));
>>       memset(sd->function_group, 0, sizeof(sd->function_group));
>>       sd->erase_start = INVALID_ADDRESS;
>>       sd->erase_end = INVALID_ADDRESS;
>> @@ -835,6 +838,7 @@ static const VMStateDescription sd_vmstate = {
>>           VMSTATE_UINT32(data_offset, SDState),
>>           VMSTATE_UINT8_ARRAY(data, SDState, 512),
>>           VMSTATE_UNUSED_V(1, 512),
>> +        VMSTATE_UINT8_ARRAY(vendor_data, SDState, 512),
> 
> Don't you need to bump the VMState version then?

Indeed. I'll add a subsection which is the recommended way:
https://www.qemu.org/docs/master/devel/migration/main.html#subsections

   The most common structure change is adding new data, e.g. when
   adding a newer form of device, or adding that state that you
   previously forgot to migrate. This is best solved using a subsection.

Thanks,

Phil.



      reply	other threads:[~2024-07-03  8:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-02 16:10 [PATCH v43 0/2] hw/sd/sdcard: Cleanups before adding eMMC support Philippe Mathieu-Daudé
2024-07-02 16:10 ` [PATCH v43 1/2] hw/sd/sdcard: Use spec v3.01 by default Philippe Mathieu-Daudé
2024-07-02 16:10 ` [PATCH v43 2/2] hw/sd/sdcard: Do not store vendor data on block drive (CMD56) Philippe Mathieu-Daudé
2024-07-03  7:39   ` Luc Michel
2024-07-03  8:08     ` Philippe Mathieu-Daudé [this message]

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=4ee9fdea-369b-4aaf-a31b-249beaa58a6a@linaro.org \
    --to=philmd@linaro.org \
    --cc=berrange@redhat.com \
    --cc=bmeng.cn@gmail.com \
    --cc=clg@kaod.org \
    --cc=clg@redhat.com \
    --cc=luc.michel@amd.com \
    --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).