All of lore.kernel.org
 help / color / mirror / Atom feed
From: Longfang Liu <liulongfang@huawei.com>
To: <gregkh@linuxfoundation.org>, <mathias.nyman@intel.com>,
	<stern@rowland.harvard.edu>
Cc: <linux-usb@vger.kernel.org>, <yisen.zhuang@huawei.com>,
	<tanxiaofei@huawei.com>, <liudongdong3@huawei.com>,
	<liulongfang@huawei.com>, <linux-kernel@vger.kernel.org>
Subject: [RFC PATCH] USB:ohci:fix ohci interruption problem
Date: Fri, 26 Mar 2021 16:54:56 +0800	[thread overview]
Message-ID: <1616748896-9415-1-git-send-email-liulongfang@huawei.com> (raw)

When OHCI enters the S4 sleep 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.

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. 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.

Since the problem is that the interrupt is not closed, we copied the
interrupt shutdown operation of ohci_suspend() into ohci_bus_suspend()
during the S4 sleep period. We found that this method can solve this
problem.

At present, we hope to be able to call ohci_suspend() directly during
the sleep process of S4. Do you have any suggestions for this
modification?

Signed-off-by: Longfang Liu <liulongfang@huawei.com>
---
 drivers/usb/host/ohci-hub.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c
index 634f3c7..d468cef 100644
--- a/drivers/usb/host/ohci-hub.c
+++ b/drivers/usb/host/ohci-hub.c
@@ -315,6 +315,14 @@ static int ohci_bus_suspend (struct usb_hcd *hcd)
 		del_timer_sync(&ohci->io_watchdog);
 		ohci->prev_frame_no = IO_WATCHDOG_OFF;
 	}
+
+	spin_lock_irqsave(&ohci->lock, flags);
+	ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
+	(void)ohci_readl(ohci, &ohci->regs->intrdisable);
+
+	clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
+	spin_unlock_irqrestore(&ohci->lock, flags);
+
 	return rc;
 }
 
@@ -326,7 +334,10 @@ static int ohci_bus_resume (struct usb_hcd *hcd)
 	if (time_before (jiffies, ohci->next_statechange))
 		msleep(5);
 
-	spin_lock_irq (&ohci->lock);
+	spin_lock_irq(&ohci->lock);
+	set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
+	ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrenable);
+	ohci_readl(ohci, &ohci->regs->intrenable);
 
 	if (unlikely(!HCD_HW_ACCESSIBLE(hcd)))
 		rc = -ESHUTDOWN;
-- 
2.8.1


             reply	other threads:[~2021-03-26  8:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-26  8:54 Longfang Liu [this message]
2021-03-26 15:28 ` [RFC PATCH] USB:ohci:fix ohci interruption problem Alan Stern
2021-03-29  8:38   ` liulongfang
2021-03-29 15:25     ` Alan Stern
2021-03-26 22:08 ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1616748896-9415-1-git-send-email-liulongfang@huawei.com \
    --to=liulongfang@huawei.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=liudongdong3@huawei.com \
    --cc=mathias.nyman@intel.com \
    --cc=stern@rowland.harvard.edu \
    --cc=tanxiaofei@huawei.com \
    --cc=yisen.zhuang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.