From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752509AbcHIJUH (ORCPT ); Tue, 9 Aug 2016 05:20:07 -0400 Received: from mga14.intel.com ([192.55.52.115]:53337 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752019AbcHIJUF (ORCPT ); Tue, 9 Aug 2016 05:20:05 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,494,1464678000"; d="asc'?scan'208";a="746213870" From: Felipe Balbi To: robert.foss@collabora.com, mathias.nyman@intel.com, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Julius Werner , Andrew Bresticker Cc: Robert Foss Subject: Re: [PACTH v3 1/2] usb: xhci: plat: Enable runtime PM In-Reply-To: <1470689307-18070-2-git-send-email-robert.foss@collabora.com> References: <1470689307-18070-1-git-send-email-robert.foss@collabora.com> <1470689307-18070-2-git-send-email-robert.foss@collabora.com> User-Agent: Notmuch/0.22.1+63~g994277e (https://notmuchmail.org) Emacs/25.1.1 (x86_64-pc-linux-gnu) Date: Tue, 09 Aug 2016 12:19:58 +0300 Message-ID: <87k2fqb8ox.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, robert.foss@collabora.com writes: > From: Andrew Bresticker > > Enable runtime PM for the xhci-plat device so that the parent device > may implement runtime PM. > > Signed-off-by: Andrew Bresticker > Tested-by: Robert Foss > Signed-off-by: Robert Foss > --- > drivers/usb/host/xhci-plat.c | 24 ++++++++++++++++++++++-- > 1 file changed, 22 insertions(+), 2 deletions(-) > > diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c > index ed56bf9..4f39d4e 100644 > --- a/drivers/usb/host/xhci-plat.c > +++ b/drivers/usb/host/xhci-plat.c > @@ -246,6 +246,9 @@ static int xhci_plat_probe(struct platform_device *pd= ev) > if (ret) > goto dealloc_usb2_hcd; >=20=20 > + pm_runtime_set_active(&pdev->dev); > + pm_runtime_enable(&pdev->dev); > + > return 0; >=20=20 >=20=20 > @@ -274,6 +277,8 @@ static int xhci_plat_remove(struct platform_device *d= ev) > struct xhci_hcd *xhci =3D hcd_to_xhci(hcd); > struct clk *clk =3D xhci->clk; >=20=20 > + pm_runtime_disable(&dev->dev); > + > usb_remove_hcd(xhci->shared_hcd); > usb_phy_shutdown(hcd->usb_phy); >=20=20 > @@ -292,7 +297,11 @@ static int xhci_plat_suspend(struct device *dev) > { > struct usb_hcd *hcd =3D dev_get_drvdata(dev); > struct xhci_hcd *xhci =3D hcd_to_xhci(hcd); > + int ret; >=20=20 > + ret =3D pm_runtime_get_sync(dev); > + if (ret < 0) > + return ret; you're leaving unbalanced PM usage_counter here. If pm_runtime_get*() fails, you still have to decrement usage_counter. > /* > * xhci_suspend() needs `do_wakeup` to know whether host is allowed > * to do wakeup during suspend. Since xhci_plat_suspend is currently > @@ -301,15 +310,26 @@ static int xhci_plat_suspend(struct device *dev) > * reconsider this when xhci_plat_suspend enlarges its scope, e.g., > * also applies to runtime suspend. > */ > - return xhci_suspend(xhci, device_may_wakeup(dev)); > + ret =3D xhci_suspend(xhci, device_may_wakeup(dev)); > + pm_runtime_put(dev); > + > + return ret; > } >=20=20 > static int xhci_plat_resume(struct device *dev) > { > struct usb_hcd *hcd =3D dev_get_drvdata(dev); > struct xhci_hcd *xhci =3D hcd_to_xhci(hcd); > + int ret; > + > + ret =3D pm_runtime_get_sync(dev); > + if (ret < 0) > + return ret; ditto =2D-=20 balbi --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXqaA+AAoJEIaOsuA1yqRElGsQAJLRvHsGKKQ6IHuCe7U3T2YD gCAR12rbEnLcPDQ05uoOn/vu32mTWesTjs4ATlmBaTRaPla/Q6HDfFOJ4/rdPrUR 2HQgAlYDWyjhhE6GYpmSPrCzsmuJWmrxhgW6B3Spjw8oJEuLhq23AiHrurNRT/KV seMB/kdz8jkeEylxV16JhLFR6pqinceja7Yk5VU+AHJLmkHTG4ZWUrpKMSX+kHhx 9UJuTYC5W2pFvhVN5FM5oFVX6Zws7ZtR9lYXvElvZ6JGUxQn0SKRWKLanEMriSIt oLAfRZSOHFoGdq0Uff168peO0AO6/LHQeL1zBBEVanVqVQYtrEhJaBCTILRTbTjq gNJ5sJ0/Fxx+2jIoFJf9UdmfZEQ3PKJmZcXHKe5+JkDsQPCb3R47cPtgGCvidc1V aFLJrD97WJWe4nk8psTMnSTn/IAVOw2XWpNCWEyQ9YPiTlW8KIqDZjAvBMpadnuR d3QE5ShaKpBlzKf+i2L10ec/CzIaqmtrAp1VglqE3J3YswMbx0MxlZRD3LLgsszb fyWtXGoS0KElbeFzkoTJz8XbbxgfWZGUtnKjOoIvMt+0uBv1rqKWNEcEyiwKBQD8 NoAJeFLNkvzH9EJmOStt0oWjWuGBDCCe8IZkmtlo5d/rkZgoe4IEMyz0wSSMrmXY Pb6hrXYcnWnoxlK4Smrz =Qk2s -----END PGP SIGNATURE----- --=-=-=--