From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1947316AbcHRNq2 (ORCPT ); Thu, 18 Aug 2016 09:46:28 -0400 Received: from mga03.intel.com ([134.134.136.65]:4027 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1945912AbcHRNqZ (ORCPT ); Thu, 18 Aug 2016 09:46:25 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,539,1464678000"; d="asc'?scan'208";a="867600661" From: Felipe Balbi To: Baolin Wang Cc: Greg KH , mathias.nyman@intel.com, USB , LKML , Mark Brown Subject: Re: [PATCH 4/4] usb: dwc3: core: Support the dwc3 host suspend/resume In-Reply-To: References: <9cca1b5a0487676a4fa912e957a03642a330c20a.1468571634.git.baolin.wang@linaro.org> <87eg5m5y6l.fsf@linux.intel.com> <87fuq24620.fsf@linux.intel.com> User-Agent: Notmuch/0.22.1+63~g994277e (https://notmuchmail.org) Emacs/25.1.1 (x86_64-pc-linux-gnu) Date: Thu, 18 Aug 2016 16:42:41 +0300 Message-ID: <87a8ga42i6.fsf@linux.intel.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi, Baolin Wang writes: [...] >>>>> diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c >>>>> index 2e960ed..2ec3eff 100644 >>>>> --- a/drivers/usb/dwc3/host.c >>>>> +++ b/drivers/usb/dwc3/host.c >>>>> @@ -17,8 +17,11 @@ >>>>> >>>>> #include >>>>> #include >>>>> +#include >>>>> +#include >>>>> >>>>> #include "core.h" >>>>> +#include "../host/xhci.h" >>>>> >>>>> int dwc3_host_init(struct dwc3 *dwc) >>>>> { >>>>> @@ -91,6 +94,8 @@ int dwc3_host_init(struct dwc3 *dwc) >>>>> memset(&pdata, 0, sizeof(pdata)); >>>>> >>>>> pdata.usb3_lpm_capable =3D dwc->usb3_lpm_capable; >>>>> + /* dwc3 controller need an extraordinary delay when suspending = xhci. */ >>>>> + pdata.usb3_slow_suspend =3D 1; >>>>> >>>>> ret =3D platform_device_add_data(xhci, &pdata, sizeof(pdata)); >>>>> if (ret) { >>>>> @@ -128,3 +133,30 @@ void dwc3_host_exit(struct dwc3 *dwc) >>>>> dev_name(&dwc->xhci->dev)); >>>>> platform_device_unregister(dwc->xhci); >>>>> } >>>>> + >>>>> +int dwc3_host_suspend(struct dwc3 *dwc) >>>>> +{ >>>>> + struct usb_hcd *hcd =3D dev_get_drvdata(&dwc->xhci->dev); >>>>> + struct xhci_hcd *xhci =3D hcd_to_xhci(hcd); >>>>> + int ret, cnt =3D 20; >>>>> + >>>>> +try_again: >>>>> + /* We should wait for xhci bus has been into suspend mode firs= tly. */ >>>>> + ret =3D xhci_suspend(xhci, device_may_wakeup(&dwc->xhci->dev)); >>>>> + if (ret && --cnt > 0) { >>>>> + dev_warn(dwc->dev, "xhci suspend failed %d, try again..= .\n", >>>>> + ret); >>>>> + msleep(200); >>>>> + goto try_again; >>>>> + } >>>>> + >>>>> + return ret; >>>>> +} >>>>> + >>>>> +int dwc3_host_resume(struct dwc3 *dwc) >>>>> +{ >>>>> + struct usb_hcd *hcd =3D dev_get_drvdata(&dwc->xhci->dev); >>>>> + struct xhci_hcd *xhci =3D hcd_to_xhci(hcd); >>>>> + >>>>> + return xhci_resume(xhci, 0); >>>>> +} >>>> >>>> This is wrong. XHCI is a child of dwc3, when dwc3 suspends, >>>> xhci_supend() has already been called. Why isn't it called for you? >>> >>> xhci-plat.c did not set the runtime PM callbacks, how can we issued >>> xhci_supend() by runtime PM from dwc3? >> >> wouldn't it be nicer to just initialize PM runtime callbacks from >> xhci-plat? It just needs to be added and verified, right? > > Yes, you are right. Alan and Peter also suggested me to implement the > runtime PM callbacks for xhci-plat. I am also testing this and I will > send out the patch if it works well. So please ignore this patch. > Thanks for your comments. cool, thanks a lot :-) =2D-=20 balbi --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIcBAEBCAAGBQJXtbtSAAoJEIaOsuA1yqRESeMP+wfn8nvdWRCGB6nPAeN/fG09 u1StU3Ooe230Y9+P6/idntLRC9KbVgvS+CW6uagHAWmw0MfDrUKVHBxO4pbSFdDU h3z0P2xq5NbmUHDfAiK1P0xhI6KuOIHBTxr6SO9n63iTy5kt9YxEzUY2T9cb9Thw 2js4EXxRRQrgCX872zz43l/33PKc2KWAQoccvxbUWNmacvo4/JwYFlbFovjEEBBR dvkhxfkOi6+xjmsmKMaeh4UFY304JolqswTo4zs75/9Ur/dY0+/1TgMYBrelZcn3 S3GxHbV+4ZZYMPs0UHd3MvCfgcLnoDx17H4kMYn1H4ZmCffnTejHbLC4ncgwpP3m i5NpinqMiTn9vBvtMVpssqRtoIHTazh9LvU6rP2lnqVbx1YDs8/H3aA8hgWCneQl Xxv4ujU6QGJZoNRWUIeYHpnrY6JgX7FViT57twGvFeUQB6OG2Qk5dlYnt/HsbN3M eS9yV8CpysYYBwf8NBbdKbfnf/0YviL446l5DSPclxVp/AieY1PbCZND41ag8Cgd JBhQKTHWWQwXsYnYwmpVvJ1yq1dY6/wCC+DjEGOgjSJouzjrEwlQUpil9Hw5UcxW d16ULU4bQwuXOJp2pFQdz25ope1aQlraBYgz9pf4yqTvya5n0kHUs3iWnpG5Rmh2 hVHGUahEI3TKyiFL0Efg =UHUd -----END PGP SIGNATURE----- --=-=-=--