Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp576021img; Fri, 22 Mar 2019 04:22:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqxwY6c5hJs8QIbcpkceejwra38fYZjjKUzO6FAyPKewh8DtBOSbpoij5BZH+xJA8vocF7UC X-Received: by 2002:a17:902:7e0f:: with SMTP id b15mr8514573plm.124.1553253759305; Fri, 22 Mar 2019 04:22:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553253759; cv=none; d=google.com; s=arc-20160816; b=RO/T9E/OtgpwhW+O5mo0fK8fn6aqmgzTVNLrj0xbwEMjLveTEov4H1/TvbaeeU9MPg MdtFOrvx45D5ds/eb6B7v+ZYL3Y0rTOVTUm+OeOtDy3nXtt2hm37D4a95bB8SAKkuUxe P0x9CbtJDG5j3WpEuXBEt/kdMKf4ti/kyCDTreOogS+ihjNmB0FaVBNLsj7atf3EUOpN zT2kvpPGtpP2iOaG2B54Ks3XqXMZVmou5YOMQ+tYS7Q0rGiThieRJenKT2E96xJHyqvN KrtcDkJFywPfh7byA5aAlNP4QZN/p9LMFQT22hgBDMoqyVO3/S874LBMh9pcYoixPU7E JeDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=G2kYkWc8Ko/s/O1lHvoBR3WdJt9p9Tkp8MLLA0LAYoM=; b=DnHf6vcMTk1wfNrkeEIaox0kEmd1Qy4kW3oDC0/lt7a4H0gvw5nYSg4afVUUzlIOMu j6fYx58wQI+c5cfPpTz54/hTZWf/xlETUtPrz8q3UuqU3ld80iCtwPwiPDrlOD4c2A5I TeM4Yti/nWVzl4iAraQ/WMGhR3Y8uFLIRGjwO6eat555TFNTtmTSWsmCBzVOEI5sLFT2 jluAEAi/mPkdfQVvJVudRXJviBEYTCIPCijGZpGENmR2MTX1zafLqEdJtw1QPpXEBMfY h6au9c2vsqzwtZ2WqJLtbRxG6I7RkayvVy3wqvM4O4T7G9wI/0vVpf7XOebgwg6L32oM d+gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="uyfLc/cC"; 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 f73si6476092pff.184.2019.03.22.04.22.21; Fri, 22 Mar 2019 04:22:39 -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; dkim=pass header.i=@kernel.org header.s=default header.b="uyfLc/cC"; 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 S1728469AbfCVLUx (ORCPT + 99 others); Fri, 22 Mar 2019 07:20:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:47258 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727957AbfCVLUw (ORCPT ); Fri, 22 Mar 2019 07:20:52 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CFA2321916; Fri, 22 Mar 2019 11:20:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553253651; bh=2YTYZRx3cDAXk8oQWk6n+sfXgT2RLyqYvbVv0Yv84WM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uyfLc/cCqcpHs/HeA5JL2irgW6GQLdnEhOUZ8Y7Euu1C19XZJXJ/S6X9S6HiVM6vU OZkCClvtyFD/cLgWXyCRObflnQUWBOtJuZFRoLYjsTuxQ3nDsA98UzD2tJ0E7+1Xf+ zi/mcxNOcFBh5ZZg7sA5mNOGAP1mBoOASSMEuX4I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zeng Tao , Felipe Balbi , Sasha Levin Subject: [PATCH 3.18 030/134] usb: dwc3: gadget: Fix the uninitialized link_state when udc starts Date: Fri, 22 Mar 2019 12:14:03 +0100 Message-Id: <20190322111211.946929423@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111210.465931067@linuxfoundation.org> References: <20190322111210.465931067@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 88b1bb1f3b88e0bf20b05d543a53a5b99bd7ceb6 ] Currently the link_state is uninitialized and the default value is 0(U0) before the first time we start the udc, and after we start the udc then stop the udc, the link_state will be undefined. We may have the following warnings if we start the udc again with an undefined link_state: WARNING: CPU: 0 PID: 327 at drivers/usb/dwc3/gadget.c:294 dwc3_send_gadget_ep_cmd+0x304/0x308 dwc3 100e0000.hidwc3_0: wakeup failed --> -22 [...] Call Trace: [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [] (show_stack) from [] (dump_stack+0x84/0x98) [] (dump_stack) from [] (__warn+0xe8/0x100) [] (__warn) from [](warn_slowpath_fmt+0x38/0x48) [] (warn_slowpath_fmt) from [](dwc3_send_gadget_ep_cmd+0x304/0x308) [] (dwc3_send_gadget_ep_cmd) from [](dwc3_ep0_start_trans+0x48/0xf4) [] (dwc3_ep0_start_trans) from [](dwc3_ep0_out_start+0x64/0x80) [] (dwc3_ep0_out_start) from [](__dwc3_gadget_start+0x1e0/0x278) [] (__dwc3_gadget_start) from [](dwc3_gadget_start+0x88/0x10c) [] (dwc3_gadget_start) from [](udc_bind_to_driver+0x88/0xbc) [] (udc_bind_to_driver) from [](usb_gadget_probe_driver+0xf8/0x140) [] (usb_gadget_probe_driver) from [](gadget_dev_desc_UDC_store+0xac/0xc4 [libcomposite]) [] (gadget_dev_desc_UDC_store [libcomposite]) from[] (configfs_write_file+0xd4/0x160) [] (configfs_write_file) from [] (__vfs_write+0x1c/0x114) [] (__vfs_write) from [] (vfs_write+0xa4/0x168) [] (vfs_write) from [] (SyS_write+0x3c/0x90) [] (SyS_write) from [] (ret_fast_syscall+0x0/0x3c) Signed-off-by: Zeng Tao Signed-off-by: Felipe Balbi Signed-off-by: Sasha Levin --- drivers/usb/dwc3/gadget.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index a1ab837691911..8daf7145b3046 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1641,6 +1641,7 @@ static int dwc3_gadget_start(struct usb_gadget *g, /* begin to receive SETUP packets */ dwc->ep0state = EP0_SETUP_PHASE; + dwc->link_state = DWC3_LINK_STATE_SS_DIS; dwc3_ep0_out_start(dwc); dwc3_gadget_enable_irq(dwc); -- 2.19.1