Skip to contentSkip to conversation

i2c: i801: Fix runtime PM

PATCH In review Jarkko Nikula 5 participants 7 messages Jun 26, 2018 – Sep 1, 2020

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

PATCH 1/2 i2c: i801: Fix runtime PM

Commit 9c8088c7988 ("i2c: i801: Don't restore config registers on runtime PM") nullified the runtime PM suspend/resume callback pointers while keeping the runtime PM enabled. This causes that device stays in D0 power state and sysfs /sys/bus/pci/devices/.../power/runtime_status shows "error" when runtime PM framework attempts to autosuspend the device.

This is due PCI bus runtime PM which checks for driver runtime PM callbacks and returns with -ENOSYS if they are not set. Fix this by having a shared dummy runtime PM callback that returns with success.

Fixes a9c8088c7988 ("i2c: i801: Don't restore config registers on runtime PM")
---
 drivers/i2c/busses/i2c-i801.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-i801.c +14 -1
index aa726607645e..3747484c2669 100644
@@ -1731,7 +1731,20 @@ static int i801_resume(struct device *dev)
 }
 #endif
 
-static SIMPLE_DEV_PM_OPS(i801_pm_ops, i801_suspend, i801_resume);
+static int __maybe_unused i801_runtime_nop(struct device *dev)
+{
+	/*
+	 * PCI core expects runtime PM suspend/resume callbacks return
+	 * successfully before really suspending/resuming the device.
+	 * Have a shared dummy callback that returns with success.
+	 */
+	return 0;
+}
+
+static const struct dev_pm_ops i801_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(i801_suspend, i801_resume)
+	SET_RUNTIME_PM_OPS(i801_runtime_nop, i801_runtime_nop, NULL)
+};
 
 static struct pci_driver i801_driver = {
 	.name		= "i801_smbus",
Signature · 1 line
2.18.0
Tested-by on v1 1/2
#1 lore raw
Quoted 7 lines · Jarkko Nikula

Commit 9c8088c7988 ("i2c: i801: Don't restore config registers on runtime PM") nullified the runtime PM suspend/resume callback pointers while keeping the runtime PM enabled. This causes that device stays in D0 power state and sysfs /sys/bus/pci/devices/.../power/runtime_status shows "error" when runtime PM framework attempts to autosuspend the device.

Quoted 6 lines

This is due PCI bus runtime PM which checks for driver runtime PM callbacks and returns with -ENOSYS if they are not set. Fix this by having a shared dummy runtime PM callback that returns with success.

Fixes a9c8088c7988 ("i2c: i801: Don't restore config registers on runtime PM")

This fixes the issue for me, thanks Jarkko!

#2 lore raw
In reply to Jarkko Nikula

Hi Jarkko,

Quoted 7 lines · Jarkko Nikula

Commit 9c8088c7988 ("i2c: i801: Don't restore config registers on runtime PM") nullified the runtime PM suspend/resume callback pointers while keeping the runtime PM enabled. This causes that device stays in D0 power state and sysfs /sys/bus/pci/devices/.../power/runtime_status shows "error" when runtime PM framework attempts to autosuspend the device.

Quoted 5 lines

This is due PCI bus runtime PM which checks for driver runtime PM callbacks and returns with -ENOSYS if they are not set. Fix this by having a shared dummy runtime PM callback that returns with success.

Fixes a9c8088c7988 ("i2c: i801: Don't restore config registers on runtime PM")

I don't want to sound like I'm trying to decline all responsibility for a regression I caused, but frankly, if just using SIMPLE_DEV_PM_OPS() breaks runtime PM, then it's the PM model which is broken, not the i2c-i801 driver.

I will boldly claim that the PCI bus runtime code is simply wrong in returning -ENOSYS in the absence of runtime PM callbacks, and it should be changed to return 0 instead. Or whoever receives that -ENOSYS should not treat it as an error - whatever makes more sense.

Having to add dummy functions in every PCI driver that doesn't need to do anything special for runtime PM sounds plain stupid. It should be pretty obvious that a whole lot of drivers are going to use SIMPLE_DEV_PM_OPS() because it exists and seems to do what they want, and all of them will be bugged because the PCI core is doing something silly and unexpected.

So please let's fix it at the PCI subsystem core level. Adding Bjorn and the linux-pci list to Cc.

Thanks,

Signature · 2 lines
Jean Delvare
SUSE L3 Support
#3 lore raw

[+cc Rafael, linux-pm, linux-kernel]

Quoted 33 lines · Jean Delvare

Hi Jarkko,

Quoted 7 lines · Jarkko Nikula

Commit 9c8088c7988 ("i2c: i801: Don't restore config registers on runtime PM") nullified the runtime PM suspend/resume callback pointers while keeping the runtime PM enabled. This causes that device stays in D0 power state and sysfs /sys/bus/pci/devices/.../power/runtime_status shows "error" when runtime PM framework attempts to autosuspend the device.

Quoted 5 lines

This is due PCI bus runtime PM which checks for driver runtime PM callbacks and returns with -ENOSYS if they are not set. Fix this by having a shared dummy runtime PM callback that returns with success.

Fixes a9c8088c7988 ("i2c: i801: Don't restore config registers on runtime PM")

I don't want to sound like I'm trying to decline all responsibility for a regression I caused, but frankly, if just using SIMPLE_DEV_PM_OPS() breaks runtime PM, then it's the PM model which is broken, not the i2c-i801 driver.

I will boldly claim that the PCI bus runtime code is simply wrong in returning -ENOSYS in the absence of runtime PM callbacks, and it should be changed to return 0 instead. Or whoever receives that -ENOSYS should not treat it as an error - whatever makes more sense.

Having to add dummy functions in every PCI driver that doesn't need to do anything special for runtime PM sounds plain stupid. It should be pretty obvious that a whole lot of drivers are going to use SIMPLE_DEV_PM_OPS() because it exists and seems to do what they want, and all of them will be bugged because the PCI core is doing something silly and unexpected.

Quoted 2 lines

So please let's fix it at the PCI subsystem core level. Adding Bjorn and the linux-pci list to Cc.

Thanks Jean. What you describe does sound broken. I think the PM guys (cc'd) will have a better idea of how to deal with this.

#4 lore raw

[+cc Vaibhav]

Quoted 36 lines · Bjorn Helgaas

[+cc Rafael, linux-pm, linux-kernel]

Quoted 33 lines · Jean Delvare

Hi Jarkko,

Quoted 7 lines · Jarkko Nikula

Commit 9c8088c7988 ("i2c: i801: Don't restore config registers on runtime PM") nullified the runtime PM suspend/resume callback pointers while keeping the runtime PM enabled. This causes that device stays in D0 power state and sysfs /sys/bus/pci/devices/.../power/runtime_status shows "error" when runtime PM framework attempts to autosuspend the device.

Quoted 5 lines

This is due PCI bus runtime PM which checks for driver runtime PM callbacks and returns with -ENOSYS if they are not set. Fix this by having a shared dummy runtime PM callback that returns with success.

Fixes a9c8088c7988 ("i2c: i801: Don't restore config registers on runtime PM")

I don't want to sound like I'm trying to decline all responsibility for a regression I caused, but frankly, if just using SIMPLE_DEV_PM_OPS() breaks runtime PM, then it's the PM model which is broken, not the i2c-i801 driver.

I will boldly claim that the PCI bus runtime code is simply wrong in returning -ENOSYS in the absence of runtime PM callbacks, and it should be changed to return 0 instead. Or whoever receives that -ENOSYS should not treat it as an error - whatever makes more sense.

Having to add dummy functions in every PCI driver that doesn't need to do anything special for runtime PM sounds plain stupid. It should be pretty obvious that a whole lot of drivers are going to use SIMPLE_DEV_PM_OPS() because it exists and seems to do what they want, and all of them will be bugged because the PCI core is doing something silly and unexpected.

Quoted 5 lines
Quoted 2 lines

So please let's fix it at the PCI subsystem core level. Adding Bjorn and the linux-pci list to Cc.

Thanks Jean. What you describe does sound broken. I think the PM guys (cc'd) will have a better idea of how to deal with this.

Did we ever get anywhere with this? It seems like the thread petered out.

#5 lore raw
Quoted 39 lines · Bjorn Helgaas

[+cc Vaibhav]

Quoted 36 lines · Bjorn Helgaas

[+cc Rafael, linux-pm, linux-kernel]

Quoted 33 lines · Jean Delvare

Hi Jarkko,

Quoted 7 lines · Jarkko Nikula

Commit 9c8088c7988 ("i2c: i801: Don't restore config registers on runtime PM") nullified the runtime PM suspend/resume callback pointers while keeping the runtime PM enabled. This causes that device stays in D0 power state and sysfs /sys/bus/pci/devices/.../power/runtime_status shows "error" when runtime PM framework attempts to autosuspend the device.

Quoted 5 lines

This is due PCI bus runtime PM which checks for driver runtime PM callbacks and returns with -ENOSYS if they are not set. Fix this by having a shared dummy runtime PM callback that returns with success.

Fixes a9c8088c7988 ("i2c: i801: Don't restore config registers on runtime PM")

I don't want to sound like I'm trying to decline all responsibility for a regression I caused, but frankly, if just using SIMPLE_DEV_PM_OPS() breaks runtime PM, then it's the PM model which is broken, not the i2c-i801 driver.

I will boldly claim that the PCI bus runtime code is simply wrong in returning -ENOSYS in the absence of runtime PM callbacks, and it should be changed to return 0 instead. Or whoever receives that -ENOSYS should not treat it as an error - whatever makes more sense.

Having to add dummy functions in every PCI driver that doesn't need to do anything special for runtime PM sounds plain stupid. It should be pretty obvious that a whole lot of drivers are going to use SIMPLE_DEV_PM_OPS() because it exists and seems to do what they want, and all of them will be bugged because the PCI core is doing something silly and unexpected.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

So please let's fix it at the PCI subsystem core level. Adding Bjorn and the linux-pci list to Cc.

Thanks Jean. What you describe does sound broken. I think the PM guys (cc'd) will have a better idea of how to deal with this.

Did we ever get anywhere with this? It seems like the thread petered out.

This does seems worrying. I remember, few days earlier you pointed out a driver i2c-nvidia-gpuc.c. In the code, gpu_i2c_suspend() is an empty-body function. And comment mentioned that empty stub is necessary for runtime_pm to work.

And this driver also uses UNIVERSAL_DEV_PM_OPS.

#6 lore raw
Quoted 46 lines · Vaibhav Gupta
Quoted 45 lines · Bjorn Helgaas

[+cc Vaibhav]

Quoted 41 lines · Bjorn Helgaas

[+cc Rafael, linux-pm, linux-kernel]

Quoted 33 lines · Jean Delvare

Hi Jarkko,

Quoted 7 lines · Jarkko Nikula

Commit 9c8088c7988 ("i2c: i801: Don't restore config registers on runtime PM") nullified the runtime PM suspend/resume callback pointers while keeping the runtime PM enabled. This causes that device stays in D0 power state and sysfs /sys/bus/pci/devices/.../power/runtime_status shows "error" when runtime PM framework attempts to autosuspend the device.

Quoted 5 lines

This is due PCI bus runtime PM which checks for driver runtime PM callbacks and returns with -ENOSYS if they are not set. Fix this by having a shared dummy runtime PM callback that returns with success.

Fixes a9c8088c7988 ("i2c: i801: Don't restore config registers on runtime PM")

I don't want to sound like I'm trying to decline all responsibility for a regression I caused, but frankly, if just using SIMPLE_DEV_PM_OPS() breaks runtime PM, then it's the PM model which is broken, not the i2c-i801 driver.

I will boldly claim that the PCI bus runtime code is simply wrong in returning -ENOSYS in the absence of runtime PM callbacks, and it should be changed to return 0 instead. Or whoever receives that -ENOSYS should not treat it as an error - whatever makes more sense.

Having to add dummy functions in every PCI driver that doesn't need to do anything special for runtime PM sounds plain stupid. It should be pretty obvious that a whole lot of drivers are going to use SIMPLE_DEV_PM_OPS() because it exists and seems to do what they want, and all of them will be bugged because the PCI core is doing something silly and unexpected.

Quoted 2 lines

So please let's fix it at the PCI subsystem core level. Adding Bjorn and the linux-pci list to Cc.

Thanks Jean. What you describe does sound broken. I think the PM guys (cc'd) will have a better idea of how to deal with this.

Quoted 8 lines
Quoted 2 lines

Did we ever get anywhere with this? It seems like the thread petered out.

This does seems worrying. I remember, few days earlier you pointed out a driver i2c-nvidia-gpuc.c. In the code, gpu_i2c_suspend() is an empty-body function. And comment mentioned that empty stub is necessary for runtime_pm to work.

And this driver also uses UNIVERSAL_DEV_PM_OPS.

This was fixed by c5eb1190074c ("PCI / PM: Allow runtime PM without callback functions"). So no need for empty runtime PM callbacks anymore.

Signature · 1 line
Jarkko