From patchwork Fri Mar 22 15:44:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 160924 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp961329jan; Fri, 22 Mar 2019 08:47:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqxZtgPnCUR+8hSed6vVrBo1A2q9YIqnNIFvo6UwZNlnPO4+u5+YJmjQctffx3xSw3S/CY7h X-Received: by 2002:a62:204b:: with SMTP id g72mr6457068pfg.51.1553269626035; Fri, 22 Mar 2019 08:47:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553269626; cv=none; d=google.com; s=arc-20160816; b=BNEiclHOGDldmC2a4FWqoLv/EmfhHDVvxzfR1XJAZB5SHJtM8FsSpS/6Q+HucyuT35 LklrBZjj08qR+DUg+QZT54qxsQ1r9/sx1obkNsaOoat8dnXI1wJry8iB7pmXQD2N1BLL XiAiLxr5EDK0uxO4R6ObxHtywEDZZ4H3T25gCeV807b40714/TcV4rscvPNt61TL/33h 1TZnR9P40PP8jWWYDGwjjtcedz8/8bINc+qXQNHp7tWDTPmOfASaj0MM2qKSOsOTPkVy KzFhsVFaMwamR60/e2M3SvPsJPZGpEl7p0nGTxZejeEMgiv9K0Dtufua0B3v36hiReBm Q/oA== 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=ON3c4WZBjTDw0hPSGULqR4e2IVcaupi4LCAVjXj90TwjKbBmaSonFuArBwkz9LAewm GCqoXvi6eFoILP56DVSR3JmbPZi9ZJE4e3l+BZFRJol7v2WMQj4wo+pU10D4imkcbZLV zHkscm/XQh5/zdMDABxjNn6cFdD7xtOnqLVThbHvSy9GvPFpv5OUrsIZDoW8Ug/7V9OR DyjjmbH5WxKEsTsEMaHtbmuibOvM4AFEsh8E7/qFzfYmtP8wcsCFpEgC10Pf9PeMUFOt iyCRlXUG4XgMf2NrfmRgoGEHHlc74GJ/THictgGKhn1p7RIKkZ6UIZOWl9j1Glk6Cae2 73jg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-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 a6si3411181plm.62.2019.03.22.08.47.05; Fri, 22 Mar 2019 08:47:06 -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; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727867AbfCVPrF (ORCPT + 5 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 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-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@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(+) -- 2.20.0 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);