mmc: rpmb: fixes pause retune on all RPMB partitions.
PATCH 1/1 mmc: rpmb: fixes pause retune on all RPMB partitions.
When RPMB was converted to a character device, it added support for multiple RPMB partitions (Commit 97548575bef3 ("mmc: block: Convert RPMB to a character device").
One of the changes in this commit was transforming the variable target_part defined in __mmc_blk_ioctl_cmd into a bitmask.
This inadvertedly regressed the validation check done in mmc_blk_part_switch_pre() and mmc_blk_part_switch_post().
This commit fixes that regression.
--- drivers/mmc/core/block.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/mmc/core/block.c +4 -2
@@ -851,9 +851,10 @@ static const struct block_device_operations mmc_bdops = {static int mmc_blk_part_switch_pre (struct mmc_card *card,unsigned int part_type) { +const unsigned int mask =EXT_CSD_PART_CONFIG_ACC_RPMB ;int ret =0 ; -if (part_type ==EXT_CSD_PART_CONFIG_ACC_RPMB ) { +if (part_type & mask == mask) {if (card->ext_csd.cmdq_en) { ret =mmc_cmdq_disable (card);if (ret)
@@ -868,9 +869,10 @@ static int mmc_blk_part_switch_pre(struct mmc_card *card,static int mmc_blk_part_switch_post (struct mmc_card *card,unsigned int part_type) { +const unsigned int mask =EXT_CSD_PART_CONFIG_ACC_RPMB ;int ret =0 ; -if (part_type ==EXT_CSD_PART_CONFIG_ACC_RPMB ) { +if (part_type & mask == mask) {mmc_retune_unpause (card->host);if (card->reenable_cmdq && !card->ext_csd.cmdq_en) ret =mmc_cmdq_enable (card);
--
2.34.1
Hi Jorge,
thanks for your patch!
Quoted 7 lines · Jorge Ramirez-Ortiz
When RPMB was converted to a character device, it added support for multiple RPMB partitions (Commit
97548575bef3("mmc: block: Convert RPMB to a character device").One of the changes in this commit was transforming the variable
target_partdefined in__mmc_blk_ioctl_cmdinto a bitmask.
Quoted 7 lines
This inadvertedly regressed the validation check done in
mmc_blk_part_switch_pre()andmmc_blk_part_switch_post().This commit fixes that regression.
Fixes 97548575bef3 ("mmc: block: Convert RPMB to a character device")Signed-off-by Jorge Ramirez-Ortiz <[email protected]>
My bug :/
Shouldn't we also add Cc: [email protected]?
drivers/mmc/core/block.c static const struct block_device_operations mmc_bdops = { · line 857
Quoted 5 lines
drivers/mmc/core/block.c +2
-1+const unsigned int mask =EXT_CSD_PART_CONFIG_ACC_RPMB ;int ret =0 ; -if (part_type ==EXT_CSD_PART_CONFIG_ACC_RPMB ) { +if (part_type & mask == mask) {
That looks complex, can't we just:
if (part_type & EXT_CSD_PART_CONFIG_ACC_RPMB)?
drivers/mmc/core/block.c static const struct block_device_operations mmc_bdops = { · line 857
Quoted 5 lines
drivers/mmc/core/block.c +2
-1+const unsigned int mask =EXT_CSD_PART_CONFIG_ACC_RPMB ;int ret =0 ; -if (part_type ==EXT_CSD_PART_CONFIG_ACC_RPMB ) { +if (part_type & mask == mask) {
Dito here.
Yours,
Linus Walleij
Quoted 16 lines · Linus Walleij
Hi Jorge,
thanks for your patch!
Quoted 10 lines · Jorge Ramirez-Ortiz
When RPMB was converted to a character device, it added support for multiple RPMB partitions (Commit
97548575bef3("mmc: block: Convert RPMB to a character device").One of the changes in this commit was transforming the variable
target_partdefined in__mmc_blk_ioctl_cmdinto a bitmask.This inadvertedly regressed the validation check done in
mmc_blk_part_switch_pre()andmmc_blk_part_switch_post().
Quoted 7 lines
Quoted 4 lines
This commit fixes that regression.
Fixes 97548575bef3 ("mmc: block: Convert RPMB to a character device")Signed-off-by Jorge Ramirez-Ortiz <[email protected]>My bug :/
Shouldn't we also add Cc: [email protected]?
ack, will do.
Quoted 11 lines
drivers/mmc/core/block.c static const struct block_device_operations mmc_bdops = { · line 857
Quoted 7 lines
drivers/mmc/core/block.c +2
-1+const unsigned int mask =EXT_CSD_PART_CONFIG_ACC_RPMB ;int ret =0 ; -if (part_type ==EXT_CSD_PART_CONFIG_ACC_RPMB ) { +if (part_type & mask == mask) {That looks complex, can't we just:
if (
part_type&EXT_CSD_PART_CONFIG_ACC_RPMB)?
I chose to mention the mask nature of the field for clarity - just in case - but I'd much rather do your suggestion. So will do :)
Quoted 8 lines
drivers/mmc/core/block.c static const struct block_device_operations mmc_bdops = { · line 857
Quoted 6 lines
drivers/mmc/core/block.c +2
-1+const unsigned int mask =EXT_CSD_PART_CONFIG_ACC_RPMB ;int ret =0 ; -if (part_type ==EXT_CSD_PART_CONFIG_ACC_RPMB ) { +if (part_type & mask == mask) {Dito here.
yep
Quoted 3 lines
Yours,
Linus Walleij
thanks !
A message that is not in the archive (sent off-list or not yet received): CAJ1nHOW9T3yvFj5FFdOZYrdgfy0f=opiDri+2srE=yBp5vtVZw@mail.gmail.com
Quoted 14 lines · Jorge Ramirez
Quoted 13 lines · Foundries
Quoted 9 lines · Linus Walleij
drivers/mmc/core/block.c static const struct block_device_operations mmc_bdops = { · line 857
Quoted 5 lines
drivers/mmc/core/block.c +2
-1+const unsigned int mask =EXT_CSD_PART_CONFIG_ACC_RPMB ;int ret =0 ; -if (part_type ==EXT_CSD_PART_CONFIG_ACC_RPMB ) { +if (part_type & mask == mask) {That looks complex, can't we just:
if (
part_type&EXT_CSD_PART_CONFIG_ACC_RPMB)?
Quoted 8 lines
Quoted 2 lines
I chose to mention the mask nature of the field for clarity - just in case - but I'd much rather do your suggestion. So will do :)
sorry no, I mispoke (I like clean code so yours looked neat) we have to compare against
EXT_CSD_PART_CONFIG_ACC_RPMBbitfield sincepart_typecould beEXT_CSD_PART_CONFIG_ACC_BOOT0(0x1) in which case we have to skip it.
Aha those defines are not flags but enumerators. I get it.
Yours,
Linus Walleij