Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1236325 > unrolled thread
| Started by | Sascha Hauer <s.hauer@pengutronix.de> |
|---|---|
| First post | 2015-09-30 16:10 +0200 |
| Last post | 2015-09-30 16:30 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 2/6] regulator: core: introduce function to lock regulators and its supplies Sascha Hauer <s.hauer@pengutronix.de> - 2015-09-30 16:10 +0200
Re: [PATCH 2/6] regulator: core: introduce function to lock regulators and its supplies kbuild test robot <lkp@intel.com> - 2015-09-30 16:30 +0200
| From | Sascha Hauer <s.hauer@pengutronix.de> |
|---|---|
| Date | 2015-09-30 16:10 +0200 |
| Subject | [PATCH 2/6] regulator: core: introduce function to lock regulators and its supplies |
| Message-ID | <qeqf0-7dN-1@gated-at.bofh.it> |
Each regulator_dev is locked with its own mutex. This is fine as long
as only one regulator_dev is locked, but makes lockdep unhappy when we
have to walk up the supply chain like it can happen in
regulator_get_voltage:
regulator_get_voltage ->
mutex_lock(®ulator->rdev->mutex) ->
_regulator_get_voltage(regulator->rdev) ->
regulator_get_voltage(rdev->supply) ->
mutex_lock(®ulator->rdev->mutex);
This causes lockdep to issue a possible deadlock warning.
There are at least two ways to work around this:
- We can always lock the whole supply chain using the functions
introduced with this patch.
- We could store the current voltage in struct regulator_rdev so
that we do not have to walk up the supply chain for the
_regulator_get_voltage case.
Anyway, regulator_lock_supply/regulator_unlock_supply will be needed
once we allow regulator_set_voltage to optimize the supply voltages.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/regulator/core.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index bd9db70..e5de3d9 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -132,6 +132,45 @@ static bool have_full_constraints(void)
}
/**
+ * regulator_lock_supply - lock a regulator and its supplies
+ * @rdev: regulator source
+ */
+static void regulator_lock_supply(struct regulator_dev *rdev)
+{
+ struct regulator *supply;
+ int i = 0;
+
+ while (1) {
+ mutex_lock_nested(&rdev->mutex, i++);
+ supply = rdev->supply;
+
+ if (!rdev->supply)
+ return;
+
+ rdev = supply->rdev;
+ }
+}
+
+/**
+ * regulator_unlock_supply - unlock a regulator and its supplies
+ * @rdev: regulator source
+ */
+static void regulator_unlock_supply(struct regulator_dev *rdev)
+{
+ struct regulator *supply;
+
+ while (1) {
+ mutex_unlock(&rdev->mutex);
+ supply = rdev->supply;
+
+ if (!rdev->supply)
+ return;
+
+ rdev = supply->rdev;
+ }
+}
+
+/**
* of_get_regulator - get a regulator device node based on supply name
* @dev: Device pointer for the consumer (of regulator) device
* @supply: regulator supply name
--
2.5.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | kbuild test robot <lkp@intel.com> |
|---|---|
| Date | 2015-09-30 16:30 +0200 |
| Subject | Re: [PATCH 2/6] regulator: core: introduce function to lock regulators and its supplies |
| Message-ID | <qeqyn-7BV-49@gated-at.bofh.it> |
| In reply to | #1236325 |
[Multipart message — attachments visible in raw view] — view raw
Hi Sascha,
[auto build test results on v4.3-rc3 -- if it's inappropriate base, please ignore]
config: x86_64-randconfig-i0-201539 (attached as .config)
reproduce:
git checkout 70f6f03239f72ac3a34fad792af5200c613f4dbc
# save the attached .config to linux build tree
make ARCH=x86_64
All warnings (new ones prefixed by >>):
drivers/regulator/core.c: In function 'regulator_lock_supply':
>> drivers/regulator/core.c:141:6: warning: unused variable 'i' [-Wunused-variable]
int i = 0;
^
drivers/regulator/core.c: At top level:
drivers/regulator/core.c:138:13: warning: 'regulator_lock_supply' defined but not used [-Wunused-function]
static void regulator_lock_supply(struct regulator_dev *rdev)
^
drivers/regulator/core.c:158:13: warning: 'regulator_unlock_supply' defined but not used [-Wunused-function]
static void regulator_unlock_supply(struct regulator_dev *rdev)
^
vim +/i +141 drivers/regulator/core.c
125 else
126 return "";
127 }
128
129 static bool have_full_constraints(void)
130 {
131 return has_full_constraints || of_have_populated_dt();
132 }
133
134 /**
135 * regulator_lock_supply - lock a regulator and its supplies
136 * @rdev: regulator source
137 */
138 static void regulator_lock_supply(struct regulator_dev *rdev)
139 {
140 struct regulator *supply;
> 141 int i = 0;
142
143 while (1) {
144 mutex_lock_nested(&rdev->mutex, i++);
145 supply = rdev->supply;
146
147 if (!rdev->supply)
148 return;
149
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web