Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp798923img; Fri, 22 Mar 2019 08:48:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqze6k5Z7kc1WDd1zO6TkbDLRo3JgE8zXBmz5hZ1COw7yEPZ05r/kpp8+mUyX/kELbDLtyPx X-Received: by 2002:a62:1193:: with SMTP id 19mr9793639pfr.82.1553269707314; Fri, 22 Mar 2019 08:48:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553269707; cv=none; d=google.com; s=arc-20160816; b=OJGQiKFR3+xwbayaaHbi1U8Z4OZ9Xne28f05iHmCjcenWLco7oPF2d1/LCGItd9fxH 1BhT/9tc3i3pZIFjLP4VG1k4BtAr0QR50WS0b6+WZ2iixbf9b5rtcDhDr7H0C/RqaNhQ fs9kyouCT62TfwYIsv0STOdf7QdurjhHuN74hglOsXcHpMW0a6fu0tNRePL8o92n4xjl CJ414ve/FAUoD/bPjPUGrdxweUnHEFD6j24QkHO/zGhywrsLBEvDJBGIypKnl07XvBhY 1EQZez0B+irmGS6+UYETrIInv5rC+5kWyAeGdMqMWpERfCTsoAUGozba6weJ7WdsOxlI nykQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=feKQmVFtEinYxPc+YueTNciypJEJviHo80dkzJcygGQ=; b=I0NzUaAdpmcqgqzZrm2gvtoJYRezJ/3VtoBeL5DWkEVGsNENIlTthsKFCIxMcGtLBD xyUBrh21rVJrYFWmNp4SCm5PQ8msHNSN8tnM1lxFbCDXe3YHvZ5lS3Ml7+GgkT2BaBx+ PYQFmexEgAabXEGJaPlXmzPLxr937dEdG2fP0Wdvp4vdDD9tlhc3rpwcdVnERw0sh+uo i3BOS2Wsl7x2Wu29Rpr1ZSMrORdqgro3Y0t1RlOc+LJepMdGphfEcGBOAQqhomfMe0io yKuNjBPaqPYB0XWyjJ/0okxUWsJdrMlAXyg+g2m+0E9oorEafgNt82vF0POcrBPsMOjV UmCw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g24si7159247pfd.212.2019.03.22.08.48.12; Fri, 22 Mar 2019 08:48:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727893AbfCVPrF (ORCPT + 99 others); Fri, 22 Mar 2019 11:47:05 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:36445 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727244AbfCVPrE (ORCPT ); Fri, 22 Mar 2019 11:47:04 -0400 Received: from wuerfel.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.145]) with ESMTPA (Nemesis) id 1N2E5Q-1h0ShS0wrm-013iJA; Fri, 22 Mar 2019 16:46:48 +0100 From: Arnd Bergmann To: stable@vger.kernel.org, Felipe Balbi , Greg Kroah-Hartman Cc: Roger Quadros , Felipe Balbi , Arnd Bergmann , Thinh Nguyen , Anurag Kumar Vulisha , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [BACKPORT 4.4.y 09/25] usb: dwc3: gadget: Fix suspend/resume during device mode Date: Fri, 22 Mar 2019 16:44:00 +0100 Message-Id: <20190322154425.3852517-10-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190322154425.3852517-1-arnd@arndb.de> References: <20190322154425.3852517-1-arnd@arndb.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:Wa0NxvaJKz9beWWyK1EmT1GXc1pQUSQRbNYzwZGpDAvrUmOYVYT q3CqinTh9aDABHa0qxK1R/HCGB1KbBMcCZ4Fe1UqQp5zRwBy19SpIOItH5dEX2pbxKvSgFF 2bis02UUdwIjepEi2xBbwSpJ2hFx4+nLB5QVIycTDOHVWwD2Kh6XJ9KNymAD3uVFz0ZGpZ2 Ce7OEFixLoPZbyvrHwDIA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:CS48oms4k5w=:vp39lAbh7N7UOKpIVgtHb2 5g3ykR086ja1JLlNtCrAgvl2QwLdKiCbRBfYNF21ciOKlMv17WPa/537erZMitBhSNwPXm99A 2gTX0rvmrp/+4haUYR7bUKtb6c0Uo70r28JLpE4DHPmV64B/o7b1E/6WV5raNX+Pi4vq7pFHJ 2ueU8xm7rlF4d4Wyw/BzvJEuoAh3jzFCEUHRcJ4YJTGaGNFFqUMtwfOVDFvFU6lezU4drF54V Xnljq9Cz4tk2xij/jD+c+J5K8Ie3CrVilqDi4RL1DWWg0gUSpmvSkLTPZhr+sraqXTkEwAcKi hfoYCuQAsBA+lWOit8/PvhWaNiFgE5LBVMa/zvUmc5zBakF+JBnzTljv4B3WRpiGOJt9QacLk bt00+6NwA7CqNo/mRJiL4ST4bx1PdxmcwSzHhWmheyqkA8zwOJlh+NiWZyhPKFcvmfJ27F4JT vcyWAh86VImTYLsdCt/l7sqRIqryRFcic6vmAEYX/4g/iPtx8IexKcdLC2yNLUlTdE9gL4mXd OYvIjDi2wZYhMXFGgc63x4qofteLKsVRCwe8K6EvHCxCfuGrkkc4AqfN6XDBWMDFQaH3cdKzr gyn+hwdDyFlcKsQBNyvEi4vMZMmFVLlLGHQX2HP1A3vpC+FaMz+mKIhcccq2oUnRuLSIN1aHR TE3uxZc/aobrU7F67dA3cElJF1c8fyZbTf1LUHmdli6Up4I65GBtpbWHKO7fDozQBN0O2qpOF 7CvpTRWDpELhDEzviXhKRn7v5bnqcPqhnVYrNg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Roger Quadros Gadget controller might not be always active during system suspend/resume as gadget driver might not have yet been loaded or might have been unloaded prior to system suspend. Check if we're active and only then perform necessary actions during suspend/resume. Signed-off-by: Roger Quadros Signed-off-by: Felipe Balbi (cherry picked from commit 9772b47a4c2916d645c551228b6085ea24acbe5d) Signed-off-by: Arnd Bergmann --- drivers/usb/dwc3/gadget.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index b6037a0ae829..58e67c228971 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2893,6 +2893,9 @@ void dwc3_gadget_exit(struct dwc3 *dwc) int dwc3_gadget_suspend(struct dwc3 *dwc) { + if (!dwc->gadget_driver) + return 0; + if (dwc->pullups_connected) { dwc3_gadget_disable_irq(dwc); dwc3_gadget_run_stop(dwc, true, true); @@ -2911,6 +2914,9 @@ int dwc3_gadget_resume(struct dwc3 *dwc) struct dwc3_ep *dep; int ret; + if (!dwc->gadget_driver) + return 0; + /* Start with SuperSpeed Default */ dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(512); -- 2.20.0