Skip to contentSkip to conversation

i2c: designware: Keep pm_runtime_enable/_disable calls in sync

PATCH Applied Jarkko Nikula 4 participants 10 messages Dec 10, 2015 – Jun 19, 2016

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

PATCH 1/2 i2c: designware: Keep pm_runtime_enable/_disable calls in sync

On an hardware shared I2C bus (certain Intel Baytrail SoC platforms) the runtime PM disable depth keeps increasing over repeated modprobe/rmmod cycle because pm_runtime_disable() is called without checking should it be disabled already because of bus sharing.

This hasn't made any other harm than dev->power.disable_depth keeps increasing but keep it sync by calling pm_runtime_disable() only when runtime PM is not disabled.

---
 drivers/i2c/busses/i2c-designware-platdrv.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/i2c/busses/i2c-designware-platdrv.c +4 -5
index 809579ecb5a4..1308666b054b 100644
@@ -240,12 +240,10 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
 	}
 
 	r = i2c_dw_probe(dev);
-	if (r) {
+	if (r && !dev->pm_runtime_disabled)
 		pm_runtime_disable(&pdev->dev);
-		return r;
-	}
 
-	return 0;
+	return r;
 }
 
 static int dw_i2c_plat_remove(struct platform_device *pdev)
@@ -260,7 +258,8 @@ static int dw_i2c_plat_remove(struct platform_device *pdev)
 
 	pm_runtime_dont_use_autosuspend(&pdev->dev);
 	pm_runtime_put_sync(&pdev->dev);
-	pm_runtime_disable(&pdev->dev);
+	if (!dev->pm_runtime_disabled)
+		pm_runtime_disable(&pdev->dev);
 
 	return 0;
 }
Signature · 1 line
2.6.2
#1 lore raw

PATCH 2/2 i2c: designware: Allow build Baytrail semaphore support when IOSF_MBI=m

I believe i2c-designware-baytrail.c doesn't have strict dependency that Intel SoC IOSF Sideband support must be always built-in in order to be able to compile support for Intel Baytrail I2C bus sharing HW semaphore.

Redefine build dependencies so that CONFIG_IOSF_MBI=y is required only when CONFIG_I2C_DESIGNWARE_PLATFORM is built-in.

---
Hi David. Can you ack/nak this patch as I'm not fully familiar with this HW semaphore can there be problems when IOSF_MBI is built as a module. At least I'm getting similar sensible looking "punit semaphore acquired/held for x ms" debug messages when I modprobe/rmmod i2c_designware_platform independently is the CONFIG_IOSF_MBI=y or =m.

---
 drivers/i2c/busses/Kconfig | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/i2c/busses/Kconfig +3 -1
index 69c46fe13777..76f4d024def0 100644
@@ -490,7 +490,9 @@ config I2C_DESIGNWARE_PCI
 
 config I2C_DESIGNWARE_BAYTRAIL
 	bool "Intel Baytrail I2C semaphore support"
-	depends on I2C_DESIGNWARE_PLATFORM && IOSF_MBI=y && ACPI
+	depends on ACPI
+	depends on (I2C_DESIGNWARE_PLATFORM=m && IOSF_MBI) || \
+		   (I2C_DESIGNWARE_PLATFORM=y && IOSF_MBI=y)
 	help
 	  This driver enables managed host access to the PMIC I2C bus on select
 	  Intel BayTrail platforms using the X-Powers AXP288 PMIC. It allows
Signature · 1 line
2.6.2
#2 lore raw

Re: [PATCH 2/2] i2c: designware: Allow build Baytrail semaphore support when IOSF_MBI=m

Quoted 34 lines · Jarkko Nikula

I believe i2c-designware-baytrail.c doesn't have strict dependency that
Intel SoC IOSF Sideband support must be always built-in in order to be
able to compile support for Intel Baytrail I2C bus sharing HW semaphore.

Redefine build dependencies so that CONFIG_IOSF_MBI=y is required only
when CONFIG_I2C_DESIGNWARE_PLATFORM is built-in.

---
Hi David. Can you ack/nak this patch as I'm not fully familiar with this
HW semaphore can there be problems when IOSF_MBI is built as a module.

