From patchwork Thu Apr 21 02:04:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2h1bmZlbmcgWXVuICjkupHmmKXls7Ap?= X-Patchwork-Id: 8895731 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CCF259F39A for ; Thu, 21 Apr 2016 02:07:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 02592202F2 for ; Thu, 21 Apr 2016 02:07:00 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 192AA202E5 for ; Thu, 21 Apr 2016 02:06:59 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1at3zq-0000jt-Ud; Thu, 21 Apr 2016 02:05:34 +0000 Received: from [210.61.82.183] (helo=mailgw01.mediatek.com) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1at3zm-00081d-EN; Thu, 21 Apr 2016 02:05:32 +0000 Received: from mtkhts07.mediatek.inc [(172.21.101.69)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 2024943096; Thu, 21 Apr 2016 10:04:59 +0800 Received: from mhfsdcap03.gcn.mediatek.inc (10.17.3.153) by mtkhts07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 14.3.266.1; Thu, 21 Apr 2016 10:04:57 +0800 From: Chunfeng Yun To: Mathias Nyman Subject: [PATCH] usb: xhci-mtk: fixup mouse wakeup failure during system suspend Date: Thu, 21 Apr 2016 10:04:53 +0800 Message-ID: <1461204293-18243-1-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160420_190531_506409_4A75B6CC X-CRM114-Status: GOOD ( 14.82 ) X-Spam-Score: -1.1 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Felipe Balbi , Chunfeng Yun , linux-mediatek@lists.infradead.org, Daniel Kurtz , Matthias Brugger , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 #include #include +#include #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);