All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RESEND v3 0/5] scsi: ufs: Fix regulator operations and remove "<name>-fixed-regulator" device tree property
@ 2019-03-27  9:58 Stanley Chu
       [not found] ` <1553680707-28579-1-git-send-email-stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
  0 siblings, 1 reply; 13+ messages in thread
From: Stanley Chu @ 2019-03-27  9:58 UTC (permalink / raw)
  To: linux-scsi-u79uwXL29TY76Z2rM5mHXA,
	martin.petersen-QHcLZuEGTsvQT0dZR+AlfA, avri.altman-Sjgp3cTcYWE,
	alim.akhtar-Sze3O3UU22JBDgjK7y7TUQ,
	pedrom.sousa-HKixBCOQz3hWk0Htik3J/w
  Cc: marc.w.gonzalez-GANU6spQydw, chun-hung.wu-NuS5LvNUpcJWk0Htik3J/w,
	kuohong.wang-NuS5LvNUpcJWk0Htik3J/w,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	peter.wang-NuS5LvNUpcJWk0Htik3J/w,
	matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w, Stanley Chu

Hi,

Resend this patch series for review.

This version (v3) fixed and added more details in commit messages, and added one patch to fix "undefined voltage range" issue as well.

This patch series fixes UFS regulator operations, including voltage and current (re-)configuration flow during UFS initialization and power mode switching.

In the end, remove "<name>-fixed-regulator" device tree property because it is not necessary anymore after these fixes.

V3:
- Fix and add more details in commit messages.
- Add one patch "scsi: ufs: Avoid configuring undefined voltage range on a regulator".

V2:
- Add two patches to prepare to and remove "<name>-fixed-regulator" device tree property.
- Add more details on patch "scsi: ufs: remove unused min_uA field in struct ufs_vreg" (Marc Gonzalez).

Stanley Chu (5):
  scsi: ufs: Remove unused min_uA field in struct ufs_vreg
  scsi: ufs: Avoid configuring regulator with undefined voltage range
  scsi: ufs: Fix regulator load and icc-level configuration
  scsi: ufs: Change "<name>-max-microamp" to non-mandatory property
  scsi: ufs: Remove "<name>-fixed-regulator" device tree property

 drivers/scsi/ufs/ufs.h           |  1 -
 drivers/scsi/ufs/ufshcd-pltfrm.c | 14 +++-----------
 drivers/scsi/ufs/ufshcd.c        | 28 ++++++++++++++++++++--------
 3 files changed, 23 insertions(+), 20 deletions(-)

-- 
2.18.0

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH RESEND v3 1/5] scsi: ufs: Remove unused min_uA field in struct ufs_vreg
       [not found] ` <1553680707-28579-1-git-send-email-stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
@ 2019-03-27  9:58   ` Stanley Chu
  2019-03-27  9:58   ` [PATCH RESEND v3 2/5] scsi: ufs: Avoid configuring regulator with undefined voltage range Stanley Chu
                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Stanley Chu @ 2019-03-27  9:58 UTC (permalink / raw)
  To: linux-scsi-u79uwXL29TY76Z2rM5mHXA,
	martin.petersen-QHcLZuEGTsvQT0dZR+AlfA, avri.altman-Sjgp3cTcYWE,
	alim.akhtar-Sze3O3UU22JBDgjK7y7TUQ,
	pedrom.sousa-HKixBCOQz3hWk0Htik3J/w
  Cc: marc.w.gonzalez-GANU6spQydw, chun-hung.wu-NuS5LvNUpcJWk0Htik3J/w,
	kuohong.wang-NuS5LvNUpcJWk0Htik3J/w,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	peter.wang-NuS5LvNUpcJWk0Htik3J/w,
	matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w, Stanley Chu

There are two fields related to regulator current limit in struct
ufs_vreg: "min_uA" and "max_uA".

"max_uA" is probed by "<name>-max-microamp" property from device
tree and used for

- regulator_set_load operations, and
- icc_level configuration in device.

However "min_uA" field is not used anywhere, thus we can remove it.

Signed-off-by: Stanley Chu <stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
Reviewed-by: Marc Gonzalez <marc.w.gonzalez-GANU6spQydw@public.gmane.org>
---
 drivers/scsi/ufs/ufs.h           | 1 -
 drivers/scsi/ufs/ufshcd-pltfrm.c | 1 -
 2 files changed, 2 deletions(-)

diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h
index 21e4ccb5ba6e..99a9c4d16f6b 100644
--- a/drivers/scsi/ufs/ufs.h
+++ b/drivers/scsi/ufs/ufs.h
@@ -516,7 +516,6 @@ struct ufs_vreg {
 	bool enabled;
 	int min_uV;
 	int max_uV;
-	int min_uA;
 	int max_uA;
 };
 
diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
index 27213676329c..32cf8c56f029 100644
--- a/drivers/scsi/ufs/ufshcd-pltfrm.c
+++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
@@ -164,7 +164,6 @@ static int ufshcd_populate_vreg(struct device *dev, const char *name,
 		goto out;
 	}
 
