Skip to contentSkip to conversation

mmc: block: Disable CMDQ on the ioctl path

PATCH In review Bean Huo 3 participants 3 messages May 4, 2021 – May 11, 2021 MMC, SD and SDIO

lore
Share & tools
lore

Bean Huo

author
#0 lore raw

PATCH 1/1 mmc: block: Disable CMDQ on the ioctl path

From: Bean Huo <[email protected]>

According to the eMMC Spec:
"When command queuing is enabled (CMDQ Mode En bit in CMDQ_MODE_EN field is set to ‘1’) class 11 commands are the only method through which data transfer tasks can be issued. Existing data transfer commands, namely CMD18/CMD17 and CMD25/CMD24, are not supported when command queuing is enabled."
which means if CMDQ is enabled, the FFU commands will not be supported. To fix this issue, just simply disable CMDQ on the ioctl path, and re-enable CMDQ once ioctl request is completed.

---
 drivers/mmc/core/block.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/mmc/core/block.c +7 -0
index 689eb9afeeed..21fb99883b1e 100644
@@ -1004,6 +1004,11 @@ static void mmc_blk_issue_drv_op(struct mmc_queue *mq, struct request *req)
 
 	switch (mq_rq->drv_op) {
 	case MMC_DRV_OP_IOCTL:
+		if (card->ext_csd.cmdq_en) {
+			ret = mmc_cmdq_disable(card);
+			if (ret)
+				break;
+		}
 	case MMC_DRV_OP_IOCTL_RPMB:
 		idata = mq_rq->drv_op_data;
 		for (i = 0, ret = 0; i < mq_rq->ioc_count; i++) {
@@ -1014,6 +1019,8 @@ static void mmc_blk_issue_drv_op(struct mmc_queue *mq, struct request *req)
 		/* Always switch back to main area after RPMB access */
 		if (rpmb_ioctl)
 			mmc_blk_part_switch(card, 0);
+		else if (card->reenable_cmdq && !card->ext_csd.cmdq_en)
+			mmc_cmdq_enable(card);
 		break;
 	case MMC_DRV_OP_BOOT_WP:
 		ret = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BOOT_WP,
Signature · 1 line
2.25.1
Acked-by on v1 1/1
#1 lore raw
Quoted 12 lines · Bean Huo

From: Bean Huo <[email protected]>

According to the eMMC Spec:
"When command queuing is enabled (CMDQ Mode En bit in CMDQ_MODE_EN field is set to ‘1’) class 11 commands are the only method through which data transfer tasks can be issued. Existing data transfer commands, namely CMD18/CMD17 and CMD25/CMD24, are not supported when command queuing is enabled."
which means if CMDQ is enabled, the FFU commands will not be supported. To fix this issue, just simply disable CMDQ on the ioctl path, and re-enable CMDQ once ioctl request is completed.

Quoted 2 lines
Quoted 30 lines
---
 drivers/mmc/core/block.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/mmc/core/block.c +7 -0
index 689eb9afeeed..21fb99883b1e 100644
@@ -1004,6 +1004,11 @@ static void mmc_blk_issue_drv_op(struct mmc_queue *mq, struct request *req)
 
 	switch (mq_rq->drv_op) {
 	case MMC_DRV_OP_IOCTL:
+		if (card->ext_csd.cmdq_en) {
+			ret = mmc_cmdq_disable(card);
+			if (ret)
+				break;
+		}
 	case MMC_DRV_OP_IOCTL_RPMB:
 		idata = mq_rq->drv_op_data;
 		for (i = 0, ret = 0; i < mq_rq->ioc_count; i++) {
@@ -1014,6 +1019,8 @@ static void mmc_blk_issue_drv_op(struct mmc_queue *mq, struct request *req)
 		/* Always switch back to main area after RPMB access */
 		if (rpmb_ioctl)
 			mmc_blk_part_switch(card, 0);
+		else if (card->reenable_cmdq && !card->ext_csd.cmdq_en)
+			mmc_cmdq_enable(card);
 		break;
 	case MMC_DRV_OP_BOOT_WP:
 		ret = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BOOT_WP,
#2 lore raw
In reply to Bean Huo
Quoted 13 lines · Bean Huo

From: Bean Huo <[email protected]>

According to the eMMC Spec:
"When command queuing is enabled (CMDQ Mode En bit in CMDQ_MODE_EN field is set to ‘1’) class 11 commands are the only method through which data transfer tasks can be issued. Existing data transfer commands, namely CMD18/CMD17 and CMD25/CMD24, are not supported when command queuing is enabled."
which means if CMDQ is enabled, the FFU commands will not be supported. To fix this issue, just simply disable CMDQ on the ioctl path, and re-enable CMDQ once ioctl request is completed.

Quoted 2 lines

Applied for next and by adding a fixes/stable tag, thanks!

Kind regards
Uffe

Quoted 9 lines
---
 drivers/mmc/core/block.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/mmc/core/block.c +0 -0
index 689eb9afeeed..21fb99883b1e 100644

drivers/mmc/core/block.c static void mmc_blk_issue_drv_op(struct mmc_queue *mq, struct request *req) · line 1011

Quoted 8 lines
drivers/mmc/core/block.c +5 -0
@@ -1004,6 +1004,11 @@ static void mmc_blk_issue_drv_op(struct mmc_queue *mq, struct request *req)
 
        switch (mq_rq->drv_op) {
        case MMC_DRV_OP_IOCTL:
+               if (card->ext_csd.cmdq_en) {
+                       ret = mmc_cmdq_disable(card);
+                       if (ret)
+                               break;
+               }

This should have a "fallthrough;" statement. No need for a respin, I have amended the change this time.

Quoted 13 lines
drivers/mmc/core/block.c +2 -1
        case MMC_DRV_OP_IOCTL_RPMB:
                idata = mq_rq->drv_op_data;
                for (i = 0, ret = 0; i < mq_rq->ioc_count; i++) {
@@ -1014,6 +1019,8 @@ static void mmc_blk_issue_drv_op(struct mmc_queue *mq, struct request *req)
                /* Always switch back to main area after RPMB access */
                if (rpmb_ioctl)
                        mmc_blk_part_switch(card, 0);
+               else if (card->reenable_cmdq && !card->ext_csd.cmdq_en)
+                       mmc_cmdq_enable(card);
                break;
        case MMC_DRV_OP_BOOT_WP:
                ret = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BOOT_WP,
--
Quoted 2 lines

2.25.1

Kind regards
Uffe