All of lore.kernel.org
 help / color / mirror / Atom feed
* [RESEND PATCH v2] usb: xhci-mtk: fix AHB bus hang up caused by roothubs polling
@ 2016-01-08  1:28 ` Chunfeng Yun
  0 siblings, 0 replies; 8+ messages in thread
From: Chunfeng Yun @ 2016-01-08  1:28 UTC (permalink / raw)
  To: Mathias Nyman
  Cc: Matthias Brugger, Felipe Balbi, Chunfeng Yun, linux-kernel,
	linux-arm-kernel, linux-usb, linux-mediatek, Daniel Kurtz,
	Sergei Shtylyov, Greg Kroah-Hartman

when ip fails to enter sleep mode, register access protection will
be disabled, at the same time if all clocks are disabled, access
register will hang up AHB bus.
the common case causes ip sleep failure is that after all ports
enter U3 but before ip enters sleep mode, a port receives a resume
signal('K'). this will happens when such as clicks mouse to try to
do remote-wakeup to stop system enter suspend.
so stop polling root hubs to avoid access xHCI register on bus
suspend, and restart it when bus resumes.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
 drivers/usb/host/xhci-mtk.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index c9ab6a4..9532f5a 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -696,9 +696,24 @@ static int xhci_mtk_remove(struct platform_device *dev)
 }
 
 #ifdef CONFIG_PM_SLEEP
+/*
+ * if ip sleep fails, and all clocks are disabled, access register will hang
+ * AHB bus, so stop polling roothubs to avoid regs access on bus suspend.
+ * and no need to check whether ip sleep failed or not; this will cause SPM
+ * to wake up system immediately after system suspend complete if ip sleep
+ * fails, it is what we wanted.
+ */
 static int xhci_mtk_suspend(struct device *dev)
 {
 	struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev);
+	struct usb_hcd *hcd = mtk->hcd;
+	struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+
+	xhci_dbg(xhci, "%s: stop port polling\n", __func__);
+	clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);
+	del_timer_sync(&hcd->rh_timer);
+	clear_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags);
+	del_timer_sync(&xhci->shared_hcd->rh_timer);
 
 	xhci_mtk_host_disable(mtk);
 	xhci_mtk_phy_power_off(mtk);
@@ -710,11 +725,19 @@ static int xhci_mtk_suspend(struct device *dev)
 static int xhci_mtk_resume(struct device *dev)
 {
 	struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev);
+	struct usb_hcd *hcd = mtk->hcd;
+	struct xhci_hcd *xhci = hcd_to_xhci(hcd);
 
 	usb_wakeup_disable(mtk);
 	xhci_mtk_clks_enable(mtk);
 	xhci_mtk_phy_power_on(mtk);
 	xhci_mtk_host_enable(mtk);
+
+	xhci_dbg(xhci, "%s: restart port polling\n", __func__);
+	set_bit(HCD_FLAG_POLL_RH, &hcd->flags);
+	usb_hcd_poll_rh_status(hcd);
+	set_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags);
+	usb_hcd_poll_rh_status(xhci->shared_hcd);
 	return 0;
 }
 
-- 
1.8.1.1.dirty

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

* [RESEND PATCH v2] usb: xhci-mtk: fix AHB bus hang up caused by roothubs polling
@ 2016-01-08  1:28 ` Chunfeng Yun
  0 siblings, 0 replies; 8+ messages in thread
From: Chunfeng Yun @ 2016-01-08  1:28 UTC (permalink / raw)
  To: Mathias Nyman
  Cc: Matthias Brugger, Felipe Balbi, Chunfeng Yun, linux-kernel,
	linux-arm-kernel, linux-usb, linux-mediatek, Daniel Kurtz,
	Sergei Shtylyov, Greg Kroah-Hartman

when ip fails to enter sleep mode, register access protection will
be disabled, at the same time if all clocks are disabled, access
register will hang up AHB bus.
the common case causes ip sleep failure is that after all ports
enter U3 but before ip enters sleep mode, a port receives a resume
signal('K'). this will happens when such as clicks mouse to try to
do remote-wakeup to stop system enter suspend.
so stop polling root hubs to avoid access xHCI register on bus
suspend, and restart it when bus resumes.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
 drivers/usb/host/xhci-mtk.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index c9ab6a4..9532f5a 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -696,9 +696,24 @@ static int xhci_mtk_remove(struct platform_device *dev)
 }
 
 #ifdef CONFIG_PM_SLEEP
