Received: by 10.213.65.68 with SMTP id h4csp180412imn; Fri, 16 Mar 2018 23:34:25 -0700 (PDT) X-Google-Smtp-Source: AG47ELvL9/ADGQFqPic9SxjWURDAl+xU4uJuXMZg5cOlm6SLRUn3YHfjrWqfQBOikRzmjDvgrSPB X-Received: by 2002:a17:902:9349:: with SMTP id g9-v6mr2558103plp.243.1521268465495; Fri, 16 Mar 2018 23:34:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521268465; cv=none; d=google.com; s=arc-20160816; b=qdp6KPV+cl4z7rVsBHPr8OH3KU/WuWa978QZfn2qAQOWSV3/OSHgTm+hpI8mDfDS7o siJrQ41KowcklSJGXTIyxdUYeaWUInmgUDngp8N/twmVfe+yS2aKhTRFt/ZUMvkeSRRs 8X+JFad5qBs2jSXVDxOwXmPs4kJOJ5DDbAJoU4tkyrezO1cp1uLZjG1qGX7/45sP9iXh leaM3gJtBMbLartLsFdtyiSjDrSAmrAGivCfellyw4F84KaosMG27GlDQbTBQTg2zc2W AtFhaUZNk6ynKg9l5Kndmt/BQcOxqDZAhCX3OM4Al69RbqJux9BC1ivw3EywObq/KOK/ Pmbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:references:message-id:date :thread-index:thread-topic:subject:cc:to:from :arc-authentication-results; bh=WvmVWEMWmSWxVUQioQv3ireD8cLzdfGWLtocTD0LNeY=; b=f5mdaSo0kPv/Vs5+NepXkQIL9CjpTfzafJFZScEPCfy+f8f1C8s+fDhqz0Dw2jkIxJ Z4FqgaB9+nWb2wmJTAPhaKBzOEYK/mSht1/xuns0ina47YG+d2/hlvhFyqjzMVbDrEgt siqW9rcjGWLRIr/aZLY30u6AUMguLkLeGdzh7T/ZDl9GUcltlWvVw+Q57ivKP+QgRUh8 jPS3Jb4+qqT09kZ7IlLWbLSvWbOD7Tb4Ib9MfB4wq5JuUFBevAwoaxTN1eEsnq/4rEOM 6AMHuczQGg+uv496Ch1c7x0f8bFQOJVovML3lzXST9jTOq3W7k6H9VhtneDv5gLA/oqL YVyQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 64-v6si7688231ply.528.2018.03.16.23.34.10; Fri, 16 Mar 2018 23:34:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751544AbeCQGdS convert rfc822-to-8bit (ORCPT + 99 others); Sat, 17 Mar 2018 02:33:18 -0400 Received: from smtprelay2.synopsys.com ([198.182.60.111]:48731 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750982AbeCQGdQ (ORCPT ); Sat, 17 Mar 2018 02:33:16 -0400 Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66]) by smtprelay.synopsys.com (Postfix) with ESMTP id B00D310C0EEF; Fri, 16 Mar 2018 23:33:15 -0700 (PDT) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id 98BF83B8D; Fri, 16 Mar 2018 23:33:15 -0700 (PDT) Received: from us01wehtc1.internal.synopsys.com (us01wehtc1.internal.synopsys.com [10.12.239.235]) by mailhost.synopsys.com (Postfix) with ESMTP id 8A9033B8C; Fri, 16 Mar 2018 23:33:15 -0700 (PDT) Received: from AM04WEHTCB.internal.synopsys.com (10.116.16.192) by us01wehtc1.internal.synopsys.com (10.12.239.235) with Microsoft SMTP Server (TLS) id 14.3.361.1; Fri, 16 Mar 2018 23:33:14 -0700 Received: from AM04WEMBXA.internal.synopsys.com ([fe80::79c3:55f2:1f20:5bf4]) by am04wehtcb.internal.synopsys.com ([::1]) with mapi id 14.03.0361.001; Sat, 17 Mar 2018 10:33:12 +0400 From: Minas Harutyunyan To: Felipe Balbi , Minas Harutyunyan , Roger Quadros CC: "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v2] usb: dwc3: Prevent indefinite sleep in _dwc3_set_mode during suspend/resume Thread-Topic: [PATCH v2] usb: dwc3: Prevent indefinite sleep in _dwc3_set_mode during suspend/resume Thread-Index: AQHTt7VttcDOmDIowUqzUI1Hi/JpmA== Date: Sat, 17 Mar 2018 06:33:12 +0000 Message-ID: <410670D7E743164D87FA6160E7907A560113ABBA4B@am04wembxa.internal.synopsys.com> References: <1519730526-22274-1-git-send-email-rogerq@ti.com> <69517684-bd39-e945-0c9e-ccd52b8050d5@ti.com> <87y3isffog.fsf@linux.intel.com> <5ea0ad17-d538-72ec-ed59-004242c4cd26@ti.com> <410670D7E743164D87FA6160E7907A560113ABB478@am04wembxa.internal.synopsys.com> <87zi38438h.fsf@linux.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.116.70.62] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 3/16/2018 4:25 PM, Felipe Balbi wrote: > > Hi, > > Minas Harutyunyan writes: >>>>> On 09/03/18 14:47, Roger Quadros wrote: >>>>>> In the following test we get stuck by sleeping forever in _dwc3_set_mode() >>>>>> after which dual-role switching doesn't work. >>>>>> >>>>>> On dra7-evm's dual-role port, >>>>>> - Load g_zero gadget driver and enumerate to host >>>>>> - suspend to mem >>>>>> - disconnect USB cable to host and connect otg cable with Pen drive in it. >>>>>> - resume system >>>>>> - we sleep indefinitely in _dwc3_set_mode due to. >>>>>> dwc3_gadget_exit()->usb_del_gadget_udc()->udc_stop()-> >>>>>> dwc3_gadget_stop()->wait_event_lock_irq() >>>>>> >>>>>> To fix this instead of waiting indefinitely with wait_event_lock_irq() >>>>>> we use wait_event_interruptible_lock_irq_timeout() and print >>>>>> and error message if there was a timeout. >>>>>> >>>>>> Signed-off-by: Roger Quadros >>>>> >>>>> Thanks for picking this for -next. >>>>> Is it better to have this in v4.16-rc fixes? >>>>> and also stable? v4.12+ >>>> >>>> Well, there was no "Fixes: foobar" or "Cc: stable" lines in the commit >>>> log ;-) >>>> >>>> The best we can do now, is wait for -rc1 and manually send the commit to >>>> stable. >>>> >>> >>> That's fine. Thanks. >>> >> >> Same issue seen in dwc3_gadget_ep_dequeue() function where also used >> wait_event_lock_irq() - as result infinite loop. > > how did this happen? During rmmod dwc3? Or, perhaps, after you unloaded > a gadget driver? > No, not during rmmod's. We using our internal USB testing tool. Test case; ISOC OUT, transfer size N frames. When host starts ISOC OUT traffic then the dwc3 based on "Transfer not ready" event in frame F starts transfers staring from frame F+4 (for bInterval=1) as result 4 requests, which already queued on device side, remain incomplete. Function driver on some timeout trying dequeue these 4 requests (without disabling EP) to complete test. For IN ISOC's these requests completed on MISSED ISOC event, but for ISOC OUT required call dequeue on some timeout. >> Actually to fix this issue I updated condition of wait function >> from: >> !(dep->flags & DWC3_EP_END_TRANSFER_PENDING) >> to: >> !(dep->flags & DWC3_EP_END_TRANSFER_PENDING & DWC3_EP_ENABLED) > > you're not fixing anything. You're, essentially, removing the entire > end transfer pending logic. yes, you are right, but how to overcome this infinite loop? Replace wait_event_lock_irq() by wait_event_interruptible_lock_irq_timeout()? The whole idea of this is that we can > disable the endpoint and wait for the End Transfer interrupt. When you > add a check for the endpoint being enabled, then that code will never > run and, thus, never wait for the End Transfer IRQ. > > If you manage to find a more reliable way of reproducing this, then make > sure to capture dwc3 tracepoints (see the documentation for details) and > let's start trying to figure out what's going on. > > cheers >