Received: by 10.213.65.68 with SMTP id h4csp679415imn; Fri, 6 Apr 2018 07:12:20 -0700 (PDT) X-Google-Smtp-Source: AIpwx49xe9/EuAKrgsKvLU/AgiF6dyOGHQMvKuA9PACjmfeqAYwzF95ac9YqdLDBRbos4jxPyT3x X-Received: by 2002:a17:902:6984:: with SMTP id l4-v6mr28445626plk.61.1523023940250; Fri, 06 Apr 2018 07:12:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523023940; cv=none; d=google.com; s=arc-20160816; b=WFJ9g7iIgnrggVZM5zEdI+F5XS3fIurKAS0EDACyk9I050DGPGdyLDxjtgbK/K0YRu n/Wz9ceEg32uVpPhqdEigs1wTmXJ6YOE4UqeCKrW1k8GncwVv0rcU+MKukfINFOGnAtO blA2cPp6XiXb9cmp9rGJ94REyw7QColhPyJJ/EMe9+FVzExCTiTdDUacS1u8rUqZAdvK 30WhKqDyv8XdhDRgj8Y0Lm6KVxCKQ5wBdp0jAQTjD8oemCoohlhUcKi4NBYl20u5KbdJ elfGYR6nL2udcIBiqrUWyTqePOetsvDUJ/ulxn9hk6934URPNPZ5/TrfLiH6RLiWHV5T QFAg== 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=OosutoFPDTgB65kXxAgXT2dwNIg744EsHOEZjz4/H6o=; b=0mR7c3aXwVGYNlGza8v/mXT0gFTQD/BSlCIsmr8aS9d/8+N9GY9yCIVYOfb+J9Q08g wBEVd/xEnv53CHZKZ/BDVm/UJaJig9mxCnH0fRBb2GQUY3KHIwUfV6S9L8Cb8J+ymrtg 6AhfUBKlzuciE3RZQDk9h5HUXVQGmFhmUjc9VOXtQxSOIwfoc6Bei87z4TMZp0n3TvKZ oHR2ZcYRH0R/ijl1Ky0wNIlj36yBLn4+K6zSejbqVFqBy10tiRxIxwgpcseKFPx7VP9J FGN1Xh2lq3BWqGpOZiKejd2Urj14bopaWhD2Jk9Tsz69ZO1wa4RwWt1zZntQpY+9VdAj iU+g== 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 z7si7105678pgv.447.2018.04.06.07.12.06; Fri, 06 Apr 2018 07:12:20 -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 S1756447AbeDFOLE (ORCPT + 99 others); Fri, 6 Apr 2018 10:11:04 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:35830 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756318AbeDFNk0 (ORCPT ); Fri, 6 Apr 2018 09:40:26 -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 735AEDD2; Fri, 6 Apr 2018 13:40:21 +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.14 36/67] usb: dwc2: Improve gadget state disconnection handling Date: Fri, 6 Apr 2018 15:24:06 +0200 Message-Id: <20180406084346.173607297@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180406084341.225558262@linuxfoundation.org> References: <20180406084341.225558262@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: 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 @@ -3277,7 +3277,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); @@ -3296,8 +3295,12 @@ host: 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);