+/*
+ * if ip sleep fails, and all clocks are disabled, access register will hang
+ * AHB bus, so stop polling roothubs to avoid regs access on bus suspend.
+ * and no need to check whether ip sleep failed or not; this will cause SPM
+ * to wake up system immediately after system suspend complete if ip sleep
+ * fails, it is what we wanted.
+ */
 static int xhci_mtk_suspend(struct device *dev)
 {
 	struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev);
+	struct usb_hcd *hcd = mtk->hcd;
+	struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+
+	xhci_dbg(xhci, "%s: stop port polling\n", __func__);
+	clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);
+	del_timer_sync(&hcd->rh_timer);
+	clear_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags);
+	del_timer_sync(&xhci->shared_hcd->rh_timer);
 
 	xhci_mtk_host_disable(mtk);
 	xhci_mtk_phy_power_off(mtk);
@@ -710,11 +725,19 @@ static int xhci_mtk_suspend(struct device *dev)
 static int xhci_mtk_resume(struct device *dev)
 {
 	struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev);
+	struct usb_hcd *hcd = mtk->hcd;
+	struct xhci_hcd *xhci = hcd_to_xhci(hcd);
 
 	usb_wakeup_disable(mtk);
 	xhci_mtk_clks_enable(mtk);
 	xhci_mtk_phy_power_on(mtk);
 	xhci_mtk_host_enable(mtk);
+
+	xhci_dbg(xhci, "%s: restart port polling\n", __func__);
+	set_bit(HCD_FLAG_POLL_RH, &hcd->flags);
+	usb_hcd_poll_rh_status(hcd);
+	set_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags);
+	usb_hcd_poll_rh_status(xhci->shared_hcd);
 	return 0;
 }
 
-- 
1.8.1.1.dirty

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

* [RESEND PATCH v2] usb: xhci-mtk: fix AHB bus hang up caused by roothubs polling
@ 2016-01-08  1:28 ` Chunfeng Yun
  0 siblings, 0 replies; 8+ messages in thread
From: Chunfeng Yun @ 2016-01-08  1:28 UTC (permalink / raw)
  To: linux-arm-kernel

when ip fails to enter sleep mode, register access protection will
be disabled, at the same time if all clocks are disabled, access
register will hang up AHB bus.
the common case causes ip sleep failure is that after all ports
enter U3 but before ip enters sleep mode, a port receives a resume
signal('K'). this will happens when such as clicks mouse to try to
do remote-wakeup to stop system enter suspend.
so stop polling root hubs to avoid access xHCI register on bus
suspend, and restart it when bus resumes.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
 drivers/usb/host/xhci-mtk.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index c9ab6a4..9532f5a 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -696,9 +696,24 @@ static int xhci_mtk_remove(struct platform_device *dev)
 }
 
 #ifdef CONFIG_PM_SLEEP
+/*
+ * if ip sleep fails, and all clocks are disabled, access register will hang
+ * AHB bus, so stop polling roothubs to avoid regs access on bus suspend.
+ * and no need to check whether ip sleep failed or not; this will cause SPM
+ * to wake up system immediately after system suspend complete if ip sleep
+ * fails, it is what we wanted.
+ */
 static int xhci_mtk_suspend(struct device *dev)
 {
 	struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev);
+	struct usb_hcd *hcd = mtk->hcd;
+	struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+
+	xhci_dbg(xhci, "%s: stop port polling\n", __func__);
+	clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);
+	del_timer_sync(&hcd->rh_timer);
+	clear_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags);
+	del_timer_sync(&xhci->shared_hcd->rh_timer);
 
 	xhci_mtk_host_disable(mtk);
 	xhci_mtk_phy_power_off(mtk);
@@ -710,11 +725,19 @@ static int xhci_mtk_suspend(struct device *dev)
 static int xhci_mtk_resume(struct device *dev)
 {
 	struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev);
+	struct usb_hcd *hcd = mtk->hcd;
+	struct xhci_hcd *xhci = hcd_to_xhci(hcd);
 
 	usb_wakeup_disable(mtk);
 	xhci_mtk_clks_enable(mtk);
 	xhci_mtk_phy_power_on(mtk);
 	xhci_mtk_host_enable(mtk);
+
+	xhci_dbg(xhci, "%s: restart port polling\n", __func__);
+	set_bit(HCD_FLAG_POLL_RH, &hcd->flags);
+	usb_hcd_poll_rh_status(hcd);
+	set_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags);
+	usb_hcd_poll_rh_status(xhci->shared_hcd);
 	return 0;
 }
 
-- 
1.8.1.1.dirty

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

* Re: [RESEND PATCH v2] usb: xhci-mtk: fix AHB bus hang up caused by roothubs polling
  2016-01-08  1:28 ` Chunfeng Yun