At least I'm getting similar sensible looking "punit semaphore acquired/held for x ms" debug messages when I modprobe/rmmod i2c_designware_platform independently is the CONFIG_IOSF_MBI=y or =m.
---
 drivers/i2c/busses/Kconfig | 4 +++-

 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/i2c/busses/Kconfig +0 -0
index 69c46fe13777..76f4d024def0 100644
@@ -490,7 +490,9 @@ config I2C_DESIGNWARE_PCI


 config I2C_DESIGNWARE_BAYTRAIL
  bool "Intel Baytrail I2C semaphore support"

drivers/i2c/busses/Kconfig config I2C_DESIGNWARE_PCI · line 495

Quoted 4 lines
drivers/i2c/busses/Kconfig +3 -1
-	depends on I2C_DESIGNWARE_PLATFORM && IOSF_MBI=y && ACPI
+	depends on ACPI
+	depends on (I2C_DESIGNWARE_PLATFORM=m && IOSF_MBI) || \
+		   (I2C_DESIGNWARE_PLATFORM=y && IOSF_MBI=y)

Would it be more readable in the following way

depends on ACPI
depends on I2C_DESIGNWARE_PLATFORM
depends on IOSF_MBI if I2C_DESIGNWARE_PLATFORM=m depends on IOSF_MBI=y if I2C_DESIGNWARE_PLATFORM=y

Quoted 5 lines

  help
    This driver enables managed host access to the PMIC I2C bus on select
    Intel BayTrail platforms using the X-Powers AXP288 PMIC. It allows

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
#3 lore raw

Re: [PATCH 2/2] i2c: designware: Allow build Baytrail semaphore support when IOSF_MBI=m

Quoted 42 lines · Andy Shevchenko
Quoted 31 lines · Jarkko Nikula

I believe i2c-designware-baytrail.c doesn't have strict dependency that
Intel SoC IOSF Sideband support must be always built-in in order to be
able to compile support for Intel Baytrail I2C bus sharing HW semaphore.

Redefine build dependencies so that CONFIG_IOSF_MBI=y is required only
when CONFIG_I2C_DESIGNWARE_PLATFORM is built-in.

---
Hi David. Can you ack/nak this patch as I'm not fully familiar with this
HW semaphore can there be problems when IOSF_MBI is built as a module.

At least I'm getting similar sensible looking "punit semaphore acquired/held for x ms" debug messages when I modprobe/rmmod i2c_designware_platform independently is the CONFIG_IOSF_MBI=y or =m.

---
  drivers/i2c/busses/Kconfig | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/i2c/busses/Kconfig +0 -0
index 69c46fe13777..76f4d024def0 100644

drivers/i2c/busses/Kconfig config I2C_DESIGNWARE_PCI · line 495

Quoted 7 lines
drivers/i2c/busses/Kconfig +3 -1
@@ -490,7 +490,9 @@ config I2C_DESIGNWARE_PCI
 
  config I2C_DESIGNWARE_BAYTRAIL
  	bool "Intel Baytrail I2C semaphore support"
-	depends on I2C_DESIGNWARE_PLATFORM && IOSF_MBI=y && ACPI
+	depends on ACPI
+	depends on (I2C_DESIGNWARE_PLATFORM=m && IOSF_MBI) || \
+		   (I2C_DESIGNWARE_PLATFORM=y && IOSF_MBI=y)

Would it be more readable in the following way

Quoted 5 lines

depends on ACPI
depends on I2C_DESIGNWARE_PLATFORM
depends on IOSF_MBI if I2C_DESIGNWARE_PLATFORM=m depends on IOSF_MBI=y if I2C_DESIGNWARE_PLATFORM=y

For my eyes it looks a bit more complex but I think it's matter of taste. However, the syntax you are proposing is not supported for "depends on" like it is for "select" statements.

Signature · 1 line
Jarkko
#4 lore raw

Re: [PATCH 2/2] i2c: designware: Allow build Baytrail semaphore support when IOSF_MBI=m

Quoted 43 lines · Jarkko Nikula
Quoted 42 lines · Andy Shevchenko
Quoted 31 lines · Jarkko Nikula

