From patchwork Wed Jul 8 10:37:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 6744551 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 088ED9F2F0 for ; Wed, 8 Jul 2015 10:37:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 905A2206F0 for ; Wed, 8 Jul 2015 10:37:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 990D4206DB for ; Wed, 8 Jul 2015 10:37:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934853AbbGHKha (ORCPT ); Wed, 8 Jul 2015 06:37:30 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:49509 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932762AbbGHKh1 (ORCPT ); Wed, 8 Jul 2015 06:37:27 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id t68AbOAe026170; Wed, 8 Jul 2015 05:37:24 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id t68AbOnn011738; Wed, 8 Jul 2015 05:37:24 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.224.2; Wed, 8 Jul 2015 05:37:09 -0500 Received: from rockdesk.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id t68AbMvw009324; Wed, 8 Jul 2015 05:37:22 -0500 From: Roger Quadros To: CC: , , , , , Roger Quadros Subject: [PATCH v3 8/9] usb: dwc3: core: Prevent otg events from disabling themselves Date: Wed, 8 Jul 2015 13:37:18 +0300 Message-ID: <1436351838-28732-1-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1436351524-28385-1-git-send-email-rogerq@ti.com> References: <1436351524-28385-1-git-send-email-rogerq@ti.com> MIME-Version: 1.0 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.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 There is a race happening during dwc3_drd_init() that causes otg events to get disabled. This is what happens. dwc3_otg_irq() happens immediately when PRTCAP is set to OTG, even though OEVTEN is 0. This is because BIT 31 IRQ of OEVT can't be disabled by OEVTEN. We configure OEVTEN in dwc3_otg_init() but dwc3_otg_irq() has already saved OEVTEN as 0 into dwc->oevten. So finally when dwc3_irq_thread_irq() is called we save 0 into OEVTEN thus disabling OTG irqs forever. We fix this by disabling IRQs when configuring OEVTEN in dwc3_otg_init(). Signed-off-by: Roger Quadros --- drivers/usb/dwc3/core.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index d050e0e..e3c094d 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -905,6 +905,7 @@ static int dwc3_drd_init(struct dwc3 *dwc) int ret, id, vbus; u32 reg; struct dwc3_hwparams *parms = &dwc->hwparams; + unsigned long flags; /* If extcon device is not present we rely on OTG core for ID event */ if (!dwc->edev) { @@ -982,6 +983,8 @@ try_otg_core: goto error; } + spin_lock_irqsave(&dwc->lock, flags); + /* we need to set OTG to get events from OTG core */ dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG); /* GUSB2PHYCFG0.SusPHY=0 */ @@ -1007,6 +1010,8 @@ try_otg_core: /* OCTL.PeriMode = 1 */ dwc3_writel(dwc->regs, DWC3_OCTL, DWC3_OCTL_PERIMODE); + spin_unlock_irqrestore(&dwc->lock, flags); + dwc3_otg_fsm_sync(dwc); usb_otg_sync_inputs(dwc->fsm);