From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751673AbbCYVcl (ORCPT ); Wed, 25 Mar 2015 17:32:41 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:55690 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750881AbbCYVci (ORCPT ); Wed, 25 Mar 2015 17:32:38 -0400 Message-ID: <55132965.3090002@ti.com> Date: Thu, 26 Mar 2015 03:02:21 +0530 From: Kishon Vijay Abraham I User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: NeilBrown CC: Tony Lindgren , , , GTA04 owners , NeilBrown , Pavel Machek Subject: Re: [PATCH 1/5] usb: phy: twl4030: make runtime pm more reliable. References: <20150322223307.21765.62974.stgit@notabene.brown> <20150322223523.21765.3199.stgit@notabene.brown> In-Reply-To: <20150322223523.21765.3199.stgit@notabene.brown> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Monday 23 March 2015 04:05 AM, NeilBrown wrote: > From: NeilBrown > > A construct like: > > if (pm_runtime_suspended(twl->dev)) > pm_runtime_get_sync(twl->dev); > > is against the spirit of the runtime_pm interface as it > makes the internal refcounting useless. > > In this case it is also racy, particularly as 'put_autosuspend' > is use to drop a reference. > When that happens a timer is started and the device is > runtime-suspended after the timeout. > If the above code runs in this window, the device will not be > found to be suspended so no pm_runtime reference is taken. > When the timer expires the device will be suspended, which is > against the intention of the code. > > So be more direct is taking and dropping references. > If twl->linkstat is VBUS_VALID or ID_GROUND, then hold a > pm_runtime reference, otherwise don't. > Define "cable_present()" to test for this condition. minor comment below.. > > Tested-by: Tony Lindgren > Signed-off-by: NeilBrown > --- > drivers/phy/phy-twl4030-usb.c | 29 ++++++++++++++++++++--------- > 1 file changed, 20 insertions(+), 9 deletions(-) > > diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c > index 8e87f54671f3..1a244f34b748 100644 > --- a/drivers/phy/phy-twl4030-usb.c > +++ b/drivers/phy/phy-twl4030-usb.c > @@ -144,6 +144,16 @@ > #define PMBR1 0x0D > #define GPIO_USB_4PIN_ULPI_2430C (3 << 0) > > +/* > + * If VBUS is valid or ID is ground, then we know a > + * cable is present and we need to be runtime-enabled > + */ > +static inline bool cable_present(enum omap_musb_vbus_id_status stat) twl4030_cable_present? -Kishon