From patchwork Thu Dec 12 00:20:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grazvydas Ignotas X-Patchwork-Id: 3329331 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DD1919F37C for ; Thu, 12 Dec 2013 00:21:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1B4BE207B4 for ; Thu, 12 Dec 2013 00:21:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 32AAC207B2 for ; Thu, 12 Dec 2013 00:21:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751526Ab3LLAVD (ORCPT ); Wed, 11 Dec 2013 19:21:03 -0500 Received: from mail-ee0-f46.google.com ([74.125.83.46]:59196 "EHLO mail-ee0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751377Ab3LLAVB (ORCPT ); Wed, 11 Dec 2013 19:21:01 -0500 Received: by mail-ee0-f46.google.com with SMTP id d49so3201991eek.19 for ; Wed, 11 Dec 2013 16:21:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=5kYeUtZSoNmcQoJTYOC+/LjIAZiKhtdGBtf+j8gbbqU=; b=HjxQwxmoaOhmG6R5DBgseD2E5gnYX09GGYJM1StJ8yiB+PgQuxSHf9Q9ML+76Ksrji G5Tglj7Lg6IL3Ln70J3Ho5qxIVf1jThksR4CuOem/6txQpNjZjvVDpZz9/rC3V+PWIJV kjJ2aipN7N4woN3Cjq+d05RZ0WFgxnUgpbOLMAiHQMAp1j/pPHAzdtKDfPYoe01nR7A3 A+9ecplTEzGdLlzrjmg1QMTIPk5HzV3abwiZ+JHIpH7/U74NDY/iMIAsuc8uw8dptccl UMCrJIG7yUO+nrkC/kkToEb7IIo2NmiUu9FY8TUcJgsDKS6HK/sJYUXP2fgqR0Z4HqT8 wu8A== X-Received: by 10.14.107.3 with SMTP id n3mr4431893eeg.67.1386807659940; Wed, 11 Dec 2013 16:20:59 -0800 (PST) Received: from localhost.localdomain (ip-88-119-226-136.static.b4net.lt. [88.119.226.136]) by mx.google.com with ESMTPSA id v7sm59283798eel.2.2013.12.11.16.20.58 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 11 Dec 2013 16:20:59 -0800 (PST) From: Grazvydas Ignotas To: linux-usb@vger.kernel.org Cc: Felipe Balbi , linux-omap@vger.kernel.org, Andreas Naumann , Grazvydas Ignotas , Subject: [PATCH] usb: musb: omap2430: fix occasional musb breakage on boot Date: Thu, 12 Dec 2013 02:20:59 +0200 Message-Id: <1386807659-5505-1-git-send-email-notasas@gmail.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This is a hard to reproduce problem which leads to non-functional USB-OTG port in 0.1%-1% of all boots. Tracked it down to commit e25bec160158abe86c "omap2+: save and restore OTG_INTERFSEL", which introduces save/restore of OTG_INTERFSEL over suspend. Since the resume function is also called early in driver init, it uses a non-initialized value (which is 0 and a non-supported setting in DM37xx for INTERFSEL). Shortly after the correct value is set. Apparently this works most time, but not always. Fix it by not writing the value on runtime resume if it is 0 (0 should never be saved in the context as it's invalid value, so we use it as an indicator that context hasn't been saved yet). This issue was originally found by Andreas Naumann: http://marc.info/?l=linux-usb&m=138562574719654&w=2 Reported-and-bisected-by: Andreas Naumann Signed-off-by: Grazvydas Ignotas Cc: --- This is a regression from 3.2, so should go to -rc and stable, IMO. It's really annoying issue if you want to have a stable OTG behavior, I've burned quite a lot of time on it myself over a year ago and gave up eventually. Good thing Andreas finally found it, many thanks to him! drivers/usb/musb/omap2430.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index 2a408cd..737b3da 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -672,7 +672,8 @@ static int omap2430_runtime_resume(struct device *dev) if (musb) { omap2430_low_level_init(musb); - musb_writel(musb->mregs, OTG_INTERFSEL, + if (musb->context.otg_interfsel != 0) + musb_writel(musb->mregs, OTG_INTERFSEL, musb->context.otg_interfsel); phy_power_on(musb->phy); }