[PATCH v1 0/9] ufs: sysfs: read-only access to device descriptors, attributes and flags

2017-12-25 Thread Stanislav Nijnikov
This patch introduces sysfs entries that will provide read-only access to
device management data that could be received with UFS query requests.
User-space applications will be able to read UFS device descriptors,
flags and attributes. This will allow to get full UFS device configuration
and its status. The descriptors are provided as set of files representing
its parameters. The flags are using "true"/"false" representation of
their value. The attributes are shown as hexadecimal value. The
descriptors, attributes and flags are placed in separate subfolders under
the UFS device sysfs entry (/sys/bus/platform/drivers/ufshcd/*/). The
string descriptor subfolder contains five string descriptors defined by
UFS specification 2.1. The LUN specific descriptor and attribute are 
placed under corresponding SCSI device sysfs entries
(/sys/class/scsi_device/*/device/).
In addition the patch presents an additional field in the
scsi_host_template structure - struct attribute_group **sdev_group.
This field allows to define groups of attributes. It will provide an
ability to use binary attributes in addition to device attributes and
to group them under subfolders if necessary.

Stanislav Nijnikov (9):
  ufs: sysfs: device descriptor
  ufs: sysfs: interconnect descriptor
  ufs: sysfs: geometry descriptor
  ufs: sysfs: health descriptor
  ufs: sysfs: power descriptor
  ufs: sysfs: string descriptors
  ufs: sysfs: unit descriptor
  ufs: sysfs: flags
  ufs: sysfs: attributes

 Documentation/ABI/testing/sysfs-driver-ufs | 804 +
 drivers/scsi/scsi_sysfs.c  |  14 +
 drivers/scsi/ufs/Makefile  |   2 +-
 drivers/scsi/ufs/ufs-sysfs.c   | 643 +++
 drivers/scsi/ufs/ufs-sysfs.h   |  14 +
 drivers/scsi/ufs/ufs.h | 115 -
 drivers/scsi/ufs/ufshcd.c  |  52 +-
 drivers/scsi/ufs/ufshcd.h  |  25 +
 include/scsi/scsi_host.h   |   6 +
 9 files changed, 1642 insertions(+), 33 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-ufs
 create mode 100644 drivers/scsi/ufs/ufs-sysfs.c
 create mode 100644 drivers/scsi/ufs/ufs-sysfs.h

-- 
2.7.4



[PATCH v1 9/9] ufs: sysfs: attributes

2017-12-25 Thread Stanislav Nijnikov
Signed-off-by: Stanislav Nijnikov 
---
 Documentation/ABI/testing/sysfs-driver-ufs | 141 -
 drivers/scsi/ufs/ufs-sysfs.c   |  89 ++
 drivers/scsi/ufs/ufs-sysfs.h   |   1 +
 drivers/scsi/ufs/ufs.h |  27 +-
 drivers/scsi/ufs/ufshcd.c  |   5 +-
 drivers/scsi/ufs/ufshcd.h  |   2 +
 6 files changed, 258 insertions(+), 7 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-driver-ufs 
b/Documentation/ABI/testing/sysfs-driver-ufs
index 832da97..804e952 100644
--- a/Documentation/ABI/testing/sysfs-driver-ufs
+++ b/Documentation/ABI/testing/sysfs-driver-ufs
@@ -662,4 +662,143 @@ Contact:  Stanislav Nijnikov 
 Description:   This file shows whether the device FW update is permanently
