Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2685813imj; Mon, 11 Feb 2019 07:01:55 -0800 (PST) X-Google-Smtp-Source: AHgI3IYfMHwz8JJ9o9iPw9AXOfhVP0yM5XLS9XSmrQzA1+8cQpD1T79ElGuGdz8tsZ5dAByQi4G3 X-Received: by 2002:a62:503:: with SMTP id 3mr5961362pff.176.1549897315063; Mon, 11 Feb 2019 07:01:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549897315; cv=none; d=google.com; s=arc-20160816; b=uYK/mDahFRscArqkFxehg08OIqVuGrwcVo6yD0Hp/p/EG94W6RLtDyr/jSBaFHEXZj 2vJ83M7F0kDaEJGZe/qtnxCy2q0CNVstMKxjcDGUismKLGijuqViz9C4gZG5JN++rYav wwk3+tnCp+dFaKlngI2BkwJ7J0zXdkxF9dJcD+T9gH78jnNimfwqfR8h77Ei+Zg7+iFj 9PcZhhws0VpL+MZW8sYfCD+MT3Xz1ByuNIIvTKExUEFtyGT49GgIKGUGd8TQdWGIUt8M M1l6OKA57rgJYgfPw5D5s6IyOtmIATdqan4Ofdl531Sa1nOrIrALnOo0Uuo2SQr2F70m DvwQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=scjloCOU8VoUQClcm46/u38tM/ctPFAiCOSPUl+0tDE=; b=Zwty62RgtNQmnDjO2wJw+BJV2oi2V9ia7C7lxh37DnAVPAwm6v48W2XVGJ9YcKXcK4 xqJetqhICC3eWTaC1InLEY+58BaQ5D2sd//OpA2fENM9kAPp8KyAnO8Q/RcUAUMWEy17 ip6BFKhH4Kmei8TiCflkKm2W3W+1lJE51MrcVJzAb6oLyq6qU2DNjJRABM6KS+ZN6iW1 kBbpYFznarhIjIhZiZ4E2EFlm0nDCxFW+KoOV7lxQOPwDpTZyQhtoI+czvjJ/mIz6Ola B8YkU/dhfoEP2aBsHLE8s1QUiqB3niELo9iyK2BJz5ztLSmrRoPnicqzDnVF2fHFBot3 s6zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pzyVYJkZ; 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 e4si12061928plk.300.2019.02.11.07.01.37; Mon, 11 Feb 2019 07:01:55 -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=pzyVYJkZ; 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 S2389741AbfBKO7K (ORCPT + 99 others); Mon, 11 Feb 2019 09:59:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:46882 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388652AbfBKO7J (ORCPT ); Mon, 11 Feb 2019 09:59:09 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 A1FEA206BA; Mon, 11 Feb 2019 14:59:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549897148; bh=kgRp3W6uTr5gnvFko2kXZBNGwmuCfE0z9FlFxGZ0KGc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pzyVYJkZFazi57Z6KlLlsP23l3/zjaZNOnrJBj8HVxB3QJ0HhJIFrB33CLK1Xv4KP JfL/u+/QZ3QZrguMBd4CpCnu4xXQPyCyKUgtWi0lfaz7Bf9UEdGsfbc1T80w5S9jpn HM0nBL04BizOVYdX2WD9RV5i42eq/2vLH2esTpvE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bin Liu , Sasha Levin Subject: [PATCH 4.14 106/205] usb: musb: dsps: fix otg state machine Date: Mon, 11 Feb 2019 15:18:24 +0100 Message-Id: <20190211141835.492605668@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141827.214852402@linuxfoundation.org> References: <20190211141827.214852402@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. ------------------ [ Upstream commit 6010abf2c2c0e382d7e8ee44bd11f343aae90cce ] Due to lack of ID pin interrupt event on AM335x devices, the musb dsps driver uses polling to detect usb device attach for dual-role port. But in the case if a micro-A cable adapter is attached without a USB device attached to the cable, the musb state machine gets stuck in a_wait_vrise state waiting for the MUSB_CONNECT interrupt which won't happen due to the usb device is not attached. The state is stuck in a_wait_vrise even after the micro-A cable is detached, which could cause VBUS retention if then the dual-role port is attached to a host port. To fix the problem, make a_wait_vrise as a transient state, then move the state to either a_wait_bcon for host port or a_idle state for dual-role port, if no usb device is attached to the port. Signed-off-by: Bin Liu Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/musb/musb_dsps.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index dbb482b7e0ba..b7d460adaa61 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -242,8 +242,13 @@ static int dsps_check_status(struct musb *musb, void *unused) switch (musb->xceiv->otg->state) { case OTG_STATE_A_WAIT_VRISE: - dsps_mod_timer_optional(glue); - break; + if (musb->port_mode == MUSB_HOST) { + musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON; + dsps_mod_timer_optional(glue); + break; + } + /* fall through */ + case OTG_STATE_A_WAIT_BCON: /* keep VBUS on for host-only mode */ if (musb->port_mode == MUSB_PORT_MODE_HOST) { -- 2.19.1