From patchwork Wed Mar 27 09:56:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 161252 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp6265842jan; Wed, 27 Mar 2019 02:56:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqwqNtXqWmJe2Ibv+lGFIBUq2qfuhFGFeX4nDzY08EZihQm1gkWRP99mcTXnRzmiVuNzxd/6 X-Received: by 2002:a62:469a:: with SMTP id o26mr35433599pfi.251.1553680592474; Wed, 27 Mar 2019 02:56:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553680592; cv=none; d=google.com; s=arc-20160816; b=AhJ1Huz4ZIybT3ZdKQbh9kQpBFbsppgy7MNgy4e8sm2uEO/IHbDdIaa5cTKCEHEvAh HOz1ECoxV4AiCzar6r6S73wrx8CtcL11EsgfzSGBOUSKUMrJXPowNM7AqvYdnXOBcNFS aK5SFCrlziNYddzZ+6W2LrfQmDWeUDwUQ6njwzzFGbIQbP1/CrgRIMt7RDOM8mCFSHfk ZWelfSK+YuOJylzpXcedfCH3AvFHqIzSoftOM5MZTGt64BJnWykbpXScx6RqKCtF0aol Jo1eIAWmwpZX1EPough1OiYOlX5lGjVp/Ao65R1c6dMS/FAjS5UGVtDRcu/kDM1XnG6e NQmg== 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=WTw6BwHOzpM55hx8SWKd9jUjVlNSrvw0UaCwAfYsfyY=; b=MsvaWLfujWACcTEkuradCQJGylvFxnnVQOhUTEozeZOD1cpuXm92PNb8LotR7Z5LK6 GAIArmg7koRfSi8AWyKHMNcZ5pi90e0h9oHCQPkA2UUdTq3J3DEQkoy07UYTn3PMiQgU PRFrqDl2FlS2lZCKOXAYKkoJORKHIHVbOvuoBSz7BGedEN/VHvpJAbGC/xVWzk7IkqrU MYOR3J2r8sF7rkbaVRTlcbn6vLmX6mAqtT37E39unF360OBZ9G9CCmRZ7sXwmd+OFqKo wiwCQNA2/H43Lsod/0S+5C05Ux256sBLi0Vf8LB8zmjH5fn0YntHH1AmPRty0VjpRbNT dvgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=NuL4NdzE; 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; 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 f34si7000300pgb.49.2019.03.27.02.56.32; Wed, 27 Mar 2019 02:56:32 -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; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=NuL4NdzE; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732991AbfC0J4Z (ORCPT + 5 others); Wed, 27 Mar 2019 05:56:25 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:53893 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732843AbfC0J4W (ORCPT ); Wed, 27 Mar 2019 05:56:22 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20190327095620euoutp02ed38d66344e13ee30fb49bd0c73bebb5~PyEGYCm462306723067euoutp02G; Wed, 27 Mar 2019 09:56:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20190327095620euoutp02ed38d66344e13ee30fb49bd0c73bebb5~PyEGYCm462306723067euoutp02G DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1553680580; bh=WTw6BwHOzpM55hx8SWKd9jUjVlNSrvw0UaCwAfYsfyY=; h=From:To:Cc:Subject:Date:References:From; b=NuL4NdzEkVh/wI4R2E/JyVtLLXWtGhfiGdyZyNwCPWtHqzOCz4sxmEGv5lnbH4pXx EKZimdQXwWco17NvlrOw5IY36Nle6nAi5EBDSD3DnPvgSQ6qy+9m7KjWBPTyBP9sKA YRIKBNY/oG+Z1aKTlenKRxI7Rq0iQXlPjCMPoKYA= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20190327095620eucas1p205d667b3b27fd04dcda03254ff9c6ebc~PyEF-L--N3063230632eucas1p2s; Wed, 27 Mar 2019 09:56:20 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 4D.6B.04325.3C84B9C5; Wed, 27 Mar 2019 09:56:19 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20190327095619eucas1p12349c49c92d05329920a4ff931e763be~PyEFUaYQR2948029480eucas1p1N; Wed, 27 Mar 2019 09:56:19 +0000 (GMT) X-AuditID: cbfec7f5-b75ff700000010e5-ce-5c9b48c35111 Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 28.73.04140.3C84B9C5; Wed, 27 Mar 2019 09:56:19 +0000 (GMT) Received: from AMDC2765.DIGITAL.local ([106.120.51.73]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0PP0001A7RLRT170@eusync1.samsung.com>; Wed, 27 Mar 2019 09:56:19 +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 v2] usb: dwc3: move synchronize_irq() out of the spinlock protected block Date: Wed, 27 Mar 2019 10:56:08 +0100 Message-id: <20190327095608.13274-1-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprJIsWRmVeSWpSXmKPExsWy7djPc7qHPWbHGMyfr2+xccZ6VotjbU/Y Le48fcli0bx4PZvF+fMb2C1mnN/HZLFoWSuzxdojd9kttp38xuLA6bF4z0smj02rOtk89s9d w+7Rt2UVo8fnTXIBrFFcNimpOZllqUX6dglcGV8W32IteK9U0T8hqIHxnlwXIyeHhICJxK8P y5hBbCGBFYwSCxbKdDFyAdmfGSVad3SzdzFyQBQ9doGIL2OU2Hb9KAuE859RYt3ryWDdbAKG El1vu9hAbBEBB4klS++wgRQxC8xhkphx6QE7SEJYIFri7q1pYEUsAqoSq05+ZwWxeQVsJY4t PcQKcZK8xOoNB5hBmiUE/rJKPL4+lw0i4SKxYcd3KFtG4vLkbhaIomZGiYfn1rJDOD2MEpeb ZjBCVFlLHD5+EWwsswCfxKRt05khHuKV6GgTgjA9JPbclID4P1ZizpV3zBMYxRcwMqxiFE8t Lc5NTy02zkst1ytOzC0uzUvXS87P3cQIjLDT/45/3cG470/SIUYBDkYlHt4PErNihFgTy4or cw8xSnAwK4nwPhGdESPEm5JYWZValB9fVJqTWnyIUZqDRUmct5rhQbSQQHpiSWp2ampBahFM lomDU6qBMYLB7XKI+w7/sFVb5YU5frhW7f3SuLXmyoH93/Jf2X9QrAmLX/qPdaZ664J7hxMu B+S5sqk15NUY2vFXleeazd8/f/8P/bisbDNbb92679IiikstF1//WzrTKfCG3E+GPZ+0Zp6r kH7wZH8+y4zTKU5FXJOnx3wRuNB78m6p5pwT3z+8LNtRocRSnJFoqMVcVJwIAEwDdwisAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBJMWRmVeSWpSXmKPExsVy+t/xy7qHPWbHGGxZIWyxccZ6VotjbU/Y Le48fcli0bx4PZvF+fMb2C1mnN/HZLFoWSuzxdojd9kttp38xuLA6bF4z0smj02rOtk89s9d w+7Rt2UVo8fnTXIBrFFcNimpOZllqUX6dglcGV8W32IteK9U0T8hqIHxnlwXIweHhICJxK/H Ll2MXBxCAksYJTbNPsIK4TQySXyd+4C5i5GTg03AUKLrbRcbiC0i4CCxZOkdNpAiZoF5TBKz 509iBEkIC0RL3L01DayIRUBVYtXJ76wgNq+ArcSxpYfAbAkBeYnVGw4wT2DkWsDIsIpRJLW0 ODc9t9hIrzgxt7g0L10vOT93EyMwPLYd+7llB2PXu+BDjAIcjEo8vB7Ss2KEWBPLiitzDzFK cDArifA+EZ0RI8SbklhZlVqUH19UmpNafIhRmoNFSZz3vEFllJBAemJJanZqakFqEUyWiYNT qoEx38tNJmamwpUNVy60sM29VHDvSE3DTX+9BbkrNrYwOsjv3WW76iiH/o3MK4HFGbx872Y/ ey2vmaN/3sh+eeltpZgdUz0/zwlqyTC9sXOCLueSbSEtTJZ9dx/Ee8XozTif7ZG6LPDBcX4B hY1yMst+/P2k0NN1ZU14h+phlmmM5WVLXp9n62dVYinOSDTUYi4qTgQA2dtvyAsCAAA= X-CMS-MailID: 20190327095619eucas1p12349c49c92d05329920a4ff931e763be CMS-TYPE: 201P X-CMS-RootMailID: 20190327095619eucas1p12349c49c92d05329920a4ff931e763be References: Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@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) ... Fixes: 01c10880d242 ("usb: dwc3: gadget: synchronize_irq dwc irq in suspend") Signed-off-by: Marek Szyprowski --- v2: added 'Fixes' tag --- 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; }