Skip to content

Commit 73ddacb

Browse files
P33Mpelwell
authored andcommitted
mmc: block: disable CQ on SD cards when doing non-Discard erase
Only CMD38 with Arg=0x1 (Discard) is supported when in CQ mode, so turn it off before issuing a non-discard erase op. Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
1 parent 4d702b5 commit 73ddacb

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

drivers/mmc/core/block.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,12 +1177,26 @@ static void mmc_blk_issue_erase_rq(struct mmc_queue *mq, struct request *req,
11771177
unsigned int from, nr;
11781178
int err = 0;
11791179
blk_status_t status = BLK_STS_OK;
1180+
bool restart_cmdq = false;
11801181

11811182
if (!mmc_can_erase(card)) {
11821183
status = BLK_STS_NOTSUPP;
11831184
goto fail;
11841185
}
11851186

1187+
/*
1188+
* Only Discard ops are supported with SD cards in CQ mode
1189+
* (SD Physical Spec v9.00 4.19.2)
1190+
*/
1191+
if (mmc_card_sd(card) && card->ext_csd.cmdq_en && erase_arg != SD_DISCARD_ARG) {
1192+
restart_cmdq = true;
1193+
err = mmc_sd_cmdq_disable(card);
1194+
if (err) {
1195+
status = BLK_STS_IOERR;
1196+
goto fail;
1197+
}
1198+
}
1199+
11861200
from = blk_rq_pos(req);
11871201
nr = blk_rq_sectors(req);
11881202

@@ -1203,6 +1217,11 @@ static void mmc_blk_issue_erase_rq(struct mmc_queue *mq, struct request *req,
12031217
status = BLK_STS_IOERR;
12041218
else
12051219
mmc_blk_reset_success(md, type);
1220+
1221+
if (restart_cmdq)
1222+
err = mmc_sd_cmdq_enable(card);
1223+
if (err)
1224+
status = BLK_STS_IOERR;
12061225
fail:
12071226
blk_mq_end_request(req, status);
12081227
}

0 commit comments

Comments
 (0)