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: 10823449 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 68A8715AC for ; Thu, 21 Feb 2019 09:57:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C4F73040E for ; Thu, 21 Feb 2019 09:57:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A63F30436; Thu, 21 Feb 2019 09:57:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C41253046B for ; Thu, 21 Feb 2019 09:57:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727505AbfBUJ5V (ORCPT ); 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-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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; }