Skip to contentSkip to conversation

gpio: pca953x: add a comment explaining the need for a lockdep subclass

PATCH New Bartosz Golaszewski 3 participants 8 messages Sep 26, 2016 – Oct 12, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio: pca953x: add a comment explaining the need for a lockdep subclass

Since there's an rc8 I thought I'd send a follow-up patch to the series addressing the lockdep false positive in pca953x.

The reason for setting the subclass in the probe function is not explained in the code nor is it obvious at first glance. This patch adds a comment explaining the problem.

Rebased on top of current i2c/for-next.

Bartosz Golaszewski (1):
gpio: pca953x: add a comment explaining the need for a lockdep
subclass

 drivers/gpio/gpio-pca953x.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 gpio: pca953x: add a comment explaining the need for a lockdep subclass

This is a follow-up to commit 559b46990e76 ("gpio: pca953x: fix an incorrect lockdep warning"). The reason for calling lockdep_set_subclass() in pca953x_probe() is not explained in the code.

Add a comment describing the problem, partial solution and required future extensions.

---
 drivers/gpio/gpio-pca953x.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/gpio/gpio-pca953x.c +16 -0
index 018f39c..f306909 100644
@@ -786,6 +786,22 @@ static int pca953x_probe(struct i2c_client *client,
 	chip->chip_type = PCA_CHIP_TYPE(chip->driver_data);
 
 	mutex_init(&chip->i2c_lock);
+	/*
+	 * In case we have an i2c-mux controlled by a GPIO provided by an
+	 * expander using the same driver higher on the device tree, read the
+	 * i2c adapter nesting depth and use the retrieved value as lockdep
+	 * subclass for chip->i2c_lock.
+	 *
+	 * REVISIT: This solution is not complete. It protects us from lockdep
+	 * false positives when the expander controlling the i2c-mux is on
+	 * a different level on the device tree, but not when it's on the same
+	 * level on a different branch (in which case the subclass number
+	 * would be the same).
+	 *
+	 * TODO: Once a correct solution is developed, a similar fix should be
+	 * applied to all other i2c-controlled GPIO expanders (and potentially
+	 * regmap-i2c).
+	 */
 	lockdep_set_subclass(&chip->i2c_lock,
 			     i2c_adapter_depth(client->adapter));
 
Signature · 1 line
2.7.4
Acked-by on v1 1/1
#2 lore raw
Quoted 9 lines · Bartosz Golaszewski

This is a follow-up to commit 559b46990e76 ("gpio: pca953x: fix an incorrect lockdep warning"). The reason for calling lockdep_set_subclass() in pca953x_probe() is not explained in the code.

Add a comment describing the problem, partial solution and required future extensions.

Linus, because of dependencies, I should probably pick it up?

#3 lore raw
Quoted 6 lines · Wolfram Sang
Quoted 5 lines · Bartosz Golaszewski

This is a follow-up to commit 559b46990e76 ("gpio: pca953x: fix an incorrect lockdep warning"). The reason for calling lockdep_set_subclass() in pca953x_probe() is not explained in the code.

Quoted 8 lines
Quoted 4 lines

Add a comment describing the problem, partial solution and required future extensions.

Linus, because of dependencies, I should probably pick it up?

Linus, ping!

#4 lore raw

2016-09-29 8:06 GMT+02:00 Wolfram Sang <[email protected]>:

Quoted 10 lines · Wolfram Sang
Quoted 9 lines · Bartosz Golaszewski
Quoted 8 lines

This is a follow-up to commit 559b46990e76 ("gpio: pca953x: fix an incorrect lockdep warning"). The reason for calling lockdep_set_subclass() in pca953x_probe() is not explained in the code.

Add a comment describing the problem, partial solution and required future extensions.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Linus, because of dependencies, I should probably pick it up?

Linus, ping!

Hi Wolfram,

this patch will not apply to the gpio tree. If Linus is too busy to comment, maybe you could pick it up anyway - it doesn't change anything in terms of functionality and it's better to have the code commented when it's not obvious what it does.

Thanks,
Bartosz

#5 lore raw
Quoted 20 lines · Bartosz Golaszewski

2016-09-29 8:06 GMT+02:00 Wolfram Sang <[email protected]>:

Quoted 10 lines · Wolfram Sang
Quoted 9 lines · Bartosz Golaszewski
Quoted 8 lines

This is a follow-up to commit 559b46990e76 ("gpio: pca953x: fix an incorrect lockdep warning"). The reason for calling lockdep_set_subclass() in pca953x_probe() is not explained in the code.

Add a comment describing the problem, partial solution and required future extensions.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Linus, because of dependencies, I should probably pick it up?

Linus, ping!

Quoted 6 lines

Hi Wolfram,

this patch will not apply to the gpio tree. If Linus is too busy to comment, maybe you could pick it up anyway - it doesn't change anything in terms of functionality and it's better to have the code commented when it's not obvious what it does.

I want to pick it up and am likely to do so anyway, but to be formally perfect, I need an ack from Linus.

#6 lore raw
In reply to Wolfram Sang
Quoted 6 lines · Wolfram Sang
Quoted 5 lines · Bartosz Golaszewski

This is a follow-up to commit 559b46990e76 ("gpio: pca953x: fix an incorrect lockdep warning"). The reason for calling lockdep_set_subclass() in pca953x_probe() is not explained in the code.

Quoted 8 lines
Quoted 4 lines

Add a comment describing the problem, partial solution and required future extensions.

Linus, because of dependencies, I should probably pick it up?

Yes Acked-by: Linus Walleij <[email protected]>

Sorry was travelling.

Yours,
Linus Walleij

Applied
#7 lore raw
In reply to Bartosz Golaszewski
Quoted 9 lines · Bartosz Golaszewski

This is a follow-up to commit 559b46990e76 ("gpio: pca953x: fix an incorrect lockdep warning"). The reason for calling lockdep_set_subclass() in pca953x_probe() is not explained in the code.

Add a comment describing the problem, partial solution and required future extensions.

Applied to for-current, thanks!