I believe i2c-designware-baytrail.c doesn't have strict dependency that
Intel SoC IOSF Sideband support must be always built-in in order to be
able to compile support for Intel Baytrail I2C bus sharing HW semaphore.

Redefine build dependencies so that CONFIG_IOSF_MBI=y is required only
when CONFIG_I2C_DESIGNWARE_PLATFORM is built-in.

---
Hi David. Can you ack/nak this patch as I'm not fully familiar with this
HW semaphore can there be problems when IOSF_MBI is built as a module.

At least I'm getting similar sensible looking "punit semaphore acquired/held for x ms" debug messages when I modprobe/rmmod i2c_designware_platform independently is the CONFIG_IOSF_MBI=y or =m.

---
 drivers/i2c/busses/Kconfig | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/i2c/busses/Kconfig +0 -0
index 69c46fe13777..76f4d024def0 100644

drivers/i2c/busses/Kconfig config I2C_DESIGNWARE_PCI · line 495

Quoted 7 lines
drivers/i2c/busses/Kconfig +3 -1
@@ -490,7 +490,9 @@ config I2C_DESIGNWARE_PCI
 
 config I2C_DESIGNWARE_BAYTRAIL
 	bool "Intel Baytrail I2C semaphore support"
-	depends on I2C_DESIGNWARE_PLATFORM && IOSF_MBI=y && ACPI
+	depends on ACPI
+	depends on (I2C_DESIGNWARE_PLATFORM=m && IOSF_MBI) || \
+		   (I2C_DESIGNWARE_PLATFORM=y && IOSF_MBI=y)

Would it be more readable in the following way

Quoted 8 lines
Quoted 5 lines

depends on ACPI
depends on I2C_DESIGNWARE_PLATFORM
depends on IOSF_MBI if I2C_DESIGNWARE_PLATFORM=m depends on IOSF_MBI=y if I2C_DESIGNWARE_PLATFORM=y

For my eyes it looks a bit more complex but I think it's matter of taste. However, the syntax you are proposing is not supported for "depends on" like it is for "select" statements.

Any news? David?

#5 lore raw

Re: [PATCH 2/2] i2c: designware: Allow build Baytrail semaphore support when IOSF_MBI=m

In reply to Jarkko Nikula

Hi

Sorry I missed this discussion. I believe the following code in i2c_dw_eval_lock_support() should make it so that it doesn't matter how IOSF_MBI is built:

if (!iosf_mbi_available())

           return -EPROBE_DEFER;

I added this to address i2c_designware probing before iosf_mbi. It worked but I do not recall if IOSF_MBI=m was the problem scenario. If so you can just change it to:

   depends in I2C_DESIGNWARE_PLATFORM && IOSF_MBI

Give me a few days to confirm on my Baytrail device.

David

Quoted 36 lines · Jarkko Nikula

I believe i2c-designware-baytrail.c doesn't have strict dependency that Intel SoC IOSF Sideband support must be always built-in in order to be able to compile support for Intel Baytrail I2C bus sharing HW semaphore.

Redefine build dependencies so that CONFIG_IOSF_MBI=y is required only when CONFIG_I2C_DESIGNWARE_PLATFORM is built-in.

---
Hi David. Can you ack/nak this patch as I'm not fully familiar with this HW semaphore can there be problems when IOSF_MBI is built as a module. At least I'm getting similar sensible looking "punit semaphore acquired/held for x ms" debug messages when I modprobe/rmmod i2c_designware_platform independently is the CONFIG_IOSF_MBI=y or =m.

---
 drivers/i2c/busses/Kconfig | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/i2c/busses/Kconfig +3 -1
index 69c46fe13777..76f4d024def0 100644
@@ -490,7 +490,9 @@ config I2C_DESIGNWARE_PCI
 
 config I2C_DESIGNWARE_BAYTRAIL
 	bool "Intel Baytrail I2C semaphore support"
