From patchwork Sun Sep 18 16:50:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 9337975 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A656F6077F for ; Sun, 18 Sep 2016 16:52:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9598B28993 for ; Sun, 18 Sep 2016 16:52:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89C7728C63; Sun, 18 Sep 2016 16:52:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 16B8D28993 for ; Sun, 18 Sep 2016 16:52:41 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1blfJC-00067N-1v; Sun, 18 Sep 2016 16:51:14 +0000 Received: from mx1.redhat.com ([209.132.183.28]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1blfIj-000631-Mz for linux-arm-kernel@lists.infradead.org; Sun, 18 Sep 2016 16:50:46 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EA534159CE3; Sun, 18 Sep 2016 16:50:26 +0000 (UTC) Received: from shalem.localdomain.com (vpn1-5-65.ams2.redhat.com [10.36.5.65]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8IGoKhG030272; Sun, 18 Sep 2016 12:50:24 -0400 From: Hans de Goede To: Bin Liu , Kishon Vijay Abraham I Subject: [PATCH 2/2] musb: sunxi: Force session end on babble errors in host-mode Date: Sun, 18 Sep 2016 18:50:18 +0200 Message-Id: <20160918165018.24547-2-hdegoede@redhat.com> In-Reply-To: <20160918165018.24547-1-hdegoede@redhat.com> References: <20160918165018.24547-1-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Sun, 18 Sep 2016 16:50:27 +0000 (UTC) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160918_095045_832242_5C2116D8 X-CRM114-Status: GOOD ( 11.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, Hans de Goede , Chen-Yu Tsai , Maxime Ripard , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The sunxi musb has a bug where sometimes it will generate a babble error on device disconnect instead of a disconnect irq. When this happens the musb-controller switches from host mode to device mode (it clears MUSB_DEVCTL_SESSION and sets MUSB_DEVCTL_BDEVICE) and gets stuck in this state. Clearing this requires reporting Vbus low for 200 or more ms, but on some devices Vbus is simply always high (host-only mode, no Vbus control). This commit calls sun4i_usb_phy_force_session_end() on babble errors in host-mode, fixing the musb controller being stuck in this state on systems without Vbus control; and also fixes the need to unplug the usb-b -> usb-a cable to get out of this state on systems with Vbus control. Signed-off-by: Hans de Goede --- drivers/usb/musb/sunxi.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/usb/musb/sunxi.c b/drivers/usb/musb/sunxi.c index 1408245..5079d90 100644 --- a/drivers/usb/musb/sunxi.c +++ b/drivers/usb/musb/sunxi.c @@ -192,8 +192,18 @@ static irqreturn_t sunxi_musb_interrupt(int irq, void *__hci) * normally babble never happens treat it as disconnect. */ if ((musb->int_usb & MUSB_INTR_BABBLE) && is_host_active(musb)) { + struct sunxi_glue *glue = + dev_get_drvdata(musb->controller->parent); + + dev_warn(musb->controller->parent, "babble, treating as disconnect\n"); + musb->int_usb &= ~MUSB_INTR_BABBLE; musb->int_usb |= MUSB_INTR_DISCONNECT; + /* + * Fix the musb controller sometimes getting stuck in + * bdevice state after a babble error. + */ + sun4i_usb_phy_force_session_end(glue->phy); } if ((musb->int_usb & MUSB_INTR_RESET) && !is_host_active(musb)) {