From patchwork Wed Sep 27 10:35:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Liu X-Patchwork-Id: 9973677 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 253DC60365 for ; Wed, 27 Sep 2017 10:34:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 243E82918A for ; Wed, 27 Sep 2017 10:34:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 18DF92918D; Wed, 27 Sep 2017 10:34:17 +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, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1BE7D2918A for ; Wed, 27 Sep 2017 10:34:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=1/35KZWZG5oyGOza7Lvm/dgEprgf7jOTu0ldGfb8eMs=; b=pCV NuVUDYKmAyQWmyp/kiDL9XHh8K3A+EXJSakkQMqDjV0zyJb8r7rV/g7p89SfM0wDA3FyWvPJ3CxpH klk1BWoy47VQYjCHn2aJitcNy3Ni/P+iAcHoZ7U9lhZmByYtyxlHBcwP4BrA/SzdoJDCusegkTP46 /G8uJ4aJulNSqpZ1McgWIEADhWSyAlEGMa14X1j4j4NCR8P+kzgQXJouHcx8B8GXRVWLJdLtEKvYA ZUdvSKcJKLcn6KQ0jB5ff3dWYfAnQBHhGJMslZdLLxXUlEfKlnJJQX2/GrXHTSOQXJH5e/FQ5K98I XeW5FntICBpOW+ocRtdVHBx5zVa8RQA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dx9fM-0006lw-Kq; Wed, 27 Sep 2017 10:34:08 +0000 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dx9ei-00065K-5v for linux-arm-kernel@lists.infradead.org; Wed, 27 Sep 2017 10:33:29 +0000 Received: by mail-pf0-x243.google.com with SMTP id g65so6529005pfe.1 for ; Wed, 27 Sep 2017 03:33:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=r7yDNEpBjImRvipgcsGI7MCT4TPXcjP90jIPKegl0oI=; b=utGDQhkM82+3ID2+qqA3XxDwWX2FZj/zRHN68U9NAqwUhJkoNEmuEUdsx9w9uFNq4i LpUFe6wyFpA4oOpLIVqR7Mgl4vYAuYn1flpZZ1+l1LvZu8lfpjIdA7HYTz55O1MEcCMX Gc0LCwnmZo1nwzIBlqizLf6PmyMhmFrYMq6iEtopR6Rmuux44/zDyCjyKN0HNmSCb67H nNGev4wqnm3tdwZj2w13/o+7q06vv0uYOHsi+6erwMdRVTE3qy6D1GmOe8mUO03xojhY b4l6AGTsUSS9KpisB5WNm3Ncf7DLJtTV1efB3KFaEnWil1q8k1KLcHtFkHX6ODYYWrtA VNxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=r7yDNEpBjImRvipgcsGI7MCT4TPXcjP90jIPKegl0oI=; b=M2AHm8styPDJ8VUUIiQk8ZCEr9r0sQDrwC0ic6akXtsQMKUI9sHJPNIm5HpLJMZpJL TSIf56yZ7FLdOwDoX4VV9svFUxKyzxw/9VQDAkH8Ghyp4f1B1xOs9en/DHsmmhJQpPVd FvhfRQ/I7h5jUxGx0X/VEPvqW+5qMTSZ5ym56gxYs3nGdEo82eEZF8c0OePaBtjcd3Dm hIWPaMDYS5/gO1hudXnHbRxyZ7k4nx6SxmRjNL33pwPmP8kLTnDFs2i6o5SP8NsSDX7Z cnoPj7AA1prKjW9jcE75HJlT/M70eiRr5bAT0ky18oYMPqZNT8ietRsJF+KjHJuAFQJq wAAg== X-Gm-Message-State: AHPjjUgEgfUfMq+jDNTPyC5IP9YxBSg/6e+ZD19NqtzvNMs6HvWgEChc rli4vWWUBOAZYFYUymcF280= X-Google-Smtp-Source: AOwi7QC2NCfuS6VQO4wphBxdZSRKvefr1TH/3mKX78JYmnVrzG7dJBlYIlNwBrwtDUldLo94cC3D5A== X-Received: by 10.99.43.4 with SMTP id r4mr920100pgr.380.1506508387016; Wed, 27 Sep 2017 03:33:07 -0700 (PDT) Received: from 60-242-179-244.static.tpgi.com.au (60-242-179-244.static.tpgi.com.au. [60.242.179.244]) by smtp.gmail.com with ESMTPSA id p85sm20063705pfj.47.2017.09.27.03.33.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Sep 2017 03:33:05 -0700 (PDT) From: Jonathan Liu To: Bin Liu , Greg Kroah-Hartman , Maxime Ripard , Chen-Yu Tsai Subject: [PATCH] usb: musb: Check for host-mode using is_host_active() on reset interrupt Date: Wed, 27 Sep 2017 20:35:22 +1000 Message-Id: <20170927103522.30202-1-net147@gmail.com> X-Mailer: git-send-email 2.13.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170927_033328_274752_D80D7D42 X-CRM114-Status: GOOD ( 10.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-sunxi@googlegroups.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Jonathan Liu 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_HM/MUSB_DEVCTL_SESSION and sets MUSB_DEVCTL_BDEVICE) and gets stuck in this state. The babble error is misdetected as a bus reset because MUSB_DEVCTL_HM was cleared. To fix this, use is_host_active() rather than (devctl & MUSB_DEVCTL_HM) to detect babble error so that sunxi musb babble recovery can handle it by restoring the mode. This information is provided by the driver logic and does not rely on register contents. Cc: stable@vger.kernel.org # v4.1+ Signed-off-by: Jonathan Liu --- drivers/usb/musb/musb_core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 029692053dd3..1bce7df3e110 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -906,7 +906,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, */ if (int_usb & MUSB_INTR_RESET) { handled = IRQ_HANDLED; - if (devctl & MUSB_DEVCTL_HM) { + if (is_host_active(musb)) { /* * When BABBLE happens what we can depends on which * platform MUSB is running, because some platforms @@ -916,9 +916,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, * drop the session. */ dev_err(musb->controller, "Babble\n"); - - if (is_host_active(musb)) - musb_recover_from_babble(musb); + musb_recover_from_babble(musb); } else { musb_dbg(musb, "BUS RESET as %s", usb_otg_state_string(musb->xceiv->otg->state));