diff options
author | Andres Rodriguez <andresx7@gmail.com> | 2022-11-08 17:32:25 -0500 |
---|---|---|
committer | Cristian Ciocaltea <cristian.ciocaltea@collabora.com> | 2023-09-11 23:31:24 +0300 |
commit | b049538b926da3c157cc204234a6d30de477316b (patch) | |
tree | 4f90f9ba65e872acf39f1d03458274dfadd8def5 | |
parent | 702cde8d6a95a9b5f7be4d54f5222ae142d33b9e (diff) | |
download | linux-b049538b926da3c157cc204234a6d30de477316b.tar.gz |
mmc: core: add safe_trim_quirk attribute
This attribute is intended to be used by userspace tools to identify if trimming a device is safe or not. It helps in cases where a userspace tool is aware of the necessity of the quirk and a user accidentally downgrades their kernel to a one that doesn't have support for the quirk. Signed-off-by: Andres Rodriguez <andresx7@gmail.com> (cherry picked from commit dfc5952c55f58d0e0863ccba0aa598fdae16ed14) Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
-rw-r--r-- | drivers/mmc/core/mmc.c | 2 | ||||
-rw-r--r-- | drivers/mmc/core/quirks.h | 2 | ||||
-rw-r--r-- | drivers/mmc/core/sd.c | 2 | ||||
-rw-r--r-- | include/linux/mmc/card.h | 1 |
4 files changed, 7 insertions, 0 deletions
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 89cd48fcec79..d11ddcae86ed 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -813,6 +813,7 @@ MMC_DEV_ATTR(rel_sectors, "%#x\n", card->ext_csd.rel_sectors); MMC_DEV_ATTR(ocr, "0x%08x\n", card->ocr); MMC_DEV_ATTR(rca, "0x%04x\n", card->rca); MMC_DEV_ATTR(cmdq_en, "%d\n", card->ext_csd.cmdq_en); +MMC_DEV_ATTR(safe_trim_quirk, "%d\n", card->safe_trim_quirk_version); static ssize_t mmc_fwrev_show(struct device *dev, struct device_attribute *attr, @@ -871,6 +872,7 @@ static struct attribute *mmc_std_attrs[] = { &dev_attr_rca.attr, &dev_attr_dsr.attr, &dev_attr_cmdq_en.attr, + &dev_attr_safe_trim_quirk.attr, NULL, }; ATTRIBUTE_GROUPS(mmc_std); diff --git a/drivers/mmc/core/quirks.h b/drivers/mmc/core/quirks.h index 857315f185fc..4503d644d71e 100644 --- a/drivers/mmc/core/quirks.h +++ b/drivers/mmc/core/quirks.h @@ -240,4 +240,6 @@ static inline void mmc_fixup_device(struct mmc_card *card, dev_dbg(&card->dev, "calling %ps\n", f->vendor_fixup); f->vendor_fixup(card, f->data); } + + card->safe_trim_quirk_version = 1; } diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index 246ce027ae0a..1d79294e6577 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -714,6 +714,7 @@ MMC_DEV_ATTR(oemid, "0x%04x\n", card->cid.oemid); MMC_DEV_ATTR(serial, "0x%08x\n", card->cid.serial); MMC_DEV_ATTR(ocr, "0x%08x\n", card->ocr); MMC_DEV_ATTR(rca, "0x%04x\n", card->rca); +MMC_DEV_ATTR(safe_trim_quirk, "%d\n", card->safe_trim_quirk_version); static ssize_t mmc_dsr_show(struct device *dev, struct device_attribute *attr, @@ -776,6 +777,7 @@ static struct attribute *sd_std_attrs[] = { &dev_attr_ocr.attr, &dev_attr_rca.attr, &dev_attr_dsr.attr, + &dev_attr_safe_trim_quirk.attr, NULL, }; diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h index daa2f40d9ce6..6b7cb137def8 100644 --- a/include/linux/mmc/card.h +++ b/include/linux/mmc/card.h @@ -277,6 +277,7 @@ struct mmc_card { unsigned int state; /* (our) card state */ unsigned int quirks; /* card quirks */ unsigned int quirk_max_rate; /* max rate set by quirks */ + unsigned int safe_trim_quirk_version; /* advertise if we have protection for cards which misbehave with trim */ #define MMC_QUIRK_LENIENT_FN0 (1<<0) /* allow SDIO FN0 writes outside of the VS CCCR range */ #define MMC_QUIRK_BLKSZ_FOR_BYTE_MODE (1<<1) /* use func->cur_blksize */ /* for byte mode */ |