All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chunfeng Yun <chunfeng.yun@mediatek.com>
To: Mathias Nyman <mathias.nyman@intel.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>,
	Felipe Balbi <balbi@ti.com>,
	Chunfeng Yun <chunfeng.yun@mediatek.com>,
	<linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-usb@vger.kernel.org>, <linux-mediatek@lists.infradead.org>,
	Daniel Kurtz <djkurtz@chromium.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: [PATCH] usb: xhci-mtk: fixup mouse wakeup failure during system suspend
Date: Thu, 21 Apr 2016 10:04:53 +0800	[thread overview]
Message-ID: <1461204293-18243-1-git-send-email-chunfeng.yun@mediatek.com> (raw)

Click mouse after xhci suspend completion but before system suspend
completion, system will not be waken up by mouse if the duration of
them is larger than 20ms which is the device UFP's resume signaling
lasted. Another reason is that the SPM is not enabled before system
suspend compeltion, this causes SPM also not notice the resume signal.
So in order to reduce the duration less than 20ms, make use of
syscore's suspend/resume interface.
In fact it is a work around solution which only reduces the
probability of failure, because we can't ensure that the duration from
syscore's suspend completion to SPM working is always less than 20ms.

Because the syscore runs on irq disabled context, and xhci's
suspend/resume calls some sleeping functions, enable local irq
and then disable it during suspend/resume. This may be not a problem,
since only boot CPU is runing.

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

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index 79959f1..8277f02 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -28,6 +28,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/regmap.h>
 #include <linux/regulator/consumer.h>
+#include <linux/syscore_ops.h>
 
 #include "xhci.h"
 #include "xhci-mtk.h"
@@ -490,6 +491,8 @@ static int xhci_mtk_setup(struct usb_hcd *hcd)
 	return xhci_gen_setup(hcd, xhci_mtk_quirks);
 }
 
+static struct device *xhci_mtk_syscore_dev;
+
 static int xhci_mtk_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -512,6 +515,7 @@ static int xhci_mtk_probe(struct platform_device *pdev)
 	if (!mtk)
 		return -ENOMEM;
 
+	xhci_mtk_syscore_dev = dev;
 	mtk->dev = dev;
 	mtk->vbus = devm_regulator_get(dev, "vbus");
 	if (IS_ERR(mtk->vbus)) {
@@ -740,6 +744,29 @@ static int __maybe_unused xhci_mtk_resume(struct device *dev)
 	return 0;
 }
 
+static int xhci_mtk_syscore_suspend(void)
+{
+	local_irq_enable();
+	xhci_mtk_suspend(xhci_mtk_syscore_dev);
+	local_irq_disable();
+
+	return 0;
+}
+
+static void xhci_mtk_syscore_resume(void)
+{
+	local_irq_enable();
+	xhci_mtk_resume(xhci_mtk_syscore_dev);
+	local_irq_disable();
+
+	return;
+}
+
+static struct syscore_ops xhci_mtk_syscore_ops = {
+	.suspend = xhci_mtk_syscore_suspend,
+	.resume = xhci_mtk_syscore_resume,
+};
+
 static const struct dev_pm_ops xhci_mtk_pm_ops = {
 	SET_SYSTEM_SLEEP_PM_OPS(xhci_mtk_suspend, xhci_mtk_resume)
 };
@@ -758,7 +785,7 @@ static struct platform_driver mtk_xhci_driver = {
 	.remove	= xhci_mtk_remove,
 	.driver	= {
 		.name = "xhci-mtk",
-		.pm = DEV_PM_OPS,
+		/*.pm = DEV_PM_OPS,*/
 		.of_match_table = of_match_ptr(mtk_xhci_of_match),
 	},
 };
@@ -766,6 +793,7 @@ MODULE_ALIAS("platform:xhci-mtk");
 
 static int __init xhci_mtk_init(void)
 {
+	register_syscore_ops(&xhci_mtk_syscore_ops);
 	xhci_init_driver(&xhci_mtk_hc_driver, &xhci_mtk_overrides);
 	return platform_driver_register(&mtk_xhci_driver);
 }
@@ -774,6 +802,7 @@ module_init(xhci_mtk_init);
 static void __exit xhci_mtk_exit(void)
 {
 	platform_driver_unregister(&mtk_xhci_driver);
+	unregister_syscore_ops(&xhci_mtk_syscore_ops);
 }
 module_exit(xhci_mtk_exit);
 
-- 
1.7.9.5

WARNING: multiple messages have this Message-ID (diff)
From: Chunfeng Yun <chunfeng.yun@mediatek.com>
To: Mathias Nyman <mathias.nyman@intel.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>,
	Felipe Balbi <balbi@ti.com>,
	Chunfeng Yun <chunfeng.yun@mediatek.com>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-usb@vger.kernel.org,
	linux-mediatek@lists.infradead.org,
	Daniel Kurtz <djkurtz@chromium.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: [PATCH] usb: xhci-mtk: fixup mouse wakeup failure during system suspend
