Received: by 10.213.65.68 with SMTP id h4csp714194imn; Fri, 6 Apr 2018 07:43:29 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+xpLzRaCBh0uAz4Ib9BEceTgpecSgNcapnrS9XesfHdlCsAtn+75/rAQG8q0zlUjJsNhlE X-Received: by 10.98.141.20 with SMTP id z20mr20508994pfd.144.1523025809238; Fri, 06 Apr 2018 07:43:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523025809; cv=none; d=google.com; s=arc-20160816; b=HeGZClcq2zVDBwMKedaO0ATeZuIcnHz0PqADQbiHWeNje0m8uY1IpvpIQAeqXJ2uL2 NLcBWOeVo1ppHOOHUpdmlSMmn8KBgP0q/whoXZs3GoU9G1Fujnbztl/iwEtAQThR12SZ Ih8B1ihi7pi5F63OJ397Xqv6E+H8gftaCHiwS7eXcXfCQPEtlqBKTaDwQ2jy1bkTRu9P U4bIUhnIa/P1cCRw9FwXygyUmezo+eOeA0NUkv7tezbl3OHDQf/mSMPqOmavrvPzrE+x kThaXkDKUvwG/y/zZcZoF21lUD2qnEsSFs/LgA+cPSJUNz5/i2yUgP2LhWbE+Toxv/w/ PD6A== 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 :arc-authentication-results; bh=9AsfY96c0g0A50GPFl01UJNW5I29rd4dNj0pTU5GUB8=; b=wtwX99O4sg1enz2MUP7/9P6s7yN7DdV72xXQboDqIsAsV38UdGdgC4SpxGIcKbAGiM 3ObjXbe6qhB2hUvRPrDKds6mwIcT/b5KtVtEtnY2jpCj7gGFBaEBDxMjLpJDTsPF2BCR Q2+a/IQCyUR8ZbU9/NOfVxDSRkSocxNN3Wli1v8ZnGxeP3n/ixAO3kWHtXQ+4WonDYR5 7w8LbFVjZhR9Ax8J+g3wCUtexMaT2EquBMqcUieiYFqyP7zBIU1GczAuP1K7wVoOt+Uc SUh4Byb3/1r0XR5FAtrZ6GRj1N7FHfuPCAZsMHJCKmDnsoThTrRlRDYSWsRdVIt6BX4+ H3Rg== ARC-Authentication-Results: i=1; mx.google.com; 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 a123si1391860pgc.43.2018.04.06.07.43.15; Fri, 06 Apr 2018 07:43:29 -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; 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 S1755951AbeDFOmN (ORCPT + 99 others); Fri, 6 Apr 2018 10:42:13 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58350 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755872AbeDFNeb (ORCPT ); Fri, 6 Apr 2018 09:34:31 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 533C2DAB; Fri, 6 Apr 2018 13:34:30 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wei Xu , Guodong Xu , Amit Pundir , YongQin Liu , John Youn , Minas Harutyunyan , Douglas Anderson , Chen Yu , Felipe Balbi , linux-usb@vger.kernel.org, Minas Harutyunyan , John Stultz , Ben Hutchings Subject: [PATCH 4.9 049/102] usb: dwc2: Improve gadget state disconnection handling Date: Fri, 6 Apr 2018 15:23:30 +0200 Message-Id: <20180406084338.535787470@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180406084331.507038179@linuxfoundation.org> References: <20180406084331.507038179@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: John Stultz commit d2471d4a24dfbff5e463d382e2c6fec7d7e25a09 upstream. In the earlier commit dad3f793f20f ("usb: dwc2: Make sure we disconnect the gadget state"), I was trying to fix up the fact that we somehow weren't disconnecting the gadget state, so that when the OTG port was plugged in the second time we would get warnings about the state tracking being wrong. (This seems to be due to a quirk of the HiKey board where we do not ever get any otg interrupts, particularly the session end detected signal. Instead we only see status change interrupt.) The fix there was somewhat simple, as it just made sure to call dwc2_hsotg_disconnect() before we connected things up in OTG mode, ensuring the state handling didn't throw errors. But in looking at a different issue I was seeing with UDC state handling, I realized that it would be much better to call dwc2_hsotg_disconnect when we get the state change signal moving to host mode. Thus, this patch removes the earlier disconnect call I added and moves it (and the needed locking) to the host mode transition. Cc: Wei Xu Cc: Guodong Xu Cc: Amit Pundir Cc: YongQin Liu Cc: John Youn Cc: Minas Harutyunyan Cc: Douglas Anderson Cc: Chen Yu Cc: Felipe Balbi Cc: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org Acked-by: Minas Harutyunyan Tested-by: Minas Harutyunyan Signed-off-by: John Stultz Signed-off-by: Felipe Balbi Cc: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc2/hcd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -3220,7 +3220,6 @@ static void dwc2_conn_id_status_change(s dwc2_core_init(hsotg, false); dwc2_enable_global_interrupts(hsotg); spin_lock_irqsave(&hsotg->lock, flags); - dwc2_hsotg_disconnect(hsotg); dwc2_hsotg_core_init_disconnected(hsotg, false); spin_unlock_irqrestore(&hsotg->lock, flags); dwc2_hsotg_core_connect(hsotg); @@ -3238,8 +3237,12 @@ static void dwc2_conn_id_status_change(s if (count > 250) dev_err(hsotg->dev, "Connection id status change timed out\n"); - hsotg->op_state = OTG_STATE_A_HOST; + spin_lock_irqsave(&hsotg->lock, flags); + dwc2_hsotg_disconnect(hsotg); + spin_unlock_irqrestore(&hsotg->lock, flags); + + hsotg->op_state = OTG_STATE_A_HOST; /* Initialize the Core for Host mode */ dwc2_core_init(hsotg, false); dwc2_enable_global_interrupts(hsotg);