Skip to contentSkip to conversation

MMC_SWITCH command doesn't update the ext_csd data structure

PATCH Dirk Behme 2 participants 3 messages Sep 3, 2013 MMC, SD and SDIO

lore
Share & tools
lore

Dirk Behme

author
#0 lore raw

Hi,

using the MMC_SWITCH command via the ioctl to write registers of the EXT_CSD, it looks to us that in this case the internal ext_csd data structure isn't updated. Resulting in a mismatch of what the ext_csd data structure contains and what's written to the real hardware.

We are using the mmc utils [1] to e.g. enable the bootpart

mmc bootpart enable 1 0 /dev/mmcblk1

This correctly writes to the EXT_CSD structure of the device, but doesn't update

card->ext_csd.part_config

Issuing additional MMC_SWITCH commands afterwards use the then (wrong) card->ext_csd.part_config. Resulting in a undo of the mmc bootpart enable.

What we think might be necessary here is anything like

drivers/mmc/card/block.c +5 -0
@@ -542,11 +544,17 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev,
                                        __func__, status, err);
        }
 
+       if ((cmd.opcode == MMC_SWITCH) && ((cmd.arg >> 24) & 0x3)) {
+               /* In case the IOCTL has modified the EXT_CSD, update it, i.e. re-read the EXT_CSD */
+		mmc_update_ext_csd(card->ext_csd);
+       }
+
 cmd_rel_host:
        mmc_release_host(card->host);
 

?

Opinions?

Best regards

Dirk

[1] https://git.kernel.org/cgit/linux/kernel/git/cjb/mmc-utils.git/

#1 lore raw

Hi,

drivers/mmc/card/block.c static int mmc_blk_ioctl_cmd(struct block_device *bdev, · line 551

Quoted 6 lines · Dirk Behme
(quoted diff) +2 -0
+       if ((cmd.opcode == MMC_SWITCH) && ((cmd.arg >> 24) & 0x3)) {
+               /* In case the IOCTL has modified the EXT_CSD, update

it, i.e. re-read the EXT_CSD */

drivers/mmc/card/block.c +3 -0
+		mmc_update_ext_csd(card->ext_csd);
+       }
+

Your analysis looks good, please go ahead and submit a full patch. Thanks!

- Chris.

Signature · 1 line
Chris Ball   <[email protected]>   <http://printf.net/>
author
#2 lore raw
Quoted 11 lines · Chris Ball

Hi,

drivers/mmc/card/block.c static int mmc_blk_ioctl_cmd(struct block_device *bdev, · line 551

Quoted 6 lines · Dirk Behme
(quoted diff) +2 -0
+       if ((cmd.opcode == MMC_SWITCH) && ((cmd.arg >> 24) & 0x3)) {
+               /* In case the IOCTL has modified the EXT_CSD, update

it, i.e. re-read the EXT_CSD */

drivers/mmc/card/block.c +3 -0
+		mmc_update_ext_csd(card->ext_csd);
+       }
+

Your analysis looks good, please go ahead and submit a full patch.

The issue here is that something like mmc_update_ext_csd() doesn't exist, yet?

So we have to implement a mmc_update_ext_csd() in core/mmc.c and call it from mmc_blk_ioctl_cmd() in card/block.c?

Or any better proposal?

Thanks

Dirk