Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp309307ybi; Wed, 29 May 2019 21:59:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqxyjGw6qWsROYmgIvvUpWwEteOK4wJDt3SVWWqk7KMwbAVjJJKYE6qczN0hRmrVgqQKFHA3 X-Received: by 2002:a17:902:4481:: with SMTP id l1mr2003893pld.121.1559192388163; Wed, 29 May 2019 21:59:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559192388; cv=none; d=google.com; s=arc-20160816; b=BS2nfWXbunTBqPVESFLelU48ZuhVaRAOlFf5P4NZbhiT4hBYP7kWMfZXGhKSGmftkw UrJFY4JXwT2D2EMV5FupM888essQ8mTyn+Ot1q4qNMNbI+xbbqUtqcjVtmQgOQrg30ln 71Frea5f/W0KeLm2u8iZV9n2ll9s1GISujW9+Yte9MSYM/VENPnBrBhXNITPyuIlkFaa iij6CWcp+Z3HkAXj8TJ8EcNjVgzr4CGkjcci8J+zhWdtbJMzi8JNLIbsoqqTf0loji39 WXF/cHKLaWbcfc2T1cu96rDXcQ4tXRZC9PNlEAYU51NvK5EpWr68JDzK6R31p3DuJ79w cBtQ== 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=2JL1hkwG01uI5JbzcO7Ce/IuYRKB4OojlhykQHpd0IU=; b=MH5RRK/UZ/aKThpXiFHv8ou1pezHcHA+5d7djzmWfdL/zEo3UmfFOOcyYZ0GPFpucu DflOum6zR/kaAeqpBILhcypoRIxkIttumw4AiG5vKcMauzIT6PXueWL/GEdh2gF839SC w4Wp2vBuJ/Foc+wWF0/7p2q6oegRtjm+PKAX7bg2KpAJAv5+pzCSCEHKH7oVPAqi1222 l0lLa95Y8caN8NDlZ+qpvxBGQMDT8nQDDYM/lL7UvMF617kF219YnU+1pORzXBdbhci0 oyvEs112g4cqdIZ+HdECijJD3vvEnNBP/YrkAq8j4fkEW23OestBmjYYtMQno0LLLUVF bGQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FuLboCVi; 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 n31si510444pjc.5.2019.05.29.21.59.32; Wed, 29 May 2019 21:59:48 -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=FuLboCVi; 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 S1729981AbfE3E5d (ORCPT + 99 others); Thu, 30 May 2019 00:57:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:45638 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727856AbfE3DJ4 (ORCPT ); Wed, 29 May 2019 23:09:56 -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 A498C24493; Thu, 30 May 2019 03:09:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559185795; bh=e7YpTiI/R85tFaDldvpcVyKXKZReWeOqdmOkGxnT2Q8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FuLboCVibiVk44/JLL43f56dCG1aGBBVtpNOWOGw55Es0Ed1oUxNgjmL1yjSfWRfb X8JENA72lzfq4YBcNYn3xZLoJboIbvQ4JC/tHy/QVcokhNRPdtkkkFrc/Wyb7KdlTP S0gTlsikM5lthzPi3GXXLNvyNRkx44FPT77iWuXA= 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 5.1 071/405] usb: dwc3: move synchronize_irq() out of the spinlock protected block Date: Wed, 29 May 2019 20:01:09 -0700 Message-Id: <20190530030544.519906721@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030540.291644921@linuxfoundation.org> References: <20190530030540.291644921@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 f944cea4056bc..72110a8c49d68 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 e293400cc6e95..2bb0ff9608d30 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; } -- 2.20.1