From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3983C282CE for ; Mon, 11 Feb 2019 14:46:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 732E320844 for ; Mon, 11 Feb 2019 14:46:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549896394; bh=RKp6cQP8MhzJlcyBBeHthL/6qRG1osCiFPt+NcNB74w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=BL5pkim3IUVX7X135iE0hnfnOGCebb3M/RWZexIgHH7cdyeG6+MO4rRNRdfMb7FKv +p83GKve7VrSiSv0AYzwc/jo28z6jh+MeHTtwz+WTL4XNvdwdOsp8R+ppWOb9w7XcT 6tXu6tZqEFZOTwVPlB5YARWJ0CboOSxgr9foF83g= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733253AbfBKOqd (ORCPT ); Mon, 11 Feb 2019 09:46:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:59606 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733247AbfBKOq3 (ORCPT ); Mon, 11 Feb 2019 09:46:29 -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 D484220700; Mon, 11 Feb 2019 14:46:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549896388; bh=RKp6cQP8MhzJlcyBBeHthL/6qRG1osCiFPt+NcNB74w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V+lZidd4xc+54OHLj3kNb63hOgMgcFdQ0wN2Np978tBPkPIgYzU4a77wzJ2tjqc1Z tDtmAAcHuEXqQMQ5gl6mZuRuHROx7sx7oV8fHsPwNvOt/kRP3gpKIRxJU2G0b3s4/z Xrgy2djD68SaFhlUSl5Ao9Z7xzcRBoWHS1D1hvpw= 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.19 168/313] usb: musb: dsps: fix otg state machine Date: Mon, 11 Feb 2019 15:17:28 +0100 Message-Id: <20190211141904.645025754@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141852.749630980@linuxfoundation.org> References: <20190211141852.749630980@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.19-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 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