Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp252404ybi; Wed, 29 May 2019 20:41:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqzC2IsPSEAhzG3M/i7FnRO/21yG8mrsknrZfluzrGA4Ixltum6ZOIbuArJ7aJmt7//kYZLp X-Received: by 2002:a63:4419:: with SMTP id r25mr1778420pga.247.1559187703269; Wed, 29 May 2019 20:41:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559187703; cv=none; d=google.com; s=arc-20160816; b=YG3CAuS6CSPh0xl+XcOqXt1ZeKjmm9y7YK0wIHGsYPYFTLrpN1eA7OvtwmFpFCNr4c KMwckc/r32vqTeTH3NvqG7LsWKiCoUPzFK0V4K6KEy1KzmA732HJunsyzy2ENARPvzcd 3x5u3/rWsFhRljtlq4qoTWTMgpKbM4HkAGaYtZNbdLDt0EpcCNrKVnR2lJleCI3NUEpO zp7d3HyA9DKEAu8KBGwsegETBBsxvt+uzDY7YRtqJVKYtUOWooXQk8ubg/hEI4PPHffq suZ/g8U/9JTVbN0yCoAxsK28TDFL0dwJohO9RYyDHvqwni0vt6UdLnvBntPoeo+q3Xcc IEaQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/QvQUilFMptJtGokR3tc1dpOfN6XnmhoiObylo60H2E=; b=a1y9ubueoI3T29ktNrabLH0q6dGcFwu7WWUGA2HM7jSa8AZzL2H9c/WUWDEBQA8w+7 op83ohqAO4NQwKhLB1FXp1+05ZAp3iftg2E/0zGwVC/RP+IMT4AFCFswIXQnWxfKC9Fc MVdTY62fgJCbJAbH+Vh4BX4wJTrMhZ4kRvFWfkxHEHflLrbPFiv4WPK1nOh01HZT0Ss5 hAvoUgidw1x+lMPNNbCYKk4D6jikjjj+QPfcC6iD5TfNDYpW7iSMThQ/jJwru0Ufcdfq BjUPXF2CetBFYNfIHkUEH4eZt2JH2dokHGIMHyF+8bceFhBPugHCCaeoTOp/nhsTc5ne sUFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="xMgLg/NI"; 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 f3si2063749pld.434.2019.05.29.20.41.27; Wed, 29 May 2019 20:41:43 -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; dkim=pass header.i=@kernel.org header.s=default header.b="xMgLg/NI"; 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 S1732631AbfE3DVq (ORCPT + 99 others); Wed, 29 May 2019 23:21:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:42876 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729737AbfE3DQb (ORCPT ); Wed, 29 May 2019 23:16:31 -0400 Received: from localhost (ip67-88-213-2.z213-88-67.customer.algx.net [67.88.213.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A6982245F0; Thu, 30 May 2019 03:16:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186190; bh=zFoYtjp+vrdzECkq2amQa9VEnWcjeeYiyR/YZRoQRLg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xMgLg/NIxiCyHVY4nj6mI/M+k5RQyT/mCLsjfRrWGI190UL6Gz5xQtVqYnaq/eITx 9GeQdfSeTcJvQ82BuF8+TOMjSIzqRGAgzj8s1f3a2wOYdwckx1/BCeI4FZJcp3VD8w 0hemKDciyLh9T/8X+1JDJTwt/nYfUYrtoj7U4p/I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marek Szyprowski , Felipe Balbi , Sasha Levin Subject: [PATCH 4.19 060/276] usb: dwc3: move synchronize_irq() out of the spinlock protected block Date: Wed, 29 May 2019 20:03:38 -0700 Message-Id: <20190530030529.391703364@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030523.133519668@linuxfoundation.org> References: <20190530030523.133519668@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 41a91c606e7d2b74358a944525267cc451c271e8 ] 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 Signed-off-by: Felipe Balbi Signed-off-by: Sasha Levin --- 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 4d5c7dda8f54d..05b9ccff7447a 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1591,6 +1591,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: @@ -1623,6 +1624,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 524104eed8a71..65ba1038b1111 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -3277,8 +3277,6 @@ int dwc3_gadget_suspend(struct dwc3 *dwc) dwc3_disconnect_gadget(dwc); __dwc3_gadget_stop(dwc); - synchronize_irq(dwc->irq_gadget); - return 0; } -- 2.20.1