Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1998605imm; Thu, 24 May 2018 04:16:08 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoW1rh7ZQE63jZ3z23k+RxAy7etKJKaonRECNWG+ufgLg/2epI9tR7toNMRuKWeHjc66B+r X-Received: by 2002:a17:902:a702:: with SMTP id w2-v6mr6838618plq.8.1527160568130; Thu, 24 May 2018 04:16:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527160568; cv=none; d=google.com; s=arc-20160816; b=R8I6AsTOX88iT4p8uMYN5pBNAaWizhOl3x+iU1pRX1o3RTAaPT1a3fcPqSCa3BG2e8 zfgZAprWspcDBbuG9xbLViwaD9WTxA27H5zspkdDAe3ThHHuuEw3M2O1oswnxPLSPIxQ NhN0A3paK5bpjfhplYLwpoi6IyRcIk0Jjlj96xa+eCulSV5m1To8WPVSMCw5mLwjT8Rm D7cv3vdfYGOn0rVRNALfnwNfcXhnO8p0eG+TfvstME3gDwWs1d17x2/+6vRx+0/dAcVF zlorWIxnq6of5BpNyaxBpkaE9FQwKWnydku+/v88BYXBa0b0KMDtVKAgl0YikByAMCEh RA1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=kLzua9xBzZcbC+lhk8A/gHpcONU3h2nil4HshN53Ki4=; b=LvoUwn4a/2GrC9AsGlZglLfZtK4/Bgj/YcZpWGI9/FhL/cAaV5ScejPqHuApZBvqX0 d6O/zNsMFs+W0kq/yQlDq0CvqfVLjFp0j/Nqo/lsxY9nJb7cgAKJEn2sFWzMGn/TCN5z D6AAvt1+uka2D+pHy6fAy4iB4hI5yw3UjWjFB+3hbhzY9+p2EeVz1nl80JX17jtyBKAN ofWdOrx+AHJLq8WJ10xOC41cwO8i96nJ5abAlW8O/uUtHpFm3bzOpPK9z0rGIvCRoi/a bKKlPOoK/C7IkyAA66I1eiY5V6gh26lKAwCnAwCMBq8To9/lhrtR0sDIdHlEBNUvmLq0 /LwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WmmD/0wX; 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 b96-v6si21329091pli.172.2018.05.24.04.15.45; Thu, 24 May 2018 04:16:08 -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=WmmD/0wX; 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 S968100AbeEXJx6 (ORCPT + 99 others); Thu, 24 May 2018 05:53:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:60988 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S968088AbeEXJxv (ORCPT ); Thu, 24 May 2018 05:53:51 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 277AB2089F; Thu, 24 May 2018 09:53:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155630; bh=j4eoF0zQwyoy2bhGPSo9oDo8gOmdOn8tzmDspfYnYTU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WmmD/0wXr5CaYpCqVVEb2mEtoXPGnmte/DtFiTtyGYh1ixFWQrU/cgENb0S2JM8VQ 9u1O2ToS6sqRuPpw80CejAKME5dHD6/UMx8s9zmJEg34+GICHpicyTGrIg740tovDC DtvISJ3Cmd1REkRRgTYNjovNI+e4TBq9UwAm1GXI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, John Youn , Vardan Mikayelyan , Grigor Tovmasyan , Felipe Balbi , Sasha Levin Subject: [PATCH 4.14 059/165] usb: dwc2: Fix dwc2_hsotg_core_init_disconnected() Date: Thu, 24 May 2018 11:37:45 +0200 Message-Id: <20180524093624.403719551@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093621.979359379@linuxfoundation.org> References: <20180524093621.979359379@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Vardan Mikayelyan [ Upstream commit 755d739534f998d92e348fba8ffb0478416576e7 ] We should call dwc2_hsotg_enqueue_setup() after properly setting lx_state. Because it may cause error-out from dwc2_hsotg_enqueue_setup() due to wrong value in lx_state. Issue can be reproduced by loading driver while connected A-Connector (start in A-HOST mode) then disconnect A-Connector to switch to B-DEVICE. Acked-by: John Youn Signed-off-by: Vardan Mikayelyan Signed-off-by: Grigor Tovmasyan Signed-off-by: Felipe Balbi Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc2/gadget.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -3414,12 +3414,6 @@ void dwc2_hsotg_core_init_disconnected(s dwc2_writel(dwc2_hsotg_ep0_mps(hsotg->eps_out[0]->ep.maxpacket) | DXEPCTL_USBACTEP, hsotg->regs + DIEPCTL0); - dwc2_hsotg_enqueue_setup(hsotg); - - dev_dbg(hsotg->dev, "EP0: DIEPCTL0=0x%08x, DOEPCTL0=0x%08x\n", - dwc2_readl(hsotg->regs + DIEPCTL0), - dwc2_readl(hsotg->regs + DOEPCTL0)); - /* clear global NAKs */ val = DCTL_CGOUTNAK | DCTL_CGNPINNAK; if (!is_usb_reset) @@ -3430,6 +3424,12 @@ void dwc2_hsotg_core_init_disconnected(s mdelay(3); hsotg->lx_state = DWC2_L0; + + dwc2_hsotg_enqueue_setup(hsotg); + + dev_dbg(hsotg->dev, "EP0: DIEPCTL0=0x%08x, DOEPCTL0=0x%08x\n", + dwc2_readl(hsotg->regs + DIEPCTL0), + dwc2_readl(hsotg->regs + DOEPCTL0)); } static void dwc2_hsotg_core_disconnect(struct dwc2_hsotg *hsotg)