Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1361662pxf; Fri, 2 Apr 2021 08:27:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmZFe+n0dFA152u+Dvhhri76IzwN0EpKOCYU8393uw+y6DHgt6wqib3PQJ/KwP4+mK4fAZ X-Received: by 2002:aa7:c684:: with SMTP id n4mr15962026edq.141.1617377272466; Fri, 02 Apr 2021 08:27:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617377272; cv=none; d=google.com; s=arc-20160816; b=Yhr2yLlBtvZw8Zvr5AWyg+wQPwUte/gW661ghyjHVhX2DzenlUke1znnlsQ5rjVocm PAfahsGG2GzunOuBRSC1a1wvqZujETLgsTc7PK1B/lsjFNOW0dUJV/atUTchjXv/RHUj MfseIha04CAzacQm/Dh4JbGSCBOBRLgbgfGujwio1VxubEQLMdx7FhA7+akQ1mXj5Kkc jcH3SPW1qzeAZyi/7lToFRvO5BjGZRZ307COhymZsbZMWoErI3w8xx5mAzH8Say0vUN/ 1S7O02Jjx3WI7ST3boN93gxmogtDmIcPbqYmxugnJryxHbhKSrJua4ZA/y9hpubLQQuV 41YA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=8Pw78dsYp0AAs0nWpGmNNu8MFNaOZURXyvSNmUAn23U=; b=nafIufqT9VSci2JWAywPQrBnlbJHsWK1CB2QerHeROXFMFy9Fmp1QwND7BDT3WlYC+ DPB9Uc2d9wvtCNLDt5fyM3E1HJKLjxi9OsVPpRmpyyfnvGz0znUF5wlhYFQEnupI+b5Y Q0QHsskNx3n7XWshuYEEjZCCl49J3LykZ/4ouHWOttou/Io6pXUHHooBDkiZNY69cWFS wlDtj6JKlTAErywfHEsjUkA+LH1ESIBvvoJYcNW5ZSNWUi73bgFkBmIf5kpfZyc4glOa PaCVnbsMp+qInL0jcFKyEFdtGGQ28ULh06lkoLB55yFl5DHKu3l0MrKpy7EwKSMRT7vU laiA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z21si6972672edx.208.2021.04.02.08.27.28; Fri, 02 Apr 2021 08:27:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234981AbhDBP07 (ORCPT + 99 others); Fri, 2 Apr 2021 11:26:59 -0400 Received: from netrider.rowland.org ([192.131.102.5]:39269 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S234723AbhDBP05 (ORCPT ); Fri, 2 Apr 2021 11:26:57 -0400 Received: (qmail 1097185 invoked by uid 1000); 2 Apr 2021 11:26:55 -0400 Date: Fri, 2 Apr 2021 11:26:55 -0400 From: Alan Stern To: Longfang Liu Cc: gregkh@linuxfoundation.org, mathias.nyman@intel.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, kong.kongxinwei@hisilicon.com, yisen.zhuang@huawei.com Subject: Re: [PATCH] USB:ohci:fix ohci interruption problem Message-ID: <20210402152655.GC1095271@rowland.harvard.edu> References: <1617355679-9417-1-git-send-email-liulongfang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1617355679-9417-1-git-send-email-liulongfang@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 02, 2021 at 05:27:59PM +0800, Longfang Liu wrote: > The operating method of the system entering S4 sleep mode: > echo disk > /sys/power/state This discussion is still not right. > When OHCI enters the S4 sleep state, To start with, you should be talking about hibernation (also known as suspend-to-disk), not S4. When the system enters hibernation -- for example, when you write "disk" to /sys/power/state -- the controller may go into S4 or it may go into some other power-saving state. > the USB sleep process will call > check_root_hub_suspend() and ohci_bus_suspend() instead of > ohci_suspend() and ohci_bus_suspend(), this causes the OHCI interrupt > to not be closed. This isn't true. The procedure _does_ call ohci_suspend, through the .poweroff callback in hcd-pci.c. That callback goes to the hcd_pci_suspend routine, which calls suspend_common and then ohci_suspend. However, these calls happen after the kernel image has be written to the storage area on the disk. As a result, any log messages produced during the calls do not get saved, so they don't get reloaded when the system resumes from hibernation, and they aren't present in the log after the system wakes up. That's why they didn't appear in the log you included in an earlier email. The only way to observe them is to use a remote console, such as a network console. In fact, that's pretty much the only way to debug problems that occur during a hibernation transition. > At this time, if just one device interrupt is reported. Since rh_state > has been changed to OHCI_RH_SUSPENDED after ohci_bus_suspend(), the > driver will not process and close this device interrupt. That's not true either. The ohci_irq routine does indeed process interrupts even when rh_state is set to OHCI_RH_SUSPENDED. How else could it handle a device's wakeup request? > It will cause > the entire system to be stuck during sleep, causing the device to > fail to respond. During hibernation, the system is powered off. Obviously the kernel is not capable of handling interrupts at this time. Also, why would a device interrupt be reported at this time? What causes the interrupt request? > 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. No. The freeze interface does not need to power-down the controller. All it needs to do is make sure that no communication between the computer and the attached USB devices takes place, and this is handled by ohci_bus_suspend. Furthermore, it is a mistake for the freeze routine to change anything unless the thaw routine reverses the change. Your patch leaves the thaw callback pointer set to NULL. > After using this solution, it is verified by the stress test of sleep > wake up in S4 mode for a long time that this problem no longer occurs. Something else must be happeneing, something you don't understand. Alan Stern > Signed-off-by: Longfang Liu > --- > 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 >