Skip to contentSkip to conversation

sd: mmc: Fix SET_BLOCK_COUNT command argument

PATCH In review Cédric Le Goater 3 participants 9 messages Jun 23, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sd: mmc: Fix SET_BLOCK_COUNT command argument

The number of blocks is defined in the lower bits [15:0]

---
 hw/sd/sd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/sd/sd.c +1 -1
index a73d80661a10..a2553a502edc 100644
@@ -1358,7 +1358,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)
         }
         switch (sd->state) {
         case sd_transfer_state:
-            sd->multi_blk_cnt = req.arg;
+            sd->multi_blk_cnt = req.arg & 0xFFFF;
             return sd_r1;
 
         default:
Signature · 1 line
2.31.1
#1 lore raw
Quoted 2 lines · Cédric Le Goater

The number of blocks is defined in the lower bits [15:0]

I checked the physical spec v8.00 and it says bits [31:0] for CMD23 argument.

Quoted 6 lines
---
 hw/sd/sd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Regards,
Bin

#2 lore raw
Quoted 5 lines · Bin Meng
Quoted 2 lines · Cédric Le Goater

The number of blocks is defined in the lower bits [15:0]

I checked the physical spec v8.00 and it says bits [31:0] for CMD23 argument.

Watch out, we only support 1-3:

enum SDPhySpecificationVersion {
    SD_PHY_SPECv1_10_VERS     = 1,
    SD_PHY_SPECv2_00_VERS     = 2,
    SD_PHY_SPECv3_01_VERS     = 3,
};
Quoted 11 lines
Quoted 7 lines
---
 hw/sd/sd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Regards,
Bin

#3 lore raw
Quoted 7 lines · Philippe Mathieu-Daudé
Quoted 5 lines · Bin Meng
Quoted 2 lines · Cédric Le Goater

The number of blocks is defined in the lower bits [15:0]

I checked the physical spec v8.00 and it says bits [31:0] for CMD23 argument.

Quoted 8 lines

Watch out, we only support 1-3:

enum SDPhySpecificationVersion {
    SD_PHY_SPECv1_10_VERS     = 1,
    SD_PHY_SPECv2_00_VERS     = 2,
    SD_PHY_SPECv3_01_VERS     = 3,
};

Yes. block count was increased to 32-bit in v4 if I am correct.

Any how, it is a bit more complex than the patch I sent which is fixing an issue I saw with eMMC.

Thanks,

C.

#4 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 10 lines · Philippe Mathieu-Daudé
Quoted 5 lines · Bin Meng
Quoted 2 lines · Cédric Le Goater

The number of blocks is defined in the lower bits [15:0]

I checked the physical spec v8.00 and it says bits [31:0] for CMD23 argument.

Watch out, we only support 1-3:

Yes

Quoted 6 lines
enum SDPhySpecificationVersion {
    SD_PHY_SPECv1_10_VERS     = 1,
    SD_PHY_SPECv2_00_VERS     = 2,
    SD_PHY_SPECv3_01_VERS     = 3,
};

However the physical sepc v8.00 should document any difference between ver 3.0 and ver 8.0 if there are indeed any, but for CMD23 it does not. So it means it's 32-bit since day 1.

To double check, I just downloaded the spec 3.01 and confirmed it's still 32-bit.

Regards,
Bin

#5 lore raw
Quoted 21 lines · Bin Meng
Quoted 10 lines · Philippe Mathieu-Daudé
Quoted 5 lines · Bin Meng
Quoted 2 lines · Cédric Le Goater

The number of blocks is defined in the lower bits [15:0]

I checked the physical spec v8.00 and it says bits [31:0] for CMD23 argument.

Watch out, we only support 1-3:

Yes

Quoted 6 lines
enum SDPhySpecificationVersion {
    SD_PHY_SPECv1_10_VERS     = 1,
    SD_PHY_SPECv2_00_VERS     = 2,
    SD_PHY_SPECv3_01_VERS     = 3,
};
Quoted 6 lines

However the physical sepc v8.00 should document any difference between ver 3.0 and ver 8.0 if there are indeed any, but for CMD23 it does not. So it means it's 32-bit since day 1.

To double check, I just downloaded the spec 3.01 and confirmed it's still 32-bit.

OK, so patch is incorrect then.

Thanks,

Phil.

#6 lore raw
In reply to Bin Meng
Quoted 5 lines · Bin Meng
Quoted 2 lines · Cédric Le Goater

The number of blocks is defined in the lower bits [15:0]

I checked the physical spec v8.00 and it says bits [31:0] for CMD23 argument.

May be that's an eMMC thing. That's what I read from the specs :

[31] Reliable Write Request
[30:16] set to 0
[15:0] number of blocks

Thanks,

C.

#7 lore raw
Quoted 6 lines · Cédric Le Goater
Quoted 4 lines · Bin Meng
Quoted 2 lines · Cédric Le Goater

The number of blocks is defined in the lower bits [15:0]

Quoted 7 lines
Quoted 1 line

I checked the physical spec v8.00 and it says bits [31:0] for CMD23 argument.

May be that's an eMMC thing. That's what I read from the specs :

[31] Reliable Write Request
[30:16] set to 0
[15:0] number of blocks

I don't think we ever claimed eMMC support in QEMU. Did we?

Regards,
Bin

#8 lore raw
Quoted 9 lines · Bin Meng
Quoted 8 lines · Cédric Le Goater
Quoted 5 lines · Bin Meng
Quoted 2 lines · Cédric Le Goater

The number of blocks is defined in the lower bits [15:0]

I checked the physical spec v8.00 and it says bits [31:0] for CMD23 argument.

Quoted 7 lines
Quoted 5 lines

May be that's an eMMC thing. That's what I read from the specs :

[31] Reliable Write Request
[30:16] set to 0
[15:0] number of blocks

I don't think we ever claimed eMMC support in QEMU. Did we?

Is that a question ?

C.