lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1346251989-26537-1-git-send-email-ldewangan@nvidia.com>
Date:	Wed, 29 Aug 2012 20:23:09 +0530
From:	Laxman Dewangan <ldewangan@...dia.com>
To:	<lrg@...com>, <broonie@...nsource.wolfsonmicro.com>,
	<rabin.vincent@...il.com>
CC:	<linux-kernel@...r.kernel.org>,
	Laxman Dewangan <ldewangan@...dia.com>
Subject: [PATCH V2] regulator: disable supply regulator if it is enabled for boot-on

If supply regulator is enabled because of boot-on (not always-on)
then disable regulator need to be call if regulator have some
user or full constraint has been enabled.
This will make sure that reference count of supply regulator
is in sync with child regulator's state.

Signed-off-by: Laxman Dewangan <ldewangan@...dia.com>
Reported-by: Rabin Vincent <rabin.vincent@...il.com>
---
Changes from V1:
Rabin reported that the nested locking trace is getting generated.
This is because the regulator lock mutex and disable himself and then
call for supply disable which again lock the regulator lock.
Probably because both lock is taken from regulator structure in nested
manner, the trace is getting generated.
Rewritten patch to avoid nested locking.

 drivers/regulator/core.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 06186ba..e54537f 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -3606,6 +3606,7 @@ static int __init regulator_init_complete(void)
 	 * default behaviour in the future.
 	 */
 	list_for_each_entry(rdev, &regulator_list, list) {
+		bool supply_disable = false;
 		ops = rdev->desc->ops;
 		c = rdev->constraints;
 
@@ -3614,8 +3615,11 @@ static int __init regulator_init_complete(void)
 
 		mutex_lock(&rdev->mutex);
 
-		if (rdev->use_count)
+		if (rdev->use_count) {
+			if (rdev->supply && c->boot_on)
+				supply_disable = true;
 			goto unlock;
+		}
 
 		/* If we can't read the status assume it's on. */
 		if (ops->is_enabled)
@@ -3634,6 +3638,8 @@ static int __init regulator_init_complete(void)
 			if (ret != 0) {
 				rdev_err(rdev, "couldn't disable: %d\n", ret);
 			}
+			if (rdev->supply)
+				supply_disable = true;
 		} else {
 			/* The intention is that in future we will
 			 * assume that full constraints are provided
@@ -3645,6 +3651,8 @@ static int __init regulator_init_complete(void)
 
 unlock:
 		mutex_unlock(&rdev->mutex);
+		if (supply_disable)
+			regulator_disable(rdev->supply);
 	}
 
 	mutex_unlock(&regulator_list_mutex);
-- 
1.7.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