diff mbox series

[24/32] hw/sd: Subtract bootarea size from blk

Message ID 20230703132509.2474225-25-clg@kaod.org (mailing list archive)
State New, archived
Headers show
Series hw/sd: eMMC support | expand

Commit Message

Cédric Le Goater July 3, 2023, 1:25 p.m. UTC
From: Joel Stanley <joel@jms.id.au>

The userdata size is derived from the file the user passes on the
command line, but we must take into account the boot areas.

Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 hw/sd/sd.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Philippe Mathieu-Daudé June 3, 2024, 12:31 p.m. UTC | #1
On 3/7/23 15:25, Cédric Le Goater wrote:
> From: Joel Stanley <joel@jms.id.au>
> 
> The userdata size is derived from the file the user passes on the
> command line, but we must take into account the boot areas.
> 
> Signed-off-by: Joel Stanley <joel@jms.id.au>
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
>   hw/sd/sd.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/hw/sd/sd.c b/hw/sd/sd.c
> index 6da17a8d0972..1df7c7ac9dae 100644
> --- a/hw/sd/sd.c
> +++ b/hw/sd/sd.c
> @@ -674,6 +674,7 @@ static unsigned sd_boot_capacity_bytes(SDState *sd)
>   static void sd_reset(DeviceState *dev)
>   {
>       SDState *sd = SD_CARD(dev);
> +    SDCardClass *sc = SD_CARD_GET_CLASS(sd);
>       uint64_t size;
>       uint64_t sect;
>   
> @@ -685,6 +686,10 @@ static void sd_reset(DeviceState *dev)
>       }
>       size = sect << 9;
>   
> +    if (sc->bootpart_offset) {
> +        size -= sd_boot_capacity_bytes(sd) * 2;

IMO this patch and sd_boot_capacity_bytes() definition
from previous patch should be squashed in patch 22 where
you add emmc_cmd_SEND_EXT_CSD.

> +    }
> +
>       sect = sd_addr_to_wpnum(size) + 1;
>   
>       sd->state = sd_idle_state;
Cédric Le Goater June 4, 2024, 3:21 p.m. UTC | #2
On 6/3/24 14:31, Philippe Mathieu-Daudé wrote:
> On 3/7/23 15:25, Cédric Le Goater wrote:
>> From: Joel Stanley <joel@jms.id.au>
>>
>> The userdata size is derived from the file the user passes on the
>> command line, but we must take into account the boot areas.
>>
>> Signed-off-by: Joel Stanley <joel@jms.id.au>
>> Signed-off-by: Cédric Le Goater <clg@kaod.org>
>> ---
>>   hw/sd/sd.c | 5 +++++
>>   1 file changed, 5 insertions(+)
>>
>> diff --git a/hw/sd/sd.c b/hw/sd/sd.c
>> index 6da17a8d0972..1df7c7ac9dae 100644
>> --- a/hw/sd/sd.c
>> +++ b/hw/sd/sd.c
>> @@ -674,6 +674,7 @@ static unsigned sd_boot_capacity_bytes(SDState *sd)
>>   static void sd_reset(DeviceState *dev)
>>   {
>>       SDState *sd = SD_CARD(dev);
>> +    SDCardClass *sc = SD_CARD_GET_CLASS(sd);
>>       uint64_t size;
>>       uint64_t sect;
>> @@ -685,6 +686,10 @@ static void sd_reset(DeviceState *dev)
>>       }
>>       size = sect << 9;
>> +    if (sc->bootpart_offset) {
>> +        size -= sd_boot_capacity_bytes(sd) * 2;
> 
> IMO this patch and sd_boot_capacity_bytes() definition
> from previous patch should be squashed in patch 22 where
> you add emmc_cmd_SEND_EXT_CSD.

OK. I will check.

Have you looked at the other patches ?

Thanks,

C.


> 
>> +    }
>> +
>>       sect = sd_addr_to_wpnum(size) + 1;
>>       sd->state = sd_idle_state;
>
diff mbox series

Patch

diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 6da17a8d0972..1df7c7ac9dae 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -674,6 +674,7 @@  static unsigned sd_boot_capacity_bytes(SDState *sd)
 static void sd_reset(DeviceState *dev)
 {
     SDState *sd = SD_CARD(dev);
+    SDCardClass *sc = SD_CARD_GET_CLASS(sd);
     uint64_t size;
     uint64_t sect;
 
@@ -685,6 +686,10 @@  static void sd_reset(DeviceState *dev)
     }
     size = sect << 9;
 
+    if (sc->bootpart_offset) {
+        size -= sd_boot_capacity_bytes(sd) * 2;
+    }
+
     sect = sd_addr_to_wpnum(size) + 1;
 
     sd->state = sd_idle_state;