]> nv-tegra.nvidia Code Review - linux-4.9.git/commitdiff
mmc: host: Add speed class in debugfs
authorAniruddha Rao <anrao@nvidia.com>
Wed, 17 Oct 2018 08:43:57 +0000 (01:43 -0700)
committermobile promotions <svcmobile_promotions@nvidia.com>
Tue, 23 Oct 2018 17:34:17 +0000 (10:34 -0700)
Add support in debugfs to identify speed class of
SD cards.

Bug 2420580

Change-Id: I9f869aa639f5acec80bea5ba56b82974e96a7a91
Signed-off-by: Aniruddha Rao <anrao@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1928864
(cherry picked from commit b4c433d578faff4eb72451a444fd9dfc27489041)
Reviewed-on: https://git-master.nvidia.com/r/1932065
GVS: Gerrit_Virtual_Submit
Reviewed-by: Bibek Basu <bbasu@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
drivers/mmc/core/debugfs.c
drivers/mmc/core/sd.c
include/linux/mmc/card.h

index 88d7f7d1f0229985a26c5602a92f36bebc5f653e..3ceca9e30f95d5d38cbc7ed78c7dcdd2cdeb180a 100644 (file)
@@ -502,6 +502,17 @@ static int mmc_dbg_card_status_get(void *data, u64 *val)
 DEFINE_SIMPLE_ATTRIBUTE(mmc_dbg_card_status_fops, mmc_dbg_card_status_get,
                NULL, "%08llx\n");
 
+static int mmc_dbg_card_speed_class_get(void *data, u64 *val)
+{
+               struct mmc_card *card = data;
+
+                       *val = card->speed_class;
+
+                               return 0;
+}
+DEFINE_SIMPLE_ATTRIBUTE(mmc_dbg_card_speed_class_fops,
+                               mmc_dbg_card_speed_class_get, NULL, "%llu\n");
+
 static int mmc_get_ext_csd_byte_val(struct mmc_card *card, u64 *val,
                unsigned int ext_csd_byte)
 {
@@ -703,6 +714,11 @@ void mmc_add_card_debugfs(struct mmc_card *card)
                        goto err;
        }
 
+       if (mmc_card_sd(card))
+               if (!debugfs_create_file("speed_class", 0400, root, card,
+                                       &mmc_dbg_card_speed_class_fops))
+                       goto err;
+
        return;
 
 err:
index e6a99991d5dd221e0aeab8f88485cd465da0f94a..753d74309eb519570b7346024303bc813c433795 100644 (file)
@@ -264,6 +264,8 @@ static int mmc_read_ssr(struct mmc_card *card)
                                card->ssr.erase_timeout = (et * 1000) / es;
                                card->ssr.erase_offset = eo * 1000;
                        }
+                       card->speed_class = UNSTUFF_BITS(card->raw_ssr,
+                                                               440 - 384, 8);
                } else {
                        pr_warn("%s: SD Status: Invalid Allocation Unit size\n",
                                mmc_hostname(card->host));
@@ -685,7 +687,7 @@ MMC_DEV_ATTR(name, "%s\n", card->cid.prod_name);
 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(speed_class, "%u\n", card->speed_class);
 
 static ssize_t mmc_dsr_show(struct device *dev,
                            struct device_attribute *attr,
@@ -719,6 +721,7 @@ static struct attribute *sd_std_attrs[] = {
        &dev_attr_serial.attr,
        &dev_attr_ocr.attr,
        &dev_attr_dsr.attr,
+       &dev_attr_speed_class.attr,
        NULL,
 };
 ATTRIBUTE_GROUPS(sd_std);
index 76fb7550b67a724d4b2c4c94014a600294065d72..9ae5c2436792d873ec0b13d0ece5f60bdbb61443 100644 (file)
@@ -305,6 +305,7 @@ struct mmc_card {
        unsigned int            pref_erase;     /* in sectors */
        unsigned int            eg_boundary;    /* don't cross erase-group boundaries */
        u8                      erased_byte;    /* value of erased bytes */
+       u8                      speed_class;    /* speed class of the card */
 
        u32                     raw_cid[4];     /* raw card CID */
        u32                     raw_csd[4];     /* raw card CSD */