Skip to contentSkip to conversation

i2c: designware: use enable on resume instead initialization

PATCH In review [email protected] 4 participants 16 messages Jun 8, 2015 – Jun 24, 2015 2 messages not in the archive

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

PATCH 1/1 i2c: designware: use enable on resume instead initialization

From: Fabio Mello <[email protected]>

According to documentation and tests, initialization is not necessary on module resume, since the controller keeps its state between disable/enable. Change the target address is also allowed.

So, this patch replaces the initialization on module resume with a simple enable, and removes the (non required anymore) enables and disables.

---

These pictures explain a little more the consequence of letting the enable+disable in the code:

	http://pub.politreco.com/paste/TEK0011-before.jpg
	http://pub.politreco.com/paste/TEK0007-after.jpg

The yellow line is a GPIO toggle in userspace to mark when we start and finish the i2c transactions. The blue line is the SCL in that i2c bus. Take a look on the huge pauses we have between any 2 transactions. These pauses are removed with this patch and we are able to read our sensor's values in 950usec rather than 5.24msec we had before. We are testing this using a Minnowboard Max that has a designware i2c controller.

There's this comment in the code suggesting the designware controller might have problems if we don't disable it after each transfer. We left a stress code running for 3 days to check if anything bad would happen. This is the test code using a PCA9685 (just because it was the easiest device we had available to check read+write commands):

http://pub.politreco.com/paste/test-i2c.c

 drivers/i2c/busses/i2c-designware-core.c    | 19 ++++---------------
 drivers/i2c/busses/i2c-designware-platdrv.c |  2 +-
 2 files changed, 5 insertions(+), 16 deletions(-)
drivers/i2c/busses/i2c-designware-core.c +4 -15
index 6e25c01..b386c10 100644
@@ -375,8 +375,12 @@ int i2c_dw_init(struct dw_i2c_dev *dev)
 	/* configure the i2c master */
 	dw_writel(dev, dev->master_cfg , DW_IC_CON);
 
+	/* Enable the adapter */
+	__i2c_dw_enable(dev, true);
+
 	if (dev->release_lock)
 		dev->release_lock(dev);
+
 	return 0;
 }
 EXPORT_SYMBOL_GPL(i2c_dw_init);
@@ -405,9 +409,6 @@ static void i2c_dw_xfer_init(struct dw_i2c_dev *dev)
 	struct i2c_msg *msgs = dev->msgs;
 	u32 ic_con, ic_tar = 0;
 
-	/* Disable the adapter */
-	__i2c_dw_enable(dev, false);
-
 	/* if the slave address is ten bit address, enable 10BITADDR */
 	ic_con = dw_readl(dev, DW_IC_CON);
 	if (msgs[dev->msg_write_idx].flags & I2C_M_TEN) {
@@ -434,9 +435,6 @@ static void i2c_dw_xfer_init(struct dw_i2c_dev *dev)
 	/* enforce disabled interrupts (due to HW issues) */
 	i2c_dw_disable_int(dev);
 
-	/* Enable the adapter */
-	__i2c_dw_enable(dev, true);
-
 	/* Clear and enable interrupts */
 	i2c_dw_clear_int(dev);
 	dw_writel(dev, DW_IC_INTR_DEFAULT_MASK, DW_IC_INTR_MASK);
@@ -665,15 +663,6 @@ i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
 		goto done;
 	}
 
-	/*
-	 * We must disable the adapter before unlocking the &dev->lock mutex
-	 * below. Otherwise the hardware might continue generating interrupts
-	 * which in turn causes a race condition with the following transfer.
-	 * Needs some more investigation if the additional interrupts are
-	 * a hardware bug or this driver doesn't handle them correctly yet.
-	 */
-	__i2c_dw_enable(dev, false);
-
 	if (dev->msg_err) {
 		ret = dev->msg_err;
 		goto done;
drivers/i2c/busses/i2c-designware-platdrv.c +1 -1
index c270f5f..0598695 100644
@@ -320,7 +320,7 @@ static int dw_i2c_resume(struct device *dev)
 	clk_prepare_enable(i_dev->clk);
 
 	if (!i_dev->pm_runtime_disabled)
-		i2c_dw_init(i_dev);
+		i2c_dw_enable(i_dev);
 
 	return 0;
 }
