Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752195AbcJMHfF (ORCPT ); Thu, 13 Oct 2016 03:35:05 -0400 Received: from mail-yw0-f177.google.com ([209.85.161.177]:32809 "EHLO mail-yw0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750806AbcJMHez (ORCPT ); Thu, 13 Oct 2016 03:34:55 -0400 MIME-Version: 1.0 In-Reply-To: <87r37kviic.fsf@linux.intel.com> References: <87r37kviic.fsf@linux.intel.com> From: Baolin Wang Date: Thu, 13 Oct 2016 15:34:54 +0800 Message-ID: Subject: Re: [PATCH v2] usb: dwc3: gadget: Wait for end transfer complete before free irq To: Felipe Balbi Cc: Greg KH , Mark Brown , USB , LKML Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1711 Lines: 45 Hi, On 13 October 2016 at 15:02, Felipe Balbi wrote: > > Hi, > > Baolin Wang writes: >> @@ -1742,6 +1791,17 @@ static int dwc3_gadget_stop(struct usb_gadget *g) >> dwc->gadget_driver = NULL; >> spin_unlock_irqrestore(&dwc->lock, flags); >> >> + /* >> + * Since the xHCI will share the same interrupt with gadget, thus when >> + * free the gadget irq, it will not shutdown this gadget irq line. Then >> + * the gadget driver can not handle the end transfer command complete >> + * event after free the gadget irq, which will hang the system to crash. >> + * >> + * So we should wait for the end transfer command complete event before >> + * free it to avoid this situation. >> + */ >> + dwc3_wait_command_complete(dwc); > > this doesn't make sense. We have already masked all interrupts before > getting here. We have also, already, disabled all endpoints. No, you just mask the interrupts described in DEVTEN register, and you did not disable the endpoint command complete event. > > I'm thinking this is a bug in configfs interface of Gadget API, not > dwc3. The only reason for this to happen would be if we get to > ->udc_stop() with endpoints still enabled. > > Can you check if that's the case? i.e. can you check if any endpoints > are still enabled when we get here? No, it is not any endpoints are still enabled. Like I said in commit message, we will start end transfer command when disable the endpoint, if the end transfer command complete event comes after we have freed the gadget irq, it will trigger the interrupt line all the time to crash the system. -- Baolin.wang Best Regards