@@ -28,6 +28,7 @@
#define DEFAULT_CMD6_TIMEOUT_MS 500
#define MIN_CACHE_EN_TIMEOUT_MS 1600
+#define MMC_SANITIZE_TIMEOUT_MS (240 * 1000) /* 240s */
static const unsigned int tran_exp[] = {
10000, 100000, 1000000, 10000000,
@@ -835,6 +836,36 @@ static ssize_t mmc_dsr_show(struct device *dev,
static DEVICE_ATTR(dsr, S_IRUGO, mmc_dsr_show, NULL);
+static ssize_t sanitize_timeout_ms_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct mmc_card *card = mmc_dev_to_card(dev);
+ return sysfs_emit(buf, "%d\n", card->sanitize_timeout_ms);
+}
+
+static ssize_t sanitize_timeout_ms_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t len)
+{
+ struct mmc_card *card = mmc_dev_to_card(dev);
+ unsigned int new;
+ int ret;
+
+ ret = kstrtouint(buf, 0, &new);
+ if (ret < 0)
+ return ret;
+
+ if (new == 0)
+ return -EINVAL;
+
+ card->sanitize_timeout_ms = new;
+
+ return len;
+}
+static DEVICE_ATTR_RW(sanitize_timeout_ms);
+
+
static struct attribute *mmc_std_attrs[] = {
&dev_attr_cid.attr,
&dev_attr_csd.attr,
@@ -861,6 +892,7 @@ static struct attribute *mmc_std_attrs[] = {
&dev_attr_rca.attr,
&dev_attr_dsr.attr,
&dev_attr_cmdq_en.attr,
+ &dev_attr_sanitize_timeout_ms.attr,
NULL,
};
ATTRIBUTE_GROUPS(mmc_std);
@@ -1623,6 +1655,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
card->ocr = ocr;
card->type = MMC_TYPE_MMC;
card->rca = 1;
+ card->sanitize_timeout_ms = MMC_SANITIZE_TIMEOUT_MS;
memcpy(card->raw_cid, cid, sizeof(card->raw_cid));
}
@@ -21,7 +21,6 @@
#define MMC_BKOPS_TIMEOUT_MS (120 * 1000) /* 120s */
#define MMC_CACHE_FLUSH_TIMEOUT_MS (30 * 1000) /* 30s */
-#define MMC_SANITIZE_TIMEOUT_MS (240 * 1000) /* 240s */
static const u8 tuning_blk_pattern_4bit[] = {
0xff, 0x0f, 0xff, 0x00, 0xff, 0xcc, 0xc3, 0xcc,
@@ -1025,7 +1024,7 @@ int mmc_sanitize(struct mmc_card *card)
mmc_retune_hold(host);
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_SANITIZE_START,
- 1, MMC_SANITIZE_TIMEOUT_MS);
+ 1, card->sanitize_timeout_ms);
if (err)
pr_err("%s: Sanitize failed err=%d\n", mmc_hostname(host), err);
@@ -273,6 +273,7 @@ struct mmc_card {
bool reenable_cmdq; /* Re-enable Command Queue */
+ unsigned int sanitize_timeout_ms;
unsigned int erase_size; /* erase size in sectors */
unsigned int erase_shift; /* if erase unit is power 2 */
unsigned int pref_erase; /* in sectors */