Signature · 1 line
2.4.2
maintainer
#1 lore raw
Quoted 20 lines · On Mon, Jun 08, 2015 at 02:50:28PM -0300…

From: Fabio Mello <[email protected]>

According to documentation and tests, initialization is not necessary on module resume, since the controller keeps its state between disable/enable. Change the target address is also allowed.

So, this patch replaces the initialization on module resume with a simple enable, and removes the (non required anymore) enables and disables.

---

These pictures explain a little more the consequence of letting the enable+disable in the code:

	http://pub.politreco.com/paste/TEK0011-before.jpg
	http://pub.politreco.com/paste/TEK0007-after.jpg
Quoted 6 lines

The yellow line is a GPIO toggle in userspace to mark when we start and finish the i2c transactions. The blue line is the SCL in that i2c bus. Take a look on the huge pauses we have between any 2 transactions. These pauses are removed with this patch and we are able to read our sensor's values in 950usec rather than 5.24msec we had before. We are testing this using a Minnowboard Max that has a designware i2c controller.

Did you test this on any other platform than Intel Baytrail?

I'm adding Christian Ruppert (keeping the context) if he has any comments. IIRC he added the per transfer enable/disable some time ago.

Quoted 81 lines

There's this comment in the code suggesting the designware controller might have problems if we don't disable it after each transfer. We left a stress code running for 3 days to check if anything bad would happen. This is the test code using a PCA9685 (just because it was the easiest device we had available to check read+write commands):

http://pub.politreco.com/paste/test-i2c.c

 drivers/i2c/busses/i2c-designware-core.c    | 19 ++++---------------
 drivers/i2c/busses/i2c-designware-platdrv.c |  2 +-
 2 files changed, 5 insertions(+), 16 deletions(-)
drivers/i2c/busses/i2c-designware-core.c +4 -15
index 6e25c01..b386c10 100644
@@ -375,8 +375,12 @@ int i2c_dw_init(struct dw_i2c_dev *dev)
 	/* configure the i2c master */
 	dw_writel(dev, dev->master_cfg , DW_IC_CON);
 
+	/* Enable the adapter */
+	__i2c_dw_enable(dev, true);
+
 	if (dev->release_lock)
 		dev->release_lock(dev);
+
 	return 0;
 }
 EXPORT_SYMBOL_GPL(i2c_dw_init);
@@ -405,9 +409,6 @@ static void i2c_dw_xfer_init(struct dw_i2c_dev *dev)
 	struct i2c_msg *msgs = dev->msgs;
 	u32 ic_con, ic_tar = 0;
 
-	/* Disable the adapter */
-	__i2c_dw_enable(dev, false);
-
 	/* if the slave address is ten bit address, enable 10BITADDR */
 	ic_con = dw_readl(dev, DW_IC_CON);
 	if (msgs[dev->msg_write_idx].flags & I2C_M_TEN) {
@@ -434,9 +435,6 @@ static void i2c_dw_xfer_init(struct dw_i2c_dev *dev)
 	/* enforce disabled interrupts (due to HW issues) */
 	i2c_dw_disable_int(dev);
 
-	/* Enable the adapter */
-	__i2c_dw_enable(dev, true);
-
 	/* Clear and enable interrupts */
 	i2c_dw_clear_int(dev);
 	dw_writel(dev, DW_IC_INTR_DEFAULT_MASK, DW_IC_INTR_MASK);
@@ -665,15 +663,6 @@ i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
 		goto done;
 	}
 
-	/*
-	 * We must disable the adapter before unlocking the &dev->lock mutex
-	 * below. Otherwise the hardware might continue generating interrupts
-	 * which in turn causes a race condition with the following transfer.
-	 * Needs some more investigation if the additional interrupts are
-	 * a hardware bug or this driver doesn't handle them correctly yet.
-	 */
-	__i2c_dw_enable(dev, false);
-
 	if (dev->msg_err) {
 		ret = dev->msg_err;
 		goto done;
drivers/i2c/busses/i2c-designware-platdrv.c +1 -1
index c270f5f..0598695 100644
@@ -320,7 +320,7 @@ static int dw_i2c_resume(struct device *dev)
 	clk_prepare_enable(i_dev->clk);
 
 	if (!i_dev->pm_runtime_disabled)
-		i2c_dw_init(i_dev);
+		i2c_dw_enable(i_dev);
 
 	return 0;
 }
