Linux-USB Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2] USB:ohci:fix ohci interruption problem
@ 2021-04-09  7:47 Longfang Liu
  2021-04-09 15:07 ` Alan Stern
  2021-04-10 22:01 ` kernel test robot
  0 siblings, 2 replies; 4+ messages in thread
From: Longfang Liu @ 2021-04-09  7:47 UTC (permalink / raw)
  To: gregkh, mathias.nyman, stern, liudongdong3
  Cc: linux-usb, linux-kernel, liulongfang, kong.kongxinwei, yisen.zhuang

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.

Signed-off-by: Longfang Liu <liulongfang@huawei.com>
---

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(-)

diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
index 1547aa6..c5844a3 100644
--- a/drivers/usb/core/hcd-pci.c
+++ b/drivers/usb/core/hcd-pci.c
@@ -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,
-- 
2.8.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] USB:ohci:fix ohci interruption problem
  2021-04-09  7:47 [PATCH v2] USB:ohci:fix ohci interruption problem Longfang Liu
@ 2021-04-09 15:07 ` Alan Stern
  2021-04-12  1:14   ` liulongfang
  2021-04-10 22:01 ` kernel test robot
  1 sibling, 1 reply; 4+ messages in thread
From: Alan Stern @ 2021-04-09 15:07 UTC (permalink / raw)
  To: Longfang Liu
  Cc: gregkh, mathias.nyman, liudongdong3, linux-usb, linux-kernel,
	kong.kongxinwei, yisen.zhuang

On Fri, Apr 09, 2021 at 03:47:02PM +0800, Longfang Liu wrote:
> 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.
> 
> Signed-off-by: Longfang Liu <liulongfang@huawei.com>
> ---
> 
> 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

> 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(-)
> 
> diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
> index 1547aa6..c5844a3 100644
> --- a/drivers/usb/core/hcd-pci.c
> +++ b/drivers/usb/core/hcd-pci.c
> @@ -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,
> -- 
> 2.8.1
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] USB:ohci:fix ohci interruption problem
  2021-04-09  7:47 [PATCH v2] USB:ohci:fix ohci interruption problem Longfang Liu
  2021-04-09 15:07 ` Alan Stern
@ 2021-04-10 22:01 ` kernel test robot
  1 sibling, 0 replies; 4+ messages in thread
From: kernel test robot @ 2021-04-10 22:01 UTC (permalink / raw)
  To: Longfang Liu, gregkh, mathias.nyman, stern, liudongdong3
  Cc: kbuild-all, linux-usb, linux-kernel, liulongfang,
	kong.kongxinwei, yisen.zhuang


[-- Attachment #1: Type: text/plain, Size: 2341 bytes --]

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
Reported-by: kernel test robot <lkp@intel.com>

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@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 34271 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] USB:ohci:fix ohci interruption problem
  2021-04-09 15:07 ` Alan Stern
@ 2021-04-12  1:14   ` liulongfang
  0 siblings, 0 replies; 4+ messages in thread
From: liulongfang @ 2021-04-12  1:14 UTC (permalink / raw)
  To: Alan Stern
  Cc: gregkh, mathias.nyman, liudongdong3, linux-usb, linux-kernel,
	kong.kongxinwei, yisen.zhuang

On 2021/4/9 23:07, Alan Stern wrote:
> On Fri, Apr 09, 2021 at 03:47:02PM +0800, Longfang Liu wrote:
>> 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.
>>
>> Signed-off-by: Longfang Liu <liulongfang@huawei.com>
>> ---
>>
>> 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
> 

Ok! I need to analyze the PCI device sleep and wake process to see
why it will not be called.
Thanks,
Longfang.
>> 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(-)
>>
>> diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
>> index 1547aa6..c5844a3 100644
>> --- a/drivers/usb/core/hcd-pci.c
>> +++ b/drivers/usb/core/hcd-pci.c
>> @@ -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,
>> -- 
>> 2.8.1
>>
> .
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-09  7:47 [PATCH v2] USB:ohci:fix ohci interruption problem Longfang Liu
2021-04-09 15:07 ` Alan Stern
2021-04-12  1:14   ` liulongfang
2021-04-10 22:01 ` kernel test robot

Linux-USB Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-usb/0 linux-usb/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-usb linux-usb/ https://lore.kernel.org/linux-usb \
		linux-usb@vger.kernel.org
	public-inbox-index linux-usb

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-usb


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git