Re: [PATCH v2 net-next 3/4] qed*: Utilize FW 8.33.1.0

2017-12-27 Thread kbuild test robot
Hi Tomer,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on net-next/master]

url:
https://github.com/0day-ci/linux/commits/Tomer-Tayar/qed-Refactoring-and-rearranging-FW-API-with-no-functional-impact/20171227-110607
config: i386-randconfig-h0-12271326 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers/net/ethernet/qlogic/qed/qed_init_fw_funcs.o: In function 
`qed_calc_cdu_validation_byte':
>> drivers/net/ethernet/qlogic/qed/qed_init_fw_funcs.c:1322: undefined 
>> reference to `crc8_populate_msb'
>> drivers/net/ethernet/qlogic/qed/qed_init_fw_funcs.c:1343: undefined 
>> reference to `crc8'

vim +1322 drivers/net/ethernet/qlogic/qed/qed_init_fw_funcs.c

  1311  
  1312  /* Calculate and return CDU validation byte per connection 
type/region/cid */
  1313  static u8 qed_calc_cdu_validation_byte(u8 conn_type, u8 region, u32 cid)
  1314  {
  1315  const u8 validation_cfg = CDU_VALIDATION_DEFAULT_CFG;
  1316  u8 crc, validation_byte = 0;
  1317  static u8 crc8_table_valid; /* automatically initialized to 0 */
  1318  u32 validation_string = 0;
  1319  u32 data_to_crc;
  1320  
  1321  if (!crc8_table_valid) {
> 1322  crc8_populate_msb(cdu_crc8_table, 0x07);
  1323  crc8_table_valid = 1;
  1324  }
  1325  
  1326  /* The CRC is calculated on the String-to-compress:
  1327   * [31:8]  = {CID[31:20],CID[11:0]}
  1328   * [7:4]   = Region
  1329   * [3:0]   = Type
  1330   */
  1331  if ((validation_cfg >> CDU_CONTEXT_VALIDATION_CFG_USE_CID) & 1)
  1332  validation_string |= (cid & 0xFFF0) | ((cid & 
0xFFF) << 8);
  1333  
  1334  if ((validation_cfg >> CDU_CONTEXT_VALIDATION_CFG_USE_REGION) & 
1)
  1335  validation_string |= ((region & 0xF) << 4);
  1336  
  1337  if ((validation_cfg >> CDU_CONTEXT_VALIDATION_CFG_USE_TYPE) & 1)
  1338  validation_string |= (conn_type & 0xF);
  1339  
  1340  /* Convert to big-endian and calculate CRC8 */
  1341  data_to_crc = be32_to_cpu(validation_string);
  1342  
> 1343  crc = crc8(cdu_crc8_table,
  1344 (u8 *)&data_to_crc, sizeof(data_to_crc), 
CRC8_INIT_VALUE);
  1345  
  1346  /* The validation byte [7:0] is composed:
  1347   * for type A validation
  1348   * [7]  = active configuration bit
  1349   * [6:0]= crc[6:0]
  1350   *
  1351   * for type B validation
  1352   * [7]  = active configuration bit
  1353   * [6:3]= connection_type[3:0]
  1354   * [2:0]= crc[2:0]
  1355   */
  1356  validation_byte |=
  1357  ((validation_cfg >>
  1358CDU_CONTEXT_VALIDATION_CFG_USE_ACTIVE) & 1) << 7;
  1359  
  1360  if ((validation_cfg >>
  1361   CDU_CONTEXT_VALIDATION_CFG_VALIDATION_TYPE_SHIFT) & 1)
  1362  validation_byte |= ((conn_type & 0xF) << 3) | (crc & 
0x7);
  1363  else
  1364  validation_byte |= crc & 0x7F;
  1365  
  1366  return validation_byte;
  1367  }
  1368  

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


.config.gz
Description: application/gzip


RE: [PATCH 2/2 v4] scsi: ufs: introduce sysfs entries exposing UFS health info

2017-12-27 Thread Avri Altman


> -Original Message-
> From: linux-scsi-ow...@vger.kernel.org [mailto:linux-scsi-
> ow...@vger.kernel.org] On Behalf Of Greg Kroah-Hartman
> Sent: Thursday, December 21, 2017 10:00 AM
> To: Jaegeuk Kim 
> Cc: linux-ker...@vger.kernel.org; linux-scsi@vger.kernel.org; Jaegeuk Kim
> 
> Subject: Re: [PATCH 2/2 v4] scsi: ufs: introduce sysfs entries exposing UFS
> health info
> 
> On Wed, Dec 20, 2017 at 02:13:25PM -0800, Jaegeuk Kim wrote:
> > This patch adds a new sysfs group, namely health, via:
> >
> >/sys/devices/soc/X.ufshc/health/
As device health is just one piece of information out of the device management,
I think that you should address this in a more comprehensive way,
And set hooks for much more device info:
Allow access to device descriptors, attributes and flags.
The attributes and flags should be placed in separate subfolders
The LUN specific descriptors and attributes should be placed in a luns 
subfolder, and then per descriptor / attribute type
You might also would like to consider differentiating read and write - to 
control those type of accesses as well.

Cheers,
Avri



Re: You will definetely be interested...

2017-12-27 Thread Sra. Angel Rania
Hi Dear,

Reading your profile has given me courage in search of a reasponsable
and trust worthy Fellow. The past has treated me so awfully but now I
am ready to move on despite of my health condition. I will like to
have a sincere and important discussion with you that will be in your
favor likewise to you and your environment especially to your close
family. Endeavor to reply me and I have attached my picture in case
you long to know who emailed you. I will be waiting to hear from you
as soon as possble.
Thanks for paying attention to my mail and will appreciate so much if
I receive a reply from you for understable details.

Thanks,

Mrs. Rania Hassan


Re: [PATCH 00/28] aacraid: Refactor for sas transport and bug fixes

2017-12-27 Thread Guilherme G. Piccoli
On 12/26/2017 11:27 PM, Raghava Aditya Renukunta wrote:
> [...]
>> I was thinking...if possible, and just in case you plan to send a V2
>> after Bart's comments (or any other future reviews this patchset gets),
>> how about splitting in 2 patchsets, one for bug fixes and the other for
>> improvements/foundation of sas support?
>>
>> It could help to speed-up the merge of bug fixes.
> 
> Hi Guilherme,
> It did cross my mind, but I wanted to get the sas transport and bug fixes in 
> by 4.16. I thought
> that breaking the patches into 3 patch sets might not help with it.
> 

Yeah, makes sense in this case! Thanks for considering it :)
Cheers,


Guilherme

> Regards,
> Raghava Aditya
> 
>  
>> Thanks,
>>
>>
>> Guilherme
>>>
>>>  - Fixed a udev inquiry race condition
>>>  - Fixed a kdump hang issue which occurs in case of error recovery in kdump
>>>  - Made improvements to ioctl reset and reset_host sysfs reset paths
>>>  - Changed the code to retrieve lun information into stand alone functions.
>>>  - Merged container and hba hotplug event processing (device addition and
>>>and removal into single function)
>>>  - Removed scsi_scan_host for safw devices and now explicitly add devices
>>>retrieved from the fw.
>>>  - Reschedule scan in driver fails to retrieve lun information from fw.
>>>(usually works in a few attempts)
>>>  - Rescan worker waits for any pending EH recovery before rescanning
>>>  - Do not trigger rescan worker in kdump kernel
>>>
>>> Raghava Aditya Renukunta (29):
>>>   scsi: aacraid: Fix udev inquiry race condition
>>>   scsi: aacraid: Do not attempt abort when Fw panicked
>>>   scsi: aacraid: Fix hang in kdump
>>>   scsi: aacraid: Do not remove offlined devices
>>>   scsi: aacraid: Fix ioctl reset hang
>>>   scsi: aacraid: Allow reset_host sysfs var to recover Panicked Fw
>>>   scsi: aacraid: Refactor reset_host store function
>>>   scsi: aacraid: Move code to wait for IO completion to shutdown func
>>>   scsi: aacraid: Create bmic submission function from bmic identify
>>>   scsi: aacraid: Change phy luns function to use common bmic function
>>>   scsi: aacraid: Refactor and rename to make mirror existing changes
>>>   scsi: aacraid: Add target setup helper function
>>>   scsi: aacraid: Untangle targets setup from report phy luns
>>>   scsi: aacraid: Move function around to match existing code
>>>   scsi: aacraid: Create helper functions to get lun info
>>>   scsi: aacraid: Save bmic phy information for each phy
>>>   scsi: aacraid: Add helper function to set queue depth
>>>   scsi: aacraid: Merge func to get container information
>>>   scsi: aacraid: Process hba and container hot plug events in single
>>>   function
>>>   scsi: aacraid: Added macros to help loop through known buses and targets
>>>   scsi: aacraid: Refactor resolve luns code and scsi functions
>>>   scsi: aacraid: Merge adapter setup with resolve luns
>>>   scsi: aacraid: Block concurrent hotplug event handling
>>>   scsi: aacraid: Use hotplug handling function in place of scsi_scan_host
>>>   scsi: aacraid: Reschedule host scan in case of failure
>>>   scsi: aacraid: Fix hang while scanning in eh recovery
>>>   scsi: aacraid: Skip schedule rescan in case of kdump
>>>   scsi: aacraid: Remove unused rescan variable
>>>   scsi: aacraid: Remove AAC_HIDE_DISK check in queue command
>>>
>>>  drivers/scsi/aacraid/aachba.c   | 479 +++
>> -
>>>  drivers/scsi/aacraid/aacraid.h  |  52 -
>>>  drivers/scsi/aacraid/commctrl.c |   6 +-
>>>  drivers/scsi/aacraid/comminit.c |  49 +++-
>>>  drivers/scsi/aacraid/commsup.c  | 224 ++-
>>>  drivers/scsi/aacraid/linit.c|  23 +-
>>>  6 files changed, 561 insertions(+), 272 deletions(-)
>>>
> 



Re: [PATCH 2/2 v4] scsi: ufs: introduce sysfs entries exposing UFS health info

2017-12-27 Thread Greg Kroah-Hartman
On Wed, Dec 27, 2017 at 09:00:10AM +, Avri Altman wrote:
> 
> 
> > -Original Message-
> > From: linux-scsi-ow...@vger.kernel.org [mailto:linux-scsi-
> > ow...@vger.kernel.org] On Behalf Of Greg Kroah-Hartman
> > Sent: Thursday, December 21, 2017 10:00 AM
> > To: Jaegeuk Kim 
> > Cc: linux-ker...@vger.kernel.org; linux-scsi@vger.kernel.org; Jaegeuk Kim
> > 
> > Subject: Re: [PATCH 2/2 v4] scsi: ufs: introduce sysfs entries exposing UFS
> > health info
> > 
> > On Wed, Dec 20, 2017 at 02:13:25PM -0800, Jaegeuk Kim wrote:
> > > This patch adds a new sysfs group, namely health, via:
> > >
> > >/sys/devices/soc/X.ufshc/health/
> As device health is just one piece of information out of the device 
> management,
> I think that you should address this in a more comprehensive way,
> And set hooks for much more device info:
> Allow access to device descriptors, attributes and flags.

Add on patches are easy to create for this if people really want and
need it :)

> The attributes and flags should be placed in separate subfolders

Why?  What is that going to help with?

> The LUN specific descriptors and attributes should be placed in a luns
> subfolder, and then per descriptor / attribute type

Again, why?

> You might also would like to consider differentiating read and write -
> to control those type of accesses as well.

What do you mean by this exactly?

As it is, this is a step forward in getting attributes that people are
asking for and already using, into the kernel tree.  Please don't object
because not all attributes that are possible are being added here, it
should be trivial to add more as needed, right?

I'm really tired of seeing all of the various out-of-tree forks of this
driver, it's about time that someone works to get those features merged,
right?

thanks,

greg k-h


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

2017-12-27 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   | 649 +++
 drivers/scsi/ufs/ufs-sysfs.h   |  14 +
 drivers/scsi/ufs/ufs.h | 115 -
 drivers/scsi/ufs/ufshcd.c  |  56 +-
 drivers/scsi/ufs/ufshcd.h  |  25 +
 include/scsi/scsi_host.h   |   6 +
 9 files changed, 1652 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 7/9] ufs: sysfs: unit descriptor

2017-12-27 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   |  58 
 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, 222 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 blo

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

2017-12-27 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   | 158 
 drivers/scsi/ufs/ufs-sysfs.h   |  10 ++
 drivers/scsi/ufs/ufs.h |   8 ++
 drivers/scsi/ufs/ufshcd.c  |  13 +-
 drivers/scsi/ufs/ufshcd.h  |   4 +
 7 files changed, 412 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 9/9] ufs: sysfs: attributes

2017-12-27 Thread Stanislav Nijnikov
Signed-off-by: Stanislav Nijnikov 
---
 Documentation/ABI/testing/sysfs-driver-ufs | 141 -
 drivers/scsi/ufs/ufs-sysfs.c   |  90 ++
 drivers/scsi/ufs/ufs-sysfs.h   |   1 +
 drivers/scsi/ufs/ufs.h |  27 +-
 drivers/scsi/ufs/ufshcd.c  |   6 +-
 drivers/scsi/ufs/ufshcd.h  |   2 +
 6 files changed, 260 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 8/9] ufs: sysfs: flags

2017-12-27 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 +--
 drivers/scsi/ufs/ufshcd.c  |  1 +
 4 files changed, 119 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 509abc9..de80c20 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

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

2017-12-27 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  |  5 +--
 drivers/scsi/ufs/ufshcd.h  |  3 ++
 4 files changed, 103 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 a1a0636..1be058c 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-27 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 441dc87..a1a0636 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 3/9] ufs: sysfs: geometry descriptor

2017-12-27 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 

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

2017-12-27 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 82ba7b1..441dc87 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 6e15cda..7b61e02 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@

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

2017-12-27 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 63a8e68..b8e29f2 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



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

2017-12-27 Thread Greg KH
On Wed, Dec 27, 2017 at 03:49:28PM +0200, Stanislav Nijnikov wrote:
> Signed-off-by: Stanislav Nijnikov 
> ---

I never want to take a patch with no changelog text at all, and to have
a 9 patch series with nothing written in them at all?  That's not good.

Please fix up.

greg k-h


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

2017-12-27 Thread Stanislav Nijnikov
This patch introduces a sysfs group entry for the UFS geometry descriptor
parameters. The group adds "geometry_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 
---
 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
+D

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

2017-12-27 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.

Changelog:
v1 -> v2
Provided additional description for the changes

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   | 649 +++
 drivers/scsi/ufs/ufs-sysfs.h   |  14 +
 drivers/scsi/ufs/ufs.h | 115 -
 drivers/scsi/ufs/ufshcd.c  |  56 +-
 drivers/scsi/ufs/ufshcd.h  |  25 +
 include/scsi/scsi_host.h   |   6 +
 9 files changed, 1652 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 v2 7/9] ufs: sysfs: unit descriptor

2017-12-27 Thread Stanislav Nijnikov
This patch introduces a sysfs group entry for the UFS unit descriptor
parameters. The group adds "unit_descriptor" folder under the corresponding
SCSI device sysfs entry (/sys/class/scsi_device/*/device/). The parameters
are shown as hexadecimal numbers. The full information about the parameters
could be found at UFS specifications 2.1.
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   |  58 
 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, 222 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

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

2017-12-27 Thread Stanislav Nijnikov
This patch introduces a sysfs group entry for the UFS attributes. The
group adds "attributes" folder under the UFS driver sysfs entry
(/sys/bus/platform/drivers/ufshcd/*). The attributes are shown
as hexadecimal numbers. The full information about the attributes could
be found at UFS specifications 2.1.

Signed-off-by: Stanislav Nijnikov 
---
 Documentation/ABI/testing/sysfs-driver-ufs | 141 -
 drivers/scsi/ufs/ufs-sysfs.c   |  90 ++
 drivers/scsi/ufs/ufs-sysfs.h   |   1 +
 drivers/scsi/ufs/ufs.h |  27 +-
 drivers/scsi/ufs/ufshcd.c  |   6 +-
 drivers/scsi/ufs/ufshcd.h  |   2 +
 6 files changed, 260 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:   Th

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

2017-12-27 Thread Stanislav Nijnikov
This patch introduces a sysfs group entry for the UFS string descriptors.
The group adds "string_descriptors" folder under the UFS driver
sysfs entry (/sys/bus/platform/drivers/ufshcd/*). The folder will contain
5 files that will show string values defined by the UFS spec:
a manufacturer name, a product name, an OEM id, a serial number and a
product revision.  The full information about the string descriptors
could be found at UFS specifications 2.1.

Signed-off-by: Stanislav Nijnikov 
---
 Documentation/ABI/testing/sysfs-driver-ufs | 39 
 drivers/scsi/ufs/ufs-sysfs.c   | 58 ++
 drivers/scsi/ufs/ufshcd.c  |  5 +--
 drivers/scsi/ufs/ufshcd.h  |  3 ++
 4 files changed, 103 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 a1a0636..1be058c 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 = de

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

2017-12-27 Thread Stanislav Nijnikov
This patch introduces a sysfs group entry for the UFS flags. The group adds
"flags" folder under the UFS driver sysfs entry
(/sys/bus/platform/drivers/ufshcd/*). The flags are shown as boolean value
("true" or "false"). The full information about the UFS flags could be
found at UFS specifications 2.1.

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 +--
 drivers/scsi/ufs/ufshcd.c  |  1 +
 4 files changed, 119 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 509abc9..de80c20 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_drvd

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

2017-12-27 Thread Stanislav Nijnikov
This patch introduces a sysfs group entry for the UFS power descriptor
parameters. The group adds "power_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 
---
 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 441dc87..a1a0636 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

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

2017-12-27 Thread Stanislav Nijnikov
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 
---
 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 82ba7b1..441dc87 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_

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

2017-12-27 Thread Stanislav Nijnikov
This patch introduces a sysfs group entry for the UFS device descriptor
parameters. The group adds "device_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 
---
 Documentation/ABI/testing/sysfs-driver-ufs | 223 +
 drivers/scsi/ufs/Makefile  |   2 +-
 drivers/scsi/ufs/ufs-sysfs.c   | 158 
 drivers/scsi/ufs/ufs-sysfs.h   |  10 ++
 drivers/scsi/ufs/ufs.h |   8 ++
 drivers/scsi/ufs/ufshcd.c  |  13 +-
 drivers/scsi/ufs/ufshcd.h  |   4 +
 7 files changed, 412 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 afte

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

2017-12-27 Thread Stanislav Nijnikov
This patch introduces a sysfs group entry for the UFS interconnect
descriptor parameters. The group adds "interconnect_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 
---
 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 63a8e68..b8e29f2 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



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

2017-12-27 Thread Greg KH
On Wed, Dec 27, 2017 at 05:13:39PM +0200, Stanislav Nijnikov wrote:
> +EXPORT_SYMBOL(ufs_sysfs_add_device_management);

Whhy is this exported?  What external module uses it?

> +
> +void ufs_sysfs_remove_device_management(struct ufs_hba *hba)
> +{
> + sysfs_remove_groups(&hba->dev->kobj, ufs_sysfs_groups);
> +}
> +EXPORT_SYMBOL(ufs_sysfs_remove_device_management);
> +
> +MODULE_LICENSE("GPL");

Are you sure you didn't just put 2 module license fields in the same
module?

Other than those nits, looks good!

thanks,

greg k-h


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

2017-12-27 Thread Greg KH
On Wed, Dec 27, 2017 at 05:13:39PM +0200, Stanislav Nijnikov wrote:
> diff --git a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c
> new file mode 100644
> index 000..63a8e68
> --- /dev/null
> +++ b/drivers/scsi/ufs/ufs-sysfs.c
> @@ -0,0 +1,158 @@
> +#include 
> +#include 
> +
> +#include "ufs.h"
> +#include "ufs-sysfs.h"

No SPDX license information or copyright info for this file?  That's
brave :(

> diff --git a/drivers/scsi/ufs/ufs-sysfs.h b/drivers/scsi/ufs/ufs-sysfs.h
> new file mode 100644
> index 000..369ba21
> --- /dev/null
> +++ b/drivers/scsi/ufs/ufs-sysfs.h
> @@ -0,0 +1,10 @@
> +#ifndef __UFS_SYSFS_H__
> +#define __UFS_SYSFS_H__

Same comment here.

thanks,

greg k-h


Re: [PATCH v2 2/9] ufs: sysfs: interconnect descriptor

2017-12-27 Thread Greg KH
On Wed, Dec 27, 2017 at 05:13:40PM +0200, Stanislav Nijnikov wrote:
> This patch introduces a sysfs group entry for the UFS interconnect
> descriptor parameters. The group adds "interconnect_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 

Reviewed-by: Greg Kroah-Hartman 


Re: [PATCH v2 3/9] ufs: sysfs: geometry descriptor

2017-12-27 Thread Greg KH
On Wed, Dec 27, 2017 at 05:13:41PM +0200, Stanislav Nijnikov wrote:
> This patch introduces a sysfs group entry for the UFS geometry descriptor
> parameters. The group adds "geometry_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 

Reviewed-by: Greg Kroah-Hartman 


Re: [PATCH v2 4/9] ufs: sysfs: health descriptor

2017-12-27 Thread Greg KH
On Wed, Dec 27, 2017 at 05:13:42PM +0200, Stanislav Nijnikov wrote:
> 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 

Reviewed-by: Greg Kroah-Hartman 



[PATCH 10/12] hpsa: drop unneeded newline

2017-12-27 Thread Julia Lawall
hpsa_show_dev_msg prints other information and a newline after the
message string, so the message string does not need to include a
newline explicitly.  Done using Coccinelle.

Signed-off-by: Julia Lawall 

---
 drivers/scsi/hpsa.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index b0aa5dc..3bb8191 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -3518,7 +3518,7 @@ static void hpsa_get_enclosure_info(struct ctlr_info *h,
 
if (rc != IO_OK)
hpsa_show_dev_msg(KERN_INFO, h, encl_dev,
-   "Error, could not get enclosure information\n");
+   "Error, could not get enclosure information");
 }
 
 static u64 hpsa_get_sas_address_from_report_physical(struct ctlr_info *h,



[PATCH 00/12] drop unneeded newline

2017-12-27 Thread Julia Lawall
Drop newline at the end of a message string when the printing function adds
a newline.

The complete semantic patch that detects this issue is as shown below
(http://coccinelle.lip6.fr/).  It works in two phases - the first phase
counts how many uses of a function involve a newline and how many don't,
and then the second phase removes newlines in the case of calls where a
newline is used one fourth of the times or less.

This approach is only moderately reliable, and all patches have been
checked to ensure that the newline is not needed.

This also converts some cases of string concatenation to single strings in
modified code, as this improves greppability.

// 
virtual after_start

@initialize:ocaml@
@@

let withnl = Hashtbl.create 101
let withoutnl = Hashtbl.create 101

let ignore =
  ["strcpy";"strlcpy";"strcat";"strlcat";"strcmp";"strncmp";"strcspn";
"strsep";"sprintf";"printf";"strncasecmp";"seq_printf";"strstr";"strspn";
"strlen";"strpbrk";"strtok_r";"memcmp";"memcpy"]

let dignore = ["tools";"samples"]

let inc tbl k =
  let cell =
try Hashtbl.find tbl k
with Not_found ->
  let cell = ref 0 in
  Hashtbl.add tbl k cell;
  cell in
  cell := 1 + !cell

let endnl c =
  let len = String.length c in
  try
String.get c (len-3) = '\\' && String.get c (len-2) = 'n' &&
String.get c (len-1) = '"'
  with _ -> false

let clean_string s extra =
  let pieces = Str.split (Str.regexp "\" \"") s in
  let nonempty s =
not (s = "") && String.get s 0 = '"' && not (String.get s 1 = '"') in
  let rec loop = function
  [] -> []
| [x] -> [x]
| x::y::rest ->
if nonempty x && nonempty y
then
  let xend = String.get x (String.length x - 2) = ' ' in
  let yend = String.get y 1 = ' ' in
  match (xend,yend) with
(true,false) | (false,true) -> x :: (loop (y::rest))
  | (true,true) ->
  x :: (loop (((String.sub y 0 (String.length y - 2))^"\"")::rest))
  | (false,false) ->
  ((String.sub x 0 (String.length x - 1)) ^ " \"") ::
  (loop (y::rest))
else x :: (loop (y::rest)) in
  (String.concat "" (loop pieces))^extra

@r depends on !after_start@
constant char[] c;
expression list[n] es;
identifier f;
position p;
@@

f@p(es,c,...)

@script:ocaml@
f << r.f;
n << r.n;
p << r.p;
c << r.c;
@@

let pieces = Str.split (Str.regexp "/") (List.hd p).file in
if not (List.mem f ignore) &&
  List.for_all (fun x -> not (List.mem x pieces)) dignore
then
  (if endnl c
  then inc withnl (f,n)
  else inc withoutnl (f,n))

@finalize:ocaml depends on !after_start@
w1 << merge.withnl;
w2 << merge.withoutnl;
@@

let names = ref [] in
let incn tbl k v =
  let cell =
try Hashtbl.find tbl k
with Not_found ->
  begin
let cell = ref 0 in
Hashtbl.add tbl k cell;
cell
  end in
  (if not (List.mem k !names) then names := k :: !names);
  cell := !v + !cell in
List.iter (function w -> Hashtbl.iter (incn withnl) w) w1;
List.iter (function w -> Hashtbl.iter (incn withoutnl) w) w2;

List.iter
  (function name ->
let wth = try !(Hashtbl.find withnl name) with _ -> 0 in
let wo = try !(Hashtbl.find withoutnl name) with _ -> 0 in
if wth > 0 && wth <= wo / 3 then Hashtbl.remove withnl name
else (Printf.eprintf "dropping %s %d %d\n" (fst name) wth wo; 
Hashtbl.remove withoutnl name; Hashtbl.remove withnl name))
  !names;

let it = new iteration() in
it#add_virtual_rule After_start;
it#register()

@s1 depends on after_start@
constant char[] c;
expression list[n] es;
identifier f;
position p;
@@

f(es,c@p,...)

@script:ocaml s2@
f << s1.f;
n << s1.n;
c << s1.c;
newc;
@@

try
  let _ = Hashtbl.find withnl (f,n) in
  if endnl c
  then Coccilib.include_match false
  else newc :=
make_expr(clean_string (String.sub c 0 (String.length c - 1)) "\\n\"")
with Not_found ->
try
  let _ = Hashtbl.find withoutnl (f,n) in
  if endnl c
  then newc :=
make_expr(clean_string (String.sub c 0 (String.length c - 3)) "\"")
  else Coccilib.include_match false
with Not_found -> Coccilib.include_match false

@@
constant char[] s1.c;
position s1.p;
expression s2.newc;
@@

- c@p
+ newc
// 

---

 arch/arm/mach-davinci/board-da850-evm.c |4 ++--
 drivers/block/DAC960.c  |4 ++--
 drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c|   12 
 drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c  |2 +-
 drivers/gpu/drm/amd/powerplay/smumgr/iceland_smumgr.c   |2 +-
 drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c |2 +-
 drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c |2 +-
 drivers/media/usb/pvrusb2/pvrusb2-hdw.c |3 ++-
 drivers/s390/block/dasd_diag.c  |3 +--
 drivers/scsi/hpsa.c |2 +-
 fs/dlm/plock.c  |3 +--
 fs/ext2/super.c 

Re: [PATCH v2 5/9] ufs: sysfs: power descriptor

2017-12-27 Thread Greg KH
On Wed, Dec 27, 2017 at 05:13:43PM +0200, Stanislav Nijnikov wrote:
> This patch introduces a sysfs group entry for the UFS power descriptor
> parameters. The group adds "power_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 

Reviewed-by: Greg Kroah-Hartman 


Re: [PATCH v2 7/9] ufs: sysfs: unit descriptor

2017-12-27 Thread Greg KH
On Wed, Dec 27, 2017 at 05:13:45PM +0200, Stanislav Nijnikov wrote:
> This patch introduces a sysfs group entry for the UFS unit descriptor
> parameters. The group adds "unit_descriptor" folder under the corresponding
> SCSI device sysfs entry (/sys/class/scsi_device/*/device/). The parameters
> are shown as hexadecimal numbers. The full information about the parameters
> could be found at UFS specifications 2.1.
> 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   |  58 
>  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, 222 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

Minor nit for all of these, August 2017 was a few months ago :)

Reviewed-by: Greg Kroah-Hartman 


Re: [PATCH v2 8/9] ufs: sysfs: flags

2017-12-27 Thread Greg KH
On Wed, Dec 27, 2017 at 05:13:46PM +0200, Stanislav Nijnikov wrote:
> This patch introduces a sysfs group entry for the UFS flags. The group adds
> "flags" folder under the UFS driver sysfs entry
> (/sys/bus/platform/drivers/ufshcd/*). The flags are shown as boolean value
> ("true" or "false"). The full information about the UFS flags could be
> found at UFS specifications 2.1.
> 
> 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 +--
>  drivers/scsi/ufs/ufshcd.c  |  1 +
>  4 files changed, 119 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 509abc9..de80c20 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,   

Re: [PATCH v2 9/9] ufs: sysfs: attributes

2017-12-27 Thread Greg KH
On Wed, Dec 27, 2017 at 05:13:47PM +0200, Stanislav Nijnikov wrote:
> This patch introduces a sysfs group entry for the UFS attributes. The
> group adds "attributes" folder under the UFS driver sysfs entry
> (/sys/bus/platform/drivers/ufshcd/*). The attributes are shown
> as hexadecimal numbers. The full information about the attributes could
> be found at UFS specifications 2.1.
> 
> Signed-off-by: Stanislav Nijnikov 
> ---
>  Documentation/ABI/testing/sysfs-driver-ufs | 141 
> -
>  drivers/scsi/ufs/ufs-sysfs.c   |  90 ++
>  drivers/scsi/ufs/ufs-sysfs.h   |   1 +
>  drivers/scsi/ufs/ufs.h |  27 +-
>  drivers/scsi/ufs/ufshcd.c  |   6 +-
>  drivers/scsi/ufs/ufshcd.h  |   2 +
>  6 files changed, 260 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.

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

2017-12-27 Thread Greg KH
On Wed, Dec 27, 2017 at 05:13:44PM +0200, Stanislav Nijnikov wrote:
> This patch introduces a sysfs group entry for the UFS string descriptors.
> The group adds "string_descriptors" folder under the UFS driver
> sysfs entry (/sys/bus/platform/drivers/ufshcd/*). The folder will contain
> 5 files that will show string values defined by the UFS spec:
> a manufacturer name, a product name, an OEM id, a serial number and a
> product revision.  The full information about the string descriptors
> could be found at UFS specifications 2.1.
> 
> Signed-off-by: Stanislav Nijnikov 

Reviewed-by: Greg Kroah-Hartman 


[PATCH v4 net-next 0/4] qed*: Advance to FW 8.33.1.0

2017-12-27 Thread Tomer Tayar
This series advances all qed* drivers to use firmware 8.33.1.0 which brings
new capabilities and initial support of new HW. The changes are mostly in
qed, and include changes in the FW interface files, as well as updating the
FW initialization and debug collection code. The protocol drivers have
minor functional changes for this firmware.

Patch 1 Rearranges and refactors the FW interface files in preparation of
the new FW (no functional change).
Patch 2 Prepares the code for support of new HW (no functional change).
Patch 3 Actual utilization of the new FW.
Patch 4 Advances drivers' version.

v3->v4:
Fix a compilation issue which was reported by krobot (dependency on CRC8).

v2->v3:
Resend the series with a fixed title in the cover letter.

v1->v2:
- Break the previous single patch into several patches.
- Fix compilation issues which were reported by krobot.

Tomer Tayar (4):
  qed*: Refactoring and rearranging FW API with no functional impact
  qed*: HSI renaming for different types of HW
  qed*: Utilize FW 8.33.1.0
  qed*: Advance drivers' version to 8.33.0.20

 drivers/infiniband/hw/qedr/main.c  | 2 +-
 drivers/infiniband/hw/qedr/qedr_hsi_rdma.h |   125 +-
 drivers/net/ethernet/qlogic/Kconfig| 1 +
 drivers/net/ethernet/qlogic/qed/qed.h  |12 +-
 drivers/net/ethernet/qlogic/qed/qed_cxt.c  |37 +-
 drivers/net/ethernet/qlogic/qed/qed_cxt.h  | 4 +-
 drivers/net/ethernet/qlogic/qed/qed_dcbx.c | 4 +-
 drivers/net/ethernet/qlogic/qed/qed_debug.c|  1167 +-
 drivers/net/ethernet/qlogic/qed/qed_dev.c  |15 +-
 drivers/net/ethernet/qlogic/qed/qed_fcoe.c |10 +-
 drivers/net/ethernet/qlogic/qed/qed_hsi.h  | 10603 ++-
 drivers/net/ethernet/qlogic/qed/qed_hw.c   |68 +
 drivers/net/ethernet/qlogic/qed/qed_hw.h   | 4 +
 .../net/ethernet/qlogic/qed/qed_init_fw_funcs.c|  1091 +-
 drivers/net/ethernet/qlogic/qed/qed_init_ops.c |22 +-
 drivers/net/ethernet/qlogic/qed/qed_int.c  | 8 +-
 drivers/net/ethernet/qlogic/qed/qed_int.h  | 2 +-
 drivers/net/ethernet/qlogic/qed/qed_iscsi.c|58 +-
 drivers/net/ethernet/qlogic/qed/qed_iwarp.c|33 +-
 drivers/net/ethernet/qlogic/qed/qed_iwarp.h| 3 +-
 drivers/net/ethernet/qlogic/qed/qed_l2.c   |   118 +-
 drivers/net/ethernet/qlogic/qed/qed_l2.h   |33 +-
 drivers/net/ethernet/qlogic/qed/qed_ll2.c  |28 +-
 drivers/net/ethernet/qlogic/qed/qed_mcp.c  | 2 +-
 drivers/net/ethernet/qlogic/qed/qed_rdma.c | 2 +-
 drivers/net/ethernet/qlogic/qed/qed_reg_addr.h |   190 +-
 drivers/net/ethernet/qlogic/qed/qed_sp_commands.c  | 8 +-
 drivers/net/ethernet/qlogic/qed/qed_spq.c  | 8 +-
 drivers/net/ethernet/qlogic/qed/qed_sriov.c|22 +-
 drivers/net/ethernet/qlogic/qed/qed_sriov.h|24 +
 drivers/net/ethernet/qlogic/qede/qede.h| 6 +-
 drivers/net/ethernet/qlogic/qede/qede_filter.c |26 +-
 drivers/net/ethernet/qlogic/qede/qede_main.c   | 2 +-
 drivers/scsi/qedf/drv_fcoe_fw_funcs.c  |35 +-
 drivers/scsi/qedf/drv_fcoe_fw_funcs.h  | 2 +-
 drivers/scsi/qedf/qedf.h   | 4 +-
 drivers/scsi/qedf/qedf_els.c   | 2 +-
 drivers/scsi/qedf/qedf_hsi.h   |68 -
 drivers/scsi/qedf/qedf_io.c|35 +-
 drivers/scsi/qedf/qedf_main.c  |12 +-
 drivers/scsi/qedf/qedf_version.h   | 8 +-
 drivers/scsi/qedi/qedi_debugfs.c   | 4 +-
 drivers/scsi/qedi/qedi_fw.c|59 +-
 drivers/scsi/qedi/qedi_fw_api.c|   139 +-
 drivers/scsi/qedi/qedi_fw_iscsi.h  | 2 +-
 drivers/scsi/qedi/qedi_gbl.h   | 5 +-
 drivers/scsi/qedi/qedi_iscsi.c | 9 +-
 drivers/scsi/qedi/qedi_iscsi.h | 2 +-
 drivers/scsi/qedi/qedi_main.c  |29 +-
 drivers/scsi/qedi/qedi_version.h   | 8 +-
 include/linux/qed/common_hsi.h |  1264 ++-
 include/linux/qed/eth_common.h |   396 +-
 include/linux/qed/fcoe_common.h|   940 +-
 include/linux/qed/iscsi_common.h   |  1585 +--
 include/linux/qed/iwarp_common.h   |17 +-
 include/linux/qed/qed_eth_if.h |38 +-
 include/linux/qed/qed_if.h |36 +-
 include/linux/qed/qed_iscsi_if.h   | 2 -
 include/linux/qed/qed_ll2_if.h | 2 +-
 include/linux/qed/rdma_common.h|25 +-
 include/linux/qed/roce_common.h|15 +-
 include/linux/qed/storage_common.h |91 +-

[PATCH v4 net-next 4/4] qed*: Advance drivers' version to 8.33.0.20

2017-12-27 Thread Tomer Tayar
Signed-off-by: Ariel Elior 
Signed-off-by: Chad Dupuis 
Signed-off-by: Manish Rangankar 
Signed-off-by: Tomer Tayar 
---
 drivers/net/ethernet/qlogic/qed/qed.h   | 8 
 drivers/net/ethernet/qlogic/qede/qede.h | 6 +++---
 drivers/scsi/qedf/qedf_version.h| 8 
 drivers/scsi/qedi/qedi_version.h| 8 
 4 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed.h 
b/drivers/net/ethernet/qlogic/qed/qed.h
index 323c13f..6948855 100644
--- a/drivers/net/ethernet/qlogic/qed/qed.h
+++ b/drivers/net/ethernet/qlogic/qed/qed.h
@@ -52,10 +52,10 @@
 
 extern const struct qed_common_ops qed_common_ops_pass;
 
-#define QED_MAJOR_VERSION   8
-#define QED_MINOR_VERSION   10
-#define QED_REVISION_VERSION11
-#define QED_ENGINEERING_VERSION 21
+#define QED_MAJOR_VERSION  8
+#define QED_MINOR_VERSION  33
+#define QED_REVISION_VERSION   0
+#define QED_ENGINEERING_VERSION20
 
 #define QED_VERSION \
((QED_MAJOR_VERSION << 24) | (QED_MINOR_VERSION << 16) | \
diff --git a/drivers/net/ethernet/qlogic/qede/qede.h 
b/drivers/net/ethernet/qlogic/qede/qede.h
index 8a33651..8e01b53 100644
--- a/drivers/net/ethernet/qlogic/qede/qede.h
+++ b/drivers/net/ethernet/qlogic/qede/qede.h
@@ -52,9 +52,9 @@
 #include 
 
 #define QEDE_MAJOR_VERSION 8
-#define QEDE_MINOR_VERSION 10
-#define QEDE_REVISION_VERSION  10
-#define QEDE_ENGINEERING_VERSION   21
+#define QEDE_MINOR_VERSION 33
+#define QEDE_REVISION_VERSION  0
+#define QEDE_ENGINEERING_VERSION   20
 #define DRV_MODULE_VERSION __stringify(QEDE_MAJOR_VERSION) "." \
__stringify(QEDE_MINOR_VERSION) "." \
__stringify(QEDE_REVISION_VERSION) "."  \
diff --git a/drivers/scsi/qedf/qedf_version.h b/drivers/scsi/qedf/qedf_version.h
index 397b3b8..c247805 100644
--- a/drivers/scsi/qedf/qedf_version.h
+++ b/drivers/scsi/qedf/qedf_version.h
@@ -7,9 +7,9 @@
  *  this source tree.
  */
 
-#define QEDF_VERSION   "8.20.5.0"
+#define QEDF_VERSION   "8.33.0.20"
 #define QEDF_DRIVER_MAJOR_VER  8
-#define QEDF_DRIVER_MINOR_VER  20
-#define QEDF_DRIVER_REV_VER5
-#define QEDF_DRIVER_ENG_VER0
+#define QEDF_DRIVER_MINOR_VER  33
+#define QEDF_DRIVER_REV_VER0
+#define QEDF_DRIVER_ENG_VER20
 
diff --git a/drivers/scsi/qedi/qedi_version.h b/drivers/scsi/qedi/qedi_version.h
index d61e3ac..8a0e523 100644
--- a/drivers/scsi/qedi/qedi_version.h
+++ b/drivers/scsi/qedi/qedi_version.h
@@ -7,8 +7,8 @@
  * this source tree.
  */
 
-#define QEDI_MODULE_VERSION"8.10.4.0"
+#define QEDI_MODULE_VERSION"8.33.0.20"
 #define QEDI_DRIVER_MAJOR_VER  8
-#define QEDI_DRIVER_MINOR_VER  10
-#define QEDI_DRIVER_REV_VER4
-#define QEDI_DRIVER_ENG_VER0
+#define QEDI_DRIVER_MINOR_VER  33
+#define QEDI_DRIVER_REV_VER0
+#define QEDI_DRIVER_ENG_VER20
-- 
1.8.3.1



[PATCH v2] target: add a target/iscsi driver-api Documentation chapter

2017-12-27 Thread Randy Dunlap
From: Randy Dunlap 

Add a driver-api document for target/iSCSI interfaces.

Signed-off-by: Randy Dunlap 
---

This patch depends on 4 previous patches to driver source files:

[PATCH] target: fix kernel-doc warnings in 
drivers/target/target_core_transport.c
  https://marc.info/?l=linux-scsi&m=151398041926906&w=2

[PATCH] scsi: fix iscsi-related kernel-doc warnings
  https://marc.info/?l=linux-scsi&m=151398051426923&w=2

[PATCH] target: add kernel-doc overview in target_core_user.[hc]
  [PATCH] target: add kernel-doc overview in target_core_user.[hc]

[PATCH] target: cleanup target_core_transport.c for kernel-doc
  https://marc.info/?l=linux-scsi&m=151409284812033&w=2

v2: fix missing ':' on one line (:export:)

 Documentation/driver-api/index.rst  |1 
 Documentation/driver-api/scsi.rst   |2 
 Documentation/driver-api/target.rst |   64 ++
 3 files changed, 66 insertions(+), 1 deletion(-)

--- linux-next-20171221.orig/Documentation/driver-api/index.rst
+++ linux-next-20171221/Documentation/driver-api/index.rst
@@ -34,6 +34,7 @@ available subsections can be seen below.
edac
scsi
libata
+   target
mtdnand
miscellaneous
w1
--- linux-next-20171221.orig/Documentation/driver-api/scsi.rst
+++ linux-next-20171221/Documentation/driver-api/scsi.rst
@@ -340,5 +340,5 @@ todo
 
 
 Parallel (fast/wide/ultra) SCSI, USB, SATA, SAS, Fibre Channel,
-FireWire, ATAPI devices, Infiniband, I2O, iSCSI, Parallel ports,
+FireWire, ATAPI devices, Infiniband, I2O, Parallel ports,
 netlink...
--- /dev/null
+++ linux-next-20171221/Documentation/driver-api/target.rst
@@ -0,0 +1,64 @@
+=
+target and iSCSI Interfaces Guide
+=
+
+Introduction and Overview
+=
+
+TBD
+
+Target core device interfaces
+=
+
+.. kernel-doc:: drivers/target/target_core_device.c
+:export:
+
+Target core transport interfaces
+
+
+.. kernel-doc:: drivers/target/target_core_transport.c
+:export:
+
+Target-supported userspace I/O
+==
+
+.. kernel-doc:: drivers/target/target_core_user.c
+:doc: Userspace I/O
+
+.. kernel-doc:: include/uapi/linux/target_core_user.h
+:doc: Ring Design
+
+iSCSI helper functions
+==
+
+.. kernel-doc:: drivers/scsi/libiscsi.c
+   :export:
+
+
+iSCSI boot information
+==
+
+.. kernel-doc:: drivers/scsi/iscsi_boot_sysfs.c
+   :export:
+
+
+iSCSI transport class
+=
+
+The file drivers/scsi/scsi_transport_iscsi.c defines transport
+attributes for the iSCSI class, which sends SCSI packets over TCP/IP
+connections.
+
+.. kernel-doc:: drivers/scsi/scsi_transport_iscsi.c
+   :export:
+
+
+iSCSI TCP interfaces
+
+
+.. kernel-doc:: drivers/scsi/iscsi_tcp.c
+   :internal:
+
+.. kernel-doc:: drivers/scsi/libiscsi_tcp.c
+   :export:
+


[PATCH] mpt3sas: Proper handling of set/clear of "ATA command pending" flag.

2017-12-27 Thread Chaitra P B
1.In IO path, setting of "ATA command pending" flag early before device
 removal, invalid device handle etc., checks causes any new commands to be
 always returned with SAM_STAT_BUSY and when the driver removes the drive
 the SML issues SYNC Cache command and that command is always returned with
 SAM_STAT_BUSY and thus making SYNC Cache command to requeued.

2.If the driver gets an ATA PT command for a SATA drive then the driver set
 "ATA command pending" flag in device specific data structure not to allow
 any further commands until the ATA PT command is completed. However, after
 setting the flag if the driver decides to return the command back to upper
 layers without actually issuing to the firmware(I,e., returns from qcmd
 failure return paths) then the corresponding flag is not cleared and this
 prevents the driver from sending any new commands to the drive.

 This patch fixes above two issues by setting of "ATA command pending" flag
 after checking for whether device deleted, invalid device handle, device
 busy with task management. And by setting "ATA command pending" flag to
 false in all of the qcmd failure return paths after setting the flag.

Signed-off-by: Chaitra P B 
Signed-off-by: Suganath Prabu S 
---
 drivers/scsi/mpt3sas/mpt3sas_scsih.c |   28 +++-
 1 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c 
b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index 82d5612..74fca18 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -4600,19 +4600,6 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd 
*scmd)
return 0;
}
 
-   /*
-* Bug work around for firmware SATL handling.  The loop
-* is based on atomic operations and ensures consistency
-* since we're lockless at this point
-*/
-   do {
-   if (test_bit(0, &sas_device_priv_data->ata_command_pending)) {
-   scmd->result = SAM_STAT_BUSY;
-   scmd->scsi_done(scmd);
-   return 0;
-   }
-   } while (_scsih_set_satl_pending(scmd, true));
-
sas_target_priv_data = sas_device_priv_data->sas_target;
 
/* invalid device handle */
@@ -4638,6 +4625,19 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd 
*scmd)
sas_device_priv_data->block)
return SCSI_MLQUEUE_DEVICE_BUSY;
 
+   /*
+* Bug work around for firmware SATL handling.  The loop
+* is based on atomic operations and ensures consistency
+* since we're lockless at this point
+*/
+   do {
+   if (test_bit(0, &sas_device_priv_data->ata_command_pending)) {
+   scmd->result = SAM_STAT_BUSY;
+   scmd->scsi_done(scmd);
+   return 0;
+   }
+   } while (_scsih_set_satl_pending(scmd, true));
+
if (scmd->sc_data_direction == DMA_FROM_DEVICE)
mpi_control = MPI2_SCSIIO_CONTROL_READ;
else if (scmd->sc_data_direction == DMA_TO_DEVICE)
@@ -4665,6 +4665,7 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd 
*scmd)
if (!smid) {
pr_err(MPT3SAS_FMT "%s: failed obtaining a smid\n",
ioc->name, __func__);
+   _scsih_set_satl_pending(scmd, false);
goto out;
}
mpi_request = mpt3sas_base_get_msg_frame(ioc, smid);
@@ -4696,6 +4697,7 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd 
*scmd)
pcie_device = sas_target_priv_data->pcie_dev;
if (ioc->build_sg_scmd(ioc, scmd, smid, pcie_device)) {
mpt3sas_base_free_smid(ioc, smid);
+   _scsih_set_satl_pending(scmd, false);
goto out;
}
} else
-- 
1.7.1