Signature · 1 line
2.4.2
#2 lore raw

Hi Mika,

Quoted 21 lines · Mika Westerberg
Quoted 20 lines · On Mon, Jun 08, 2015 at 02:50:28PM -0300…

From: Fabio Mello <[email protected]>

According to documentation and tests, initialization is not necessary on module resume, since the controller keeps its state between disable/enable. Change the target address is also allowed.

So, this patch replaces the initialization on module resume with a simple enable, and removes the (non required anymore) enables and disables.

---

These pictures explain a little more the consequence of letting the enable+disable in the code:

      http://pub.politreco.com/paste/TEK0011-before.jpg
      http://pub.politreco.com/paste/TEK0007-after.jpg
Quoted 8 lines
Quoted 6 lines

The yellow line is a GPIO toggle in userspace to mark when we start and finish the i2c transactions. The blue line is the SCL in that i2c bus. Take a look on the huge pauses we have between any 2 transactions. These pauses are removed with this patch and we are able to read our sensor's values in 950usec rather than 5.24msec we had before. We are testing this using a Minnowboard Max that has a designware i2c controller.

Did you test this on any other platform than Intel Baytrail?

No. The only soc we have here with this controller is the Baytrail.

Signature · 1 line
Lucas De Marchi
maintainer
#3 lore raw
Quoted 32 lines · Lucas De Marchi

Hi Mika,

Quoted 28 lines · Mika Westerberg
Quoted 26 lines · On Mon, Jun 08, 2015 at 02:50:28PM -0300…

From: Fabio Mello <[email protected]>

According to documentation and tests, initialization is not necessary on module resume, since the controller keeps its state between disable/enable. Change the target address is also allowed.

So, this patch replaces the initialization on module resume with a simple enable, and removes the (non required anymore) enables and disables.

---

These pictures explain a little more the consequence of letting the enable+disable in the code:

      http://pub.politreco.com/paste/TEK0011-before.jpg
      http://pub.politreco.com/paste/TEK0007-after.jpg

The yellow line is a GPIO toggle in userspace to mark when we start and finish the i2c transactions. The blue line is the SCL in that i2c bus. Take a look on the huge pauses we have between any 2 transactions. These pauses are removed with this patch and we are able to read our sensor's values in 950usec rather than 5.24msec we had before. We are testing this using a Minnowboard Max that has a designware i2c controller.

Quoted 3 lines
Quoted 1 line

Did you test this on any other platform than Intel Baytrail?

No. The only soc we have here with this controller is the Baytrail.

My concern is that this patch might break some non-Intel platform. It would be nice if someone (Christian?) could try this out.

A message that is not in the archive (sent off-list or not yet received): OF847FFF39.1FF5F96A-ONC1257E60.00506AFD-C1257E60.0052A8CE@alitech.com

maintainer
#5 lore raw
Quoted 3 lines · On Wed, Jun 10, 2015 at 05:05:16PM +0200…

We should understand why the controller was disabled after successful transfers in the first place, however. Maybe some quirk with older versions of the hardware? Mika, do you have any memories about this?

I think it was in the original driver even before I did Intel specific changes to that. I have no idea why it is done. Probably, like you said, because some older version of the hardware needed it.

#6 lore raw
In reply to a message not in the archive

Hi,

Quoted 16 lines · On 06/10, [email protected] wrote:

Mika Westerberg <mika.westerberg-VuQAYsv1563Yd54FQh9/[email protected]> wrote on 10.06.2015 09:07:22:

Quoted 2 lines

My concern is that this patch might break some non-Intel platform. It would be nice if someone (Christian?) could try this out.

Ouch, this one brings back painful memories. Take a look at patch 38d7fadef4973bb94e36897fcb6bb6a12fdd10c9 (
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=38d7fadef4973bb94e36897fcb6bb6a12fdd10c9
) for the context.

