Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3631887imu; Mon, 28 Jan 2019 08:08:53 -0800 (PST) X-Google-Smtp-Source: ALg8bN460aufz3Md+vmc72AQcShz3gJZBCnSq13FaNY/dD658q0ewOyLIwuAuoUGcL32aeyUqe4q X-Received: by 2002:a62:4587:: with SMTP id n7mr22251093pfi.118.1548691733173; Mon, 28 Jan 2019 08:08:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548691733; cv=none; d=google.com; s=arc-20160816; b=CbZ+MIQLsnT+j009QDoDjmV5UtHqlx6XA8F2sjSka6flfDU8QrI2ZMR60PWls60g/K E1HRLQ/sap3PR646ltvKR1IoSVQ/BS8cFWV6vVAYCimBP7Wh6nGrJfV9Kbyg9w0aTsu/ HTb0UnDJfbn/3siKFLMc5tOsWetXejizaXrrVrrYKFV3GfJn23SdTt/NbDswfhJZEjOs zuQbEzMjNiNTDGErlWLd9szvtQ5WPcVvnlqQZ+a57UvJRprfI/RBLeGHuSvdGwtuokge tcvHxnZDibO0QoY3werxQLXWDxIjsih8Y7+xNwCWtCjNDoC1uxgXIHn6J39ZvUm4rdc5 thRg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kwMEG8hc2/V8HNakHDAAgVcdScdzzbb097FkV+eZ0ck=; b=blp4JfpW8kqG5HpNb+B+mokV3th+IWGKU6oaG/9RyFaQUWHAKU60vFE5A2os+y9sGd ndVf+w986x7eCZ0g6awKUyC4KDQOBQHbNexzGdOCJRPZeiipe/pcfnYGgUqo2VmfyjF6 Qxw4ir6GkR4nKh4U7+6MYb3pK4cKgx9COPAvHzRWSDPZKXfhG12licqvLOLPZ9AfyLvS OjsIm/cVTydJ2My2Onw++PlWLBv5EeUieN0UAqo1sKQKqF7C2In494E9zjHAIyrB0vxr K+WMzkaElAq8/BlV14wr3BqP8+COXSUxoH9Pbuevc3VZQZ1yjURxvBnKj773j7P/N/wC cA7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bCVJuRrk; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a3si28389638pga.297.2019.01.28.08.08.37; Mon, 28 Jan 2019 08:08:53 -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=bCVJuRrk; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731494AbfA1QHm (ORCPT + 99 others); Mon, 28 Jan 2019 11:07:42 -0500 Received: from mail.kernel.org ([198.145.29.99]:58566 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732244AbfA1QHi (ORCPT ); Mon, 28 Jan 2019 11:07:38 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7415821920; Mon, 28 Jan 2019 16:07:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691657; bh=AUEDBcY/wBRAAI39J9IfvBDD8AWP9bWC15s4yvCXJ3M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bCVJuRrk2AYYhHmucXstbtpQtW8tQymRT/Kcs7ozb/dJJSHyxlMEaCOkPt5s8QWsQ /GW1gFq61sezntmjBOJNO31kEX4b6QwBTyVDZpgT+S6g6xT6K8sc0ntNTPJVSyD8g0 QJwjq36MojPM3cRW4Ceb0eTBdcA8C3s8wWRCB+bQ= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Bin Liu , Greg Kroah-Hartman , Sasha Levin , linux-usb@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 176/258] usb: musb: dsps: fix otg state machine Date: Mon, 28 Jan 2019 10:58:02 -0500 Message-Id: <20190128155924.51521-176-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bin Liu [ 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 23a0df79ef21..1e6d78b1334e 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -227,8 +227,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_HOST) { -- 2.19.1