]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-5.10/mmc-core-fix-switch-on-gp3-partition.patch
5.10-stable patches
[thirdparty/kernel/stable-queue.git] / queue-5.10 / mmc-core-fix-switch-on-gp3-partition.patch
1 From 97952ccb21447f4a11ddb26e4a44593f2c403bbe Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Wed, 6 Mar 2024 10:44:38 +0900
4 Subject: mmc: core: Fix switch on gp3 partition
5
6 From: Dominique Martinet <dominique.martinet@atmark-techno.com>
7
8 [ Upstream commit 4af59a8df5ea930038cd3355e822f5eedf4accc1 ]
9
10 Commit e7794c14fd73 ("mmc: rpmb: fixes pause retune on all RPMB
11 partitions.") added a mask check for 'part_type', but the mask used was
12 wrong leading to the code intended for rpmb also being executed for GP3.
13
14 On some MMCs (but not all) this would make gp3 partition inaccessible:
15 armadillo:~# head -c 1 < /dev/mmcblk2gp3
16 head: standard input: I/O error
17 armadillo:~# dmesg -c
18 [ 422.976583] mmc2: running CQE recovery
19 [ 423.058182] mmc2: running CQE recovery
20 [ 423.137607] mmc2: running CQE recovery
21 [ 423.137802] blk_update_request: I/O error, dev mmcblk2gp3, sector 0 op 0x0:(READ) flags 0x80700 phys_seg 4 prio class 0
22 [ 423.237125] mmc2: running CQE recovery
23 [ 423.318206] mmc2: running CQE recovery
24 [ 423.397680] mmc2: running CQE recovery
25 [ 423.397837] blk_update_request: I/O error, dev mmcblk2gp3, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0
26 [ 423.408287] Buffer I/O error on dev mmcblk2gp3, logical block 0, async page read
27
28 the part_type values of interest here are defined as follow:
29 main 0
30 boot0 1
31 boot1 2
32 rpmb 3
33 gp0 4
34 gp1 5
35 gp2 6
36 gp3 7
37
38 so mask with EXT_CSD_PART_CONFIG_ACC_MASK (7) to correctly identify rpmb
39
40 Fixes: e7794c14fd73 ("mmc: rpmb: fixes pause retune on all RPMB partitions.")
41 Cc: stable@vger.kernel.org
42 Cc: Jorge Ramirez-Ortiz <jorge@foundries.io>
43 Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
44 Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
45 Link: https://lore.kernel.org/r/20240306-mmc-partswitch-v1-1-bf116985d950@codewreck.org
46 Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
47 Signed-off-by: Sasha Levin <sashal@kernel.org>
48 ---
49 drivers/mmc/core/block.c | 10 ++++++----
50 1 file changed, 6 insertions(+), 4 deletions(-)
51
52 diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
53 index 2058f31a1bce6..d826a1bb39f2c 100644
54 --- a/drivers/mmc/core/block.c
55 +++ b/drivers/mmc/core/block.c
56 @@ -823,10 +823,11 @@ static const struct block_device_operations mmc_bdops = {
57 static int mmc_blk_part_switch_pre(struct mmc_card *card,
58 unsigned int part_type)
59 {
60 - const unsigned int mask = EXT_CSD_PART_CONFIG_ACC_RPMB;
61 + const unsigned int mask = EXT_CSD_PART_CONFIG_ACC_MASK;
62 + const unsigned int rpmb = EXT_CSD_PART_CONFIG_ACC_RPMB;
63 int ret = 0;
64
65 - if ((part_type & mask) == mask) {
66 + if ((part_type & mask) == rpmb) {
67 if (card->ext_csd.cmdq_en) {
68 ret = mmc_cmdq_disable(card);
69 if (ret)
70 @@ -841,10 +842,11 @@ static int mmc_blk_part_switch_pre(struct mmc_card *card,
71 static int mmc_blk_part_switch_post(struct mmc_card *card,
72 unsigned int part_type)
73 {
74 - const unsigned int mask = EXT_CSD_PART_CONFIG_ACC_RPMB;
75 + const unsigned int mask = EXT_CSD_PART_CONFIG_ACC_MASK;
76 + const unsigned int rpmb = EXT_CSD_PART_CONFIG_ACC_RPMB;
77 int ret = 0;
78
79 - if ((part_type & mask) == mask) {
80 + if ((part_type & mask) == rpmb) {
81 mmc_retune_unpause(card->host);
82 if (card->reenable_cmdq && !card->ext_csd.cmdq_en)
83 ret = mmc_cmdq_enable(card);
84 --
85 2.43.0
86