disabled. The full information about the flag could be found
at UFS specifications 2.1.
-   The file is read only.
\ No newline at end of file
+   The file is read only.
+
+
+What:  /sys/bus/platform/drivers/ufshcd/*/attributes/boot_lun_enabled
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file provides the boot lun enabled UFS device attribute.
+   The full information about the attribute could be found at
+   UFS specifications 2.1.
+   The file is read only.
+
+What:  /sys/bus/platform/drivers/ufshcd/*/attributes/current_power_mode
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file provides the current power mode UFS device attribute.
+   The full information about the attribute could be found at
+   UFS specifications 2.1.
+   The file is read only.
+
+What:  /sys/bus/platform/drivers/ufshcd/*/attributes/active_icc_level
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file provides the active icc level UFS device attribute.
+   The full information about the attribute could be found at
+   UFS specifications 2.1.
+   The file is read only.
+
+What:  /sys/bus/platform/drivers/ufshcd/*/attributes/ooo_data_enabled
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file provides the out of order data transfer enabled UFS
+   device attribute. The full information about the attribute
+   could be found at UFS specifications 2.1.
+   The file is read only.
+
+What:  /sys/bus/platform/drivers/ufshcd/*/attributes/bkops_status
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file provides the background operations status UFS device
+   attribute. The full information about the attribute could
+   be found at UFS specifications 2.1.
+   The file is read only.
+
+What:  /sys/bus/platform/drivers/ufshcd/*/attributes/purge_status
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file provides the purge operation status UFS device
+   attribute. The full information about the attribute could
+   be found at UFS specifications 2.1.
+   The file is read only.
+
+What:  /sys/bus/platform/drivers/ufshcd/*/attributes/max_data_in_size
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows the maximum data size in a DATA IN
+   UPIU. The full information about the attribute could
+   be found at UFS specifications 2.1.
+   The file is read only.
+
+What:  /sys/bus/platform/drivers/ufshcd/*/attributes/max_data_out_size
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows the maximum number of bytes that can be
+   requested with a READY TO TRANSFER UPIU. The full information
+   about the attribute could be found at UFS specifications 2.1.
+   The file is read only.
+
+What:  
/sys/bus/platform/drivers/ufshcd/*/attributes/reference_clock_frequency
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file provides the reference clock frequency UFS device
+   attribute. The full information about the attribute could
+   be found at UFS specifications 2.1.
+   The file is read only.
+
+What:  
/sys/bus/platform/drivers/ufshcd/*/attributes/configuration_descriptor_lock
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows whether the configuration descriptor is locked.
+   The full information about the attribute could be found at
+   UFS specifications 2.1. The file is read only.
+
+What:  /sys/bus/platform/drivers/ufshcd/*/attributes/max_number_of_rtt
+Date:  August 2

[PATCH v1 2/9] ufs: sysfs: interconnect descriptor

2017-12-25 Thread Stanislav Nijnikov
Signed-off-by: Stanislav Nijnikov 
---
 Documentation/ABI/testing/sysfs-driver-ufs | 19 +++
 drivers/scsi/ufs/ufs-sysfs.c   | 18 ++
 drivers/scsi/ufs/ufs.h |  8 
 3 files changed, 45 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-driver-ufs 
b/Documentation/ABI/testing/sysfs-driver-ufs
index da39c63..35a8731 100644
--- a/Documentation/ABI/testing/sysfs-driver-ufs
+++ b/Documentation/ABI/testing/sysfs-driver-ufs
@@ -221,3 +221,22 @@ Description:   This file shows the command maximum 
timeout for a change
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/*/interconnect_descriptor/unipro_version
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows the MIPI UniPro version number in BCD format.
+   This is one of the UFS interconnect 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/*/interconnect_descriptor/mphy_version
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows the MIPI M-PHY version number in BCD format.
+   This is one of the UFS interconnect descriptor parameters.
+   The full information about the descriptor could be found at
+   UFS specifications 2.1.
+   The file is read only.
\ No newline at end of file
diff --git a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c
index 1d7867c..0e2bfdb 100644
--- a/drivers/scsi/ufs/ufs-sysfs.c
+++ b/drivers/scsi/ufs/ufs-sysfs.c
@@ -132,8 +132,26 @@ static const struct attribute_group 
ufs_sysfs_device_descriptor_group = {
.attrs = ufs_sysfs_device_descriptor,
 };
 
+#define UFS_INTERCONNECT_DESC_PARAM(_name, _uname, _size) \
+   UFS_DESC_PARAM(_name, _uname, INTERCONNECT, _size)
+
+UFS_INTERCONNECT_DESC_PARAM(unipro_version, UNIPRO_VER, WORD);
+UFS_INTERCONNECT_DESC_PARAM(mphy_version, MPHY_VER, WORD);
+
+static struct attribute *ufs_sysfs_interconnect_descriptor[] = {
+   &dev_attr_unipro_version.attr,
+   &dev_attr_mphy_version.attr,
+   NULL,
+};
+
+static const struct attribute_group ufs_sysfs_interconnect_descriptor_group = {
+   .name = "interconnect_descriptor",
+   .attrs = ufs_sysfs_interconnect_descriptor,
+};
+
 static const struct attribute_group *ufs_sysfs_groups[] = {
&ufs_sysfs_device_descriptor_group,
+   &ufs_sysfs_interconnect_descriptor_group,
NULL,
 };
 
diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h
index 6ae1e08..773c049 100644
--- a/drivers/scsi/ufs/ufs.h
+++ b/drivers/scsi/ufs/ufs.h
@@ -230,6 +230,14 @@ enum device_desc_param {
DEVICE_DESC_PARAM_PRDCT_REV = 0x2A,
 };
 
+/* Interconnect descriptor parameters offsets in bytes*/
+enum interconnect_desc_param {
+   INTERCONNECT_DESC_PARAM_LEN = 0x0,
+   INTERCONNECT_DESC_PARAM_TYPE= 0x1,
+   INTERCONNECT_DESC_PARAM_UNIPRO_VER  = 0x2,
+   INTERCONNECT_DESC_PARAM_MPHY_VER= 0x4,
+};
+
 /*
  * Logical Unit Write Protect
  * 00h: LU not write protected
-- 
2.7.4



[PATCH v1 1/9] ufs: sysfs: device descriptor

2017-12-25 Thread Stanislav Nijnikov
Signed-off-by: Stanislav Nijnikov 
---
 Documentation/ABI/testing/sysfs-driver-ufs | 223 +
 drivers/scsi/ufs/Makefile  |   2 +-
 drivers/scsi/ufs/ufs-sysfs.c   | 154 
 drivers/scsi/ufs/ufs-sysfs.h   |  10 ++
 drivers/scsi/ufs/ufs.h |   8 ++
 drivers/scsi/ufs/ufshcd.c  |  12 +-
 drivers/scsi/ufs/ufshcd.h  |   4 +
 7 files changed, 407 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-ufs
 create mode 100644 drivers/scsi/ufs/ufs-sysfs.c
 create mode 100644 drivers/scsi/ufs/ufs-sysfs.h

diff --git a/Documentation/ABI/testing/sysfs-driver-ufs 
b/Documentation/ABI/testing/sysfs-driver-ufs
new file mode 100644
index 000..da39c63
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-driver-ufs
@@ -0,0 +1,223 @@
+What:  /sys/bus/platform/drivers/ufshcd/*/device_descriptor/device_type
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows the device type. This is one of the UFS
+   device 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/*/device_descriptor/device_class
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows the device class. This is one of the UFS
+   device 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/*/device_descriptor/device_sub_class
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows the UFS storage subclass. This is one of
+   the UFS device 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/*/device_descriptor/protocol
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows the protocol supported by an UFS device.
+   This is one of the UFS device 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/*/device_descriptor/number_of_luns
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows number of logical units. This is one of
+   the UFS device 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/*/device_descriptor/number_of_wluns
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows number of well known logical units.
+   This is one of the UFS device 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/*/device_descriptor/boot_enable
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows value that indicates whether the device is
+   enabled for boot. This is one of the UFS device 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/*/device_descriptor/descriptor_access_enable
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows value that indicates whether the device
+   descriptor could be read after partial initialization phase
+   of the boot sequence. This is one of the UFS device 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/*/device_descriptor/initial_power_mode
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows value that defines the power mode after
+   device initialization or hardware reset. This is one of
+   the UFS device 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/*/device_des

[PATCH v1 8/9] ufs: sysfs: flags

2017-12-25 Thread Stanislav Nijnikov
Signed-off-by: Stanislav Nijnikov 
---
 Documentation/ABI/testing/sysfs-driver-ufs | 65 ++
 drivers/scsi/ufs/ufs-sysfs.c   | 42 +++
 drivers/scsi/ufs/ufs.h | 14 +--
 3 files changed, 118 insertions(+), 3 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-driver-ufs 
b/Documentation/ABI/testing/sysfs-driver-ufs
index 5ff8dfa..832da97 100644
--- a/Documentation/ABI/testing/sysfs-driver-ufs
+++ b/Documentation/ABI/testing/sysfs-driver-ufs
@@ -597,4 +597,69 @@ Contact:   Stanislav Nijnikov 
 Description:   This file shows the granularity of the LUN. This is one of
the UFS unit 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/*/flags/device_init
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows the device init status. The full information
+   about the flag could be found at UFS specifications 2.1.
+   The file is read only.
+
+What:  /sys/bus/platform/drivers/ufshcd/*/flags/permanent_wpe
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows whether permanent write protection is enabled.
+   The full information about the flag could be found at
+   UFS specifications 2.1.
+   The file is read only.
+
+What:  /sys/bus/platform/drivers/ufshcd/*/flags/power_on_wpe
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows whether write protection is enabled on all
+   logical units configured as power on write protected. The
+   full information about the flag could be found at
+   UFS specifications 2.1.
+   The file is read only.
+
+What:  /sys/bus/platform/drivers/ufshcd/*/flags/bkops_enable
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows whether the device background operations are
+   enabled. The full information about the flag could be
+   found at UFS specifications 2.1.
+   The file is read only.
+
+What:  /sys/bus/platform/drivers/ufshcd/*/flags/life_span_mode_enable
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows whether the device life span mode is enabled.
+   The full information about the flag could be found at
+   UFS specifications 2.1.
+   The file is read only.
+
+What:  /sys/bus/platform/drivers/ufshcd/*/flags/phy_resource_removal
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows whether physical resource removal is enable.
+   The full information about the flag could be found at
+   UFS specifications 2.1.
+   The file is read only.
+
+What:  /sys/bus/platform/drivers/ufshcd/*/flags/busy_rtc
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows whether the device is executing internal
+   operation related to real time clock. The full information
+   about the flag could be found at UFS specifications 2.1.
+   The file is read only.
+
+What:  /sys/bus/platform/drivers/ufshcd/*/flags/disable_fw_update
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows whether the device FW update is permanently
+   disabled. The full information about the flag could be found
+   at UFS specifications 2.1.
The file is read only.
\ No newline at end of file
diff --git a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c
index dfb4965..fbc9926 100644
--- a/drivers/scsi/ufs/ufs-sysfs.c
+++ b/drivers/scsi/ufs/ufs-sysfs.c
@@ -427,6 +427,47 @@ static const struct attribute_group 
ufs_sysfs_string_descriptors_group = {
.attrs = ufs_sysfs_string_descriptors,
 };
 
+#define ufs_sysfs_flag_show(_name, _uname)\
+static ssize_t _name##_show(struct device *dev,   \
+   struct device_attribute *attr, char *buf) \
+{ \
+   bool flag;\
+   struct ufs_hba *hba = dev_get_drvdata(dev);   \
+   if (ufshcd_query_flag(hba, UPIU_QUERY_OPCODE_READ_FLAG,   \
+   QUERY_FLAG_IDN_##_uname, &flag))  \
+   return -EINVAL;   \
+   return sprintf(buf, "%s\n", flag ? "true" : "false");

[PATCH v1 4/9] ufs: sysfs: health descriptor

2017-12-25 Thread Stanislav Nijnikov
Signed-off-by: Stanislav Nijnikov 
---
 Documentation/ABI/testing/sysfs-driver-ufs | 28 
 drivers/scsi/ufs/ufs-sysfs.c   | 20 
 drivers/scsi/ufs/ufs.h | 11 +++
 drivers/scsi/ufs/ufshcd.c  |  8 
 drivers/scsi/ufs/ufshcd.h  |  1 +
 5 files changed, 68 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-driver-ufs 
b/Documentation/ABI/testing/sysfs-driver-ufs
index db68bf6..59399e3 100644
--- a/Documentation/ABI/testing/sysfs-driver-ufs
+++ b/Documentation/ABI/testing/sysfs-driver-ufs
@@ -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:  August 2017
+Contact:   Stanislav Nijnikov 
+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:  August 2017
+Contact:   Stanislav Nijnikov 
+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:  August 2017
+Contact:   Stanislav Nijnikov 
+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.
\ No newline at end of file
diff --git a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c
index 413acb5..7b96677 100644
--- a/drivers/scsi/ufs/ufs-sysfs.c
+++ b/drivers/scsi/ufs/ufs-sysfs.c
@@ -232,10 +232,30 @@ 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, BYTE);
+UFS_HEALTH_DESC_PARAM(life_time_estimation_a, LIFE_TIME_EST_A, BYTE);
+UFS_HEALTH_DESC_PARAM(life_time_estimation_b, LIFE_TIME_EST_B, BYTE);
+
+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_device_descriptor_group,
&ufs_sysfs_interconnect_descriptor_group,
&ufs_sysfs_geometry_descriptor_group,
+   &ufs_sysfs_health_descriptor_group,
NULL,
 };
 
diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h
index 04d41c8..6bfeedb 100644
--- a/drivers/scsi/ufs/ufs.h
+++ b/drivers/scsi/ufs/ufs.h
@@ -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
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 8513d68..e75866e 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@

[PATCH v1 6/9] ufs: sysfs: string descriptors

2017-12-25 Thread Stanislav Nijnikov
Signed-off-by: Stanislav Nijnikov 
---
 Documentation/ABI/testing/sysfs-driver-ufs | 39 
 drivers/scsi/ufs/ufs-sysfs.c   | 58 ++
 drivers/scsi/ufs/ufshcd.c  |  4 +--
 drivers/scsi/ufs/ufshcd.h  |  3 ++
 4 files changed, 102 insertions(+), 2 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-driver-ufs 
b/Documentation/ABI/testing/sysfs-driver-ufs
index 7b86efd..736280e 100644
--- a/Documentation/ABI/testing/sysfs-driver-ufs
+++ b/Documentation/ABI/testing/sysfs-driver-ufs
@@ -450,4 +450,43 @@ Description:   This file shows maximum VCC, VCCQ and 
VCCQ2 value for
active ICC levels from 0 to 15. This is one of the UFS
power 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/*/string_descriptors/manufacturer_name
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file contains a device manufactureer name string.
+   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/*/string_descriptors/product_name
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file contains a product name string. 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/*/string_descriptors/oem_id
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file contains a OEM ID string. 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/*/string_descriptors/serial_number
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file contains a device serial number string. 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/*/string_descriptors/product_revision
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file contains a product revision string. The full
+   information about the descriptor could be found at
+   UFS specifications 2.1.
The file is read only.
\ No newline at end of file
diff --git a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c
index b47cd2a..3a20f8d 100644
--- a/drivers/scsi/ufs/ufs-sysfs.c
+++ b/drivers/scsi/ufs/ufs-sysfs.c
@@ -371,12 +371,70 @@ static const struct attribute_group 
ufs_sysfs_power_descriptor_group = {
.attrs = ufs_sysfs_power_descriptor,
 };
 
