Received: by 10.213.65.68 with SMTP id h4csp357023imn; Fri, 16 Mar 2018 05:26:36 -0700 (PDT) X-Google-Smtp-Source: AG47ELuiwJO3KJ3HCHFUWKDPCtjJywS8PT84/YLMttpTc9N9HVh1IkMnG6J0nQcTNVnOwbiKtqyo X-Received: by 2002:a17:902:aa8e:: with SMTP id d14-v6mr1959356plr.318.1521203196554; Fri, 16 Mar 2018 05:26:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521203196; cv=none; d=google.com; s=arc-20160816; b=ytSs/zoyDor+nAu7VAG2BJx76wWHyFXT/UOqGhb+7PgrN5eXF4cNnr7OTfriIxcnBn nTE1XmN5u5AgMV1ISqDW3ZLozvbmukFagxwVRf5LwyXKi0rIy9rGw3oqFiZNQNXx1/WO dL6kIdHVessWM7JtB/aH52iVJawO3/GiQvJmhZW9cpKTzfutRhE8w79J0qcn8dfaCGjm LTfGEibq5SH4vUie02tK+v9MG+mrxyoS3rnCK9Keqw2zAr2GkKw1wBI3VkYoGwd2m/Iy 6M8P4xxmuQAYd86AJnNu097Llt4kuqPoUgGhIn6G3hUgMdO7uR5GGpPqUSBK6QWqw3Uz xmow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:arc-authentication-results; bh=ba8ZDHG4CpuT10IxX4V2AwzUnWEPkG2MSrQT0gFSIas=; b=wcF4eAU/45eN5/N++8B2afNu4w3XLtcLf4mV12PEinnoxagePoFyc7/M0Oe75EA5Uy DaxpCPui0407QMo8Qxs2/pMAHeJYlcMxYgucvBInBRff1UXP5PrlqDjigfuiYfW6bk2d WzsaZKpKFPIhZ8jHb5CZPN9kR5Cs6xEm1/nMDnQej21KRexSqT+smXS3AvRRiBVBbIsP dMclIKxw+ZhdlcoRNU8eHY2ncD/tgpW1z9SfZyiWTmSOAqLhSwM5vdrqEMtCfzIAH8i5 Ba+3Xg4uxXXQ7Zzpah4Y47jZxtsDaFeJw26RzKRdAhMtubpBOYOL6PTS97rlltiYU5Rk UuEg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b9si4937764pgn.443.2018.03.16.05.26.22; Fri, 16 Mar 2018 05:26:36 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752031AbeCPMZT (ORCPT + 99 others); Fri, 16 Mar 2018 08:25:19 -0400 Received: from mga14.intel.com ([192.55.52.115]:22215 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750982AbeCPMZS (ORCPT ); Fri, 16 Mar 2018 08:25:18 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Mar 2018 05:25:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,315,1517904000"; d="scan'208";a="25047096" Received: from pipin.fi.intel.com (HELO localhost) ([10.237.68.37]) by fmsmga008.fm.intel.com with ESMTP; 16 Mar 2018 05:25:16 -0700 From: Felipe Balbi To: 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 In-Reply-To: <410670D7E743164D87FA6160E7907A560113ABB478@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> Date: Fri, 16 Mar 2018 14:25:02 +0200 Message-ID: <87zi38438h.fsf@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? > 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. 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 -- balbi