From patchwork Tue Mar 10 06:59:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 11428583 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2B1EF14B7 for ; Tue, 10 Mar 2020 06:59:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0B33B24684 for ; Tue, 10 Mar 2020 06:59:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583823584; bh=cmbgetZfb6P+3CdH0q8rIWefP0yljF8X4Bt3d4dAjCc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=IoS36lNG2sX/By1TutOQ2sE6NEEvGcWI/wZ6uGtsQqtjiItRmjiHrdlTGv2vKyJQs XLeMZF7u2glX0KA4AO4G9vvLWLnAxC5+iIVsTM7/8d2fHEi0fVy81WrWAfFPDYChyi 8YUTgHeDa2XwyLiPOdhODB+5qa+j1Dwm9Ov+1gvE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726211AbgCJG7n (ORCPT ); Tue, 10 Mar 2020 02:59:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:35812 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725919AbgCJG7m (ORCPT ); Tue, 10 Mar 2020 02:59:42 -0400 Received: from localhost.localdomain (unknown [180.171.74.255]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7E20A2467C; Tue, 10 Mar 2020 06:59:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583823582; bh=cmbgetZfb6P+3CdH0q8rIWefP0yljF8X4Bt3d4dAjCc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K2P5OD7b8gjsTNi5sZjdMR0Ih/opDfViJrh9b5F0LfuOCUFdpD6rJfplp88aClsjt X/YQUWfu1/V7M+BJG+9GrGJSS+YwzUK3/ByR1brMlprTAPGxtyDZdcvkMwapBTjjuO LzZBspAmactf8uA/OzwcDtvyBjoG+m23J59mYAb4= From: Peter Chen To: gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, Peter Chen , stable@vger.kernel.org Subject: [PATCH 1/1] usb: chipidea: udc: fix sleeping function called from invalid context Date: Tue, 10 Mar 2020 14:59:26 +0800 Message-Id: <20200310065926.17746-2-peter.chen@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200310065926.17746-1-peter.chen@kernel.org> References: <20200310065926.17746-1-peter.chen@kernel.org> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Peter Chen The code calls pm_runtime_get_sync with irq disabled, it causes below warning: BUG: sleeping function called from invalid context at wer/runtime.c:1075 in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid: er/u8:1 CPU: 1 PID: 37 Comm: kworker/u8:1 Not tainted 20200304-00181-gbebfd2a5be98 #1588 Hardware name: NVIDIA Tegra SoC (Flattened Device Tree) Workqueue: ci_otg ci_otg_work [] (unwind_backtrace) from [] 1/0x14) [] (show_stack) from [] 5/0x94) [] (dump_stack) from [] +0xeb/0x118) [] (___might_sleep) from [] esume+0x75/0x78) [] (__pm_runtime_resume) from [] 0x23/0x74) [] (ci_udc_pullup) from [] nect+0x2b/0xcc) [] (usb_gadget_connect) from [] _connect+0x59/0x104) [] (ci_hdrc_gadget_connect) from [] ssion+0x43/0x48) [] (ci_udc_vbus_session) from [] s_connect+0x17/0x9c) [] (usb_gadget_vbus_connect) from [] bd/0x128) [] (ci_otg_work) from [] rk+0x149/0x404) [] (process_one_work) from [] 0xf7/0x3bc) [] (worker_thread) from [] x118) [] (kthread) from [] (ret_from_fork+0x11/0x34) Tested-by: Dmitry Osipenko Cc: #v5.5 Fixes: 72dc8df7920f ("usb: chipidea: udc: protect usb interrupt enable") Reported-by: Dmitry Osipenko Signed-off-by: Peter Chen --- drivers/usb/chipidea/udc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index ffaf46f5d062..1fa587ec52fc 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c @@ -1539,9 +1539,11 @@ static void ci_hdrc_gadget_connect(struct usb_gadget *_gadget, int is_active) if (ci->driver) { hw_device_state(ci, ci->ep0out->qh.dma); usb_gadget_set_state(_gadget, USB_STATE_POWERED); + spin_unlock_irqrestore(&ci->lock, flags); usb_udc_vbus_handler(_gadget, true); + } else { + spin_unlock_irqrestore(&ci->lock, flags); } - spin_unlock_irqrestore(&ci->lock, flags); } else { usb_udc_vbus_handler(_gadget, false); if (ci->driver)