+#define ufs_sysfs_string_descriptor_show(_name, _pname)   \
+static ssize_t _name##_show(struct device *dev,   \
+   struct device_attribute *attr, char *buf) \
+{ \
+   u8 index; \
+   struct ufs_hba *hba = dev_get_drvdata(dev);   \
+   int ret;  \
+   int desc_len = QUERY_DESC_MAX_SIZE;   \
+   u8 *desc_buf; \
+   desc_buf = kzalloc(QUERY_DESC_MAX_SIZE, GFP_ATOMIC);  \
+   if (!desc_buf)\
+   return -ENOMEM;   \
+   ret = ufshcd_query_descriptor_retry(hba, UPIU_QUERY_OPCODE_READ_DESC, \
+   QUERY_DESC_IDN_DEVICE, 0, 0, desc_buf, &desc_len);\
+   if (ret) {\
+   ret = -EINVAL;\
+   goto out; \
+   } \
+   index = desc_buf[DEVICE_DESC_PARAM_##_pname]; \
+   memset(desc_buf, 0, QUERY_DESC_MAX_SIZE); \
+   if (ufshcd_read_string_desc(hba, index, desc_buf, \
+   QUERY_DESC_MAX_SIZE, true)) { \
+   ret = -EINVAL;\
+   goto out; 

[PATCH v1 5/9] ufs: sysfs: power descriptor

2017-12-25 Thread Stanislav Nijnikov
Signed-off-by: Stanislav Nijnikov 
---
 Documentation/ABI/testing/sysfs-driver-ufs |  10 +++
 drivers/scsi/ufs/ufs-sysfs.c   | 121 +
 2 files changed, 131 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-driver-ufs 
b/Documentation/ABI/testing/sysfs-driver-ufs
index 59399e3..7b86efd 100644
--- a/Documentation/ABI/testing/sysfs-driver-ufs
+++ b/Documentation/ABI/testing/sysfs-driver-ufs
@@ -440,4 +440,14 @@ 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.
+
+
+What:  
/sys/bus/platform/drivers/ufshcd/*/power_descriptor/active_icc_levels_vcc*
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows maximum VCC, VCCQ and VCCQ2 value for
+   active ICC levels from 0 to 15. This is one of the UFS
+   power descriptor parameters. The full information about
+   the descriptor could be found at UFS specifications 2.1.
The file is read only.
\ No newline at end of file
diff --git a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c
index 7b96677..b47cd2a 100644
--- a/drivers/scsi/ufs/ufs-sysfs.c
+++ b/drivers/scsi/ufs/ufs-sysfs.c
@@ -251,11 +251,132 @@ static const struct attribute_group 
ufs_sysfs_health_descriptor_group = {
.attrs = ufs_sysfs_health_descriptor,
 };
 
+#define ufs_sysfs_power_desc_param_show(_name, _puname, _index)   \
+static ssize_t _name##_index##_show(struct device *dev,   \
+   struct device_attribute *attr, char *buf) \
+{ \
+   struct ufs_hba *hba = dev_get_drvdata(dev);   \
+   return ufs_sysfs_read_desc_param(hba, QUERY_DESC_IDN_POWER, 0, buf,   \
+   PWR_DESC_##_puname##_0 + _index * UFS_PARAM_WORD_SIZE,\
+   UFS_PARAM_WORD_SIZE); \
+}
+
+#define UFS_POWER_DESC_PARAM(_pname, _puname, _index) \
+   ufs_sysfs_power_desc_param_show(_pname, _puname, _index)  \
+   static DEVICE_ATTR_RO(_pname##_index)
+
+UFS_POWER_DESC_PARAM(active_icc_levels_vcc, ACTIVE_LVLS_VCC, 0);
+UFS_POWER_DESC_PARAM(active_icc_levels_vcc, ACTIVE_LVLS_VCC, 1);
+UFS_POWER_DESC_PARAM(active_icc_levels_vcc, ACTIVE_LVLS_VCC, 2);
+UFS_POWER_DESC_PARAM(active_icc_levels_vcc, ACTIVE_LVLS_VCC, 3);
+UFS_POWER_DESC_PARAM(active_icc_levels_vcc, ACTIVE_LVLS_VCC, 4);
+UFS_POWER_DESC_PARAM(active_icc_levels_vcc, ACTIVE_LVLS_VCC, 5);
+UFS_POWER_DESC_PARAM(active_icc_levels_vcc, ACTIVE_LVLS_VCC, 6);
+UFS_POWER_DESC_PARAM(active_icc_levels_vcc, ACTIVE_LVLS_VCC, 7);
+UFS_POWER_DESC_PARAM(active_icc_levels_vcc, ACTIVE_LVLS_VCC, 8);
+UFS_POWER_DESC_PARAM(active_icc_levels_vcc, ACTIVE_LVLS_VCC, 9);
+UFS_POWER_DESC_PARAM(active_icc_levels_vcc, ACTIVE_LVLS_VCC, 10);
+UFS_POWER_DESC_PARAM(active_icc_levels_vcc, ACTIVE_LVLS_VCC, 11);
+UFS_POWER_DESC_PARAM(active_icc_levels_vcc, ACTIVE_LVLS_VCC, 12);
+UFS_POWER_DESC_PARAM(active_icc_levels_vcc, ACTIVE_LVLS_VCC, 13);
+UFS_POWER_DESC_PARAM(active_icc_levels_vcc, ACTIVE_LVLS_VCC, 14);
+UFS_POWER_DESC_PARAM(active_icc_levels_vcc, ACTIVE_LVLS_VCC, 15);
+UFS_POWER_DESC_PARAM(active_icc_levels_vccq, ACTIVE_LVLS_VCCQ, 0);
+UFS_POWER_DESC_PARAM(active_icc_levels_vccq, ACTIVE_LVLS_VCCQ, 1);
+UFS_POWER_DESC_PARAM(active_icc_levels_vccq, ACTIVE_LVLS_VCCQ, 2);
+UFS_POWER_DESC_PARAM(active_icc_levels_vccq, ACTIVE_LVLS_VCCQ, 3);
+UFS_POWER_DESC_PARAM(active_icc_levels_vccq, ACTIVE_LVLS_VCCQ, 4);
+UFS_POWER_DESC_PARAM(active_icc_levels_vccq, ACTIVE_LVLS_VCCQ, 5);
+UFS_POWER_DESC_PARAM(active_icc_levels_vccq, ACTIVE_LVLS_VCCQ, 6);
+UFS_POWER_DESC_PARAM(active_icc_levels_vccq, ACTIVE_LVLS_VCCQ, 7);
+UFS_POWER_DESC_PARAM(active_icc_levels_vccq, ACTIVE_LVLS_VCCQ, 8);
+UFS_POWER_DESC_PARAM(active_icc_levels_vccq, ACTIVE_LVLS_VCCQ, 9);
+UFS_POWER_DESC_PARAM(active_icc_levels_vccq, ACTIVE_LVLS_VCCQ, 10);
+UFS_POWER_DESC_PARAM(active_icc_levels_vccq, ACTIVE_LVLS_VCCQ, 11);
+UFS_POWER_DESC_PARAM(active_icc_levels_vccq, ACTIVE_LVLS_VCCQ, 12);
+UFS_POWER_DESC_PARAM(active_icc_levels_vccq, ACTIVE_LVLS_VCCQ, 13);
+UFS_POWER_DESC_PARAM(active_icc_levels_vccq, ACTIVE_LVLS_VCCQ, 14);
+UFS_POWER_DESC_PARAM(active_icc_levels_vccq, ACTIVE_LVLS_VCCQ, 15);
+UFS_POWER_DESC_PARAM(active_icc_levels_vccq2, ACTIVE_LVLS_VCCQ2, 0);
+UFS_POWER_DESC_PARAM(active_icc_levels_vccq2, ACTIVE_LVLS_VCCQ2, 1);
+UFS_POWER_DESC_PARAM(active_icc_levels_vccq2, ACTIVE_LVLS_VCCQ2, 2);
+UFS_POWER_DESC_PARAM(active_icc_levels_vccq2, ACTIVE_LVLS_VCCQ2, 3);
+UFS_POWER_DESC_PARAM(active_icc_levels_vccq2, ACTIVE_LVLS_VCCQ2, 4);
+UFS_POWER_DESC_PARAM(active_icc

[PATCH v1 7/9] ufs: sysfs: unit descriptor

2017-12-25 Thread Stanislav Nijnikov
In addition the patch presents an additional field in the
scsi_host_template structure - struct attribute_group **sdev_group.
This field allows to define groups of attributes. It will provide an
ability to use binary attributes in addition to device attributes and
to group them under subfolders if necessary.

Signed-off-by: Stanislav Nijnikov 
---
 Documentation/ABI/testing/sysfs-driver-ufs | 108 +
 drivers/scsi/scsi_sysfs.c  |  14 
 drivers/scsi/ufs/ufs-sysfs.c   |  57 +++
 drivers/scsi/ufs/ufs-sysfs.h   |   3 +
 drivers/scsi/ufs/ufs.h |  11 +++
 drivers/scsi/ufs/ufshcd.c  |  23 ++
 drivers/scsi/ufs/ufshcd.h  |  15 
 include/scsi/scsi_host.h   |   6 ++
 8 files changed, 221 insertions(+), 16 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-driver-ufs 
b/Documentation/ABI/testing/sysfs-driver-ufs
index 736280e..5ff8dfa 100644
--- a/Documentation/ABI/testing/sysfs-driver-ufs
+++ b/Documentation/ABI/testing/sysfs-driver-ufs
@@ -489,4 +489,112 @@ Contact:  Stanislav Nijnikov 
 Description:   This file contains a product revision string. The full
information about the descriptor could be found at
UFS specifications 2.1.
+   The file is read only.
+
+
+What:  /sys/class/scsi_device/*/device/unit_descriptor/boot_lun_id
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows boot LUN information. This is one of
+   the UFS unit descriptor parameters. The full information
+   about the descriptor could be found at UFS specifications 2.1.
+   The file is read only.
+
+What:  
/sys/class/scsi_device/*/device/unit_descriptor/lun_write_protect
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows LUN write protection status. This is one of
+   the UFS unit descriptor parameters. The full information
+   about the descriptor could be found at UFS specifications 2.1.
+   The file is read only.
+
+What:  /sys/class/scsi_device/*/device/unit_descriptor/lun_queue_depth
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows LUN queue depth. This is one of the UFS
+   unit descriptor parameters. The full information about
+   the descriptor could be found at UFS specifications 2.1.
+   The file is read only.
+
+What:  /sys/class/scsi_device/*/device/unit_descriptor/psa_sensitive
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows PSA sensitivity. This is one of the UFS
+   unit descriptor parameters. The full information about
+   the descriptor could be found at UFS specifications 2.1.
+   The file is read only.
+
+What:  /sys/class/scsi_device/*/device/unit_descriptor/lun_memory_type
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows LUN memory type. This is one of the UFS
+   unit descriptor parameters. The full information about
+   the descriptor could be found at UFS specifications 2.1.
+   The file is read only.
+
+What:  /sys/class/scsi_device/*/device/unit_descriptor/data_reliability
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file defines the device behavior when a power failure
+   occurs during a write operation. This is one of the UFS
+   unit descriptor parameters. The full information about
+   the descriptor could be found at UFS specifications 2.1.
+   The file is read only.
+
+What:  
/sys/class/scsi_device/*/device/unit_descriptor/logical_block_size
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows the size of addressable logical blocks
+   (calculated as an exponent with base 2). This is one of
+   the UFS unit descriptor parameters. The full information about
+   the descriptor could be found at UFS specifications 2.1.
+   The file is read only.
+
+What:  
/sys/class/scsi_device/*/device/unit_descriptor/logical_block_count
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows total number of addressable logical blocks.
+   This is one of the UFS unit descriptor parameters. The full
+   information about the descriptor could be found at
+   UFS specifications 2.1.
+   The file is read only.
+
+What:  /sys/class/scsi_device/*/device/unit_descriptor/erase_block_size
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows the erase bloc

[PATCH v1 3/9] ufs: sysfs: geometry descriptor

2017-12-25 Thread Stanislav Nijnikov
Signed-off-by: Stanislav Nijnikov 
---
 Documentation/ABI/testing/sysfs-driver-ufs | 175 -
 drivers/scsi/ufs/ufs-sysfs.c   |  84 ++
 drivers/scsi/ufs/ufs.h |  36 ++
 3 files changed, 294 insertions(+), 1 deletion(-)

diff --git a/Documentation/ABI/testing/sysfs-driver-ufs 
b/Documentation/ABI/testing/sysfs-driver-ufs
index 35a8731..db68bf6 100644
--- a/Documentation/ABI/testing/sysfs-driver-ufs
+++ b/Documentation/ABI/testing/sysfs-driver-ufs
@@ -239,4 +239,177 @@ Description:  This file shows the MIPI M-PHY version 
number in BCD format.
This is one of the UFS interconnect descriptor parameters.
The full information about the descriptor could be found at
UFS specifications 2.1.
-   The file is read only.
\ No newline at end of file
+   The file is read only.
+
+
+What:  
/sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/raw_device_capacity
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows the total memory quantity available to
+   the user to configure the device logical units. This is one
+   of the UFS geometry 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/*/geometry_descriptor/max_number_of_luns
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows the maximum number of logical units
+   supported by the UFS device. This is one of the UFS
+   geometry 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/*/geometry_descriptor/segment_size
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows the segment size. This is one of the UFS
+   geometry 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/*/geometry_descriptor/allocation_unit_size
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows the allocation unit size. This is one of
+   the UFS geometry 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/*/geometry_descriptor/min_addressable_block_size
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows the minimum addressable block size. This
+   is one of the UFS geometry 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/*/geometry_descriptor/optimal_read_block_size
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows the optimal read block size. This is one
+   of the UFS geometry 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/*/geometry_descriptor/optimal_write_block_size
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows the optimal write block size. This is one
+   of the UFS geometry 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/*/geometry_descriptor/max_in_buffer_size
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows the maximum data-in buffer size. This
+   is one of the UFS geometry 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/*/geometry_descriptor/max_out_buffer_size
+Date:  August 2017
+Contact:   Stanislav Nijnikov 
+Description:   This file shows the maximum data-out buffer size. This
+   is one of the UFS geometry descriptor parameters. The full
+   information about the descriptor could be found at UFS
+   specifications 2.1.
+   The 

Re: SSD being put to sleep during boot-up when laptop on battery

2017-12-25 Thread Alan Stern
On Sun, 24 Dec 2017, Adam Bennett wrote:

> Alan,
> 
> I have a Dell Precision 7520 with an Samsung SSD in addition to an NVMe 
> drive.  I'm currently running 4.14.8 but have seen the below problem 
> since I moved from 4.9 to 4.13.
> 
> When I boot without AC plugged in, the SSD is stopped almost immediately 
> in the boot process, not allowing the boot to continue.
> 
> I can boot on fine on AC.  When I unplug the cord, I see the "Stopping 
> disk" message, and the system is unresponsive until I plug the AC back in.
> 
> I initially thought the problem was in user-space, but I set up 
> laptop-mode-tools to keep "control" as "on", and the problem still 
> persists.  Also, I don't see the issue in 4.9.

It's entirely possible that the problem does lie in userspace, during 
boot-up.  Don't forget that your initramfs image could be causing this; 
have you tried to rebuild it with the new laptop settings?

> I have temporarily worked around the problem by returning from 
> sd_suspend_runtime without calling sd_suspend_common in sd.c (obviously 
> not the true fix).
> 
> I have tried a number of searches, and couldn't find any bug reports of 
> this nature, but I'm not that in-tune with the linux development process 
> to have searched all the correct places.

This should be sent to the linux-pm and linux-scsi mailing lists 
(CC'ed).

> I'd like to help track this problem down, do you have any suggestions or 
> is there some additional details I could provide?

You can try bisecting between the 4.9 and 4.13 kernels to find the 
commit which first caused the problem.

Alan Stern



Re: st driver doesn't seem to grok LTO partitioning (LTO-5 firmware upgrade)

2017-12-25 Thread Jérôme Carretero
Hi,


This is just to state that I used the SAS LTO firmware upgrade method
Douglas suggested (1 year ago) and it worked fine, upgrading an HPE
LTO-5 Ultrium 3000 internal SAS tape drive from a .frm / .E file.


Best regards,

-- 
Jérôme

PS: It took me a while to find a way to get the latest firmware for
that drive, so here is some additional info: the Z6ED_019_233.E aka
LTT_Ultrium_5-SCSI_Z6ED_STANDALONE.frm firmware is available inside a
package not blocked by HPE paywall:
 
https://downloads.hpe.com/pub/softlib2/software1/sc-windows/p368283668/v124587/cp031432.exe
 
https://support.hpe.com/hpsc/swd/public/detail?sp4ts.oid=7271242&swItemId=MTX_afc26488547047b2b55cec874c&swEnvOid=4138#tab4


Re: [PATCH v1 1/9] ufs: sysfs: device descriptor

2017-12-25 Thread kbuild test robot
Hi Stanislav,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on scsi/for-next]
[also build test WARNING on v4.15-rc5 next-20171222]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Stanislav-Nijnikov/ufs-sysfs-read-only-access-to-device-descriptors-attributes-and-flags/20171226-075252
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)


vim +40 drivers/scsi/ufs/ufs-sysfs.c

15  
16  static inline ssize_t ufs_sysfs_read_desc_param(
17  struct ufs_hba *hba, u8 desc_idn, u8 index, char *buf, u8 off,
18  enum ufs_desc_param_size param_size)
19  {
20  int desc_len;
21  int ret;
22  u8 *desc_buf;
23  
24  if (ufshcd_map_desc_id_to_length(hba, desc_idn, &desc_len) ||
25  off >= desc_len)
26  return -EINVAL;
27  desc_buf = kzalloc(desc_len, GFP_ATOMIC);
28  if (!desc_buf)
29  return -ENOMEM;
30  ret = ufshcd_query_descriptor_retry(hba, 
UPIU_QUERY_OPCODE_READ_DESC,
31  desc_idn, index, 0, desc_buf, &desc_len);
32  if (ret)
33  return -EINVAL;
34  switch (param_size) {
35  case UFS_PARAM_BYTE_SIZE:
36  ret = sprintf(buf, "0x%02X\n", desc_buf[off]);
37  break;
38  case UFS_PARAM_WORD_SIZE:
39  ret = sprintf(buf, "0x%04X\n",
  > 40  be16_to_cpu(*((u16 *)(desc_buf + off;
41  break;
42  case UFS_PARAM_DWORD_SIZE:
43  ret = sprintf(buf, "0x%08X\n",
  > 44  be32_to_cpu(*((u32 *)(desc_buf + off;
45  break;
46  case UFS_PARAM_QWORD_SIZE:
47  ret = sprintf(buf, "0x%016llX\n",
  > 48  be64_to_cpu(*((u64 *)(desc_buf + off;
49  break;
50  }
51  kfree(desc_buf);
52  
53  return ret;
54  }
55  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


Re: [PATCH v1 1/9] ufs: sysfs: device descriptor

2017-12-25 Thread kbuild test robot
Hi Stanislav,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on scsi/for-next]
[also build test ERROR on v4.15-rc5 next-20171222]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Stanislav-Nijnikov/ufs-sysfs-read-only-access-to-device-descriptors-attributes-and-flags/20171226-075252
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
config: x86_64-kexec (attached as .config)
compiler: gcc-7 (Debian 7.2.0-12) 7.2.1 20171025
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All errors (new ones prefixed by >>):

   WARNING: modpost: missing MODULE_LICENSE() in drivers/scsi/ufs/ufs-sysfs.o
   see include/linux/module.h for more information
>> ERROR: "ufs_sysfs_remove_device_management" [drivers/scsi/ufs/ufshcd.ko] 
>> undefined!
>> ERROR: "ufs_sysfs_add_device_management" [drivers/scsi/ufs/ufshcd.ko] 
>> undefined!
>> ERROR: "ufshcd_query_descriptor_retry" [drivers/scsi/ufs/ufs-sysfs.ko] 
>> undefined!

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


Re: [PATCH v1 6/9] ufs: sysfs: string descriptors

2017-12-25 Thread kbuild test robot
Hi Stanislav,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on scsi/for-next]
[also build test ERROR on v4.15-rc5 next-20171222]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Stanislav-Nijnikov/ufs-sysfs-read-only-access-to-device-descriptors-attributes-and-flags/20171226-075252
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
config: x86_64-rhel (attached as .config)
compiler: gcc-7 (Debian 7.2.0-12) 7.2.1 20171025
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All errors (new ones prefixed by >>):

   WARNING: modpost: missing MODULE_LICENSE() in drivers/hid/hid-holtekff.o
   see include/linux/module.h for more information
   WARNING: modpost: missing MODULE_LICENSE() in drivers/scsi/ufs/ufs-sysfs.o
   see include/linux/module.h for more information
   ERROR: "ufs_sysfs_add_device_management" [drivers/scsi/ufs/ufshcd.ko] 
undefined!
   ERROR: "ufs_sysfs_remove_device_management" [drivers/scsi/ufs/ufshcd.ko] 
undefined!
>> ERROR: "ufshcd_read_string_desc" [drivers/scsi/ufs/ufs-sysfs.ko] undefined!
   ERROR: "ufshcd_query_descriptor_retry" [drivers/scsi/ufs/ufs-sysfs.ko] 
undefined!

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip