From patchwork Thu Feb 21 09:55:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 158887 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp289081jaa; Thu, 21 Feb 2019 01:57:22 -0800 (PST) X-Google-Smtp-Source: AHgI3IYPeXvyhfmbD9AS8LkYfIgo+ssg58/xG/HdpeDOeAnllw0R/9Q8NDD02E3foBZP82QCrd3V X-Received: by 2002:a62:e515:: with SMTP id n21mr39990130pff.159.1550743042023; Thu, 21 Feb 2019 01:57:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550743042; cv=none; d=google.com; s=arc-20160816; b=V/+LRGScdMGiAUoHsCYhPwdYGg+y8qWKipWUfv4ogKuttVtYLRnT9RHOeKtuyRdv4l zi9/qwRC6bvOukQlhAJprEXqm5RP5n0eZBqdFVR5GTC8crq8b8Nu1jy2dRnJEucFsH5U tqZvJyMIYHk72JCuzS4dxvnNpGP7Bcb4werYEp2Gl4dCLKLil008pr23oICIIxpqmXfd 4Q/hp3yl80wbBbHefYXNjVjgdweLti6fDGLfTc+ibzwDYYmROtq3R7IxExEKnT8xUmjz 92hj15HShW21kLm3WK7qwVYp3McLWHHCfzvlJe+mGOvmCBwZFDGU7snXndbNjrbQx/ei 6gcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=DCbNi4Mi6E02+w8vYQCqkALKRkQ1YFCwkAZxxLaBy2o=; b=Sp5VZ7kjWQ1IlM6xsfwilGv5y5LcaN8Iqa5LmBSFIV8tfzQVDTjtOfkFn2e5CVr4BI QF7U0v2M8jl4R/9PXUzeo/bBOccecffkmFOiS0hEwsQhHMyhr6ABWlx7Hz7n0hxi2p8E bkozrEEvWScekiod3k9f3S3w06kyHcrJHZWPRC+NVskhZ5Sfq6t9KNlGohqAKhB20UhB BtNJtKm5R50QDvdGfjCIMMguNqyvXgOEbtAwc2EClVolkMdn+72IOsYIZICiwsSfTLpM p/UDICDy0u4Fhx3xjB+tafDUCnrcKTHY+1cuG5sJEqxzGpmHVtj+yRo9L3VFqqRYRgKP uboQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=F19Podaa; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f4si22444536plf.370.2019.02.21.01.57.21; Thu, 21 Feb 2019 01:57:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=F19Podaa; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727482AbfBUJ5V (ORCPT + 3 others); Thu, 21 Feb 2019 04:57:21 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:42673 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726151AbfBUJ5V (ORCPT ); Thu, 21 Feb 2019 04:57:21 -0500 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20190221095719euoutp029c7f977d7c62605c98bd30ac91a1e3c6~FWJP64nRZ0852808528euoutp02J; Thu, 21 Feb 2019 09:57:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20190221095719euoutp029c7f977d7c62605c98bd30ac91a1e3c6~FWJP64nRZ0852808528euoutp02J DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1550743039; bh=DCbNi4Mi6E02+w8vYQCqkALKRkQ1YFCwkAZxxLaBy2o=; h=From:To:Cc:Subject:Date:References:From; b=F19PodaahgEN4USg9NHKgcA6pB/9FBqIZOe+QCokJPA+4ZxcL9W/9rWNGx20A2vRQ v9HVaDSNqvAoHhKAWG0Fh/pzynt1UsRkW4/9V6PibLWnO9e3QiOJjZpzrQu43pfa7u o9RNtSICBA/UKvts4CHt3Av1gdCkwhKnjniJgNQM= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20190221095718eucas1p1e115ae9b5ef423c8f6c29d7864b86d86~FWJPCv_fm2203222032eucas1p1Y; Thu, 21 Feb 2019 09:57:18 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id A9.60.04294.EF57E6C5; Thu, 21 Feb 2019 09:57:18 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20190221095717eucas1p221ef58f4a2f4aaae17f75e8267c9839f~FWJOSk62e2300023000eucas1p2l; Thu, 21 Feb 2019 09:57:17 +0000 (GMT) X-AuditID: cbfec7f4-835ff700000010c6-a8-5c6e75fe22ad Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 41.F3.04284.DF57E6C5; Thu, 21 Feb 2019 09:57:17 +0000 (GMT) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0PN9007HGSZ9D110@eusync3.samsung.com>; Thu, 21 Feb 2019 09:57:17 +0000 (GMT) From: Marek Szyprowski To: linux-usb@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , Greg Kroah-Hartman , Felipe Balbi , Bo He , Yu Wang , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz Subject: [PATCH] usb: dwc3: move synchronize_irq() out of the spinlock protected block Date: Thu, 21 Feb 2019 10:55:50 +0100 Message-id: <20190221095550.4609-1-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprFIsWRmVeSWpSXmKPExsWy7djP87r/SvNiDDbvYLbYOGM9q8Wxtifs FneevmSxaF68ns3i/PkN7BYzzu9jsli0rJXZYu2Ru+wW205+Y3Hg9Fi85yWTx6ZVnWwe++eu Yffo27KK0ePzJrkA1igum5TUnMyy1CJ9uwSujP6lm1kLWpQq/rd+YmpgbJXrYuTkkBAwkdhw aQ5LFyMXh5DACkaJLYt2MkI4nxklNj14wN7FyAFWda4rCCK+jFFi2Z9/TBBOA5PEganfmEBG sQkYSnS97WIDsUUEHCSWLL3DBlLELDCHSWLGJZBJnBzCAhES778+ZAOZyiKgKrFzUhlImFfA RuL85A4WiJPkJVZvOMAM0ish8JdV4sHSj1AJF4lLb04xQ9gyEp0dB5kgipoZJdpnzGKHcHoY JbbO2cEGUWUtcfj4RVYQm1mAT2LStunMEP/wSnS0CUGUeEhceT2TFSQsJBArcbU7cQKj+AJG hlWM4qmlxbnpqcVGeanlesWJucWleel6yfm5mxiBMXb63/EvOxh3/Uk6xCjAwajEw7shIjdG iDWxrLgy9xCjBAezkgivV2ZejBBvSmJlVWpRfnxRaU5q8SFGaQ4WJXHeaoYH0UIC6Yklqdmp qQWpRTBZJg5OqQbGtKzZU1/pTPCP5EzrCbmfdqsg1HFKi2+MbOhm/iCd4nUxvrPv3bQ6e+tI lY1yiM++5d/t71dN2LJywrqqh4UJeTtmXvz8Mt1dhmlBufF9AcM1lztZXeVX6+vvvW+06pnq lBk/49gXSOQJrO7d+DSniOteVyL/j0+c0rO32Vu+uq7+5kHIJF15JZbijERDLeai4kQAN5sZ x60CAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBJMWRmVeSWpSXmKPExsVy+t/xq7p/S/NiDLZ+5bfYOGM9q8Wxtifs FneevmSxaF68ns3i/PkN7BYzzu9jsli0rJXZYu2Ru+wW205+Y3Hg9Fi85yWTx6ZVnWwe++eu Yffo27KK0ePzJrkA1igum5TUnMyy1CJ9uwSujP6lm1kLWpQq/rd+YmpgbJXrYuTgkBAwkTjX FdTFyMUhJLCEUWLD+W5GCKeJSWLv3Q1MXYycHGwChhJdb7vYQGwRAQeJJUvvsIEUMQvMY5KY PX8SI0hCWCBC4v3Xh2wgU1kEVCV2TioDCfMK2Eicn9zBAmJLCMhLrN5wgHkCI9cCRoZVjCKp pcW56bnFhnrFibnFpXnpesn5uZsYgeGx7djPzTsYL20MPsQowMGoxMO7ISI3Rog1say4MvcQ owQHs5IIr1dmXowQb0piZVVqUX58UWlOavEhRmkOFiVx3vMGlVFCAumJJanZqakFqUUwWSYO TqkGRi29538L+Hummq7Y7lbFeP3hzA/bZuZFBGctk5tu1rCl5FnxCa7TmubVLK+85riU2PAl n35fWTtRM++O5rTaF9NmbNwplmC0x27DTSNpIecV194GyDeeMr77865y1+zjvSfVVlUK3l46 4Wqbs2V2c6ueuAHn4f8zT7/UzpxZmHhbUWH5rD0KL5VYijMSDbWYi4oTAfuFZ3wLAgAA X-CMS-MailID: 20190221095717eucas1p221ef58f4a2f4aaae17f75e8267c9839f CMS-TYPE: 201P X-CMS-RootMailID: 20190221095717eucas1p221ef58f4a2f4aaae17f75e8267c9839f References: Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org dwc3_gadget_suspend() is called under dwc->lock spinlock. In such context calling synchronize_irq() is not allowed. Move the problematic call out of the protected block to fix the following kernel BUG during system suspend: BUG: sleeping function called from invalid context at kernel/irq/manage.c:112 in_atomic(): 1, irqs_disabled(): 128, pid: 1601, name: rtcwake 6 locks held by rtcwake/1601: #0: f70ac2a2 (sb_writers#7){.+.+}, at: vfs_write+0x130/0x16c #1: b5fe1270 (&of->mutex){+.+.}, at: kernfs_fop_write+0xc0/0x1e4 #2: 7e597705 (kn->count#60){.+.+}, at: kernfs_fop_write+0xc8/0x1e4 #3: 8b3527d0 (system_transition_mutex){+.+.}, at: pm_suspend+0xc4/0xc04 #4: fc7f1c42 (&dev->mutex){....}, at: __device_suspend+0xd8/0x74c #5: 4b36507e (&(&dwc->lock)->rlock){....}, at: dwc3_gadget_suspend+0x24/0x3c irq event stamp: 11252 hardirqs last enabled at (11251): [] _raw_spin_unlock_irqrestore+0x6c/0x74 hardirqs last disabled at (11252): [] _raw_spin_lock_irqsave+0x1c/0x5c softirqs last enabled at (9744): [] __do_softirq+0x3a4/0x66c softirqs last disabled at (9737): [] irq_exit+0x140/0x168 Preemption disabled at: [<00000000>] (null) CPU: 7 PID: 1601 Comm: rtcwake Not tainted 5.0.0-rc3-next-20190122-00039-ga3f4ee4f8a52 #5252 Hardware name: SAMSUNG EXYNOS (Flattened Device Tree) [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [] (show_stack) from [] (dump_stack+0x90/0xc8) [] (dump_stack) from [] (___might_sleep+0x22c/0x2c8) [] (___might_sleep) from [] (synchronize_irq+0x28/0x84) [] (synchronize_irq) from [] (dwc3_gadget_suspend+0x34/0x3c) [] (dwc3_gadget_suspend) from [] (dwc3_suspend_common+0x154/0x410) [] (dwc3_suspend_common) from [] (dwc3_suspend+0x14/0x2c) [] (dwc3_suspend) from [] (platform_pm_suspend+0x2c/0x54) [] (platform_pm_suspend) from [] (dpm_run_callback+0xa4/0x3dc) [] (dpm_run_callback) from [] (__device_suspend+0x134/0x74c) [] (__device_suspend) from [] (dpm_suspend+0x174/0x588) [] (dpm_suspend) from [] (suspend_devices_and_enter+0xc0/0xe74) [] (suspend_devices_and_enter) from [] (pm_suspend+0x770/0xc04) [] (pm_suspend) from [] (state_store+0x6c/0xcc) [] (state_store) from [] (kobj_attr_store+0x14/0x20) [] (kobj_attr_store) from [] (sysfs_kf_write+0x4c/0x50) [] (sysfs_kf_write) from [] (kernfs_fop_write+0xfc/0x1e4) [] (kernfs_fop_write) from [] (__vfs_write+0x2c/0x160) [] (__vfs_write) from [] (vfs_write+0xa4/0x16c) [] (vfs_write) from [] (ksys_write+0x40/0x8c) [] (ksys_write) from [] (ret_fast_syscall+0x0/0x28) Exception stack(0xed55ffa8 to 0xed55fff0) ... Signed-off-by: Marek Szyprowski --- drivers/usb/dwc3/core.c | 2 ++ drivers/usb/dwc3/gadget.c | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index a1b126f90261..206d7e5d6d71 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1600,6 +1600,7 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg) spin_lock_irqsave(&dwc->lock, flags); dwc3_gadget_suspend(dwc); spin_unlock_irqrestore(&dwc->lock, flags); + synchronize_irq(dwc->irq_gadget); dwc3_core_exit(dwc); break; case DWC3_GCTL_PRTCAP_HOST: @@ -1632,6 +1633,7 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg) spin_lock_irqsave(&dwc->lock, flags); dwc3_gadget_suspend(dwc); spin_unlock_irqrestore(&dwc->lock, flags); + synchronize_irq(dwc->irq_gadget); } dwc3_otg_exit(dwc); diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index e293400cc6e9..2bb0ff9608d3 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -3384,8 +3384,6 @@ int dwc3_gadget_suspend(struct dwc3 *dwc) dwc3_disconnect_gadget(dwc); __dwc3_gadget_stop(dwc); - synchronize_irq(dwc->irq_gadget); - return 0; }