scsi: ufs: sysfs: health descriptor
authorStanislav Nijnikov <stanislav.nijnikov@wdc.com>
Thu, 15 Feb 2018 12:14:05 +0000 (14:14 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 15 Feb 2018 23:34:24 +0000 (18:34 -0500)
This patch introduces a sysfs group entry for the UFS health descriptor
parameters. The group adds "health_descriptor" folder under the UFS driver
sysfs entry (/sys/bus/platform/drivers/ufshcd/*). The parameters are shown
as hexadecimal numbers. The full information about the parameters could be
found at UFS specifications 2.1.

Signed-off-by: Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Documentation/ABI/testing/sysfs-driver-ufs
drivers/scsi/ufs/ufs-sysfs.c
drivers/scsi/ufs/ufs.h
drivers/scsi/ufs/ufshcd.c
drivers/scsi/ufs/ufshcd.h

index 6ea7613a3f3e7f6f20c5532b12ce7dd73504b674..ddb012b05f0df0f04115c9a41703d84fc8d406e6 100644 (file)
@@ -413,3 +413,31 @@ Description:       This file shows the memory capacity adjustment factor for
                descriptor parameters. The full information about the
                descriptor could be found at UFS specifications 2.1.
                The file is read only.
+
+
+What:          /sys/bus/platform/drivers/ufshcd/*/health_descriptor/eol_info
+Date:          February 2018
+Contact:       Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
+Description:   This file shows preend of life information. This is one
+               of the UFS health descriptor parameters. The full
+               information about the descriptor could be found at
+               UFS specifications 2.1.
+               The file is read only.
+
+What:          /sys/bus/platform/drivers/ufshcd/*/health_descriptor/life_time_estimation_a
+Date:          February 2018
+Contact:       Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
+Description:   This file shows indication of the device life time
+               (method a). This is one of the UFS health descriptor
+               parameters. The full information about the descriptor
+               could be found at UFS specifications 2.1.
+               The file is read only.
+
+What:          /sys/bus/platform/drivers/ufshcd/*/health_descriptor/life_time_estimation_b
+Date:          February 2018
+Contact:       Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
+Description:   This file shows indication of the device life time
+               (method b). This is one of the UFS health descriptor
+               parameters. The full information about the descriptor
+               could be found at UFS specifications 2.1.
+               The file is read only.
index ecd3dcb05f676e750db2642055ecd3e5cb030096..c4f18b0970db95fb4d9c3d414ce2b8dad5c139aa 100644 (file)
@@ -349,11 +349,31 @@ static const struct attribute_group ufs_sysfs_geometry_descriptor_group = {
        .attrs = ufs_sysfs_geometry_descriptor,
 };
 
+#define UFS_HEALTH_DESC_PARAM(_name, _uname, _size)                    \
+       UFS_DESC_PARAM(_name, _uname, HEALTH, _size)
+
+UFS_HEALTH_DESC_PARAM(eol_info, _EOL_INFO, 1);
+UFS_HEALTH_DESC_PARAM(life_time_estimation_a, _LIFE_TIME_EST_A, 1);
+UFS_HEALTH_DESC_PARAM(life_time_estimation_b, _LIFE_TIME_EST_B, 1);
+
+static struct attribute *ufs_sysfs_health_descriptor[] = {
+       &dev_attr_eol_info.attr,
+       &dev_attr_life_time_estimation_a.attr,
+       &dev_attr_life_time_estimation_b.attr,
+       NULL,
+};
+
+static const struct attribute_group ufs_sysfs_health_descriptor_group = {
+       .name = "health_descriptor",
+       .attrs = ufs_sysfs_health_descriptor,
+};
+
 static const struct attribute_group *ufs_sysfs_groups[] = {
        &ufs_sysfs_default_group,
        &ufs_sysfs_device_descriptor_group,
        &ufs_sysfs_interconnect_descriptor_group,
        &ufs_sysfs_geometry_descriptor_group,
+       &ufs_sysfs_health_descriptor_group,
        NULL,
 };
 
index 04d41c8d3dc1bfd16a46f2f8d4cc35ab2d2a61d6..6bfeedb934f13ee245321b77610f05828124c3c2 100644 (file)
@@ -154,6 +154,7 @@ enum desc_idn {
        QUERY_DESC_IDN_RFU_1            = 0x6,
        QUERY_DESC_IDN_GEOMETRY         = 0x7,
        QUERY_DESC_IDN_POWER            = 0x8,
+       QUERY_DESC_IDN_HEALTH           = 0x9,
        QUERY_DESC_IDN_MAX,
 };
 
@@ -169,6 +170,7 @@ enum ufs_desc_def_size {
        QUERY_DESC_INTERCONNECT_DEF_SIZE        = 0x06,
        QUERY_DESC_GEOMETRY_DEF_SIZE            = 0x44,
        QUERY_DESC_POWER_DEF_SIZE               = 0x62,
+       QUERY_DESC_HEALTH_DEF_SIZE              = 0x25,
 };
 
 /* Unit descriptor parameters offsets in bytes*/
@@ -274,6 +276,15 @@ enum geometry_desc_param {
        GEOMETRY_DESC_PARAM_OPT_LOG_BLK_SIZE    = 0x44,
 };
 
+/* Health descriptor parameters offsets in bytes*/
+enum health_desc_param {
+       HEALTH_DESC_PARAM_LEN                   = 0x0,
+       HEALTH_DESC_PARAM_TYPE                  = 0x1,
+       HEALTH_DESC_PARAM_EOL_INFO              = 0x2,
+       HEALTH_DESC_PARAM_LIFE_TIME_EST_A       = 0x3,
+       HEALTH_DESC_PARAM_LIFE_TIME_EST_B       = 0x4,
+};
+
 /*
  * Logical Unit Write Protect
  * 00h: LU not write protected
index 540a431e38ce5dc8e13fc85b871d67f25521d569..b88fcf7be47b344825235b29e9ad57f42bc866ac 100644 (file)
@@ -2966,6 +2966,9 @@ int ufshcd_map_desc_id_to_length(struct ufs_hba *hba,
        case QUERY_DESC_IDN_STRING:
                *desc_len = QUERY_DESC_MAX_SIZE;
                break;
+       case QUERY_DESC_IDN_HEALTH:
+               *desc_len = hba->desc_size.hlth_desc;
+               break;
        case QUERY_DESC_IDN_RFU_0:
        case QUERY_DESC_IDN_RFU_1:
                *desc_len = 0;
@@ -6277,6 +6280,10 @@ static void ufshcd_init_desc_sizes(struct ufs_hba *hba)
                &hba->desc_size.geom_desc);
        if (err)
                hba->desc_size.geom_desc = QUERY_DESC_GEOMETRY_DEF_SIZE;
+       err = ufshcd_read_desc_length(hba, QUERY_DESC_IDN_HEALTH, 0,
+               &hba->desc_size.hlth_desc);
+       if (err)
+               hba->desc_size.hlth_desc = QUERY_DESC_HEALTH_DEF_SIZE;
 }
 
 static void ufshcd_def_desc_sizes(struct ufs_hba *hba)
@@ -6287,6 +6294,7 @@ static void ufshcd_def_desc_sizes(struct ufs_hba *hba)
        hba->desc_size.conf_desc = QUERY_DESC_CONFIGURATION_DEF_SIZE;
        hba->desc_size.unit_desc = QUERY_DESC_UNIT_DEF_SIZE;
        hba->desc_size.geom_desc = QUERY_DESC_GEOMETRY_DEF_SIZE;
+       hba->desc_size.hlth_desc = QUERY_DESC_HEALTH_DEF_SIZE;
 }
 
 /**
index 38c307d053c70e40e8388129b9e2a3af6cd90da4..515c6e6244be72e801b44900667bb27e518ff6fa 100644 (file)
@@ -229,6 +229,7 @@ struct ufs_desc_size {
        int interc_desc;
        int unit_desc;
        int conf_desc;
+       int hlth_desc;
 };
 
 /**