@ 2016-01-11 14:01   ` Mathias Nyman
  -1 siblings, 0 replies; 8+ messages in thread
From: Mathias Nyman @ 2016-01-11 14:01 UTC (permalink / raw)
  To: Chunfeng Yun, Mathias Nyman
  Cc: Matthias Brugger, Felipe Balbi, linux-kernel, linux-arm-kernel,
	linux-usb, linux-mediatek, Daniel Kurtz, Sergei Shtylyov,
	Greg Kroah-Hartman

On 08.01.2016 03:28, Chunfeng Yun wrote:
> when ip fails to enter sleep mode, register access protection will
> be disabled, at the same time if all clocks are disabled, access
> register will hang up AHB bus.
> the common case causes ip sleep failure is that after all ports
> enter U3 but before ip enters sleep mode, a port receives a resume
> signal('K'). this will happens when such as clicks mouse to try to
> do remote-wakeup to stop system enter suspend.
> so stop polling root hubs to avoid access xHCI register on bus
> suspend, and restart it when bus resumes.
>
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> ---
>   drivers/usb/host/xhci-mtk.c | 23 +++++++++++++++++++++++

The xhci Mediatek (xhci-mtk etc) support is in usb-next and should be available first time
in 4.5-rc1 kernel.

I'll forward fixes for it once 4.5-rc1 is out, they should end up in final 4.5

-Mathias

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

* [RESEND PATCH v2] usb: xhci-mtk: fix AHB bus hang up caused by roothubs polling
@ 2016-01-11 14:01   ` Mathias Nyman
  0 siblings, 0 replies; 8+ messages in thread
From: Mathias Nyman @ 2016-01-11 14:01 UTC (permalink / raw)
  To: linux-arm-kernel

On 08.01.2016 03:28, Chunfeng Yun wrote:
> when ip fails to enter sleep mode, register access protection will
> be disabled, at the same time if all clocks are disabled, access
> register will hang up AHB bus.
> the common case causes ip sleep failure is that after all ports
> enter U3 but before ip enters sleep mode, a port receives a resume
> signal('K'). this will happens when such as clicks mouse to try to
> do remote-wakeup to stop system enter suspend.
> so stop polling root hubs to avoid access xHCI register on bus
> suspend, and restart it when bus resumes.
>
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> ---
>   drivers/usb/host/xhci-mtk.c | 23 +++++++++++++++++++++++

The xhci Mediatek (xhci-mtk etc) support is in usb-next and should be available first time
in 4.5-rc1 kernel.

I'll forward fixes for it once 4.5-rc1 is out, they should end up in final 4.5

-Mathias

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

* Re: [RESEND PATCH v2] usb: xhci-mtk: fix AHB bus hang up caused by roothubs polling
  2016-01-11 14:01   ` Mathias Nyman
  (?)
@ 2016-01-12  1:48     ` chunfeng yun
  -1 siblings, 0 replies; 8+ messages in thread
From: chunfeng yun @ 2016-01-12  1:48 UTC (permalink / raw)
  To: Mathias Nyman
  Cc: Mathias Nyman, Matthias Brugger, Felipe Balbi, linux-kernel,
	linux-arm-kernel, linux-usb, linux-mediatek, Daniel Kurtz,
	Sergei Shtylyov, Greg Kroah-Hartman

