Re: [PATCH v4 01/10] ufs: sysfs: attribute group for existing sysfs entries.

2018-02-04 Thread Greg KH
On Sun, Feb 04, 2018 at 01:09:09PM +, Stanislav Nijnikov wrote:
> 
> 
> > -Original Message-
> > From: Greg KH [mailto:gre...@linuxfoundation.org]
> > Sent: Sunday, February 4, 2018 2:34 PM
> > To: Stanislav Nijnikov 
> > Cc: linux-scsi@vger.kernel.org; linux-ker...@vger.kernel.org;
> > jaeg...@kernel.org; Alex Lemberg 
> > Subject: Re: [PATCH v4 01/10] ufs: sysfs: attribute group for existing sysfs
> > entries.
> > 
> > On Sun, Feb 04, 2018 at 12:29:06PM +, Stanislav Nijnikov wrote:
> > > > > + curr_len += snprintf((buf + curr_len), (PAGE_SIZE - curr_len),
> > > > > +  "\nAll available Runtime PM levels 
> > > > > info:\n");
> > > > > + for (lvl = UFS_PM_LVL_0; lvl < UFS_PM_LVL_MAX; lvl++)
> > > > > + curr_len += snprintf((buf + curr_len), (PAGE_SIZE - 
> > > > > curr_len),
> > > > > +  "\tRuntime PM level [%d] => 
> > > > > dev_state
> > > > [%s] link_state [%s]\n",
> > > > > + lvl,
> > > > > + ufschd_ufs_dev_pwr_mode_to_string(
> > > > > + 
> > > > > ufs_pm_lvl_states[lvl].dev_state),
> > > > > + ufschd_uic_link_state_to_string(
> > > > > + 
> > > > > ufs_pm_lvl_states[lvl].link_state));
> > > > > +
> > > >
> > > > sysfs if "one value per file", not "random text that someone has to
> > > > parse per file" please.
> > > >
> > > > Huge hint, if you ever care about checking the size of the sysfs
> > > > buffer you are writing into, you are doing something really really 
> > > > wrong.
> > > >
> > > Hi Greg
> > > It's the existing code, added by:
> > > commit 09690d5a6ae1b7e4cb5ac429c311b99d09352c12
> > > Author: subha...@codeaurora.org 
> > > Date:   Thu Dec 22 18:41:00 2016 -0800
> > >
> > > scsi: ufs: provide sysfs attribute to select the PM level
> > >
> > > This patch provides the sysfs attribute to choose the power management
> > > level for UFS runtime and system suspend.
> > >
> > > Reviewed-by: Sujit Reddy Thumma 
> > > Signed-off-by: Subhash Jadavani 
> > > Signed-off-by: Martin K. Petersen 
> > >
> > > I just moved it to an another file and changed the sysfs entries
> > > creation by Jaegeuk Kim' request. At the moment the entry shows the PM
> > > level, the device state, the link state and all possible PM levels. Do you
> > want me to change it?
> > 
> > Ah, you are just moving this code around.  Ok, that's fine for this patch, 
> > but
> > please fix it up as part of this patch series because this isn't an 
> > acceptable
> > sysfs file at all.  If it were documented that would be a lot more obvious 
> > as to
> > just how wrong it was :(
> > 
> > And, as it wasn't documented, you can change it as it's obvious no one used 
> > it
> > :)
> > 
> > thanks,
> > 
> > greg k-h
>  
> Can I fix these entries not in this patchset? As long as I know they are used 
> and I
> would prefer that change of the existing sysfs entries behavior be related to 
> a
> separate patch.

Ok, but it's nice to at least hope that someone will fix it up soon :)

thanks,

greg k-h


RE: [PATCH v4 01/10] ufs: sysfs: attribute group for existing sysfs entries.

2018-02-04 Thread Stanislav Nijnikov


> -Original Message-
> From: Greg KH [mailto:gre...@linuxfoundation.org]
> Sent: Sunday, February 4, 2018 2:34 PM
> To: Stanislav Nijnikov 
> Cc: linux-scsi@vger.kernel.org; linux-ker...@vger.kernel.org;
> jaeg...@kernel.org; Alex Lemberg 
> Subject: Re: [PATCH v4 01/10] ufs: sysfs: attribute group for existing sysfs
> entries.
> 
> On Sun, Feb 04, 2018 at 12:29:06PM +, Stanislav Nijnikov wrote:
> > > > +   curr_len += snprintf((buf + curr_len), (PAGE_SIZE - curr_len),
> > > > +"\nAll available Runtime PM levels 
> > > > info:\n");
> > > > +   for (lvl = UFS_PM_LVL_0; lvl < UFS_PM_LVL_MAX; lvl++)
> > > > +   curr_len += snprintf((buf + curr_len), (PAGE_SIZE - 
> > > > curr_len),
> > > > +"\tRuntime PM level [%d] => 
> > > > dev_state
> > > [%s] link_state [%s]\n",
> > > > +   lvl,
> > > > +   ufschd_ufs_dev_pwr_mode_to_string(
> > > > +   
> > > > ufs_pm_lvl_states[lvl].dev_state),
> > > > +   ufschd_uic_link_state_to_string(
> > > > +   
> > > > ufs_pm_lvl_states[lvl].link_state));
> > > > +
> > >
> > > sysfs if "one value per file", not "random text that someone has to
> > > parse per file" please.
> > >
> > > Huge hint, if you ever care about checking the size of the sysfs
> > > buffer you are writing into, you are doing something really really wrong.
> > >
> > Hi Greg
> > It's the existing code, added by:
> > commit 09690d5a6ae1b7e4cb5ac429c311b99d09352c12
> > Author: subha...@codeaurora.org 
> > Date:   Thu Dec 22 18:41:00 2016 -0800
> >
> > scsi: ufs: provide sysfs attribute to select the PM level
> >
> > This patch provides the sysfs attribute to choose the power management
> > level for UFS runtime and system suspend.
> >
> > Reviewed-by: Sujit Reddy Thumma 
> > Signed-off-by: Subhash Jadavani 
> > Signed-off-by: Martin K. Petersen 
> >
> > I just moved it to an another file and changed the sysfs entries
> > creation by Jaegeuk Kim' request. At the moment the entry shows the PM
> > level, the device state, the link state and all possible PM levels. Do you
> want me to change it?
> 
> Ah, you are just moving this code around.  Ok, that's fine for this patch, but
> please fix it up as part of this patch series because this isn't an acceptable
> sysfs file at all.  If it were documented that would be a lot more obvious as 
> to
> just how wrong it was :(
> 
> And, as it wasn't documented, you can change it as it's obvious no one used it
> :)
> 
> thanks,
> 
> greg k-h
 
Can I fix these entries not in this patchset? As long as I know they are used 
and I
would prefer that change of the existing sysfs entries behavior be related to a
separate patch.

Regards.
Stanislav.



Re: [PATCH v4 01/10] ufs: sysfs: attribute group for existing sysfs entries.

2018-02-04 Thread Greg KH
On Sun, Feb 04, 2018 at 12:29:06PM +, Stanislav Nijnikov wrote:
> > > + curr_len += snprintf((buf + curr_len), (PAGE_SIZE - curr_len),
> > > +  "\nAll available Runtime PM levels info:\n");
> > > + for (lvl = UFS_PM_LVL_0; lvl < UFS_PM_LVL_MAX; lvl++)
> > > + curr_len += snprintf((buf + curr_len), (PAGE_SIZE - curr_len),
> > > +  "\tRuntime PM level [%d] => dev_state
> > [%s] link_state [%s]\n",
> > > + lvl,
> > > + ufschd_ufs_dev_pwr_mode_to_string(
> > > + ufs_pm_lvl_states[lvl].dev_state),
> > > + ufschd_uic_link_state_to_string(
> > > + ufs_pm_lvl_states[lvl].link_state));
> > > +
> > 
> > sysfs if "one value per file", not "random text that someone has to parse 
> > per
> > file" please.
> > 
> > Huge hint, if you ever care about checking the size of the sysfs buffer you 
> > are
> > writing into, you are doing something really really wrong.
> > 
> Hi Greg
> It's the existing code, added by:
> commit 09690d5a6ae1b7e4cb5ac429c311b99d09352c12
> Author: subha...@codeaurora.org 
> Date:   Thu Dec 22 18:41:00 2016 -0800
> 
> scsi: ufs: provide sysfs attribute to select the PM level
> 
> This patch provides the sysfs attribute to choose the power management
> level for UFS runtime and system suspend.
> 
> Reviewed-by: Sujit Reddy Thumma 
> Signed-off-by: Subhash Jadavani 
> Signed-off-by: Martin K. Petersen 
> 
> I just moved it to an another file and changed the sysfs entries creation by
> Jaegeuk Kim' request. At the moment the entry shows the PM level, the device
> state, the link state and all possible PM levels. Do you want me to change it?

Ah, you are just moving this code around.  Ok, that's fine for this
patch, but please fix it up as part of this patch series because this
isn't an acceptable sysfs file at all.  If it were documented that would
be a lot more obvious as to just how wrong it was :(

And, as it wasn't documented, you can change it as it's obvious no one
used it :)

thanks,

greg k-h


RE: [PATCH v4 01/10] ufs: sysfs: attribute group for existing sysfs entries.

2018-02-04 Thread Stanislav Nijnikov


> -Original Message-
> From: Greg KH [mailto:gre...@linuxfoundation.org]
> Sent: Thursday, February 1, 2018 6:59 PM
> To: Stanislav Nijnikov 
> Cc: linux-scsi@vger.kernel.org; linux-ker...@vger.kernel.org;
> jaeg...@kernel.org; Alex Lemberg 
> Subject: Re: [PATCH v4 01/10] ufs: sysfs: attribute group for existing sysfs
> entries.
> 
> On Thu, Feb 01, 2018 at 06:15:37PM +0200, Stanislav Nijnikov wrote:
> > This patch introduces attribute group to show existing sysfs entries.
> >
> > Signed-off-by: Stanislav Nijnikov 
> > ---
> >  drivers/scsi/ufs/Makefile|   3 +-
> >  drivers/scsi/ufs/ufs-sysfs.c | 164
> > +++
> >  drivers/scsi/ufs/ufs-sysfs.h |  22 ++
> >  drivers/scsi/ufs/ufshcd.c| 156 ++--
> >  drivers/scsi/ufs/ufshcd.h|   2 +
> >  5 files changed, 194 insertions(+), 153 deletions(-)  create mode
> > 100644 drivers/scsi/ufs/ufs-sysfs.c  create mode 100644
> > drivers/scsi/ufs/ufs-sysfs.h
> >
> > diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
> > index 9310c6c..918f579 100644
> > --- a/drivers/scsi/ufs/Makefile
> > +++ b/drivers/scsi/ufs/Makefile
> > @@ -3,6 +3,7 @@
> >  obj-$(CONFIG_SCSI_UFS_DWC_TC_PCI) += tc-dwc-g210-pci.o ufshcd-
> dwc.o
> > tc-dwc-g210.o
> >  obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o
> > ufshcd-dwc.o tc-dwc-g210.o
> >  obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
> > -obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
> > +obj-$(CONFIG_SCSI_UFSHCD) += ufshcd-core.o ufshcd-core-objs :=
> > +ufshcd.o ufs-sysfs.o
> >  obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
> >  obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o diff --git
> > a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c new file
> > mode 100644 index 000..cc68a90
> > --- /dev/null
> > +++ b/drivers/scsi/ufs/ufs-sysfs.c
> > @@ -0,0 +1,164 @@
> > +//SPDX-License-Identifier: GPL-2.0-only //Copyright (C) 2018 Western
> > +Digital Corporation //This program is free software; you can
> > +redistribute it and/or modify it //under the terms of the GNU General
> > +Public License as published by the //Free Software Foundation;
> > +version 2.
> > +//
> > +//This program is distributed in the hope that it will be useful, but
> > +//WITHOUT ANY WARRANTY; without even the implied warranty of
> > +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> GNU
> > +//General Public License for more details.
> 
> No need to put the whole "This program" crud in the file here if you have the
> SPDX line already.  We are going through the kernel tree and removing all of
> the 700+ different ways we have this boilerplate code in the tree, please do
> not add new ones.
> 
> Also, please put a ' ' after "//", it just looks ugly like this, don't you 
> think so?
> 
> Please fix this for all of the files you add in this patch series.
> 
> > +#include 
> > +#include 
> > +
> > +#include "ufs-sysfs.h"
> > +
> > +static const char *ufschd_uic_link_state_to_string(
> > +   enum uic_link_state state)
> > +{
> > +   switch (state) {
> > +   case UIC_LINK_OFF_STATE:return "OFF";
> > +   case UIC_LINK_ACTIVE_STATE: return "ACTIVE";
> > +   case UIC_LINK_HIBERN8_STATE:return "HIBERN8";
> > +   default:return "UNKNOWN";
> > +   }
> > +}
> > +
> > +static const char *ufschd_ufs_dev_pwr_mode_to_string(
> > +   enum ufs_dev_pwr_mode state)
> > +{
> > +   switch (state) {
> > +   case UFS_ACTIVE_PWR_MODE:   return "ACTIVE";
> > +   case UFS_SLEEP_PWR_MODE:return "SLEEP";
> > +   case UFS_POWERDOWN_PWR_MODE:return "POWERDOWN";
> > +   default:return "UNKNOWN";
> > +   }
> > +}
> > +
> > +static inline ssize_t ufs_sysfs_pm_lvl_store(struct device *dev,
> > +struct device_attribute *attr,
> > +const char *buf, size_t count,
> > +bool rpm)
> > +{
> > +   struct ufs_hba *hba = dev_get_drvdata(dev);
> > +   unsigned long flags, value;
> > +
> > +   if (kstrtoul(buf, 0, &value))
> > +   return -EINVAL;
> > +
> > +   if (value >= UFS_PM_LVL_MAX)
> > +   return -EINVAL;
> > +
>

Re: [PATCH v4 01/10] ufs: sysfs: attribute group for existing sysfs entries.

2018-02-01 Thread Greg KH
On Thu, Feb 01, 2018 at 06:15:37PM +0200, Stanislav Nijnikov wrote:
> This patch introduces attribute group to show existing sysfs entries.
> 
> Signed-off-by: Stanislav Nijnikov 
> ---
>  drivers/scsi/ufs/Makefile|   3 +-
>  drivers/scsi/ufs/ufs-sysfs.c | 164 
> +++
>  drivers/scsi/ufs/ufs-sysfs.h |  22 ++
>  drivers/scsi/ufs/ufshcd.c| 156 ++--
>  drivers/scsi/ufs/ufshcd.h|   2 +
>  5 files changed, 194 insertions(+), 153 deletions(-)
>  create mode 100644 drivers/scsi/ufs/ufs-sysfs.c
>  create mode 100644 drivers/scsi/ufs/ufs-sysfs.h
> 
> diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
> index 9310c6c..918f579 100644
> --- a/drivers/scsi/ufs/Makefile
> +++ b/drivers/scsi/ufs/Makefile
> @@ -3,6 +3,7 @@
>  obj-$(CONFIG_SCSI_UFS_DWC_TC_PCI) += tc-dwc-g210-pci.o ufshcd-dwc.o 
> tc-dwc-g210.o
>  obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o ufshcd-dwc.o 
> tc-dwc-g210.o
>  obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
> -obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
> +obj-$(CONFIG_SCSI_UFSHCD) += ufshcd-core.o
> +ufshcd-core-objs := ufshcd.o ufs-sysfs.o
>  obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
>  obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o
> diff --git a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c
> new file mode 100644
> index 000..cc68a90
> --- /dev/null
> +++ b/drivers/scsi/ufs/ufs-sysfs.c
> @@ -0,0 +1,164 @@
> +//SPDX-License-Identifier: GPL-2.0-only
> +//Copyright (C) 2018 Western Digital Corporation
> +//This program is free software; you can redistribute it and/or modify it
> +//under the terms of the GNU General Public License as published by the
> +//Free Software Foundation; version 2.
> +//
> +//This program is distributed in the hope that it will be useful, but
> +//WITHOUT ANY WARRANTY; without even the implied warranty of
> +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> +//General Public License for more details.

No need to put the whole "This program" crud in the file here if you
have the SPDX line already.  We are going through the kernel tree and
removing all of the 700+ different ways we have this boilerplate code in
the tree, please do not add new ones.

Also, please put a ' ' after "//", it just looks ugly like this, don't
you think so?

Please fix this for all of the files you add in this patch series.

> +#include 
> +#include 
> +
> +#include "ufs-sysfs.h"
> +
> +static const char *ufschd_uic_link_state_to_string(
> + enum uic_link_state state)
> +{
> + switch (state) {
> + case UIC_LINK_OFF_STATE:return "OFF";
> + case UIC_LINK_ACTIVE_STATE: return "ACTIVE";
> + case UIC_LINK_HIBERN8_STATE:return "HIBERN8";
> + default:return "UNKNOWN";
> + }
> +}
> +
> +static const char *ufschd_ufs_dev_pwr_mode_to_string(
> + enum ufs_dev_pwr_mode state)
> +{
> + switch (state) {
> + case UFS_ACTIVE_PWR_MODE:   return "ACTIVE";
> + case UFS_SLEEP_PWR_MODE:return "SLEEP";
> + case UFS_POWERDOWN_PWR_MODE:return "POWERDOWN";
> + default:return "UNKNOWN";
> + }
> +}
> +
> +static inline ssize_t ufs_sysfs_pm_lvl_store(struct device *dev,
> +  struct device_attribute *attr,
> +  const char *buf, size_t count,
> +  bool rpm)
> +{
> + struct ufs_hba *hba = dev_get_drvdata(dev);
> + unsigned long flags, value;
> +
> + if (kstrtoul(buf, 0, &value))
> + return -EINVAL;
> +
> + if (value >= UFS_PM_LVL_MAX)
> + return -EINVAL;
> +
> + spin_lock_irqsave(hba->host->host_lock, flags);
> + if (rpm)
> + hba->rpm_lvl = value;
> + else
> + hba->spm_lvl = value;
> + spin_unlock_irqrestore(hba->host->host_lock, flags);
> + return count;
> +}
> +
> +static ssize_t rpm_lvl_show(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + struct ufs_hba *hba = dev_get_drvdata(dev);
> + int curr_len;
> + u8 lvl;
> +
> + curr_len = snprintf(buf, PAGE_SIZE,
> + "\nCurrent Runtime PM level [%d] => dev_state [%s] 
> link_state [%s]\n",
> + hba->rpm_lvl,
> + ufschd_ufs_dev_pwr_mode_to_string(
> + ufs_pm_lvl_states[hba->rpm_lvl].dev_state),
> + ufschd_uic_link_state_to_string(
> + ufs_pm_lvl_states[hba->rpm_lvl].link_state));
> +
> + curr_len += snprintf((buf + curr_len), (PAGE_SIZE - curr_len),
> +  "\nAll available Runtime PM levels info:\n");
> + for (lvl = UFS_PM_LVL_0; lvl < UFS_PM_LVL_MAX; lvl++)
> + curr_len += snprintf((buf + curr_len), (PAGE_SIZE - 

[PATCH v4 01/10] ufs: sysfs: attribute group for existing sysfs entries.

2018-02-01 Thread Stanislav Nijnikov
This patch introduces attribute group to show existing sysfs entries.

Signed-off-by: Stanislav Nijnikov 
---
 drivers/scsi/ufs/Makefile|   3 +-
 drivers/scsi/ufs/ufs-sysfs.c | 164 +++
 drivers/scsi/ufs/ufs-sysfs.h |  22 ++
 drivers/scsi/ufs/ufshcd.c| 156 ++--
 drivers/scsi/ufs/ufshcd.h|   2 +
 5 files changed, 194 insertions(+), 153 deletions(-)
 create mode 100644 drivers/scsi/ufs/ufs-sysfs.c
 create mode 100644 drivers/scsi/ufs/ufs-sysfs.h

diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
index 9310c6c..918f579 100644
--- a/drivers/scsi/ufs/Makefile
+++ b/drivers/scsi/ufs/Makefile
@@ -3,6 +3,7 @@
 obj-$(CONFIG_SCSI_UFS_DWC_TC_PCI) += tc-dwc-g210-pci.o ufshcd-dwc.o 
tc-dwc-g210.o
 obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o ufshcd-dwc.o 
tc-dwc-g210.o
 obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
-obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
+obj-$(CONFIG_SCSI_UFSHCD) += ufshcd-core.o
+ufshcd-core-objs := ufshcd.o ufs-sysfs.o
 obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
 obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o
diff --git a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c
new file mode 100644
index 000..cc68a90
--- /dev/null
+++ b/drivers/scsi/ufs/ufs-sysfs.c
@@ -0,0 +1,164 @@
+//SPDX-License-Identifier: GPL-2.0-only
+//Copyright (C) 2018 Western Digital Corporation
+//This program is free software; you can redistribute it and/or modify it
+//under the terms of the GNU General Public License as published by the
+//Free Software Foundation; version 2.
+//
+//This program is distributed in the hope that it will be useful, but
+//WITHOUT ANY WARRANTY; without even the implied warranty of
+//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+//General Public License for more details.
+
+#include 
+#include 
+
+#include "ufs-sysfs.h"
+
+static const char *ufschd_uic_link_state_to_string(
+   enum uic_link_state state)
+{
+   switch (state) {
+   case UIC_LINK_OFF_STATE:return "OFF";
+   case UIC_LINK_ACTIVE_STATE: return "ACTIVE";
+   case UIC_LINK_HIBERN8_STATE:return "HIBERN8";
+   default:return "UNKNOWN";
+   }
+}
+
+static const char *ufschd_ufs_dev_pwr_mode_to_string(
+   enum ufs_dev_pwr_mode state)
+{
+   switch (state) {
+   case UFS_ACTIVE_PWR_MODE:   return "ACTIVE";
+   case UFS_SLEEP_PWR_MODE:return "SLEEP";
+   case UFS_POWERDOWN_PWR_MODE:return "POWERDOWN";
+   default:return "UNKNOWN";
+   }
+}
+
+static inline ssize_t ufs_sysfs_pm_lvl_store(struct device *dev,
+struct device_attribute *attr,
+const char *buf, size_t count,
+bool rpm)
+{
+   struct ufs_hba *hba = dev_get_drvdata(dev);
+   unsigned long flags, value;
+
+   if (kstrtoul(buf, 0, &value))
+   return -EINVAL;
+
+   if (value >= UFS_PM_LVL_MAX)
+   return -EINVAL;
+
+   spin_lock_irqsave(hba->host->host_lock, flags);
+   if (rpm)
+   hba->rpm_lvl = value;
+   else
+   hba->spm_lvl = value;
+   spin_unlock_irqrestore(hba->host->host_lock, flags);
+   return count;
+}
+
+static ssize_t rpm_lvl_show(struct device *dev,
+   struct device_attribute *attr, char *buf)
+{
+   struct ufs_hba *hba = dev_get_drvdata(dev);
+   int curr_len;
+   u8 lvl;
+
+   curr_len = snprintf(buf, PAGE_SIZE,
+   "\nCurrent Runtime PM level [%d] => dev_state [%s] 
link_state [%s]\n",
+   hba->rpm_lvl,
+   ufschd_ufs_dev_pwr_mode_to_string(
+   ufs_pm_lvl_states[hba->rpm_lvl].dev_state),
+   ufschd_uic_link_state_to_string(
+   ufs_pm_lvl_states[hba->rpm_lvl].link_state));
+
+   curr_len += snprintf((buf + curr_len), (PAGE_SIZE - curr_len),
+"\nAll available Runtime PM levels info:\n");
+   for (lvl = UFS_PM_LVL_0; lvl < UFS_PM_LVL_MAX; lvl++)
+   curr_len += snprintf((buf + curr_len), (PAGE_SIZE - curr_len),
+"\tRuntime PM level [%d] => dev_state [%s] 
link_state [%s]\n",
+   lvl,
+   ufschd_ufs_dev_pwr_mode_to_string(
+   ufs_pm_lvl_states[lvl].dev_state),
+   ufschd_uic_link_state_to_string(
+   ufs_pm_lvl_states[lvl].link_state));
+
+   return curr_len;
+}
+
+static ssize_t rpm_lvl_store(struct device *dev,
+   struct device_attribute *attr, const char *buf, size_t count)
+{
+