Skip to contentSkip to conversation

USB:ohci:fix ohci interruption problem

PATCH In review Longfang Liu 3 participants 4 messages Apr 9, 2021 – Apr 12, 2021 USB

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 USB:ohci:fix ohci interruption problem

The operating method of the system entering S4 sleep mode:
echo reboot > /sys/power/disk
echo disk > /sys/power/state

When OHCI enters the S4 sleep state, check the log and find that the USB sleep process will call check_root_hub_suspend() and ohci_bus_suspend() instead ohci_suspend() and ohci_bus_suspend(), which will cause the OHCI interrupt to not be closed.

At this time, if just one device interrupt is reported. the driver will not process and close this device interrupt. It will cause the entire system to be stuck during sleep, causing the device to fail to respond.

When the abnormal interruption reaches 100,000 times, the system will forcibly close the interruption and make the device unusable.

Because the root cause of the problem is that ohci_suspend is not called to perform normal interrupt shutdown operations when the system enters S4 sleep mode.

Therefore, our solution is to specify freeze interface in this mode to perform normal suspend_common() operations, and call ohci_suspend() after check_root_hub_suspend() is executed through the suspend_common() operation.

---

Changes in V2:
- Modify comment and patch version information.

Changes in V1:
- Call suspend_common by adding the hcd_pci_freeze function turn off the interrupt instead of adding a shutdown operation in ohci_bus_suspend to turn off the interrupt.

 drivers/usb/core/hcd-pci.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/usb/core/hcd-pci.c +6 -1
index 1547aa6..c5844a3 100644
@@ -509,6 +509,11 @@ static int resume_common(struct device *dev, int event)
 
 #ifdef	CONFIG_PM_SLEEP
 