Date: Thu, 21 Apr 2016 10:04:53 +0800	[thread overview]
Message-ID: <1461204293-18243-1-git-send-email-chunfeng.yun@mediatek.com> (raw)

Click mouse after xhci suspend completion but before system suspend
completion, system will not be waken up by mouse if the duration of
them is larger than 20ms which is the device UFP's resume signaling
lasted. Another reason is that the SPM is not enabled before system
suspend compeltion, this causes SPM also not notice the resume signal.
So in order to reduce the duration less than 20ms, make use of
syscore's suspend/resume interface.
In fact it is a work around solution which only reduces the
probability of failure, because we can't ensure that the duration from
syscore's suspend completion to SPM working is always less than 20ms.

Because the syscore runs on irq disabled context, and xhci's
suspend/resume calls some sleeping functions, enable local irq
and then disable it during suspend/resume. This may be not a problem,
since only boot CPU is runing.

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

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index 79959f1..8277f02 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -28,6 +28,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/regmap.h>
 #include <linux/regulator/consumer.h>
+#include <linux/syscore_ops.h>
 
 #include "xhci.h"
 #include "xhci-mtk.h"
@@ -490,6 +491,8 @@ static int xhci_mtk_setup(struct usb_hcd *hcd)
 	return xhci_gen_setup(hcd, xhci_mtk_quirks);
 }
 
+static struct device *xhci_mtk_syscore_dev;
+
 static int xhci_mtk_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -512,6 +515,7 @@ static int xhci_mtk_probe(struct platform_device *pdev)
 	if (!mtk)
 		return -ENOMEM;
 
+	xhci_mtk_syscore_dev = dev;
 	mtk->dev = dev;
 	mtk->vbus = devm_regulator_get(dev, "vbus");
 	if (IS_ERR(mtk->vbus)) {
@@ -740,6 +744,29 @@ static int __maybe_unused xhci_mtk_resume(struct device *dev)
 	return 0;
 }
 
+static int xhci_mtk_syscore_suspend(void)
+{
+	local_irq_enable();
+	xhci_mtk_suspend(xhci_mtk_syscore_dev);
+	local_irq_disable();
+
+	return 0;
+}
+
+static void xhci_mtk_syscore_resume(void)
+{
+	local_irq_enable();
+	xhci_mtk_resume(xhci_mtk_syscore_dev);
+	local_irq_disable();
+
+	return;
+}
+
+static struct syscore_ops xhci_mtk_syscore_ops = {
+	.suspend = xhci_mtk_syscore_suspend,
+	.resume = xhci_mtk_syscore_resume,
+};
+
 static const struct dev_pm_ops xhci_mtk_pm_ops = {
 	SET_SYSTEM_SLEEP_PM_OPS(xhci_mtk_suspend, xhci_mtk_resume)
 };
@@ -758,7 +785,7 @@ static struct platform_driver mtk_xhci_driver = {
 	.remove	= xhci_mtk_remove,
 	.driver	= {
 		.name = "xhci-mtk",
-		.pm = DEV_PM_OPS,
+		/*.pm = DEV_PM_OPS,*/
 		.of_match_table = of_match_ptr(mtk_xhci_of_match),
 	},
 };
@@ -766,6 +793,7 @@ MODULE_ALIAS("platform:xhci-mtk");
 
 static int __init xhci_mtk_init(void)
 {
+	register_syscore_ops(&xhci_mtk_syscore_ops);
 	xhci_init_driver(&xhci_mtk_hc_driver, &xhci_mtk_overrides);
 	return platform_driver_register(&mtk_xhci_driver);
 }
@@ -774,6 +802,7 @@ module_init(xhci_mtk_init);
 static void __exit xhci_mtk_exit(void)
 {
 	platform_driver_unregister(&mtk_xhci_driver);
+	unregister_syscore_ops(&xhci_mtk_syscore_ops);
 }
 module_exit(xhci_mtk_exit);
 
-- 
1.7.9.5

WARNING: multiple messages have this Message-ID (diff)
From: chunfeng.yun@mediatek.com (Chunfeng Yun)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] usb: xhci-mtk: fixup mouse wakeup failure during system suspend
Date: Thu, 21 Apr 2016 10:04:53 +0800	[thread overview]
Message-ID: <1461204293-18243-1-git-send-email-chunfeng.yun@mediatek.com> (raw)

Click mouse after xhci suspend completion but before system suspend
completion, system will not be waken up by mouse if the duration of
them is larger than 20ms which is the device UFP's resume signaling
lasted. Another reason is that the SPM is not enabled before system
suspend compeltion, this causes SPM also not notice the resume signal.
So in order to reduce the duration less than 20ms, make use of
syscore's suspend/resume interface.
In fact it is a work around solution which only reduces the
probability of failure, because we can't ensure that the duration from
syscore's suspend completion to SPM working is always less than 20ms.