-	vreg->min_uA = 0;
 	if (!strcmp(name, "vcc")) {
 		if (of_property_read_bool(np, "vcc-supply-1p8")) {
 			vreg->min_uV = UFS_VREG_VCC_1P8_MIN_UV;
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH RESEND v3 2/5] scsi: ufs: Avoid configuring regulator with undefined voltage range
       [not found] ` <1553680707-28579-1-git-send-email-stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
  2019-03-27  9:58   ` [PATCH RESEND v3 1/5] scsi: ufs: Remove unused min_uA field in struct ufs_vreg Stanley Chu
@ 2019-03-27  9:58   ` Stanley Chu
       [not found]     ` <1553680707-28579-3-git-send-email-stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
  2019-03-27  9:58   ` [PATCH RESEND v3 3/5] scsi: ufs: Fix regulator load and icc-level configuration Stanley Chu
                     ` (4 subsequent siblings)
  6 siblings, 1 reply; 13+ messages in thread
From: Stanley Chu @ 2019-03-27  9:58 UTC (permalink / raw)
  To: linux-scsi-u79uwXL29TY76Z2rM5mHXA,
	martin.petersen-QHcLZuEGTsvQT0dZR+AlfA, avri.altman-Sjgp3cTcYWE,
	alim.akhtar-Sze3O3UU22JBDgjK7y7TUQ,
	pedrom.sousa-HKixBCOQz3hWk0Htik3J/w
  Cc: marc.w.gonzalez-GANU6spQydw, chun-hung.wu-NuS5LvNUpcJWk0Htik3J/w,
	kuohong.wang-NuS5LvNUpcJWk0Htik3J/w,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	peter.wang-NuS5LvNUpcJWk0Htik3J/w,
	matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w, Stanley Chu

For regulators used by UFS, vcc, vccq and vccq2 will have voltage range
initialized by ufshcd_populate_vreg(), however other regulators may
have undefined voltage range if dt-bindings have no such definition.

In above undefined case, both "min_uV" and "max_uV" fields in ufs_vreg
struct will be zero values and these values will be configured on
regulators in different power modes.

Currently this may have no harm if both "min_uV" and "max_uV"
always keep "zero values" because regulator_set_voltage() will always
bypass such invalid values and return "good" results.

However improper values shall be fixed to avoid potential bugs.
Simply bypass voltage configuration if voltage range is not defined.

Signed-off-by: Stanley Chu <stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
---
 drivers/scsi/ufs/ufshcd.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index e040f9dd9ff3..81d99aebb867 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -7039,12 +7039,15 @@ static int ufshcd_config_vreg(struct device *dev,
 	name = vreg->name;
 
 	if (regulator_count_voltages(reg) > 0) {
-		min_uV = on ? vreg->min_uV : 0;
-		ret = regulator_set_voltage(reg, min_uV, vreg->max_uV);
-		if (ret) {
-			dev_err(dev, "%s: %s set voltage failed, err=%d\n",
+		if (vreg->min_uV && vreg->max_uV) {
+			min_uV = on ? vreg->min_uV : 0;
+			ret = regulator_set_voltage(reg, min_uV, vreg->max_uV);
+			if (ret) {
+				dev_err(dev,
+					"%s: %s set voltage failed, err=%d\n",
 					__func__, name, ret);
-			goto out;
+				goto out;
+			}
 		}
 
 		uA_load = on ? vreg->max_uA : 0;
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH RESEND v3 3/5] scsi: ufs: Fix regulator load and icc-level configuration
       [not found] ` <1553680707-28579-1-git-send-email-stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
  2019-03-27  9:58   ` [PATCH RESEND v3 1/5] scsi: ufs: Remove unused min_uA field in struct ufs_vreg Stanley Chu
  2019-03-27  9:58   ` [PATCH RESEND v3 2/5] scsi: ufs: Avoid configuring regulator with undefined voltage range Stanley Chu
@ 2019-03-27  9:58   ` Stanley Chu
       [not found]     ` <1553680707-28579-4-git-send-email-stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
  2019-03-27  9:58   ` [PATCH RESEND v3 4/5] scsi: ufs: Change "<name>-max-microamp" to non-mandatory property Stanley Chu
                     ` (3 subsequent siblings)
  6 siblings, 1 reply; 13+ messages in thread
From: Stanley Chu @ 2019-03-27  9:58 UTC (permalink / raw)
  To: linux-scsi-u79uwXL29TY76Z2rM5mHXA,
	martin.petersen-QHcLZuEGTsvQT0dZR+AlfA, avri.altman-Sjgp3cTcYWE,
	alim.akhtar-Sze3O3UU22JBDgjK7y7TUQ,
	pedrom.sousa-HKixBCOQz3hWk0Htik3J/w
  Cc: marc.w.gonzalez-GANU6spQydw, chun-hung.wu-NuS5LvNUpcJWk0Htik3J/w,
	kuohong.wang-NuS5LvNUpcJWk0Htik3J/w,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	peter.wang-NuS5LvNUpcJWk0Htik3J/w,
	matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w, Stanley Chu

Currently if a regulator has "<name>-fixed-regulator"
property in device tree, it will skip current limit initialization.
This lead to a zero "max_uA" value in struct ufs_vreg.

However, "regulator_set_load" operation shall be required
on regulators which have valid current limits, otherwise a zero
"max_uA" set by "regulator_set_load" may cause unexpected behavior
when this regulator is enabled or set as high power mode.

Similarly, in device's icc_level configuration flow, the target
icc_level shall be updated if regulator also has valid current limit,
otherwise a wrong icc_level will be calculated by zero "max_uA" and
thus causes unexpected results after it is written to device.

Signed-off-by: Stanley Chu <stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
---
 drivers/scsi/ufs/ufshcd.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 81d99aebb867..5ba49c8cd2a3 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -6294,19 +6294,19 @@ static u32 ufshcd_find_max_sup_active_icc_level(struct ufs_hba *hba,
 		goto out;
 	}
 
-	if (hba->vreg_info.vcc)
+	if (hba->vreg_info.vcc && hba->vreg_info.vcc->max_uA)
 		icc_level = ufshcd_get_max_icc_level(
 				hba->vreg_info.vcc->max_uA,
 				POWER_DESC_MAX_ACTV_ICC_LVLS - 1,
 				&desc_buf[PWR_DESC_ACTIVE_LVLS_VCC_0]);
 
-	if (hba->vreg_info.vccq)
+	if (hba->vreg_info.vccq && hba->vreg_info.vccq->max_uA)
 		icc_level = ufshcd_get_max_icc_level(
 				hba->vreg_info.vccq->max_uA,
 				icc_level,
 				&desc_buf[PWR_DESC_ACTIVE_LVLS_VCCQ_0]);
 
-	if (hba->vreg_info.vccq2)
+	if (hba->vreg_info.vccq2 && hba->vreg_info.vccq2->max_uA)
 		icc_level = ufshcd_get_max_icc_level(
 				hba->vreg_info.vccq2->max_uA,
 				icc_level,
@@ -7004,6 +7004,15 @@ static int ufshcd_config_vreg_load(struct device *dev, struct ufs_vreg *vreg,
 	if (!vreg)
 		return 0;
 
+	/*
+	 * "set_load" operation shall be required on those regulators
+	 * which specifically configured current limitation. Otherwise
+	 * zero max_uA may cause unexpected behavior when regulator is
+	 * enabled or set as high power mode.
+	 */
+	if (!vreg->max_uA)
+		return 0;
+
 	ret = regulator_set_load(vreg->reg, ua);
 	if (ret < 0) {
 		dev_err(dev, "%s: %s set load (ua=%d) failed, err=%d\n",
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH RESEND v3 4/5] scsi: ufs: Change "<name>-max-microamp" to non-mandatory property
       [not found] ` <1553680707-28579-1-git-send-email-stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
                     ` (2 preceding siblings ...)
  2019-03-27  9:58   ` [PATCH RESEND v3 3/5] scsi: ufs: Fix regulator load and icc-level configuration Stanley Chu
@ 2019-03-27  9:58   ` Stanley Chu
       [not found]     ` <1553680707-28579-5-git-send-email-stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
  2019-03-27  9:58   ` [PATCH RESEND v3 5/5] scsi: ufs: Remove "<name>-fixed-regulator" device tree property Stanley Chu
                     ` (2 subsequent siblings)
  6 siblings, 1 reply; 13+ messages in thread
From: Stanley Chu @ 2019-03-27  9:58 UTC (permalink / raw)
  To: linux-scsi-u79uwXL29TY76Z2rM5mHXA,
	martin.petersen-QHcLZuEGTsvQT0dZR+AlfA, avri.altman-Sjgp3cTcYWE,
	alim.akhtar-Sze3O3UU22JBDgjK7y7TUQ,
	pedrom.sousa-HKixBCOQz3hWk0Htik3J/w
  Cc: marc.w.gonzalez-GANU6spQydw, chun-hung.wu-NuS5LvNUpcJWk0Htik3J/w,
	kuohong.wang-NuS5LvNUpcJWk0Htik3J/w,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	peter.wang-NuS5LvNUpcJWk0Htik3J/w,
	matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w, Stanley Chu

In dt-bindings for ufs, "<name>-max-microamp" property indicates
current limit and is mandatory if "<name>-fixed-regulator" is not
defined on a specified regulator.

However, in some platforms, regulators without "<name>-fixed-regulator"
property may not need to define their current limit because they may
want to define voltage range only for proper voltage switching in
different power modes, especially for vcc, vccq or vccq2.

Currently missing "<name>-max-microamp" property in device tree will
lead to initialization fail currently, thus such limitation shall be
resolved to tolerate this kind of regulators.

After resolving this, regulators without "<name>-max-microamp"
property will have undefined "max current" value, i.e., zero value
in "max_uA" field in struct ufs_vreg. Because we do bypass current
switching operation (by regulator_set_load) in case of undefined
current limit, this patch shall be safe.

Signed-off-by: Stanley Chu <stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
---
 drivers/scsi/ufs/ufshcd-pltfrm.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
index 32cf8c56f029..2420e6962219 100644
--- a/drivers/scsi/ufs/ufshcd-pltfrm.c
+++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
@@ -157,11 +157,9 @@ static int ufshcd_populate_vreg(struct device *dev, const char *name,
 		goto out;
 
 	snprintf(prop_name, MAX_PROP_SIZE, "%s-max-microamp", name);
-	ret = of_property_read_u32(np, prop_name, &vreg->max_uA);
-	if (ret) {
-		dev_err(dev, "%s: unable to find %s err %d\n",
-				__func__, prop_name, ret);
-		goto out;
+	if (of_property_read_u32(np, prop_name, &vreg->max_uA)) {
+		dev_info(dev, "%s: unable to find %s\n", __func__, prop_name);
+		vreg->max_uA = 0;
 	}
 
 	if (!strcmp(name, "vcc")) {
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH RESEND v3 5/5] scsi: ufs: Remove "<name>-fixed-regulator" device tree property
       [not found] ` <1553680707-28579-1-git-send-email-stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
                     ` (3 preceding siblings ...)
  2019-03-27  9:58   ` [PATCH RESEND v3 4/5] scsi: ufs: Change "<name>-max-microamp" to non-mandatory property Stanley Chu
@ 2019-03-27  9:58   ` Stanley Chu
  2019-03-27 10:57   ` [PATCH RESEND v3 0/5] scsi: ufs: Fix regulator operations and remove " Avri Altman
  2019-03-27 17:18   ` Alim Akhtar
  6 siblings, 0 replies; 13+ messages in thread
From: Stanley Chu @ 2019-03-27  9:58 UTC (permalink / raw)
  To: linux-scsi-u79uwXL29TY76Z2rM5mHXA,
	martin.petersen-QHcLZuEGTsvQT0dZR+AlfA, avri.altman-Sjgp3cTcYWE,
	alim.akhtar-Sze3O3UU22JBDgjK7y7TUQ,
	pedrom.sousa-HKixBCOQz3hWk0Htik3J/w
  Cc: marc.w.gonzalez-GANU6spQydw, chun-hung.wu-NuS5LvNUpcJWk0Htik3J/w,
	kuohong.wang-NuS5LvNUpcJWk0Htik3J/w,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	peter.wang-NuS5LvNUpcJWk0Htik3J/w,
	matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w, Stanley Chu

"<name>-fixed-regulator" device tree property can be
safely removed because below things are fixed or resolved,

1. "<name>-max-microamp" becomes optional property: Undefined
   "<name>-max-microamp" will not cause initialization fail if
   "<name>-fixed-regulator" is not defined.

2. Current switching operation (by regulator_set_load) now has rules:
   Regulators will have undefined current limit if
   "<name>-fixed-regulator" is not defined. But this is safe because
   only regulator which has configured current limit from
   "<name>-max-microamp" property is allowed to change its load.

Although "<name>-fixed-regulator" is not used in any dt-bindings
in tree, this patch is still safe for regulators already defined
"<name>-fixed-regulator". To be more clear, if a regulator defined
"<name>-fixed-regulator" before, the behavior difference after
this patch is,

1. "<name>-max-microamp":
   If a regulator defined "<name>-fixed-regulator", it is not necessary
   to define "<name>-max-microamp" property in device tree and it is
   expected to have an undefined current limit, i.e., "max_uA" field
   is zero in struct ufs_vreg. This is exactly the same as patched.

2. "vcc-supply-1p8" or volatge range settings:
   * For vcc, vccq or vccq2, these three regulators shall not define
     "<name>-fixed-regulator" because defining it will lead to
     undefined voltage range and thus voltage switching will be
     unexpected.
   * For other regulators with undefined voltage range, voltage range
     will be still undefined after patched.

Therefore this patch is safe for all existed regulators with
"<name>-fixed-regulator" property already defined.

Signed-off-by: Stanley Chu <stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
---
 drivers/scsi/ufs/ufshcd-pltfrm.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
index 2420e6962219..7b404df965b2 100644
--- a/drivers/scsi/ufs/ufshcd-pltfrm.c
+++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
@@ -151,11 +151,6 @@ static int ufshcd_populate_vreg(struct device *dev, const char *name,
 
 	vreg->name = kstrdup(name, GFP_KERNEL);
 
-	/* if fixed regulator no need further initialization */
-	snprintf(prop_name, MAX_PROP_SIZE, "%s-fixed-regulator", name);
-	if (of_property_read_bool(np, prop_name))
-		goto out;
-
 	snprintf(prop_name, MAX_PROP_SIZE, "%s-max-microamp", name);
 	if (of_property_read_u32(np, prop_name, &vreg->max_uA)) {
 		dev_info(dev, "%s: unable to find %s\n", __func__, prop_name);
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* RE: [PATCH RESEND v3 2/5] scsi: ufs: Avoid configuring regulator with undefined voltage range
       [not found]     ` <1553680707-28579-3-git-send-email-stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
@ 2019-03-27 10:35       ` Avri Altman
  0 siblings, 0 replies; 13+ messages in thread
From: Avri Altman @ 2019-03-27 10:35 UTC (permalink / raw)
  To: Stanley Chu, linux-scsi-u79uwXL29TY76Z2rM5mHXA,
	martin.petersen-QHcLZuEGTsvQT0dZR+AlfA,
	alim.akhtar-Sze3O3UU22JBDgjK7y7TUQ,
	pedrom.sousa-HKixBCOQz3hWk0Htik3J/w
  Cc: marc.w.gonzalez-GANU6spQydw, chun-hung.wu-NuS5LvNUpcJWk0Htik3J/w,
	kuohong.wang-NuS5LvNUpcJWk0Htik3J/w,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	peter.wang-NuS5LvNUpcJWk0Htik3J/w,
	matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w

> 
> For regulators used by UFS, vcc, vccq and vccq2 will have voltage range
> initialized by ufshcd_populate_vreg(), however other regulators may
> have undefined voltage range if dt-bindings have no such definition.
> 
> In above undefined case, both "min_uV" and "max_uV" fields in ufs_vreg
> struct will be zero values and these values will be configured on
> regulators in different power modes.
> 
> Currently this may have no harm if both "min_uV" and "max_uV"
> always keep "zero values" because regulator_set_voltage() will always
> bypass such invalid values and return "good" results.
> 
> However improper values shall be fixed to avoid potential bugs.
> Simply bypass voltage configuration if voltage range is not defined.
> 
> Signed-off-by: Stanley Chu <stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
Reviewed-by: Avri Altman <avri.altman-Sjgp3cTcYWE@public.gmane.org>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* RE: [PATCH RESEND v3 4/5] scsi: ufs: Change "<name>-max-microamp" to non-mandatory property
       [not found]     ` <1553680707-28579-5-git-send-email-stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
@ 2019-03-27 10:48       ` Avri Altman
  0 siblings, 0 replies; 13+ messages in thread
From: Avri Altman @ 2019-03-27 10:48 UTC (permalink / raw)
  To: Stanley Chu, linux-scsi-u79uwXL29TY76Z2rM5mHXA,
	martin.petersen-QHcLZuEGTsvQT0dZR+AlfA,
	alim.akhtar-Sze3O3UU22JBDgjK7y7TUQ,
	pedrom.sousa-HKixBCOQz3hWk0Htik3J/w
  Cc: marc.w.gonzalez-GANU6spQydw, chun-hung.wu-NuS5LvNUpcJWk0Htik3J/w,
	kuohong.wang-NuS5LvNUpcJWk0Htik3J/w,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	peter.wang-NuS5LvNUpcJWk0Htik3J/w,
	matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w

> 
> In dt-bindings for ufs, "<name>-max-microamp" property indicates
> current limit and is mandatory if "<name>-fixed-regulator" is not
> defined on a specified regulator.
> 
> However, in some platforms, regulators without "<name>-fixed-regulator"
> property may not need to define their current limit because they may
> want to define voltage range only for proper voltage switching in
> different power modes, especially for vcc, vccq or vccq2.
> 
> Currently missing "<name>-max-microamp" property in device tree will
> lead to initialization fail currently, thus such limitation shall be
lead initialization to fail, thus ...

> resolved to tolerate this kind of regulators.
> 
> After resolving this, regulators without "<name>-max-microamp"
> property will have undefined "max current" value, i.e., zero value
> in "max_uA" field in struct ufs_vreg. Because we do bypass current
> switching operation (by regulator_set_load) in case of undefined
> current limit, this patch shall be safe.
> 
> Signed-off-by: Stanley Chu <stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
Reviewed-by: Avri Altman <avri.altman-Sjgp3cTcYWE@public.gmane.org>

You might want to cc some platform guys, e.g. Evan Green and/or Codeaurora guys,
To take a look.

Thanks,
Avri

^ permalink raw reply	[flat|nested] 13+ messages in thread

* RE: [PATCH RESEND v3 3/5] scsi: ufs: Fix regulator load and icc-level configuration
       [not found]     ` <1553680707-28579-4-git-send-email-stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
@ 2019-03-27 10:55       ` Avri Altman
  0 siblings, 0 replies; 13+ messages in thread
From: Avri Altman @ 2019-03-27 10:55 UTC (permalink / raw)
  To: Stanley Chu, linux-scsi-u79uwXL29TY76Z2rM5mHXA,
	martin.petersen-QHcLZuEGTsvQT0dZR+AlfA,
	alim.akhtar-Sze3O3UU22JBDgjK7y7TUQ,
	pedrom.sousa-HKixBCOQz3hWk0Htik3J/w
  Cc: marc.w.gonzalez-GANU6spQydw, chun-hung.wu-NuS5LvNUpcJWk0Htik3J/w,
	kuohong.wang-NuS5LvNUpcJWk0Htik3J/w,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	peter.wang-NuS5LvNUpcJWk0Htik3J/w,
	matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w

> 
> Currently if a regulator has "<name>-fixed-regulator"
> property in device tree, it will skip current limit initialization.
> This lead to a zero "max_uA" value in struct ufs_vreg.
> 
> However, "regulator_set_load" operation shall be required
> on regulators which have valid current limits, otherwise a zero
> "max_uA" set by "regulator_set_load" may cause unexpected behavior
> when this regulator is enabled or set as high power mode.
> 
> Similarly, in device's icc_level configuration flow, the target
> icc_level shall be updated if regulator also has valid current limit,
> otherwise a wrong icc_level will be calculated by zero "max_uA" and
> thus causes unexpected results after it is written to device.
> 
> Signed-off-by: Stanley Chu <stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
Reviewed-by: Avri Altman <avri.altman-Sjgp3cTcYWE@public.gmane.org>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* RE: [PATCH RESEND v3 0/5] scsi: ufs: Fix regulator operations and remove "<name>-fixed-regulator" device tree property
       [not found] ` <1553680707-28579-1-git-send-email-stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
                     ` (4 preceding siblings ...)
  2019-03-27  9:58   ` [PATCH RESEND v3 5/5] scsi: ufs: Remove "<name>-fixed-regulator" device tree property Stanley Chu
@ 2019-03-27 10:57   ` Avri Altman
       [not found]     ` <SN6PR04MB49250E97111EB8975E0ED7EFFC580-UKdxhu0+N/VnT3GYGerMaFM8qxBPnqtHvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
  2019-03-27 17:18   ` Alim Akhtar
  6 siblings, 1 reply; 13+ messages in thread
From: Avri Altman @ 2019-03-27 10:57 UTC (permalink / raw)
  To: Stanley Chu, linux-scsi-u79uwXL29TY76Z2rM5mHXA,
	martin.petersen-QHcLZuEGTsvQT0dZR+AlfA,
	alim.akhtar-Sze3O3UU22JBDgjK7y7TUQ,
	pedrom.sousa-HKixBCOQz3hWk0Htik3J/w
  Cc: marc.w.gonzalez-GANU6spQydw, chun-hung.wu-NuS5LvNUpcJWk0Htik3J/w,
	kuohong.wang-NuS5LvNUpcJWk0Htik3J/w,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	peter.wang-NuS5LvNUpcJWk0Htik3J/w,
	matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w

 
> Hi,
> 
> Resend this patch series for review.
> 
> This version (v3) fixed and added more details in commit messages, and added
> one patch to fix "undefined voltage range" issue as well.
> 
> This patch series fixes UFS regulator operations, including voltage and current
> (re-)configuration flow during UFS initialization and power mode switching.
> 
> In the end, remove "<name>-fixed-regulator" device tree property because it is
> not necessary anymore after these fixes.
> 
> V3:
> - Fix and add more details in commit messages.
> - Add one patch "scsi: ufs: Avoid configuring undefined voltage range on a
> regulator".
> 
> V2:
> - Add two patches to prepare to and remove "<name>-fixed-regulator" device
> tree property.
> - Add more details on patch "scsi: ufs: remove unused min_uA field in struct
> ufs_vreg" (Marc Gonzalez).
> 
> Stanley Chu (5):
>   scsi: ufs: Remove unused min_uA field in struct ufs_vreg
>   scsi: ufs: Avoid configuring regulator with undefined voltage range
>   scsi: ufs: Fix regulator load and icc-level configuration
>   scsi: ufs: Change "<name>-max-microamp" to non-mandatory property
>   scsi: ufs: Remove "<name>-fixed-regulator" device tree property
> 
This series looks good to me, but better get acked-by from couple of platform guys as well.

Thanks,
Avri

^ permalink raw reply	[flat|nested] 13+ messages in thread

* RE: [PATCH RESEND v3 0/5] scsi: ufs: Fix regulator operations and remove "<name>-fixed-regulator" device tree property
       [not found]     ` <SN6PR04MB49250E97111EB8975E0ED7EFFC580-UKdxhu0+N/VnT3GYGerMaFM8qxBPnqtHvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
@ 2019-03-27 13:24       ` Stanley Chu
  0 siblings, 0 replies; 13+ messages in thread
From: Stanley Chu @ 2019-03-27 13:24 UTC (permalink / raw)
  To: Avri Altman
  Cc: linux-scsi-u79uwXL29TY76Z2rM5mHXA,
	martin.petersen-QHcLZuEGTsvQT0dZR+AlfA,
	marc.w.gonzalez-GANU6spQydw, chun-hung.wu-NuS5LvNUpcJWk0Htik3J/w,
	kuohong.wang-NuS5LvNUpcJWk0Htik3J/w,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	peter.wang-NuS5LvNUpcJWk0Htik3J/w,
	alim.akhtar-Sze3O3UU22JBDgjK7y7TUQ,
	matthias.bgg-Re5JQEeQqe8AvxtiuMwx3w,
	pedrom.sousa-HKixBCOQz3hWk0Htik3J/w

Hi Avri,

On Wed, 2019-03-27 at 10:57 +0000, Avri Altman wrote:
> > Hi,
> > 
> > Resend this patch series for review.
> > 
> > This version (v3) fixed and added more details in commit messages, and added
> > one patch to fix "undefined voltage range" issue as well.
> > 
> > This patch series fixes UFS regulator operations, including voltage and current
> > (re-)configuration flow during UFS initialization and power mode switching.
> > 
> > In the end, remove "<name>-fixed-regulator" device tree property because it is
> > not necessary anymore after these fixes.
> > 
> > V3:
> > - Fix and add more details in commit messages.
> > - Add one patch "scsi: ufs: Avoid configuring undefined voltage range on a
> > regulator".
> > 
> > V2:
> > - Add two patches to prepare to and remove "<name>-fixed-regulator" device
> > tree property.
> > - Add more details on patch "scsi: ufs: remove unused min_uA field in struct
> > ufs_vreg" (Marc Gonzalez).
> > 
> > Stanley Chu (5):
> >   scsi: ufs: Remove unused min_uA field in struct ufs_vreg
> >   scsi: ufs: Avoid configuring regulator with undefined voltage range
> >   scsi: ufs: Fix regulator load and icc-level configuration
> >   scsi: ufs: Change "<name>-max-microamp" to non-mandatory property
> >   scsi: ufs: Remove "<name>-fixed-regulator" device tree property
> > 
> This series looks good to me, but better get acked-by from couple of platform guys as well.

Thanks so much for review.

I'll fix commit message and invite more reviewers in next version.

> 
> Thanks,
> Avri
> 

Thanks,
Stanley

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH RESEND v3 0/5] scsi: ufs: Fix regulator operations and remove "<name>-fixed-regulator" device tree property
       [not found] ` <1553680707-28579-1-git-send-email-stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
                     ` (5 preceding siblings ...)
  2019-03-27 10:57   ` [PATCH RESEND v3 0/5] scsi: ufs: Fix regulator operations and remove " Avri Altman
@ 2019-03-27 17:18   ` Alim Akhtar
       [not found]     ` <CAGOxZ51zdtoLz=E_vmpwt+2wTJq32yUQa=h_OiV7qO1N-c=NUA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  6 siblings, 1 reply; 13+ messages in thread
From: Alim Akhtar @ 2019-03-27 17:18 UTC (permalink / raw)
  To: Stanley Chu
  Cc: linux-scsi-u79uwXL29TY76Z2rM5mHXA, Martin K. Petersen,
	marc.w.gonzalez-GANU6spQydw, chun-hung.wu-NuS5LvNUpcJWk0Htik3J/w,
	Kuohong Wang, Avri Altman,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	peter.wang-NuS5LvNUpcJWk0Htik3J/w, Alim Akhtar, Matthias Brugger,
	Pedro Sousa

Hi Stanley,
Please collect all the {review/acked}-by tags when reposting so that
people are aware which all patches need to review.
https://www.spinics.net/lists/linux-scsi/msg128818.html
This series looks good, it will be if we get a Tested-by as well.
For this series
Acked-by: Alim Akhtar <alim.akhtar-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>

On Wed, Mar 27, 2019 at 3:29 PM Stanley Chu <stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org> wrote:
>
> Hi,
>
> Resend this patch series for review.
>
> This version (v3) fixed and added more details in commit messages, and added one patch to fix "undefined voltage range" issue as well.
>
> This patch series fixes UFS regulator operations, including voltage and current (re-)configuration flow during UFS initialization and power mode switching.
>
> In the end, remove "<name>-fixed-regulator" device tree property because it is not necessary anymore after these fixes.
>
> V3:
> - Fix and add more details in commit messages.
> - Add one patch "scsi: ufs: Avoid configuring undefined voltage range on a regulator".
>
> V2:
> - Add two patches to prepare to and remove "<name>-fixed-regulator" device tree property.
> - Add more details on patch "scsi: ufs: remove unused min_uA field in struct ufs_vreg" (Marc Gonzalez).
>
> Stanley Chu (5):
>   scsi: ufs: Remove unused min_uA field in struct ufs_vreg
>   scsi: ufs: Avoid configuring regulator with undefined voltage range
>   scsi: ufs: Fix regulator load and icc-level configuration
>   scsi: ufs: Change "<name>-max-microamp" to non-mandatory property
>   scsi: ufs: Remove "<name>-fixed-regulator" device tree property
>
>  drivers/scsi/ufs/ufs.h           |  1 -
>  drivers/scsi/ufs/ufshcd-pltfrm.c | 14 +++-----------
>  drivers/scsi/ufs/ufshcd.c        | 28 ++++++++++++++++++++--------
>  3 files changed, 23 insertions(+), 20 deletions(-)
>
> --
> 2.18.0
>


-- 
Regards,
Alim

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH RESEND v3 0/5] scsi: ufs: Fix regulator operations and remove "<name>-fixed-regulator" device tree property
       [not found]     ` <CAGOxZ51zdtoLz=E_vmpwt+2wTJq32yUQa=h_OiV7qO1N-c=NUA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2019-03-28  1:21       ` Stanley Chu
  0 siblings, 0 replies; 13+ messages in thread
From: Stanley Chu @ 2019-03-28  1:21 UTC (permalink / raw)
  To: Alim Akhtar
  Cc: linux-scsi-u79uwXL29TY76Z2rM5mHXA, Martin K. Petersen,
	marc.w.gonzalez-GANU6spQydw, chun-hung.wu-NuS5LvNUpcJWk0Htik3J/w,
	Kuohong Wang, Avri Altman,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	peter.wang-NuS5LvNUpcJWk0Htik3J/w, Alim Akhtar, Matthias Brugger,
	Pedro Sousa

Hi Alim,

On Wed, 2019-03-27 at 22:48 +0530, Alim Akhtar wrote:
> Hi Stanley,
> Please collect all the {review/acked}-by tags when reposting so that
> people are aware which all patches need to review.
> https://www.spinics.net/lists/linux-scsi/msg128818.html

Sorry it's my mistake to miss some tags in reposted patch.
Will fix it in next version.

> This series looks good, it will be if we get a Tested-by as well.
> For this series
> Acked-by: Alim Akhtar <alim.akhtar-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>

Thanks so much for review.

> 
> On Wed, Mar 27, 2019 at 3:29 PM Stanley Chu <stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org> wrote:
> >
> > Hi,
> >
> > Resend this patch series for review.
> >
> > This version (v3) fixed and added more details in commit messages, and added one patch to fix "undefined voltage range" issue as well.
> >
> > This patch series fixes UFS regulator operations, including voltage and current (re-)configuration flow during UFS initialization and power mode switching.
> >
> > In the end, remove "<name>-fixed-regulator" device tree property because it is not necessary anymore after these fixes.
> >
> > V3:
> > - Fix and add more details in commit messages.
> > - Add one patch "scsi: ufs: Avoid configuring undefined voltage range on a regulator".
> >
> > V2:
> > - Add two patches to prepare to and remove "<name>-fixed-regulator" device tree property.
> > - Add more details on patch "scsi: ufs: remove unused min_uA field in struct ufs_vreg" (Marc Gonzalez).
> >
> > Stanley Chu (5):
> >   scsi: ufs: Remove unused min_uA field in struct ufs_vreg
> >   scsi: ufs: Avoid configuring regulator with undefined voltage range
> >   scsi: ufs: Fix regulator load and icc-level configuration
> >   scsi: ufs: Change "<name>-max-microamp" to non-mandatory property
> >   scsi: ufs: Remove "<name>-fixed-regulator" device tree property
> >
> >  drivers/scsi/ufs/ufs.h           |  1 -
> >  drivers/scsi/ufs/ufshcd-pltfrm.c | 14 +++-----------
> >  drivers/scsi/ufs/ufshcd.c        | 28 ++++++++++++++++++++--------
> >  3 files changed, 23 insertions(+), 20 deletions(-)
> >
> > --
> > 2.18.0
> >
> 
> 
Thanks,
Stanley

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2019-03-28  1:21 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-27  9:58 [PATCH RESEND v3 0/5] scsi: ufs: Fix regulator operations and remove "<name>-fixed-regulator" device tree property Stanley Chu
     [not found] ` <1553680707-28579-1-git-send-email-stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2019-03-27  9:58   ` [PATCH RESEND v3 1/5] scsi: ufs: Remove unused min_uA field in struct ufs_vreg Stanley Chu
2019-03-27  9:58   ` [PATCH RESEND v3 2/5] scsi: ufs: Avoid configuring regulator with undefined voltage range Stanley Chu
     [not found]     ` <1553680707-28579-3-git-send-email-stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2019-03-27 10:35       ` Avri Altman
2019-03-27  9:58   ` [PATCH RESEND v3 3/5] scsi: ufs: Fix regulator load and icc-level configuration Stanley Chu
     [not found]     ` <1553680707-28579-4-git-send-email-stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2019-03-27 10:55       ` Avri Altman
2019-03-27  9:58   ` [PATCH RESEND v3 4/5] scsi: ufs: Change "<name>-max-microamp" to non-mandatory property Stanley Chu
     [not found]     ` <1553680707-28579-5-git-send-email-stanley.chu-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2019-03-27 10:48       ` Avri Altman
2019-03-27  9:58   ` [PATCH RESEND v3 5/5] scsi: ufs: Remove "<name>-fixed-regulator" device tree property Stanley Chu
2019-03-27 10:57   ` [PATCH RESEND v3 0/5] scsi: ufs: Fix regulator operations and remove " Avri Altman
     [not found]     ` <SN6PR04MB49250E97111EB8975E0ED7EFFC580-UKdxhu0+N/VnT3GYGerMaFM8qxBPnqtHvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2019-03-27 13:24       ` Stanley Chu
2019-03-27 17:18   ` Alim Akhtar
     [not found]     ` <CAGOxZ51zdtoLz=E_vmpwt+2wTJq32yUQa=h_OiV7qO1N-c=NUA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-03-28  1:21       ` Stanley Chu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.