From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756353AbbICOK3 (ORCPT ); Thu, 3 Sep 2015 10:10:29 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:56289 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754622AbbICOK1 (ORCPT ); Thu, 3 Sep 2015 10:10:27 -0400 Subject: Re: [PATCH v4 9/9] usb: dwc3: core: don't break during suspend/resume while we're dual-role To: Sergei Shtylyov , References: <1441203864-15786-1-git-send-email-rogerq@ti.com> <1441203864-15786-10-git-send-email-rogerq@ti.com> <55E7303D.8080904@cogentembedded.com> <55E852BC.9000502@ti.com> <55E853BC.5060708@cogentembedded.com> CC: , , , , , , From: Roger Quadros Message-ID: <55E854CB.5080900@ti.com> Date: Thu, 3 Sep 2015 17:10:19 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55E853BC.5060708@cogentembedded.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/09/15 17:05, Sergei Shtylyov wrote: > Hello. > > On 09/03/2015 05:01 PM, Roger Quadros wrote: > >>>> We can't rely just on dr_mode to decide if we're in host or gadget >>>> mode when we're configured as otg/dual-role. So while dr_mode is >>>> OTG, we find out from the otg state machine if we're in host >>>> or gadget mode and take the necessary actions during suspend/resume. >>>> >>>> Also make sure that we disable OTG irq and events during system suspend >>>> so that we don't lockup the system during system suspend/resume. >>>> >>>> Signed-off-by: Roger Quadros >>>> --- >>>> drivers/usb/dwc3/core.c | 27 +++++++++------------------ >>>> 1 file changed, 9 insertions(+), 18 deletions(-) >>>> >>>> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c >>>> index 654aebf..25891e3 100644 >>>> --- a/drivers/usb/dwc3/core.c >>>> +++ b/drivers/usb/dwc3/core.c >>>> @@ -1455,18 +1455,15 @@ static int dwc3_suspend(struct device *dev) >>>> dwc->octl = dwc3_readl(dwc->regs, DWC3_OCTL); >>>> dwc->oevt = dwc3_readl(dwc->regs, DWC3_OEVT); >>>> dwc->oevten = dwc3_readl(dwc->regs, DWC3_OEVTEN); >>>> + dwc3_writel(dwc->regs, DWC3_OEVTEN, 0); >>>> + disable_irq(dwc->otg_irq); >>>> } >>>> >>>> - switch (dwc->dr_mode) { >>>> - case USB_DR_MODE_PERIPHERAL: >>>> - case USB_DR_MODE_OTG: >>>> + if (dwc->dr_mode == USB_DR_MODE_PERIPHERAL || >>>> + ((dwc->dr_mode == USB_DR_MODE_OTG) && (dwc->fsm->protocol == PROTO_GADGET))) >>> >>> Hm, you're not very consistent about your parens. :-) >> >> You're right. Should be >> >> if ((dwc->dr_mode == USB_DR_MODE_PERIPHERAL) || >> ((dwc->dr_mode == USB_DR_MODE_OTG) && (dwc->fsm->protocol == PROTO_GADGET))) > > Parens around == are useless, I'd prefer if you deleted them. But if you'd like to keep them, let it be so. :-) OK, how about this then? if (dwc->dr_mode == USB_DR_MODE_PERIPHERAL || (dwc->dr_mode == USB_DR_MODE_OTG && dwc->fsm->protocol == PROTO_GADGET)) cheers, -roger