Linux kernel: 4.1.15 (imx_4.1.15_1.0.0_ga branch) I've noticed that writing to the boot partition is overwritten by RPMB related functions as it stores this byte (card->ext_csd.part_conf). It is necessary to update this reference when issuing CMD6 SWITCH through ioctl. See below patch for above kernel version: diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index be776fa..cbd0533 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -60,7 +60,9 @@ MODULE_ALIAS("mmc:block"); #define INAND_CMD38_ARG_SECTRIM2 0x88 #define MMC_BLK_TIMEOUT_MS (10 * 60 * 1000) /* 10 minute timeout */ #define MMC_SANITIZE_REQ_TIMEOUT 240000 -#define MMC_EXTRACT_INDEX_FROM_ARG(x) ((x & 0x00FF0000) >> 16) +#define MMC_EXTRACT_SWITCH_MODE_FROM_ARG(x) (((x) & 0x03000000) >> 24) +#define MMC_EXTRACT_INDEX_FROM_ARG(x) (((x) & 0x00FF0000) >> 16) +#define MMC_EXTRACT_VALUE_FROM_ARG(x) (((x) & 0x0000FF00) >> 8) #define mmc_req_rel_wr(req) (((req->cmd_flags & REQ_FUA) || \ (req->cmd_flags & REQ_META)) && \ @@ -572,6 +574,24 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev, goto cmd_rel_host; } + /* If writing part config register, update struct */ + if ((MMC_EXTRACT_INDEX_FROM_ARG(cmd.arg) == EXT_CSD_PART_CONFIG) && + (cmd.opcode == MMC_SWITCH)) { + u8 mode = MMC_EXTRACT_SWITCH_MODE_FROM_ARG(cmd.arg); + u8 value = MMC_EXTRACT_VALUE_FROM_ARG(cmd.arg); + switch (mode) { + case MMC_SWITCH_MODE_SET_BITS: + card->ext_csd.part_config |= value; + break; + case MMC_SWITCH_MODE_CLEAR_BITS: + card->ext_csd.part_config &= ~value; + break; + case MMC_SWITCH_MODE_WRITE_BYTE: + card->ext_csd.part_config = value; + break; + } + } + /* * According to the SD specs, some commands require a delay after * issuing the command. ________________________________ ________________________________ Please be advised that this email may contain confidential information. If you are not the intended recipient, please notify us by email by replying to the sender and delete this message. The sender disclaims that the content of this email constitutes an offer to enter into, or the acceptance of, any agreement; provided that the foregoing does not invalidate the binding effect of any digital or other electronic reproduction of a manual signature that is included in any attachment. -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html