Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp200212imj; Thu, 14 Feb 2019 18:32:35 -0800 (PST) X-Google-Smtp-Source: AHgI3IbblH8c76zUjgQH6gijX3zP8i4EOmlZDAzG372/JkbAMvVASf8ZCENLir+goX8O0vJhpVLw X-Received: by 2002:a62:31c1:: with SMTP id x184mr7595733pfx.204.1550197955625; Thu, 14 Feb 2019 18:32:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550197955; cv=none; d=google.com; s=arc-20160816; b=SueTkhF0qgoy5C1jdrQE9opF372xI8MJKppMGFIdL/C/rvoq1eXHFGtUf0/DhvSuOy 66XaUzNikVqmtt1utkRAYSdXAC1J0go24UOCVEMKlY77HSZgICvZezBPdpQNZ0oqF//l QZAEq7uFZOscgMiDLjWctzvdrOJzptpP4Ngs6HBot2tcqQMXraCN5eQ3YggpldfAL06u nW/DlDPAQXUhc4uExhNpbhOwy2Ooo5NoWjJNEQPJnejVApSHEaDU+urNYOr6sZPv9BFw ah0nFawg2K7sYrc3rFt32UGWx5nfJoLGqD9hrQ0GnyfbIuwect7X+eRWgdOHvNQNqgIL a7NQ== 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=XuvL6JOBOJkmGrsnsX7OE3OZhvT0V0obZLjbGwhE5B4=; b=gFyVjOUCclNOgNQCjvW6E6m5GUJ37zc2F05faeYb7ae6UAQXgIzEanJFtexGdadnZV CD1+EDPbv7VyI+3/ZpndF+Lxwf3dLjucLMFV2ROM+Sa2U091t+GI2LCRIKHYaKMcFxiw iASenwe/8cPLNocQRJe67xg/FFAC6lqw+bmDo9gvN11lsV4rUeMI2JpeHDCucY+rGTCl M1lzdX8ovDbKSh1vKUppudf6rSRsVg5NoEmAtQngPJ7nkeXNcuUVIwinwxFX/9ZNdgMm LYiY3hoIO7DkD587VjdGp7tI8n1dEc2LXC1DPWr8GDTKCHH7B/xTG7bXn76n64dVOsac zVDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="aYGTjaz/"; 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 x9si4501338pfe.254.2019.02.14.18.32.19; Thu, 14 Feb 2019 18:32:35 -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="aYGTjaz/"; 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 S2392197AbfBOCRz (ORCPT + 99 others); Thu, 14 Feb 2019 21:17:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:55468 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405971AbfBOCPw (ORCPT ); Thu, 14 Feb 2019 21:15:52 -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 61A3E2229F; Fri, 15 Feb 2019 02:15:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550196952; bh=P6oTV/QwRGzjSFuFBysJ8VA1f5yBs9LVx07x+NnfF6Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aYGTjaz/7bzjGqTEltWji1Otk63VsQKTF0u/aCYFEMU51ChitO/LfgF3t6h5pm9da Sk7t7znsfTqLYOCIIViZTFZfaXhq4U3VhchHt6Mq+bow6GQvjyPqsCNIOfVEZ6DHjw cuB9pJ65EUM0y4kA2z9y8dPOMY6LxKktmH6NVCow= 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 3.18 04/16] usb: dwc3: gadget: Fix the uninitialized link_state when udc starts Date: Thu, 14 Feb 2019 21:15:34 -0500 Message-Id: <20190215021546.179605-4-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190215021546.179605-1-sashal@kernel.org> References: <20190215021546.179605-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 a1ab83769191..8daf7145b304 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