Skip to contentSkip to conversation

i2c: imx: defer probe if bus recovery GPIOs are not ready

PATCH In review Stefan Agner 2 participants 5 messages Nov 9, 2016

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

PATCH 1/1 i2c: imx: defer probe if bus recovery GPIOs are not ready

commit 533169d164c6b4c8571d0d48779f6ff6be593d72 upstream.

Some SoC might load the GPIO driver after the I2C driver and using the I2C bus recovery mechanism via GPIOs. In this case it is crucial to defer probing if the GPIO request functions do so, otherwise the I2C driver gets loaded without recovery mechanisms enabled.

---
 drivers/i2c/busses/i2c-imx.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-imx.c +7 -4
index d4d8536..32fae2c 100644
@@ -1002,10 +1002,13 @@ static void i2c_imx_init_recovery_info(struct imx_i2c_struct *i2c_imx,
 	rinfo->scl_gpio = of_get_named_gpio_flags(pdev->dev.of_node,
 			"scl-gpios", 0, NULL);
 
-	if (!gpio_is_valid(rinfo->sda_gpio) ||
-	    !gpio_is_valid(rinfo->scl_gpio) ||
-	    IS_ERR(i2c_imx->pinctrl_pins_default) ||
-	    IS_ERR(i2c_imx->pinctrl_pins_gpio)) {
+	if (rinfo->sda_gpio == -EPROBE_DEFER ||
+	    rinfo->scl_gpio == -EPROBE_DEFER) {
+		return -EPROBE_DEFER;
+	} else if (!gpio_is_valid(rinfo->sda_gpio) ||
+		   !gpio_is_valid(rinfo->scl_gpio) ||
+		   IS_ERR(i2c_imx->pinctrl_pins_default) ||
+		   IS_ERR(i2c_imx->pinctrl_pins_gpio)) {
 		dev_dbg(&pdev->dev, "recovery information incomplete\n");
 		return;
 	}
Signature · 1 line
2.10.2
#1 lore raw
Quoted 8 lines · Stefan Agner

commit 533169d164c6b4c8571d0d48779f6ff6be593d72 upstream.

Some SoC might load the GPIO driver after the I2C driver and using the I2C bus recovery mechanism via GPIOs. In this case it is crucial to defer probing if the GPIO request functions do so, otherwise the I2C driver gets loaded without recovery mechanisms enabled.

Quoted 5 lines

I forgot to mention, this should be applied to 4.4 only.

Later versions made the return value void, and it would require a larger rework. I am mainly concerned about LTS...

--
Stefan

Quoted 27 lines
---
 drivers/i2c/busses/i2c-imx.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-imx.c +7 -4
index d4d8536..32fae2c 100644
@@ -1002,10 +1002,13 @@ static void i2c_imx_init_recovery_info(struct
 imx_i2c_struct *i2c_imx,
 	rinfo->scl_gpio = of_get_named_gpio_flags(pdev->dev.of_node,
 			"scl-gpios", 0, NULL);
 
-	if (!gpio_is_valid(rinfo->sda_gpio) ||
-	    !gpio_is_valid(rinfo->scl_gpio) ||
-	    IS_ERR(i2c_imx->pinctrl_pins_default) ||
-	    IS_ERR(i2c_imx->pinctrl_pins_gpio)) {
+	if (rinfo->sda_gpio == -EPROBE_DEFER ||
+	    rinfo->scl_gpio == -EPROBE_DEFER) {
+		return -EPROBE_DEFER;
+	} else if (!gpio_is_valid(rinfo->sda_gpio) ||
+		   !gpio_is_valid(rinfo->scl_gpio) ||
+		   IS_ERR(i2c_imx->pinctrl_pins_default) ||
+		   IS_ERR(i2c_imx->pinctrl_pins_gpio)) {
 		dev_dbg(&pdev->dev, "recovery information incomplete\n");
 		return;

}

#4 lore raw
In reply to Stefan Agner
Quoted 22 lines · Stefan Agner

commit 533169d164c6b4c8571d0d48779f6ff6be593d72 upstream.

Some SoC might load the GPIO driver after the I2C driver and using the I2C bus recovery mechanism via GPIOs. In this case it is crucial to defer probing if the GPIO request functions do so, otherwise the I2C driver gets loaded without recovery mechanisms enabled.

---
 drivers/i2c/busses/i2c-imx.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-imx.c +0 -0
index d4d8536..32fae2c 100644

drivers/i2c/busses/i2c-imx.c static void i2c_imx_init_recovery_info(struct imx_i2c_struct *i2c_imx, · line 1007

Quoted 10 lines
drivers/i2c/busses/i2c-imx.c +3 -4
@@ -1002,10 +1002,13 @@ static void i2c_imx_init_recovery_info(struct imx_i2c_struct *i2c_imx,
 	rinfo->scl_gpio = of_get_named_gpio_flags(pdev->dev.of_node,
 			"scl-gpios", 0, NULL);
 
-	if (!gpio_is_valid(rinfo->sda_gpio) ||
-	    !gpio_is_valid(rinfo->scl_gpio) ||
-	    IS_ERR(i2c_imx->pinctrl_pins_default) ||
-	    IS_ERR(i2c_imx->pinctrl_pins_gpio)) {
+	if (rinfo->sda_gpio == -EPROBE_DEFER ||
+	    rinfo->scl_gpio == -EPROBE_DEFER) {
+		return -EPROBE_DEFER;

Ok, but...

drivers/i2c/busses/i2c-imx.c static void i2c_imx_init_recovery_info(struct imx_i2c_struct *i2c_imx, · line 1013

Quoted 6 lines
drivers/i2c/busses/i2c-imx.c +4 -0
+	} else if (!gpio_is_valid(rinfo->sda_gpio) ||
+		   !gpio_is_valid(rinfo->scl_gpio) ||
+		   IS_ERR(i2c_imx->pinctrl_pins_default) ||
+		   IS_ERR(i2c_imx->pinctrl_pins_gpio)) {
 		dev_dbg(&pdev->dev, "recovery information incomplete\n");
 		return;

Hm.

I don't think you built this patch :(

Same goes for 4.8-stable...

greg k-h

#2 lore raw
In reply to Stefan Agner
Quoted 9 lines · Stefan Agner
Quoted 8 lines · Stefan Agner

commit 533169d164c6b4c8571d0d48779f6ff6be593d72 upstream.

Some SoC might load the GPIO driver after the I2C driver and using the I2C bus recovery mechanism via GPIOs. In this case it is crucial to defer probing if the GPIO request functions do so, otherwise the I2C driver gets loaded without recovery mechanisms enabled.

Quoted 7 lines
Quoted 5 lines

I forgot to mention, this should be applied to 4.4 only.

Did you build the code there?

Quoted 2 lines

Later versions made the return value void, and it would require a larger rework. I am mainly concerned about LTS...

I don't see this working for either 4.4 or 4.8-stable right now, do you?

confused,

greg k-h

#3 lore raw
Quoted 16 lines · Greg KH
Quoted 15 lines · Stefan Agner
Quoted 13 lines · Stefan Agner

commit 533169d164c6b4c8571d0d48779f6ff6be593d72 upstream.

Some SoC might load the GPIO driver after the I2C driver and using the I2C bus recovery mechanism via GPIOs. In this case it is crucial to defer probing if the GPIO request functions do so, otherwise the I2C driver gets loaded without recovery mechanisms enabled.

Quoted 3 lines
Quoted 1 line

I forgot to mention, this should be applied to 4.4 only.

Did you build the code there?

Oh, I built it on a branch where I had some other patches applied, sorry about that.

Quoted 5 lines
Quoted 3 lines

Later versions made the return value void, and it would require a larger rework. I am mainly concerned about LTS...

I don't see this working for either 4.4 or 4.8-stable right now, do you?

No, the patch really doesn't work for 4.4 through 4.8. The patch relies on commit fd8961c5ba9e6c ("i2c: imx: make bus recovery through pinctrl optional"), which is not marked for stable (and probably also not suitable actually).

The issue can only be observed on Vybrid SoC's with I2C bus recovery enabled. The upstream device trees don't use I2C bus recovery so far. So the patch is actually just enabling a feature we did not have so far... Given all this circumstances, I think we should not further waste our time and try to backport this patch for stable.

Sorry for the noise.

--
Stefan