From patchwork Wed Sep 2 14:24:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 52977 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by patches.linaro.org (Postfix) with ESMTPS id 854742300B for ; Wed, 2 Sep 2015 14:25:34 +0000 (UTC) Received: by lagj9 with SMTP id j9sf5100467lag.0 for ; Wed, 02 Sep 2015 07:25:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-type:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe; bh=Du7bjnzDa2vj9bge0UwS9WC4kxrhF5KyP6dJLPti5ro=; b=Kul9Ff1PasFTxM0SDh57BV4NFYe+yPlQWuLjLjzwrZoHgAGYRt2MTzeUMqNfeJOiWh 7Z/mcgRWL8jWJZmmK9W4+WIPFADTf8j/KM0MHRDv3+tgeOI94kCLFtIKAKpsBrlZLJ4h 42r0mXU6F3E17iDejpN4liOcwQrHTsyuWdCh6cYIHcrvMOI3x1FMoyEgN7dW1C09sNe3 JY+0VXFk0w3v9RzB+J5G+FHj2e3xyEEs13qB0/VYNp2Ikd8Lh02mM2ARUX0P9bVdtQ81 6cPw6oECYW7cXAwAw0cFyQB72nrl4aNOXwSfS2gDqZZB8fwy59ZngyiLzap4wnoBCN7M Zjsg== X-Gm-Message-State: ALoCoQm8fiHCkiQck0Cg5MJ2oem72GUkkM5pb+LZHa3ATBlO+nURoww+5+BFsXk2Sm9w31X3PfJY X-Received: by 10.180.12.205 with SMTP id a13mr1110278wic.4.1441203933448; Wed, 02 Sep 2015 07:25:33 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.9.164 with SMTP id a4ls69403lab.105.gmail; Wed, 02 Sep 2015 07:25:32 -0700 (PDT) X-Received: by 10.152.36.161 with SMTP id r1mr15818463laj.82.1441203932980; Wed, 02 Sep 2015 07:25:32 -0700 (PDT) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id f5si19775979laa.134.2015.09.02.07.25.32 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Sep 2015 07:25:32 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by lagj9 with SMTP id j9so8390531lag.2 for ; Wed, 02 Sep 2015 07:25:32 -0700 (PDT) X-Received: by 10.112.209.106 with SMTP id ml10mr15770406lbc.112.1441203932734; Wed, 02 Sep 2015 07:25:32 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.164.42 with SMTP id yn10csp615071lbb; Wed, 2 Sep 2015 07:25:31 -0700 (PDT) X-Received: by 10.68.104.98 with SMTP id gd2mr4174942pbb.130.1441203921047; Wed, 02 Sep 2015 07:25:21 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id vr1si32360370pab.21.2015.09.02.07.25.20; Wed, 02 Sep 2015 07:25:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754954AbbIBOZE (ORCPT + 4 others); Wed, 2 Sep 2015 10:25:04 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:50783 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754653AbbIBOZA (ORCPT ); Wed, 2 Sep 2015 10:25:00 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id t82EOupr016763; Wed, 2 Sep 2015 09:24:56 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id t82EOtMM009460; Wed, 2 Sep 2015 09:24:56 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.224.2; Wed, 2 Sep 2015 09:24:55 -0500 Received: from rockdesk.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id t82EOPFW024150; Wed, 2 Sep 2015 09:24:53 -0500 From: Roger Quadros To: CC: , , , , , , , , Roger Quadros Subject: [PATCH v4 9/9] usb: dwc3: core: don't break during suspend/resume while we're dual-role Date: Wed, 2 Sep 2015 17:24:24 +0300 Message-ID: <1441203864-15786-10-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1441203864-15786-1-git-send-email-rogerq@ti.com> References: <1441203864-15786-1-git-send-email-rogerq@ti.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: rogerq@ti.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , We can't rely just on dr_mode to decide if we're in host or gadget mode when we're configured as otg/dual-role. So while dr_mode is OTG, we find out from the otg state machine if we're in host or gadget mode and take the necessary actions during suspend/resume. Also make sure that we disable OTG irq and events during system suspend so that we don't lockup the system during system suspend/resume. Signed-off-by: Roger Quadros --- drivers/usb/dwc3/core.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 654aebf..25891e3 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1455,18 +1455,15 @@ static int dwc3_suspend(struct device *dev) dwc->octl = dwc3_readl(dwc->regs, DWC3_OCTL); dwc->oevt = dwc3_readl(dwc->regs, DWC3_OEVT); dwc->oevten = dwc3_readl(dwc->regs, DWC3_OEVTEN); + dwc3_writel(dwc->regs, DWC3_OEVTEN, 0); + disable_irq(dwc->otg_irq); } - switch (dwc->dr_mode) { - case USB_DR_MODE_PERIPHERAL: - case USB_DR_MODE_OTG: + if (dwc->dr_mode == USB_DR_MODE_PERIPHERAL || + ((dwc->dr_mode == USB_DR_MODE_OTG) && (dwc->fsm->protocol == PROTO_GADGET))) dwc3_gadget_suspend(dwc); - /* FALLTHROUGH */ - case USB_DR_MODE_HOST: - default: - dwc3_event_buffers_cleanup(dwc); - break; - } + + dwc3_event_buffers_cleanup(dwc); dwc->gctl = dwc3_readl(dwc->regs, DWC3_GCTL); spin_unlock_irqrestore(&dwc->lock, flags); @@ -1506,18 +1503,12 @@ static int dwc3_resume(struct device *dev) dwc3_writel(dwc->regs, DWC3_OCTL, dwc->octl); dwc3_writel(dwc->regs, DWC3_OEVT, dwc->oevt); dwc3_writel(dwc->regs, DWC3_OEVTEN, dwc->oevten); + enable_irq(dwc->otg_irq); } - switch (dwc->dr_mode) { - case USB_DR_MODE_PERIPHERAL: - case USB_DR_MODE_OTG: + if (dwc->dr_mode == USB_DR_MODE_PERIPHERAL || + ((dwc->dr_mode == USB_DR_MODE_OTG) && (dwc->fsm->protocol == PROTO_GADGET))) dwc3_gadget_resume(dwc); - /* FALLTHROUGH */ - case USB_DR_MODE_HOST: - default: - /* do nothing */ - break; - } spin_unlock_irqrestore(&dwc->lock, flags);