From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932614AbcHCRHW (ORCPT ); Wed, 3 Aug 2016 13:07:22 -0400 Received: from mo4-p00-ob.smtp.rzone.de ([81.169.146.161]:21825 "EHLO mo4-p00-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932453AbcHCRHU (ORCPT ); Wed, 3 Aug 2016 13:07:20 -0400 X-RZG-AUTH: :JGIXVUS7cutRB/49FwqZ7WcecEarQROEYabkiUo6mSAGQ+qKID80POaRjQ== X-RZG-CLASS-ID: mo00 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Subject: Re: [Letux-kernel] [PATCH v2] musb: omap2430: do not assume balanced enable()/disable() From: "H. Nikolaus Schaller" In-Reply-To: <1470238731-32358-1-git-send-email-andreas@kemnade.info> Date: Wed, 3 Aug 2016 19:07:09 +0200 Cc: Bin Liu , Greg Kroah-Hartman , Linux USB Mailing List , linux-omap , LKML , Tony Lindgren , Discussions about the Letux Kernel Content-Transfer-Encoding: 7bit Message-Id: References: <1470238731-32358-1-git-send-email-andreas@kemnade.info> To: Andreas Kemnade X-Mailer: Apple Mail (2.3124) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > Am 03.08.2016 um 17:38 schrieb Andreas Kemnade : > > The code assumes that omap2430_musb_enable() and > omap2430_musb_disable() are called in a balanced way. > That fact is broken by the fact that musb_init_controller() calls > musb_platform_disable() to switch from unknown state to off state > on initialisation. > > That means that phy_power_off() is called first so that > phy->power_count gets -1 and the phy is not enabled on phy_power_on(). > So when usb gadget is started the phy is not powered on. > Depending on the phy used that caused various problems. > Besides of causing usb problems, that can also have side effects. > > In the case of using the phy_twl4030, that prevents also charging > the battery via usb (using twl4030_charger) and so makes further > kernel debugging hard. > The problem was seen with 4.7 on an openphoenux gta04. It has a DM3730 > SoC and a TPS65950 companion. phy->power never became 1 s/TPS65950/TPS65950 (twl4030)/ > and so the usb did get powered on. s/did get/did not get/ maybe add: All this prevents detection of cable plugin-events and VBUS measurement and setting OTG_EN before charging is attempted. > > The patch prevents phy_power_off() from being called when > it is already off. > > Signed-off-by: Andreas Kemnade > --- > changes in v2: > improved commit message > > drivers/usb/musb/omap2430.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c > index 0b4cec9..c1a2b7b 100644 > --- a/drivers/usb/musb/omap2430.c > +++ b/drivers/usb/musb/omap2430.c > @@ -413,9 +413,10 @@ static void omap2430_musb_disable(struct musb *musb) > struct device *dev = musb->controller; > struct omap2430_glue *glue = dev_get_drvdata(dev->parent); > > - if (!WARN_ON(!musb->phy)) > - phy_power_off(musb->phy); > - > + if (glue->enabled) { > + if (!WARN_ON(!musb->phy)) > + phy_power_off(musb->phy); > + } > if (glue->status != MUSB_UNKNOWN) > omap_control_usb_set_mode(glue->control_otghs, > USB_MODE_DISCONNECT); > -- > 2.1.4 > > _______________________________________________ > http://projects.goldelico.com/p/gta04-kernel/ > Letux-kernel mailing list > Letux-kernel@openphoenux.org > http://lists.goldelico.com/mailman/listinfo.cgi/letux-kernel