In brief:
- Before patch 38d7fade, the driver disabled the hardware after successful transfers. I do not know the reason for this and I cannot judge whether this is necessary or not. I thus decided not to modify this behaviour in patch 38d7fade.

Quoted 9 lines

- After patch 38d7fade, the driver disabled the dw controller after all transfers, in particular in the case of unsuccessful transfers. This modification was necessary because of a race condition triggered by an i2c slave device which interrupted transfers in the middle. In this case, the dw controller (at least our version) seems to send spurious interrupts later if it is not disabled. The interrupt handler is not designed to be called on already aborted transfers, however, which leads to undesirable behaviour if the interrupt occurs at the wrong moment (system hangs in irq loop).

Yeah. So before we had:

- sucessful transfer
-> disable the adapter after complete
- timeout transfer
-> disable the adapter after complete

And your patch added the disable in case there wasn't a timeout but dev->msg_err was set.

Quoted 7 lines

I will try to dig out the test setup we used to validate the patch at the time but given the fact that this was two years ago this might take a little while. In the meantime, do you have any means to stress test the case of unexpected events on the bus (client aborts transfer, timeout etc.)? An alternative might be to only disable the controller in the case of errors and leave it active after successful transfers. We should understand why the controller was disabled after successful transfers in

It seems pretty rad to disable the controller after each transfer. It may be due to previous revisions of the hw but may well be because of "it was the simplest way to do it" at the time. Disabling the controller after each transfer even if successful. For unsuccessful transfers we may want to disable it if there's a hw bug, but it would be good to check this indeed.

Quoted 2 lines

the first place, however. Maybe some quirk with older versions of the hardware? Mika, do you have any memories about this?

I'm not sure if it's a hw bug or if it's just an oversight from previous versions of this driver. So adding a quirk with correct versions will be difficult IMO. We've been only testing this with well behaved slaves. Do you have any idea how to test the bad guys? Maybe connecting a slave with a long wire to introduce errors?

Signature · 1 line
Lucas De Marchi

A message that is not in the archive (sent off-list or not yet received): OF847FFF39.1FF5F96A-ONC1257E60.00506AFD-C1257E60.0052A8CE@LocalDomain

#8 lore raw

Hello,

Christian Ruppert/ALi_GVA/ALi wrote on 10.06.2015 17:05:16:

Quoted 14 lines

Mika Westerberg <[email protected]> wrote on 10.06. 2015 09:07:22:

Quoted 6 lines · Lucas De Marchi
Quoted 5 lines

Hi Mika,

Quoted 1 line · Mika Westerberg

On Mon, Jun 08, 2015 at 02:50:28PM -0300,

Quoted 5 lines · [email protected] wrote:
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

From: Fabio Mello <[email protected]>

According to documentation and tests, initialization is not necessary on module resume, since the controller keeps its state between disable/enable. Change the target address is also

allowed.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

So, this patch replaces the initialization on module resume with

a

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

simple enable, and removes the (non required anymore) enables and disables.

---

These pictures explain a little more the consequence of letting

the

Quoted 45 lines
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

enable+disable in the code:

      http://pub.politreco.com/paste/TEK0011-before.jpg
      http://pub.politreco.com/paste/TEK0007-after.jpg

The yellow line is a GPIO toggle in userspace to mark when we

start and finish

Quoted 1 line
Quoted 1 line
Quoted 1 line

the i2c transactions. The blue line is the SCL in that i2c

bus. Take a look on

Quoted 1 line
Quoted 1 line
Quoted 1 line

the huge pauses we have between any 2 transactions. These

pauses are removed

Quoted 1 line
Quoted 1 line
Quoted 1 line

with this patch and we are able to read our sensor's values in

950usec rather

Quoted 1 line
Quoted 1 line
Quoted 1 line

than 5.24msec we had before. We are testing this using a

Minnowboard Max that

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

has a designware i2c controller.

Did you test this on any other platform than Intel Baytrail?

No. The only soc we have here with this controller is the Baytrail.

My concern is that this patch might break some non-Intel platform. It would be nice if someone (Christian?) could try this out.

Ouch, this one brings back painful memories. Take a look at patch 38d7fadef4973bb94e36897fcb6bb6a12fdd10c9 (https://git.kernel.org/
cgit/linux/kernel/git/torvalds/linux.git/commit/? id=38d7fadef4973bb94e36897fcb6bb6a12fdd10c9) for the context.

