Skip to content

Commit 4af59a8

Browse files
martinetdstorulf
authored andcommitted
mmc: core: Fix switch on gp3 partition
Commit e7794c1 ("mmc: rpmb: fixes pause retune on all RPMB partitions.") added a mask check for 'part_type', but the mask used was wrong leading to the code intended for rpmb also being executed for GP3. On some MMCs (but not all) this would make gp3 partition inaccessible: armadillo:~# head -c 1 < /dev/mmcblk2gp3 head: standard input: I/O error armadillo:~# dmesg -c [ 422.976583] mmc2: running CQE recovery [ 423.058182] mmc2: running CQE recovery [ 423.137607] mmc2: running CQE recovery [ 423.137802] blk_update_request: I/O error, dev mmcblk2gp3, sector 0 op 0x0:(READ) flags 0x80700 phys_seg 4 prio class 0 [ 423.237125] mmc2: running CQE recovery [ 423.318206] mmc2: running CQE recovery [ 423.397680] mmc2: running CQE recovery [ 423.397837] blk_update_request: I/O error, dev mmcblk2gp3, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0 [ 423.408287] Buffer I/O error on dev mmcblk2gp3, logical block 0, async page read the part_type values of interest here are defined as follow: main 0 boot0 1 boot1 2 rpmb 3 gp0 4 gp1 5 gp2 6 gp3 7 so mask with EXT_CSD_PART_CONFIG_ACC_MASK (7) to correctly identify rpmb Fixes: e7794c1 ("mmc: rpmb: fixes pause retune on all RPMB partitions.") Cc: [email protected] Cc: Jorge Ramirez-Ortiz <[email protected]> Signed-off-by: Dominique Martinet <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]>
1 parent e8d1b41 commit 4af59a8

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/mmc/core/block.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -874,10 +874,11 @@ static const struct block_device_operations mmc_bdops = {
874874
static int mmc_blk_part_switch_pre(struct mmc_card *card,
875875
unsigned int part_type)
876876
{
877-
const unsigned int mask = EXT_CSD_PART_CONFIG_ACC_RPMB;
877+
const unsigned int mask = EXT_CSD_PART_CONFIG_ACC_MASK;
878+
const unsigned int rpmb = EXT_CSD_PART_CONFIG_ACC_RPMB;
878879
int ret = 0;
879880

880-
if ((part_type & mask) == mask) {
881+
if ((part_type & mask) == rpmb) {
881882
if (card->ext_csd.cmdq_en) {
882883
ret = mmc_cmdq_disable(card);
883884
if (ret)
@@ -892,10 +893,11 @@ static int mmc_blk_part_switch_pre(struct mmc_card *card,
892893
static int mmc_blk_part_switch_post(struct mmc_card *card,
893894
unsigned int part_type)
894895
{
895-
const unsigned int mask = EXT_CSD_PART_CONFIG_ACC_RPMB;
896+
const unsigned int mask = EXT_CSD_PART_CONFIG_ACC_MASK;
897+
const unsigned int rpmb = EXT_CSD_PART_CONFIG_ACC_RPMB;
896898
int ret = 0;
897899

898-
if ((part_type & mask) == mask) {
900+
if ((part_type & mask) == rpmb) {
899901
mmc_retune_unpause(card->host);
900902
if (card->reenable_cmdq && !card->ext_csd.cmdq_en)
901903
ret = mmc_cmdq_enable(card);

0 commit comments

Comments
 (0)