-	depends on I2C_DESIGNWARE_PLATFORM && IOSF_MBI=y && ACPI
+	depends on ACPI
+	depends on (I2C_DESIGNWARE_PLATFORM=m && IOSF_MBI) || \
+		   (I2C_DESIGNWARE_PLATFORM=y && IOSF_MBI=y)
 	help
 	  This driver enables managed host access to the PMIC I2C bus on select
 	  Intel BayTrail platforms using the X-Powers AXP288 PMIC. It allows
Signature · 1 line
2.6.2
#6 lore raw

Re: [PATCH 2/2] i2c: designware: Allow build Baytrail semaphore support when IOSF_MBI=m

Quoted 9 lines · David E. Box

Hi

Sorry I missed this discussion. I believe the following code in i2c_dw_eval_lock_support() should make it so that it doesn't matter how IOSF_MBI is built:

   if (!iosf_mbi_available())
           return -EPROBE_DEFER;
Quoted 7 lines

I added this to address i2c_designware probing before iosf_mbi. It worked but I do not recall if IOSF_MBI=m was the problem scenario. If so you can just change it to:

   depends in I2C_DESIGNWARE_PLATFORM && IOSF_MBI

Give me a few days to confirm on my Baytrail device.

What is the status here?

Acked-by on v1 2/2
#7 lore raw

Re: [PATCH 2/2] i2c: designware: Allow build Baytrail semaphore support when IOSF_MBI=m

In reply to Jarkko Nikula
Quoted 36 lines · Jarkko Nikula

I believe i2c-designware-baytrail.c doesn't have strict dependency that Intel SoC IOSF Sideband support must be always built-in in order to be able to compile support for Intel Baytrail I2C bus sharing HW semaphore.

Redefine build dependencies so that CONFIG_IOSF_MBI=y is required only when CONFIG_I2C_DESIGNWARE_PLATFORM is built-in.

---
Hi David. Can you ack/nak this patch as I'm not fully familiar with this HW semaphore can there be problems when IOSF_MBI is built as a module. At least I'm getting similar sensible looking "punit semaphore acquired/held for x ms" debug messages when I modprobe/rmmod i2c_designware_platform independently is the CONFIG_IOSF_MBI=y or =m.

---
 drivers/i2c/busses/Kconfig | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/i2c/busses/Kconfig +3 -1
index 69c46fe13777..76f4d024def0 100644
@@ -490,7 +490,9 @@ config I2C_DESIGNWARE_PCI
 
 config I2C_DESIGNWARE_BAYTRAIL
 	bool "Intel Baytrail I2C semaphore support"
-	depends on I2C_DESIGNWARE_PLATFORM && IOSF_MBI=y && ACPI
+	depends on ACPI
+	depends on (I2C_DESIGNWARE_PLATFORM=m && IOSF_MBI) || \
+		   (I2C_DESIGNWARE_PLATFORM=y && IOSF_MBI=y)
 	help
 	  This driver enables managed host access to the PMIC I2C bus on select
 	  Intel BayTrail platforms using the X-Powers AXP288 PMIC. It allows
Signature · 1 line
2.6.2
#8 lore raw

Re: [PATCH 2/2] i2c: designware: Allow build Baytrail semaphore support when IOSF_MBI=m

In reply to Jarkko Nikula
Quoted 8 lines · Jarkko Nikula

I believe i2c-designware-baytrail.c doesn't have strict dependency that Intel SoC IOSF Sideband support must be always built-in in order to be able to compile support for Intel Baytrail I2C bus sharing HW semaphore.

Redefine build dependencies so that CONFIG_IOSF_MBI=y is required only when CONFIG_I2C_DESIGNWARE_PLATFORM is built-in.

Finally applied to for-next, thanks!

Applied
#9 lore raw
In reply to Jarkko Nikula
Quoted 10 lines · Jarkko Nikula

On an hardware shared I2C bus (certain Intel Baytrail SoC platforms) the runtime PM disable depth keeps increasing over repeated modprobe/rmmod cycle because pm_runtime_disable() is called without checking should it be disabled already because of bus sharing.

This hasn't made any other harm than dev->power.disable_depth keeps increasing but keep it sync by calling pm_runtime_disable() only when runtime PM is not disabled.

Applied to for-current, thanks!