Hi,
On Mon, 2016-01-11 at 16:01 +0200, Mathias Nyman wrote:
> On 08.01.2016 03:28, Chunfeng Yun wrote:
> > when ip fails to enter sleep mode, register access protection will
> > be disabled, at the same time if all clocks are disabled, access
> > register will hang up AHB bus.
> > the common case causes ip sleep failure is that after all ports
> > enter U3 but before ip enters sleep mode, a port receives a resume
> > signal('K'). this will happens when such as clicks mouse to try to
> > do remote-wakeup to stop system enter suspend.
> > so stop polling root hubs to avoid access xHCI register on bus
> > suspend, and restart it when bus resumes.
> >
> > Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> > ---
> >   drivers/usb/host/xhci-mtk.c | 23 +++++++++++++++++++++++
> 
> The xhci Mediatek (xhci-mtk etc) support is in usb-next and should be available first time
> in 4.5-rc1 kernel.
> 
> I'll forward fixes for it once 4.5-rc1 is out, they should end up in final 4.5
> 
Thank you!

> -Mathias
> 

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

* Re: [RESEND PATCH v2] usb: xhci-mtk: fix AHB bus hang up caused by roothubs polling
@ 2016-01-12  1:48     ` chunfeng yun
  0 siblings, 0 replies; 8+ messages in thread
From: chunfeng yun @ 2016-01-12  1:48 UTC (permalink / raw)
  To: Mathias Nyman
  Cc: Mathias Nyman, Matthias Brugger, Felipe Balbi, linux-kernel,
	linux-arm-kernel, linux-usb, linux-mediatek, Daniel Kurtz,
	Sergei Shtylyov, Greg Kroah-Hartman

Hi,
On Mon, 2016-01-11 at 16:01 +0200, Mathias Nyman wrote:
> On 08.01.2016 03:28, Chunfeng Yun wrote:
> > when ip fails to enter sleep mode, register access protection will
> > be disabled, at the same time if all clocks are disabled, access
> > register will hang up AHB bus.
> > the common case causes ip sleep failure is that after all ports
> > enter U3 but before ip enters sleep mode, a port receives a resume
> > signal('K'). this will happens when such as clicks mouse to try to
> > do remote-wakeup to stop system enter suspend.
> > so stop polling root hubs to avoid access xHCI register on bus
> > suspend, and restart it when bus resumes.
> >
> > Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> > ---
> >   drivers/usb/host/xhci-mtk.c | 23 +++++++++++++++++++++++
> 
> The xhci Mediatek (xhci-mtk etc) support is in usb-next and should be available first time
> in 4.5-rc1 kernel.
> 
> I'll forward fixes for it once 4.5-rc1 is out, they should end up in final 4.5
> 
Thank you!

> -Mathias
> 

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

* [RESEND PATCH v2] usb: xhci-mtk: fix AHB bus hang up caused by roothubs polling
@ 2016-01-12  1:48     ` chunfeng yun
  0 siblings, 0 replies; 8+ messages in thread
From: chunfeng yun @ 2016-01-12  1:48 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,
On Mon, 2016-01-11 at 16:01 +0200, Mathias Nyman wrote:
> On 08.01.2016 03:28, Chunfeng Yun wrote:
> > when ip fails to enter sleep mode, register access protection will
> > be disabled, at the same time if all clocks are disabled, access
> > register will hang up AHB bus.
> > the common case causes ip sleep failure is that after all ports
> > enter U3 but before ip enters sleep mode, a port receives a resume
> > signal('K'). this will happens when such as clicks mouse to try to
> > do remote-wakeup to stop system enter suspend.
> > so stop polling root hubs to avoid access xHCI register on bus
> > suspend, and restart it when bus resumes.
> >
> > Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> > ---
> >   drivers/usb/host/xhci-mtk.c | 23 +++++++++++++++++++++++
> 
> The xhci Mediatek (xhci-mtk etc) support is in usb-next and should be available first time
> in 4.5-rc1 kernel.
> 
> I'll forward fixes for it once 4.5-rc1 is out, they should end up in final 4.5
> 
Thank you!

> -Mathias
> 

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

end of thread, other threads:[~2016-01-12  1:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-08  1:28 [RESEND PATCH v2] usb: xhci-mtk: fix AHB bus hang up caused by roothubs polling Chunfeng Yun
2016-01-08  1:28 ` Chunfeng Yun
2016-01-08  1:28 ` Chunfeng Yun
2016-01-11 14:01 ` Mathias Nyman
2016-01-11 14:01   ` Mathias Nyman
2016-01-12  1:48   ` chunfeng yun
2016-01-12  1:48     ` chunfeng yun
2016-01-12  1:48     ` chunfeng yun

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.