Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2020150imm; Thu, 24 May 2018 04:38:10 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqCqjqWblzFb1GeSrqHNT9j/cu4jsc+8yP3pg6OGxET+RdhLCD76VXqsvMho0fM8E3PPkfT X-Received: by 2002:a17:902:710f:: with SMTP id a15-v6mr7138756pll.171.1527161890038; Thu, 24 May 2018 04:38:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527161890; cv=none; d=google.com; s=arc-20160816; b=mcL5vUYw3ZMmSnj1yYwv73Z3Vp8otHz3E1HFFJ0b0R7/Z93/AwyGNwGnAklGLyvrHq p59GX+ewURUYcBJqDG5fJS8xUMPDRVaW1vHCGEq123PCUoMrzCJcFB/+SXj7ILYjnLTn S/X1YQUEw/MHoslAXTsTDBY6Xi9CQh3fbV5ThGV3JHxdrtc2x0p10ICiJ6NzwF50LRYh H1w29mthtSeJEcMyRIBrcbUmm8IJous0gALKPRT9WfZZGveAiWyT2pZy4eJ/4QPCuEcG L1ZeOwB2tUhnf7f0lTLLxTS1NkdsbhK3EIcDaVEmm8G4cJk1D653t6X9sBtsk9wmWdNq 4reQ== 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=zIJIth2nl9Hl9hg4BDYP8AceDbnPF1xABA6bvoLnse8=; b=bNOPP+0Cm/TK12WkDAYZkWUpq1q7tvivgqCk5tRX47u9fnR7vkkKPMYmm4tAy+2tGR gie9iLjs7Onxwe/eQHQH5TUR1ofSCgvoQYToK8Q6Oew6p1UfTC2n5Irw7/eYO4O6vr7D GQ92IW4gfGlF8HC6ZTI/VyH23Ouetb1oO6QGfvM1zxF93c908awCim81UZ2PugOMOTbh JgYqOf+oyFGLGdDJW2Wr/CZvnAzsH46ii2v45BZroPCL61bAgtI2Bo5iJ27N4lgoYd+v cr6SCcBJT3Qx/GC3AUf2qx/fXH/0CLRS5Wjdp/IV4gKgqxjcKPfYhuN5mS3ZZGVRp+LA 2oPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jl/DPzhP; 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 d123-v6si16598149pgc.445.2018.05.24.04.37.55; Thu, 24 May 2018 04:38:10 -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=jl/DPzhP; 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 S969110AbeEXLhT (ORCPT + 99 others); Thu, 24 May 2018 07:37:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:38480 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967103AbeEXJte (ORCPT ); Thu, 24 May 2018 05:49:34 -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 023E1208A4; Thu, 24 May 2018 09:49:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155373; bh=H3/unEx+3OuUbakIXFWoBBx++6nBd2mRepTGWLYbwG0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jl/DPzhPDVyoefF9lNB0cs6u0oa8ykWgJ7OYGS+SMmClvkU7Bq6zxqZvYK9U9rvxB Sx1iwywZEPF4djEuxIuTU90zE2luhKJedyGwS5PGFEN3rL/zZuCGRm9cBAKmi2mYjM QI6lpPGspSWE7arQOYOOpu71pNvr7b3VzMRBXrgI= 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.9 29/96] usb: dwc2: Fix dwc2_hsotg_core_init_disconnected() Date: Thu, 24 May 2018 11:38:12 +0200 Message-Id: <20180524093607.227286892@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093605.602125311@linuxfoundation.org> References: <20180524093605.602125311@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.9-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 @@ -2642,12 +2642,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) @@ -2658,6 +2652,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)