In brief:
- Before patch 38d7fade, the driver disabled the hardware after successful transfers. I do not know the reason for this and I cannot judge whether this is necessary or not. I thus decided not to modify this behaviour in patch 38d7fade.

- After patch 38d7fade, the driver disabled the dw controller after all transfers, in particular in the case of unsuccessful transfers. This modification was necessary because of a race condition triggered by an i2c slave device which interrupted transfers in the middle. In this case, the dw controller (at least our version) seems to send spurious interrupts later if it is not disabled. The interrupt handler is not designed to be called on already aborted transfers, however, which leads to undesirable behaviour if the interrupt occurs at the wrong moment (system hangs in irq loop).

Quoted 10 lines

I will try to dig out the test setup we used to validate the patch at the time but given the fact that this was two years ago this might take a little while. In the meantime, do you have any means to stress test the case of unexpected events on the bus (client aborts transfer, timeout etc.)? An alternative might be to only disable the controller in the case of errors and leave it active after successful transfers. We should understand why the controller was disabled after successful transfers in the first place, however. Maybe some quirk with older versions of the hardware? Mika, do you have any memories about this?

As promised I tried to dig out the test setup we used to validate patch 38d7fade at the time but without success. (I half expected that after such a long time...)

So I said to myself, let's give the patch a try nevertheless and see if it works in our system at least in the nominal case (no i2c bus errors).

