diff options
Diffstat (limited to 'recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.17/0007-mmc-fixes-for-eMMC-v4.5-sanitize-operation.patch')
-rw-r--r-- | recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.17/0007-mmc-fixes-for-eMMC-v4.5-sanitize-operation.patch | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.17/0007-mmc-fixes-for-eMMC-v4.5-sanitize-operation.patch b/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.17/0007-mmc-fixes-for-eMMC-v4.5-sanitize-operation.patch new file mode 100644 index 00000000..602f2932 --- /dev/null +++ b/recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.17/0007-mmc-fixes-for-eMMC-v4.5-sanitize-operation.patch | |||
@@ -0,0 +1,136 @@ | |||
1 | From 6e1972f1214d5827d22d15985bb50d1e05307e7e Mon Sep 17 00:00:00 2001 | ||
2 | From: Adrian Hunter <adrian.hunter@intel.com> | ||
3 | Date: Thu, 5 Apr 2012 14:45:48 +0300 | ||
4 | Subject: [PATCH 007/165] mmc: fixes for eMMC v4.5 sanitize operation | ||
5 | |||
6 | commit 283028122db37621b124f079ca8eae5b64807ad4 upstream. | ||
7 | |||
8 | eMMC v4.5 sanitize operation erases all copies of unmapped | ||
9 | data. However trim or erase operations must be used first | ||
10 | to unmap the required sectors. That was not being done. | ||
11 | |||
12 | Fixes apply to linux 3.2 on. | ||
13 | |||
14 | Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> | ||
15 | Acked-by: Jaehoon Chung <jh80.chung@samsung.com> | ||
16 | Acked-by: Linus Walleij <linus.walleij@linaro.org> | ||
17 | Signed-off-by: Chris Ball <cjb@laptop.org> | ||
18 | Signed-off-by: Ben Hutchings <ben@decadent.org.uk> | ||
19 | --- | ||
20 | drivers/mmc/card/block.c | 54 ++++++++++++++++++++++++++++++++------------- | ||
21 | drivers/mmc/core/core.c | 2 + | ||
22 | 2 files changed, 40 insertions(+), 16 deletions(-) | ||
23 | |||
24 | diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c | ||
25 | index 60e8951..6679c4f 100644 | ||
26 | --- a/drivers/mmc/card/block.c | ||
27 | +++ b/drivers/mmc/card/block.c | ||
28 | @@ -799,7 +799,7 @@ static int mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq, | ||
29 | { | ||
30 | struct mmc_blk_data *md = mq->data; | ||
31 | struct mmc_card *card = md->queue.card; | ||
32 | - unsigned int from, nr, arg; | ||
33 | + unsigned int from, nr, arg, trim_arg, erase_arg; | ||
34 | int err = 0, type = MMC_BLK_SECDISCARD; | ||
35 | |||
36 | if (!(mmc_can_secure_erase_trim(card) || mmc_can_sanitize(card))) { | ||
37 | @@ -807,20 +807,26 @@ static int mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq, | ||
38 | goto out; | ||
39 | } | ||
40 | |||
41 | + from = blk_rq_pos(req); | ||
42 | + nr = blk_rq_sectors(req); | ||
43 | + | ||
44 | /* The sanitize operation is supported at v4.5 only */ | ||
45 | if (mmc_can_sanitize(card)) { | ||
46 | - err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, | ||
47 | - EXT_CSD_SANITIZE_START, 1, 0); | ||
48 | - goto out; | ||
49 | + erase_arg = MMC_ERASE_ARG; | ||
50 | + trim_arg = MMC_TRIM_ARG; | ||
51 | + } else { | ||
52 | + erase_arg = MMC_SECURE_ERASE_ARG; | ||
53 | + trim_arg = MMC_SECURE_TRIM1_ARG; | ||
54 | } | ||
55 | |||
56 | - from = blk_rq_pos(req); | ||
57 | - nr = blk_rq_sectors(req); | ||
58 | - | ||
59 | - if (mmc_can_trim(card) && !mmc_erase_group_aligned(card, from, nr)) | ||
60 | - arg = MMC_SECURE_TRIM1_ARG; | ||
61 | - else | ||
62 | - arg = MMC_SECURE_ERASE_ARG; | ||
63 | + if (mmc_erase_group_aligned(card, from, nr)) | ||
64 | + arg = erase_arg; | ||
65 | + else if (mmc_can_trim(card)) | ||
66 | + arg = trim_arg; | ||
67 | + else { | ||
68 | + err = -EINVAL; | ||
69 | + goto out; | ||
70 | + } | ||
71 | retry: | ||
72 | if (card->quirks & MMC_QUIRK_INAND_CMD38) { | ||
73 | err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, | ||
74 | @@ -830,25 +836,41 @@ retry: | ||
75 | INAND_CMD38_ARG_SECERASE, | ||
76 | 0); | ||
77 | if (err) | ||
78 | - goto out; | ||
79 | + goto out_retry; | ||
80 | } | ||
81 | + | ||
82 | err = mmc_erase(card, from, nr, arg); | ||
83 | - if (!err && arg == MMC_SECURE_TRIM1_ARG) { | ||
84 | + if (err == -EIO) | ||
85 | + goto out_retry; | ||
86 | + if (err) | ||
87 | + goto out; | ||
88 | + | ||
89 | + if (arg == MMC_SECURE_TRIM1_ARG) { | ||
90 | if (card->quirks & MMC_QUIRK_INAND_CMD38) { | ||
91 | err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, | ||
92 | INAND_CMD38_ARG_EXT_CSD, | ||
93 | INAND_CMD38_ARG_SECTRIM2, | ||
94 | 0); | ||
95 | if (err) | ||
96 | - goto out; | ||
97 | + goto out_retry; | ||
98 | } | ||
99 | + | ||
100 | err = mmc_erase(card, from, nr, MMC_SECURE_TRIM2_ARG); | ||
101 | + if (err == -EIO) | ||
102 | + goto out_retry; | ||
103 | + if (err) | ||
104 | + goto out; | ||
105 | } | ||
106 | -out: | ||
107 | - if (err == -EIO && !mmc_blk_reset(md, card->host, type)) | ||
108 | + | ||
109 | + if (mmc_can_sanitize(card)) | ||
110 | + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, | ||
111 | + EXT_CSD_SANITIZE_START, 1, 0); | ||
112 | +out_retry: | ||
113 | + if (err && !mmc_blk_reset(md, card->host, type)) | ||
114 | goto retry; | ||
115 | if (!err) | ||
116 | mmc_blk_reset_success(md, type); | ||
117 | +out: | ||
118 | spin_lock_irq(&md->lock); | ||
119 | __blk_end_request(req, err, blk_rq_bytes(req)); | ||
120 | spin_unlock_irq(&md->lock); | ||
121 | diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c | ||
122 | index c420a9e..411a994 100644 | ||
123 | --- a/drivers/mmc/core/core.c | ||
124 | +++ b/drivers/mmc/core/core.c | ||
125 | @@ -1809,6 +1809,8 @@ EXPORT_SYMBOL(mmc_can_discard); | ||
126 | |||
127 | int mmc_can_sanitize(struct mmc_card *card) | ||
128 | { | ||
129 | + if (!mmc_can_trim(card) && !mmc_can_erase(card)) | ||
130 | + return 0; | ||
131 | if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_SANITIZE) | ||
132 | return 1; | ||
133 | return 0; | ||
134 | -- | ||
135 | 1.7.7.6 | ||
136 | |||