+static int hcd_pci_freeze(struct device *dev)
+{
+	return suspend_common(dev, device_may_wakeup(dev));
+}
+
 static int hcd_pci_suspend(struct device *dev)
 {
 	return suspend_common(dev, device_may_wakeup(dev));
@@ -605,7 +610,7 @@ const struct dev_pm_ops usb_hcd_pci_pm_ops = {
 	.suspend_noirq	= hcd_pci_suspend_noirq,
 	.resume_noirq	= hcd_pci_resume_noirq,
 	.resume		= hcd_pci_resume,
-	.freeze		= check_root_hub_suspended,
+	.freeze		= hcd_pci_freeze,
 	.freeze_noirq	= check_root_hub_suspended,
 	.thaw_noirq	= NULL,
 	.thaw		= NULL,
Signature · 1 line
2.8.1
#1 lore raw
Quoted 26 lines · Longfang Liu

The operating method of the system entering S4 sleep mode:
echo reboot > /sys/power/disk
echo disk > /sys/power/state

When OHCI enters the S4 sleep state, check the log and find that the USB sleep process will call check_root_hub_suspend() and ohci_bus_suspend() instead ohci_suspend() and ohci_bus_suspend(), which will cause the OHCI interrupt to not be closed.

At this time, if just one device interrupt is reported. the driver will not process and close this device interrupt. It will cause the entire system to be stuck during sleep, causing the device to fail to respond.

When the abnormal interruption reaches 100,000 times, the system will forcibly close the interruption and make the device unusable.

Because the root cause of the problem is that ohci_suspend is not called to perform normal interrupt shutdown operations when the system enters S4 sleep mode.

Therefore, our solution is to specify freeze interface in this mode to perform normal suspend_common() operations, and call ohci_suspend() after check_root_hub_suspend() is executed through the suspend_common() operation.

Quoted 5 lines

---

Changes in V2:
- Modify comment and patch version information.

Please, instead of sending the same incorrect patch over and over again, spend some time figuring out what is really going wrong. I have already explained why this patch is not the right thing to do.

You have to determine why the poweroff callback in hcd-pci.c (which points to hcd_pci_suspend) isn't getting called. That's the real explanation for your problem.

Alan Stern

Quoted 36 lines

Changes in V1:
- Call suspend_common by adding the hcd_pci_freeze function turn off the interrupt instead of adding a shutdown operation in ohci_bus_suspend to turn off the interrupt.

 drivers/usb/core/hcd-pci.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/usb/core/hcd-pci.c +6 -1
index 1547aa6..c5844a3 100644
@@ -509,6 +509,11 @@ static int resume_common(struct device *dev, int event)
 
 #ifdef	CONFIG_PM_SLEEP
 
+static int hcd_pci_freeze(struct device *dev)
+{
+	return suspend_common(dev, device_may_wakeup(dev));
+}
+
 static int hcd_pci_suspend(struct device *dev)
 {
 	return suspend_common(dev, device_may_wakeup(dev));
@@ -605,7 +610,7 @@ const struct dev_pm_ops usb_hcd_pci_pm_ops = {
 	.suspend_noirq	= hcd_pci_suspend_noirq,
 	.resume_noirq	= hcd_pci_resume_noirq,
 	.resume		= hcd_pci_resume,
-	.freeze		= check_root_hub_suspended,
+	.freeze		= hcd_pci_freeze,
 	.freeze_noirq	= check_root_hub_suspended,
 	.thaw_noirq	= NULL,
 	.thaw		= NULL,
Signature · 1 line
2.8.1
#2 lore raw
Quoted 37 lines · Alan Stern
Quoted 26 lines · Longfang Liu

The operating method of the system entering S4 sleep mode:
echo reboot > /sys/power/disk
echo disk > /sys/power/state

When OHCI enters the S4 sleep state, check the log and find that the USB sleep process will call check_root_hub_suspend() and ohci_bus_suspend() instead ohci_suspend() and ohci_bus_suspend(), which will cause the OHCI interrupt to not be closed.

At this time, if just one device interrupt is reported. the driver will not process and close this device interrupt. It will cause the entire system to be stuck during sleep, causing the device to fail to respond.

When the abnormal interruption reaches 100,000 times, the system will forcibly close the interruption and make the device unusable.

Because the root cause of the problem is that ohci_suspend is not called to perform normal interrupt shutdown operations when the system enters S4 sleep mode.

Therefore, our solution is to specify freeze interface in this mode to perform normal suspend_common() operations, and call ohci_suspend() after check_root_hub_suspend() is executed through the suspend_common() operation.

Quoted 5 lines

---

Changes in V2:
- Modify comment and patch version information.

Please, instead of sending the same incorrect patch over and over again, spend some time figuring out what is really going wrong. I have already explained why this patch is not the right thing to do.

Quoted 6 lines

You have to determine why the poweroff callback in hcd-pci.c (which points to hcd_pci_suspend) isn't getting called. That's the real explanation for your problem.

Alan Stern

Ok! I need to analyze the PCI device sleep and wake process to see why it will not be called.
Thanks,
Longfang.

Quoted 38 lines
Quoted 36 lines

Changes in V1:
- Call suspend_common by adding the hcd_pci_freeze function turn off the interrupt instead of adding a shutdown operation in ohci_bus_suspend to turn off the interrupt.

 drivers/usb/core/hcd-pci.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/usb/core/hcd-pci.c +6 -1
index 1547aa6..c5844a3 100644
@@ -509,6 +509,11 @@ static int resume_common(struct device *dev, int event)
 
 #ifdef	CONFIG_PM_SLEEP
 
+static int hcd_pci_freeze(struct device *dev)
+{
+	return suspend_common(dev, device_may_wakeup(dev));
+}
+
 static int hcd_pci_suspend(struct device *dev)
 {
 	return suspend_common(dev, device_may_wakeup(dev));
@@ -605,7 +610,7 @@ const struct dev_pm_ops usb_hcd_pci_pm_ops = {
 	.suspend_noirq	= hcd_pci_suspend_noirq,
 	.resume_noirq	= hcd_pci_resume_noirq,
 	.resume		= hcd_pci_resume,
-	.freeze		= check_root_hub_suspended,
+	.freeze		= hcd_pci_freeze,
 	.freeze_noirq	= check_root_hub_suspended,
 	.thaw_noirq	= NULL,
 	.thaw		= NULL,
Signature · 1 line
2.8.1

.

#3 lore raw
In reply to Longfang Liu
Thank you for the patch! Yet something to improve:

Hi Longfang,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on usb/usb-testing]
[also build test ERROR on v5.12-rc6 next-20210409]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Longfang-Liu/USB-ohci-fix-ohci-interruption-problem/20210409-155150
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
config: i386-randconfig-a012-20210411 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/fa57a31f84453b32378ba3d1410e7a549b5d397d
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Longfang-Liu/USB-ohci-fix-ohci-interruption-problem/20210409-155150
        git checkout fa57a31f84453b32378ba3d1410e7a549b5d397d
        # save the attached .config to linux build tree
        make W=1 ARCH=i386 

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

>> drivers/usb/core/hcd-pci.c:624:13: error: 'hcd_pci_freeze' undeclared here (not in a function); did you mean 'hcd_pci_resume'?
     624 |  .freeze  = hcd_pci_freeze,
         |             ^~~~~~~~~~~~~~
         |             hcd_pci_resume

vim +624 drivers/usb/core/hcd-pci.c

618
619 const struct dev_pm_ops usb_hcd_pci_pm_ops = {
620 .suspend = hcd_pci_suspend,
621 .suspend_noirq = hcd_pci_suspend_noirq,
622 .resume_noirq = hcd_pci_resume_noirq,
623 .resume = hcd_pci_resume,

 > 624		.freeze		= hcd_pci_freeze,

625 .freeze_noirq = check_root_hub_suspended,
626 .thaw_noirq = NULL,
627 .thaw = NULL,
628 .poweroff = hcd_pci_suspend,
629 .poweroff_noirq = hcd_pci_suspend_noirq,
630 .restore_noirq = hcd_pci_resume_noirq,
631 .restore = hcd_pci_restore,
632 .runtime_suspend = hcd_pci_runtime_suspend,
633 .runtime_resume = hcd_pci_runtime_resume,
634 };
635 EXPORT_SYMBOL_GPL(usb_hcd_pci_pm_ops);
636

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org