The result is not very encouraging: Out of five (identical) designware i2c controllers we have on my test SOC, the first one initialises properly but the second one gets stuck in the famous irq loop right away when the module is enabled in i2c_dw_init. The system never gets around to try initialising the remaining three controllers due to the irq loop. I didn't have the time to investigate the details yet but I suspect this is triggered by some nastily behaved device on the bus. For example, some of our external devices are notorious for keeping i2c lines tied to zero before being properly powered on/reset/initialised by their respective drivers (which in turn depend on the i2c master to be initialised first, obviously). I'll grab an oscilloscope and dump the waves to confirm this suspicion on the occasion.
However, similar situations might occur in multi-master setups (which we don't have). I suspect the driver/hardware to also end up in the irq loop after loosing arbitration with this patch. Has anybody the means to test this in a multi-master system?

Greetings,
Christian

#9 lore raw
Quoted 90 lines · On Tue, Jun 23, 2015 at 1:45 PM, <christian.ruppert-Yycd8EPnGM5BDgjK7y7TUQ@pub…

Hello,

Christian Ruppert/ALi_GVA/ALi wrote on 10.06.2015 17:05:16:

Quoted 14 lines

Mika Westerberg <mika.westerberg-VuQAYsv1563Yd54FQh9/[email protected]> wrote on 10.06. 2015 09:07:22:

Quoted 6 lines · Lucas De Marchi
Quoted 5 lines

Hi Mika,

Quoted 1 line · Mika Westerberg

On Mon, Jun 08, 2015 at 02:50:28PM -0300,

Quoted 5 lines · [email protected] wrote:
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

From: Fabio Mello <[email protected]>

According to documentation and tests, initialization is not necessary on module resume, since the controller keeps its state between disable/enable. Change the target address is also

allowed.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

So, this patch replaces the initialization on module resume with

a

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

simple enable, and removes the (non required anymore) enables and disables.

---

These pictures explain a little more the consequence of letting

the

Quoted 45 lines
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

enable+disable in the code:

      http://pub.politreco.com/paste/TEK0011-before.jpg
      http://pub.politreco.com/paste/TEK0007-after.jpg

The yellow line is a GPIO toggle in userspace to mark when we

start and finish

Quoted 1 line
Quoted 1 line
Quoted 1 line

the i2c transactions. The blue line is the SCL in that i2c

bus. Take a look on

Quoted 1 line
Quoted 1 line
Quoted 1 line

the huge pauses we have between any 2 transactions. These

pauses are removed

Quoted 1 line
Quoted 1 line
Quoted 1 line

with this patch and we are able to read our sensor's values in

950usec rather

Quoted 1 line
Quoted 1 line
Quoted 1 line

than 5.24msec we had before. We are testing this using a

Minnowboard Max that

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

has a designware i2c controller.

Did you test this on any other platform than Intel Baytrail?

No. The only soc we have here with this controller is the Baytrail.

My concern is that this patch might break some non-Intel platform. It would be nice if someone (Christian?) could try this out.

Ouch, this one brings back painful memories. Take a look at patch 38d7fadef4973bb94e36897fcb6bb6a12fdd10c9 (https://git.kernel.org/
cgit/linux/kernel/git/torvalds/linux.git/commit/? id=38d7fadef4973bb94e36897fcb6bb6a12fdd10c9) for the context.

In brief:
- Before patch 38d7fade, the driver disabled the hardware after successful transfers. I do not know the reason for this and I cannot judge whether this is necessary or not. I thus decided not to modify this behaviour in patch 38d7fade.

- After patch 38d7fade, the driver disabled the dw controller after all transfers, in particular in the case of unsuccessful transfers. This modification was necessary because of a race condition triggered by an i2c slave device which interrupted transfers in the middle. In this case, the dw controller (at least our version) seems to send spurious interrupts later if it is not disabled. The interrupt handler is not designed to be called on already aborted transfers, however, which leads to undesirable behaviour if the interrupt occurs at the wrong moment (system hangs in irq loop).

Quoted 10 lines

I will try to dig out the test setup we used to validate the patch at the time but given the fact that this was two years ago this might take a little while. In the meantime, do you have any means to stress test the case of unexpected events on the bus (client aborts transfer, timeout etc.)? An alternative might be to only disable the controller in the case of errors and leave it active after successful transfers. We should understand why the controller was disabled after successful transfers in the first place, however. Maybe some quirk with older versions of the hardware? Mika, do you have any memories about this?

As promised I tried to dig out the test setup we used to validate patch 38d7fade at the time but without success. (I half expected that after such a long time...)

Quoted 7 lines

So I said to myself, let's give the patch a try nevertheless and see if it works in our system at least in the nominal case (no i2c bus errors).

The result is not very encouraging: Out of five (identical) designware i2c controllers we have on my test SOC, the first one initialises properly but the second one gets stuck in the famous irq loop right away when the module is enabled in i2c_dw_init. The system never gets around to try

Are you using the pci or platform driver? I noticed yesterday the pci version is failing here with a NULL pointer dereference.

Quoted 8 lines

initialising the remaining three controllers due to the irq loop. I didn't have the time to investigate the details yet but I suspect this is triggered by some nastily behaved device on the bus. For example, some of our external devices are notorious for keeping i2c lines tied to zero before being properly powered on/reset/initialised by their respective drivers (which in turn depend on the i2c master to be initialised first, obviously). I'll grab an oscilloscope and dump the waves to confirm this suspicion on the occasion.

Yeah, it'd be great to have it.

thanks for testing it with your setup.

Signature · 1 line
Lucas De Marchi
#10 lore raw

Dear Lucas,

Lucas De Marchi <[email protected]> wrote on 23.06.2015 19:02:03:

Quoted 6 lines · On Tue, Jun 23, 2015 at 1:45 PM, <[email protected]> wrote:
Quoted 3 lines

Hello,

Christian Ruppert/ALi_GVA/ALi wrote on 10.06.2015 17:05:16:

[...]

Quoted 1 line

The result is not very encouraging: Out of five (identical) designware

i2c

Quoted 1 line
Quoted 1 line

controllers we have on my test SOC, the first one initialises properly

but

Quoted 5 lines
Quoted 2 lines

the second one gets stuck in the famous irq loop right away when the module is enabled in i2c_dw_init. The system never gets around to try

Are you using the pci or platform driver? I noticed yesterday the pci version is failing here with a NULL pointer dereference.

The test was performed with the platform driver (instantiated through device tree).
I just re-checked and the ultimate problem which hangs/kills the system in my case is the IRQ loop.
I haven't observed any NULL pointer dereferences on the road.

Greetings,
Christian

maintainer
#11 lore raw
Quoted 15 lines · On Wed, Jun 24, 2015 at 09:36:43AM +0200…

Dear Lucas,

Lucas De Marchi <[email protected]> wrote on 23.06.2015 19:02:03:

Quoted 6 lines · On Tue, Jun 23, 2015 at 1:45 PM, <christian.ruppert-Yycd8EPnGM5BDgjK7y7TUQ@pub…
Quoted 3 lines

Hello,

Christian Ruppert/ALi_GVA/ALi wrote on 10.06.2015 17:05:16:

[...]

Quoted 1 line

The result is not very encouraging: Out of five (identical) designware

i2c

Quoted 1 line
Quoted 1 line

controllers we have on my test SOC, the first one initialises properly

but

Quoted 3 lines
Quoted 2 lines

the second one gets stuck in the famous irq loop right away when the module is enabled in i2c_dw_init. The system never gets around to try

Quoted 8 lines
Quoted 2 lines

Are you using the pci or platform driver? I noticed yesterday the pci version is failing here with a NULL pointer dereference.

The test was performed with the platform driver (instantiated through device tree).
I just re-checked and the ultimate problem which hangs/kills the system in my case is the IRQ loop.
I haven't observed any NULL pointer dereferences on the road.

Thanks Christian for testing.

Since the patch causes problems on your hardware, I don't think it is good idea to merge it.

#12 lore raw
Quoted 26 lines · Mika Westerberg

On Wed, Jun 24, 2015 at 09:36:43AM +0200, [email protected] wrot e:

Quoted 24 lines

Dear Lucas,

Lucas De Marchi <[email protected]> wrote on 23.06.2015 19:02:03:

Quoted 7 lines · On Tue, Jun 23, 2015 at 1:45 PM, <[email protected]> wrote:
Quoted 3 lines

Hello,

Christian Ruppert/ALi_GVA/ALi wrote on 10.06.2015 17:05:16:

[...]

Quoted 2 lines

The result is not very encouraging: Out of five (identical) designware

i2c

Quoted 2 lines
Quoted 2 lines

controllers we have on my test SOC, the first one initialises properly

but

Quoted 5 lines
Quoted 2 lines

the second one gets stuck in the famous irq loop right away when the module is enabled in i2c_dw_init. The system never gets around to try

Are you using the pci or platform driver? I noticed yesterday the pci version is failing here with a NULL pointer dereference.

The test was performed with the platform driver (instantiated through device tree).
I just re-checked and the ultimate problem which hangs/kills the system in

Quoted 7 lines
Quoted 2 lines

my case is the IRQ loop.
I haven't observed any NULL pointer dereferences on the road.

Thanks Christian for testing.

Since the patch causes problems on your hardware, I don't think it is good idea to merge it.

Yeah, but it would be bad to ignore the problem as well. The way it is now kills any possibility of using DW controller for reading sensors like gyroscope, accelerometer, barometer that have higher sampling rate etc. I'll try to come up with a new patch but since I can't reproduce the problem here it'd be good to know if there's any means for me to test. What do you think that could be done? Maybe putting the controller to sleep only in case of errors?

thanks

Signature · 1 line
Lucas De Marchi
#13 lore raw
Quoted 7 lines · Lucas

Yeah, but it would be bad to ignore the problem as well. The way it is now kills any possibility of using DW controller for reading sensors like gyroscope, accelerometer, barometer that have higher sampling rate etc. I'll try to come up with a new patch but since I can't reproduce the problem here it'd be good to know if there's any means for me to test. What do you think that could be done? Maybe putting the controller to sleep only in case of errors?

Instead of disabling the adapter after each transfer, I wonder if it is enough if we just mask all interrupts? That should also prevent the interrupt loop Christian is seeing on his hardware.

#14 lore raw
In reply to De Marchi, Lucas

Dear Lucas,

"De Marchi, Lucas" <[email protected]> wrote on 24.06.2015 14:56:19:

Quoted 2 lines · Mika Westerberg
Quoted 1 line

On Wed, Jun 24, 2015 at 09:36:43AM +0200,

[email protected] wrot

Quoted 4 lines
Quoted 4 lines

e:

Quoted 3 lines

Dear Lucas,

Lucas De Marchi <[email protected]> wrote on 23.06.2015

19:02:03:

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

On Tue, Jun 23, 2015 at 1:45 PM, <[email protected]>

Quoted 13 lines · wrote:
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

Hello,

Christian Ruppert/ALi_GVA/ALi wrote on 10.06.2015 17:05:16:

[...]

Quoted 1 line

The result is not very encouraging: Out of five (identical)

designware

Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line

i2c

Quoted 1 line
Quoted 1 line

controllers we have on my test SOC, the first one

initialises properly

Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line

but

Quoted 1 line
Quoted 1 line

the second one gets stuck in the famous irq loop right away when

the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

module is enabled in i2c_dw_init. The system never gets around

to try

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Are you using the pci or platform driver? I noticed yesterday the

pci

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

version is failing here with a NULL pointer dereference.

The test was performed with the platform driver (instantiated

through

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

device tree).
I just re-checked and the ultimate problem which hangs/kills

thesystem in

Quoted 11 lines
Quoted 8 lines
Quoted 3 lines

my case is the IRQ loop.
I haven't observed any NULL pointer dereferences on the road.

Thanks Christian for testing.

Since the patch causes problems on your hardware, I don't think it is good idea to merge it.

Yeah, but it would be bad to ignore the problem as well. The way it is

now

Quoted 2 lines

kills any possibility of using DW controller for reading sensors like gyroscope, accelerometer, barometer that have higher sampling rate etc.

I'll

Quoted 1 line

try to come up with a new patch but since I can't reproduce the problem

here

Quoted 1 line

it'd be good to know if there's any means for me to test.

I'll analyse the problem a bit further and send you a description (sda and scl state at enable time) as soon as I can put my hands on an oscilloscope one evening.

Greetings,
Christian

maintainer
#15 lore raw
In reply to [email protected]

drivers/i2c/busses/i2c-designware-platdrv.c static int dw_i2c_resume(struct device *dev) · line 323

Quoted 6 lines · On Mon, Jun 08, 2015 at 02:50:28PM -0300…
drivers/i2c/busses/i2c-designware-platdrv.c +1 -1
@@ -320,7 +320,7 @@ static int dw_i2c_resume(struct device *dev)
 	clk_prepare_enable(i_dev->clk);
 
 	if (!i_dev->pm_runtime_disabled)
-		i2c_dw_init(i_dev);
+		i2c_dw_enable(i_dev);

This will not work if the device power gets removed (for example being put to D3cold) as it looses context.

#16 lore raw

Hi Mika,

Quoted 10 lines · Mika Westerberg

drivers/i2c/busses/i2c-designware-platdrv.c static int dw_i2c_resume(struct device *dev) · line 323

Quoted 6 lines · On Mon, Jun 08, 2015 at 02:50:28PM -0300…
drivers/i2c/busses/i2c-designware-platdrv.c +1 -1
@@ -320,7 +320,7 @@ static int dw_i2c_resume(struct device *dev)
      clk_prepare_enable(i_dev->clk);
 
      if (!i_dev->pm_runtime_disabled)
-             i2c_dw_init(i_dev);
+             i2c_dw_enable(i_dev);

This will not work if the device power gets removed (for example being put to D3cold) as it looses context.

Do you mean we should keep the i2c_dw_init() here?

Signature · 1 line
Lucas De Marchi
maintainer
#17 lore raw
Quoted 8 lines · Lucas De Marchi

Hi Mika,

Quoted 4 lines · Mika Westerberg
Quoted 3 lines · On Mon, Jun 08, 2015 at 02:50:28PM -0300, [email protected] wrote:
drivers/i2c/busses/i2c-designware-platdrv.c +0 -0
@@ -320,7 +320,7 @@ static int dw_i2c_resume(struct device *dev)
      clk_prepare_enable(i_dev->clk);
 
Quoted 8 lines
Quoted 6 lines

drivers/i2c/busses/i2c-designware-platdrv.c static int dw_i2c_resume(struct device *dev) · line 323

Quoted 3 lines
drivers/i2c/busses/i2c-designware-platdrv.c +1 -1
      if (!i_dev->pm_runtime_disabled)
-             i2c_dw_init(i_dev);
+             i2c_dw_enable(i_dev);

This will not work if the device power gets removed (for example being put to D3cold) as it looses context.

Do you mean we should keep the i2c_dw_init() here?

Yes, that's safer if the controller power gets removed.