Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp5238268ima; Tue, 5 Feb 2019 08:28:34 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibwak8cqmyyrgzZrLnr7DXE9wiIEkx9NFPb2JuMGn8onLUM6FTDnDR8TgKZcHW28eiwLDRz X-Received: by 2002:a17:902:848f:: with SMTP id c15mr5730693plo.119.1549384114570; Tue, 05 Feb 2019 08:28:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549384114; cv=none; d=google.com; s=arc-20160816; b=OkVDKKiose4xDV4rejqT/Cqk3N676/inUFYOcf0/DZ29XJEX3VgEn3/MBP/ehfjubP VNSWofERlKajfFLsXpxLAJRDZehlPHGkCxvY0UEEwJZOjrY3SaOxKfwMm1ufbdXnhCed OSIVthJjpIGHTYGAXEWyevcIHu+ft1IE5llbRyRYNsjBXIvs0a++1XNqe7kqHaGyhKkx CwAq6YjDdYHeYURgMX8D5uI9WPA6EieH9jvcjfYnaOj4R0FcUJywf5AQ2EyRpw0mVorU CX8fLIUktcpaRPIeOfgEB3F5Zb5RQLj9FDoGNbs8U0bQtCvkhr4nNw8F17Xs7wYHzF5r VnPA== 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:in-reply-to :subject:cc:to:from:date; bh=NKIYktBbwnAgu9GQvoER23SAZB4EJjTbQ+455qe1iMY=; b=zze26Ze5fueOu3sR1PwZmf6C4yCQTBe/Tj5w6jQxkeX1KhYDfYXT7cUbo785nWqKxP mtB5gs0MnzPnDh7WzhfiNEQugpNvgOjhhaxC3Xsb+X08n/B2aW4St789FdjOEKYIdlJU mp37I+Ubysp/OL60gycMwie0m37jfVtsmm8BjtesRnAtvfXWVXaDCC449h9wnK7Cjd/f 5SqP/nPun6vAlYK0JeJBKtqqWrHBDZ5rW1rNVO3qnVlpD5J9jqmPcmSIUyBNmBdp348p Vm45unTWcUlfw+1eMf15GPT2hzgPwEigTwbCCOxkcUr4YBkdm3XsblRZx7/M1WmQp3XE dprw== 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 t74si2536519pgc.150.2019.02.05.08.28.18; Tue, 05 Feb 2019 08:28:34 -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; 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 S1729319AbfBEP6B (ORCPT + 99 others); Tue, 5 Feb 2019 10:58:01 -0500 Received: from iolanthe.rowland.org ([192.131.102.54]:52378 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726550AbfBEP6B (ORCPT ); Tue, 5 Feb 2019 10:58:01 -0500 Received: (qmail 2431 invoked by uid 2102); 5 Feb 2019 10:58:00 -0500 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 5 Feb 2019 10:58:00 -0500 Date: Tue, 5 Feb 2019 10:58:00 -0500 (EST) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: John Stultz cc: Felipe Balbi , Zeng Tao , Jack Pham , Thinh Nguyen , Chen Yu , lkml , Linux USB List , Greg Kroah-Hartman Subject: Re: Frequent dwc3 crashes on suspend or reboot since 5.0-rc1 In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 4 Feb 2019, John Stultz wrote: > On Sat, Feb 2, 2019 at 9:00 AM Alan Stern wrote: > > > > On Fri, 1 Feb 2019, John Stultz wrote: > > > > > Hey all, > > > Since the 5.0 merge window opened, I've been tripping on frequent > > > dwc3 crashes on reboot and suspend, which I've added an example to the > > > bottom of this mail. > > > > > > I've dug in a little bit and sort of have a sense of whats going on. > > > > > > In ffs_epfile_io(): > > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/gadget/function/f_fs.c#n1065 > > > > > > The completion done is setup on the stack: > > > DECLARE_COMPLETION_ONSTACK(done); > > > > > > Then later we setup a request and queue it: > > > req->context = &done; > > > ... > > > ret = usb_ep_queue(ep->ep, req, GFP_ATOMIC); > > > > > > Then wait for it: > > > if (unlikely(wait_for_completion_interruptible(&done))) { > > > /* > > > * To avoid race condition with ffs_epfile_io_complete, > > > * dequeue the request first then check > > > * status. usb_ep_dequeue API should guarantee no race > > > * condition with req->complete callback. > > > */ > > > usb_ep_dequeue(ep->ep, req); > > > > This code contains a bug: It assumes that usb_ep_dequeue() waits until > > the request has been completed. You should insert > > > > wait_for_completion(&done); > > > > right here. > > > > > interrupted = ep->status < 0; > > > } > > > > Thanks! This does seem to resolve the issue I'm seeing. > > Are you planning to send in such a patch, or would it help if I sent it out? Either way, whatever you prefer. If you decide to write the patch yourself, consider editing the preceding comment (which is confusing if not outright wrong). Also, there is an earlier call of usb_ep_dequeue() in __ffs_ep0_queue_wait() which might need to be fixed as well -- I'm not sure. Alan Stern