Because the syscore runs on irq disabled context, and xhci's
suspend/resume calls some sleeping functions, enable local irq
and then disable it during suspend/resume. This may be not a problem,
since only boot CPU is runing.

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

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index 79959f1..8277f02 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -28,6 +28,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/regmap.h>
 #include <linux/regulator/consumer.h>
+#include <linux/syscore_ops.h>
 
 #include "xhci.h"
 #include "xhci-mtk.h"
@@ -490,6 +491,8 @@ static int xhci_mtk_setup(struct usb_hcd *hcd)
 	return xhci_gen_setup(hcd, xhci_mtk_quirks);
 }
 
+static struct device *xhci_mtk_syscore_dev;
+
 static int xhci_mtk_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -512,6 +515,7 @@ static int xhci_mtk_probe(struct platform_device *pdev)
 	if (!mtk)
 		return -ENOMEM;
 
+	xhci_mtk_syscore_dev = dev;
 	mtk->dev = dev;
 	mtk->vbus = devm_regulator_get(dev, "vbus");
 	if (IS_ERR(mtk->vbus)) {
@@ -740,6 +744,29 @@ static int __maybe_unused xhci_mtk_resume(struct device *dev)
 	return 0;
 }
 
+static int xhci_mtk_syscore_suspend(void)
+{
+	local_irq_enable();
+	xhci_mtk_suspend(xhci_mtk_syscore_dev);
+	local_irq_disable();
+
+	return 0;
+}
+
+static void xhci_mtk_syscore_resume(void)
+{
+	local_irq_enable();
+	xhci_mtk_resume(xhci_mtk_syscore_dev);
+	local_irq_disable();
+
+	return;
+}
+
+static struct syscore_ops xhci_mtk_syscore_ops = {
+	.suspend = xhci_mtk_syscore_suspend,
+	.resume = xhci_mtk_syscore_resume,
+};
+
 static const struct dev_pm_ops xhci_mtk_pm_ops = {
 	SET_SYSTEM_SLEEP_PM_OPS(xhci_mtk_suspend, xhci_mtk_resume)
 };
@@ -758,7 +785,7 @@ static struct platform_driver mtk_xhci_driver = {
 	.remove	= xhci_mtk_remove,
 	.driver	= {
 		.name = "xhci-mtk",
-		.pm = DEV_PM_OPS,
+		/*.pm = DEV_PM_OPS,*/
 		.of_match_table = of_match_ptr(mtk_xhci_of_match),
 	},
 };
@@ -766,6 +793,7 @@ MODULE_ALIAS("platform:xhci-mtk");
 
 static int __init xhci_mtk_init(void)
 {
+	register_syscore_ops(&xhci_mtk_syscore_ops);
 	xhci_init_driver(&xhci_mtk_hc_driver, &xhci_mtk_overrides);
 	return platform_driver_register(&mtk_xhci_driver);
 }
@@ -774,6 +802,7 @@ module_init(xhci_mtk_init);
 static void __exit xhci_mtk_exit(void)
 {
 	platform_driver_unregister(&mtk_xhci_driver);
+	unregister_syscore_ops(&xhci_mtk_syscore_ops);
 }
 module_exit(xhci_mtk_exit);
 
-- 
1.7.9.5

             reply	other threads:[~2016-04-21  2:05 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-21  2:04 Chunfeng Yun [this message]
2016-04-21  2:04 ` [PATCH] usb: xhci-mtk: fixup mouse wakeup failure during system suspend Chunfeng Yun
2016-04-21  2:04 ` Chunfeng Yun
2016-05-03  7:44 ` chunfeng yun
2016-05-03  7:44   ` chunfeng yun
2016-05-03  7:44   ` chunfeng yun
2016-05-03  7:51   ` Felipe Balbi
2016-05-03  7:51     ` Felipe Balbi
2016-05-03  9:09     ` chunfeng yun
2016-05-03  9:09       ` chunfeng yun
2016-05-03  9:09       ` chunfeng yun
2016-05-03  9:33       ` Felipe Balbi
2016-05-03  9:33         ` Felipe Balbi
2016-05-03  9:33         ` Felipe Balbi
2016-05-04  1:21         ` chunfeng yun
2016-05-04  1:21           ` chunfeng yun
2016-05-04  1:21           ` chunfeng yun
2016-05-04  8:03           ` Felipe Balbi
2016-05-04  8:03             ` Felipe Balbi
2016-05-04 10:54             ` chunfeng yun
2016-05-04 10:54               ` chunfeng yun
2016-05-04 10:54               ` chunfeng yun
2016-05-04 11:56               ` Felipe Balbi
2016-05-04 11:56                 ` Felipe Balbi
2016-05-17  2:00                 ` chunfeng yun
2016-05-17  2:00                   ` chunfeng yun
2016-05-17  2:00                   ` chunfeng yun

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=1461204293-18243-1-git-send-email-chunfeng.yun@mediatek.com \
    --to=chunfeng.yun@mediatek.com \
    --cc=balbi@ti.com \
    --cc=djkurtz@chromium.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=matthias.bgg@gmail.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.