Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp1107641ima; Fri, 1 Feb 2019 16:42:53 -0800 (PST) X-Google-Smtp-Source: AHgI3IavJGqXPgK7mpIbgCobpbl20+ttsDuMA/PwKRSPA+jyIGRAUNcZlk6A9w7XQWgC08aZfzH5 X-Received: by 2002:a63:8149:: with SMTP id t70mr4535076pgd.172.1549068173503; Fri, 01 Feb 2019 16:42:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549068173; cv=none; d=google.com; s=arc-20160816; b=m8E6Itqql9gOu/757IlEfOUJfnwzQUsc17Os1S66MckuMMQeXIc6aEiey8cptCkgO3 hfBMzMGKhNogWmY+UhAN+sNHKzK0776JaTW76I+fguMp/SdF1WxKZcRzNfDTO8kTxj6a zuGx2K2vxdvbKSSdP6DtxaSMi3V+VOhWljiIkUQn5p/a9vKJDnap4cbxk1dNXdTx5FIm d/Fth6iDyNPE919ffU0oX2ytjlMgySicu/ZgqhgsgHYWhrUzsyAPEi2f5m8xscoNN7VK IFDaeRItsCLkolRPvDnZ5k24u3EcuJ1gdL9XgMlZQ+SyHR76TKns06AWtqwIY5kTRpWe fRGw== 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:dkim-signature; bh=d8G59exhtWW8E07LZqPyLuv0XowzvIwLMVtJEmQmjoQ=; b=UswfAxM3b92IvBcG4bCkvh8J77TRXPLRXHUyBzggpK0Omf63maNRoJAQxP7XM+GoKt Sr1AxMXcyHrGpphMLoDsaci2KaHZCve6vPIMt5L/0xQECfpiVlkEtTyXF2KY4v1sk9F8 oC2+VBzvFHQL0sqwQRJmmoidprLdxuILSE6ixqRoRiNptOZRlJvKCaOfrJ/9mGQV8njP b7P1nPQg41/i0rdvo1JuDRiPz8ETIRQxfYhCemdtkHB10q3D3LKGIAr+SgQrvii/rLc+ x7JadQotl1bMcQGK9j4oS95yqa/VTvO078fRoMxjOV+Z2RYa0RN/XKclwHN/jkX7v0Qz E9/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=WTspmBvv; 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=pass (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 23si8783345pfk.287.2019.02.01.16.42.23; Fri, 01 Feb 2019 16:42:53 -0800 (PST) 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; dkim=pass header.i=@synopsys.com header.s=mail header.b=WTspmBvv; 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=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726719AbfBBAbs (ORCPT + 99 others); Fri, 1 Feb 2019 19:31:48 -0500 Received: from smtprelay4.synopsys.com ([198.182.47.9]:35776 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726121AbfBBAbs (ORCPT ); Fri, 1 Feb 2019 19:31:48 -0500 Received: from mailhost.synopsys.com (dc8-mailhost2.synopsys.com [10.13.135.210]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtprelay.synopsys.com (Postfix) with ESMTPS id D9D1024E25AD; Fri, 1 Feb 2019 16:31:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1549067507; bh=gtQqM6Yin/i9W3cup7lKF7u0bM+g1qR+MZbhX4/+pEg=; h=From:To:CC:Subject:Date:References:From; b=WTspmBvvn24ZlD02Ni0fDRQh/LLcxet3sgCxSQngXW3ka0zKAomGAwGOGz3qqH0SD LfCw7g01qaOpq348NfCmw2hcSaw/nMf2oVB1bK9GfxYb6H576NY+Jo5o5lOHU295A7 RSyk4+1dra+C4St0aMG8UVPmQ0SVHYX6bNAH61UYr8NQKp2Fnv+8MVlU/2CNCwmpNy FejdzTNK6RWQAyAbe/GYHhAOuIN/AaHXATWLHIg/OfEQY/kTz5tQFY+a2a4yXhxXkc oi9/k8dE6P7gNdGxx5G4ClU98n9jZ7rKgpbr74nDmLGNMCm2TG2wGeDvjU6itfvbv9 1o+QGrNM7ur1w== Received: from us01wehtc1.internal.synopsys.com (us01wehtc1-vip.internal.synopsys.com [10.12.239.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mailhost.synopsys.com (Postfix) with ESMTPS id 2BE00A0062; Sat, 2 Feb 2019 00:31:35 +0000 (UTC) Received: from us01wembx1.internal.synopsys.com ([169.254.1.228]) by us01wehtc1.internal.synopsys.com ([::1]) with mapi id 14.03.0415.000; Fri, 1 Feb 2019 16:29:38 -0800 From: Thinh Nguyen To: John Stultz , Felipe Balbi , Zeng Tao , Jack Pham , Thinh Nguyen , Chen Yu CC: lkml , Linux USB List , Greg Kroah-Hartman Subject: Re: Frequent dwc3 crashes on suspend or reboot since 5.0-rc1 Thread-Topic: Frequent dwc3 crashes on suspend or reboot since 5.0-rc1 Thread-Index: AQHUuozT6kyyipjNNU6b/TjVOcoaGw== Date: Sat, 2 Feb 2019 00:29:38 +0000 Message-ID: <30102591E157244384E984126FC3CB4F639BF445@us01wembx1.internal.synopsys.com> References: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.13.184.20] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi John,=0A= =0A= John Stultz wrote:=0A= > Hey all,=0A= > Since the 5.0 merge window opened, I've been tripping on frequent=0A= > dwc3 crashes on reboot and suspend, which I've added an example to the=0A= > bottom of this mail.=0A= >=0A= > I've dug in a little bit and sort of have a sense of whats going on.=0A= >=0A= > In ffs_epfile_io():=0A= > https://urldefense.proofpoint.com/v2/url?u=3Dhttps-3A__git.kernel.org_pub= _scm_linux_kernel_git_torvalds_linux.git_tree_drivers_usb_gadget_function_f= -5Ffs.c-23n1065&d=3DDwIBaQ&c=3DDPL6_X_6JkXFx7AXWqB0tg&r=3Du9FYoxKtyhjrGFcyi= xFYqTjw1ZX0VsG2d8FCmzkTY-w&m=3Da8TU-itM8GBG_EARYf2yM-kVfCzmaPkKDNAUFQHTe3Q&= s=3DBQiVAFiViSlxVg5_LemED0x_47FLVUD43M7R6h6T8qk&e=3D=0A= >=0A= > The completion done is setup on the stack:=0A= > DECLARE_COMPLETION_ONSTACK(done);=0A= >=0A= > Then later we setup a request and queue it:=0A= > req->context =3D &done;=0A= > ...=0A= > ret =3D usb_ep_queue(ep->ep, req, GFP_ATOMIC);=0A= >=0A= > Then wait for it:=0A= > if (unlikely(wait_for_completion_interruptible(&done))) {=0A= > /*=0A= > * To avoid race condition with ffs_epfile_io_complete,=0A= > * dequeue the request first then check=0A= > * status. usb_ep_dequeue API should guarantee no race=0A= > * condition with req->complete callback.=0A= > */=0A= > usb_ep_dequeue(ep->ep, req);=0A= > interrupted =3D ep->status < 0;=0A= > }=0A= >=0A= > The problem is, that we end up being interrupted, supposedly dequeue=0A= > the request, and exit.=0A= >=0A= > But then (or in parallel) the irq triggers and we try calling=0A= > complete() on the context pointer which points to now random stack=0A= > space, which results in the panic.=0A= >=0A= > It seems like something is wrong with usb_ep_dequeue not really=0A= > stopping the irq from happening?=0A= >=0A= > If I revert all the changes to dwc3 back to 4.20, I don't see the issue.= =0A= >=0A= > I'll do some bisection to try to narrow things down, but I wanted to=0A= > see if this was a known issue or if anyone had immediate ideas as to=0A= > what might be wrong.=0A= >=0A= =0A= I'm not sure if this is related, but can you try to test using Felipe's=0A= testing/next branch? There is a fix to a race condition when the gadget=0A= driver tries to dequeue requests.=0A= =0A= See if you run into this issue again.=0A= =0A= Thanks,=0A= Thinh=0A=