Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp197452imj; Thu, 14 Feb 2019 18:29:04 -0800 (PST) X-Google-Smtp-Source: AHgI3IYJ3jjud1OXCaBGj9ikzqHimeXCUQHvsVsATU+IqRksamT/3ZgnBgk0oouv67jyKBfIung7 X-Received: by 2002:a65:610f:: with SMTP id z15mr2996072pgu.153.1550197744285; Thu, 14 Feb 2019 18:29:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550197744; cv=none; d=google.com; s=arc-20160816; b=WZbKUgDZhGp9S7Q6uoAJv6KgvDFFUBoclJ/oEjGaah76iqzAKwGN94CVnGLgtXD2GA naKgAEBwdGFZgSjF2gnzEypwmqN5YAfFHYCIKMFCiKQ4JO+e9pULvkPgWW9uY5J8+PAJ MFU3ege3S3q2wZNxTNto5+f0DswqFcp1avJ1GQFkBzIw/hE/4J1AkV0QnHduDQBLOVSF SI0dZQuad0a/yVwFnB+Aye9nLuoDLvJQ81BqNkNXl5/txtW+Ryl2yts+M3uuGXEzm/VA KoK1FUnVuVG3GindcyRgCj23CXKmvqCSI8s1dpqGBkxl2lCrawPAx3nYyzr5vYzQfZzu pyaQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WoDcbp9VSne6ZtrU/u/urxWiDsMqXHzWsN7Qeydrcyo=; b=Wt/T/6dlsa1t5tdtXGgAfb0ZIenfeUpb0UQihL+BhmwGiU+eqm7e6mZ/2SPKxvxL2V 5nqMPerbWRgXArbP3kv8Oqeyfq8Efq2V81ecbshEpjt8ifY2bshPNKY+XH05nV+mmKtq 5nJDPPvgzTQnD0MpC8OSht2r+8t0aJ1yCzFAeZn8bfN+zbanQmNPrmuLZNiC2QHNE68j 62KZl+6Jys5/O/0Vme2iW68iaZA1th58gFoheI4+u+jbzbtCf0b/MIZ+wCgfM0ga8zEq LpB5ggrRA7cJUJWsx5N99dxbb0/KXA4IHGZklU5amZxf0dJQK9t+FinRLkV5U/FuGI1c JXnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=b+ffX54e; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n66si4157752pfg.249.2019.02.14.18.28.48; Thu, 14 Feb 2019 18:29:04 -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=@kernel.org header.s=default header.b=b+ffX54e; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731686AbfBOCJS (ORCPT + 99 others); Thu, 14 Feb 2019 21:09:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:49482 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731652AbfBOCJQ (ORCPT ); Thu, 14 Feb 2019 21:09:16 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DAA502229F; Fri, 15 Feb 2019 02:09:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550196555; bh=3dJX6TaKmLA0QcqnDeQEYkcgj6801MoXU0Ro36Yg8HY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b+ffX54e7iYhJWTtw+QPen/+tJREs9y4xilujgi/Tii3mAEna7jzpYF7AQr+La3rY Z3BSxfhjZuMTmDSS2K2/9iAdEh5yMeRG3n0MhpStIDn7gbzLQ4luBCP1mIc7Q3SMSZ SGdkaWt6QCojPGpkSN7LoQpJCHlhhcBryPePXIps= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Zeng Tao , Felipe Balbi , Sasha Levin , linux-usb@vger.kernel.org Subject: [PATCH AUTOSEL 4.20 13/77] usb: dwc3: gadget: Fix the uninitialized link_state when udc starts Date: Thu, 14 Feb 2019 21:07:51 -0500 Message-Id: <20190215020855.176727-13-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190215020855.176727-1-sashal@kernel.org> References: <20190215020855.176727-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zeng Tao [ 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 f51527c8925b..2fa9685d526a 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1869,6 +1869,7 @@ static int __dwc3_gadget_start(struct dwc3 *dwc) /* 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