Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp853090pxk; Thu, 17 Sep 2020 19:07:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9hyPfzX8jeWyE/pUIXrkEse+m9Wa40Sawvr55FvsoQc8I+MYNgezfbJzALdNPVD+rzBul X-Received: by 2002:a17:906:4c42:: with SMTP id d2mr32632983ejw.506.1600394858695; Thu, 17 Sep 2020 19:07:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600394858; cv=none; d=google.com; s=arc-20160816; b=GOfz20wu377ahFT/s0vCiZjtmT9/A6K9VSUXPzklmbofvEwc+uKELweHNLH5VoMpZ3 Ope+ElexCXCIFqSrJf5dj0wCsesKd+pvGUIOyUjH/k4e03VGB6C/gD0XtIlQYDrEKhJV tWJm0ggrfTtXhSF5jPK3HTsL1kmsj1OPo5X17GhhsC7PC62QHJ7HBByYCGeBqy6S/jFE jE+G5QtisJHXBOtjDbplto5VUk6X8pGYftu+hL+3kV9RYElIWjxGloOXXjArT99R/PsE NTgNbkaN9ZIUTxx79Wai2eFLnftIxhT3UvpQIlLNjkuLevmmEeNqklwgdeiftaroOGMW rfeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IaV7MJ3t8aJyxe4kkkuZP+AugCNuXj4bhwfouPysiLA=; b=rbpcBSUF5NGmSeNMeHsoj8migZhXiK4tC3lHUYfHGO20h61WjSMlqLPYwYwtS5xmCy Y7pxP7+Rdx6dHtGvNTjZXtslkbZ25E8cAZvFOjV3jqJIg9f0lzrOhUEv8yiSosEki9Md iOgxLmRaJhQ9TR8O8F+x+wTGLoRt4h2bepqO+4yIVAvs/TZlvFnjvTySJ1voG5huyM5M HY2EH+axRYERaSuNjewSNZmlm0m0p9XlYEhtHZEE5sTcV3YN1tEaIgjTVzUxTm1r4+7T I2sBDBFowjZNmh19++Ri9YwLB79paBu1bTk8s4PGUHKmYJjZ59Y0jSgLun7frjiwURO4 VV6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YfrcGDm+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n17si1081068edq.422.2020.09.17.19.07.15; Thu, 17 Sep 2020 19:07:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YfrcGDm+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727460AbgIRCFK (ORCPT + 99 others); Thu, 17 Sep 2020 22:05:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:53058 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726735AbgIRCFG (ORCPT ); Thu, 17 Sep 2020 22:05:06 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (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 8AA442388E; Fri, 18 Sep 2020 02:05:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394705; bh=qlotgXebtLnYCKBlDgxBtcaePM7N4LilOIyoIeSPEOo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YfrcGDm+aLvRrSqsoNUa2ecGEElQaOFn8Q6s1ltt0TiGV2fwMjg/1sYImF4oV9Ceg sEL7uDUjiRtYoKiR/v7Pt73DycP2UVXJpPVWhFtad7BTGMm+036S2CwtOKMB9nk5ws Xq7WGa2gkc2lKUe2PDi3YqMHSs5Od4/zZZor6mic= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Peter Ujfalusi , Tomi Valkeinen , Greg Kroah-Hartman , Sasha Levin , linux-serial@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 191/330] serial: 8250_omap: Fix sleeping function called from invalid context during probe Date: Thu, 17 Sep 2020 21:58:51 -0400 Message-Id: <20200918020110.2063155-191-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Ujfalusi [ Upstream commit 4ce35a3617c0ac758c61122b2218b6c8c9ac9398 ] When booting j721e the following bug is printed: [ 1.154821] BUG: sleeping function called from invalid context at kernel/sched/completion.c:99 [ 1.154827] in_atomic(): 0, irqs_disabled(): 128, non_block: 0, pid: 12, name: kworker/0:1 [ 1.154832] 3 locks held by kworker/0:1/12: [ 1.154836] #0: ffff000840030728 ((wq_completion)events){+.+.}, at: process_one_work+0x1d4/0x6e8 [ 1.154852] #1: ffff80001214fdd8 (deferred_probe_work){+.+.}, at: process_one_work+0x1d4/0x6e8 [ 1.154860] #2: ffff00084060b170 (&dev->mutex){....}, at: __device_attach+0x38/0x138 [ 1.154872] irq event stamp: 63096 [ 1.154881] hardirqs last enabled at (63095): [] _raw_spin_unlock_irqrestore+0x70/0x78 [ 1.154887] hardirqs last disabled at (63096): [] _raw_spin_lock_irqsave+0x28/0x80 [ 1.154893] softirqs last enabled at (62254): [] _stext+0x488/0x564 [ 1.154899] softirqs last disabled at (62247): [] irq_exit+0x114/0x140 [ 1.154906] CPU: 0 PID: 12 Comm: kworker/0:1 Not tainted 5.6.0-rc6-next-20200318-00094-g45e4089b0bd3 #221 [ 1.154911] Hardware name: Texas Instruments K3 J721E SoC (DT) [ 1.154917] Workqueue: events deferred_probe_work_func [ 1.154923] Call trace: [ 1.154928] dump_backtrace+0x0/0x190 [ 1.154933] show_stack+0x14/0x20 [ 1.154940] dump_stack+0xe0/0x148 [ 1.154946] ___might_sleep+0x150/0x1f0 [ 1.154952] __might_sleep+0x4c/0x80 [ 1.154957] wait_for_completion_timeout+0x40/0x140 [ 1.154964] ti_sci_set_device_state+0xa0/0x158 [ 1.154969] ti_sci_cmd_get_device_exclusive+0x14/0x20 [ 1.154977] ti_sci_dev_start+0x34/0x50 [ 1.154984] genpd_runtime_resume+0x78/0x1f8 [ 1.154991] __rpm_callback+0x3c/0x140 [ 1.154996] rpm_callback+0x20/0x80 [ 1.155001] rpm_resume+0x568/0x758 [ 1.155007] __pm_runtime_resume+0x44/0xb0 [ 1.155013] omap8250_probe+0x2b4/0x508 [ 1.155019] platform_drv_probe+0x50/0xa0 [ 1.155023] really_probe+0xd4/0x318 [ 1.155028] driver_probe_device+0x54/0xe8 [ 1.155033] __device_attach_driver+0x80/0xb8 [ 1.155039] bus_for_each_drv+0x74/0xc0 [ 1.155044] __device_attach+0xdc/0x138 [ 1.155049] device_initial_probe+0x10/0x18 [ 1.155053] bus_probe_device+0x98/0xa0 [ 1.155058] deferred_probe_work_func+0x74/0xb0 [ 1.155063] process_one_work+0x280/0x6e8 [ 1.155068] worker_thread+0x48/0x430 [ 1.155073] kthread+0x108/0x138 [ 1.155079] ret_from_fork+0x10/0x18 To fix the bug we need to first call pm_runtime_enable() prior to any pm_runtime calls. Reported-by: Tomi Valkeinen Signed-off-by: Peter Ujfalusi Link: https://lore.kernel.org/r/20200320125200.6772-1-peter.ujfalusi@ti.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/8250/8250_omap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c index 836e736ae188b..2624b5d083366 100644 --- a/drivers/tty/serial/8250/8250_omap.c +++ b/drivers/tty/serial/8250/8250_omap.c @@ -1234,6 +1234,7 @@ static int omap8250_probe(struct platform_device *pdev) spin_lock_init(&priv->rx_dma_lock); device_init_wakeup(&pdev->dev, true); + pm_runtime_enable(&pdev->dev); pm_runtime_use_autosuspend(&pdev->dev); /* @@ -1247,7 +1248,6 @@ static int omap8250_probe(struct platform_device *pdev) pm_runtime_set_autosuspend_delay(&pdev->dev, -1); pm_runtime_irq_safe(&pdev->dev); - pm_runtime_enable(&pdev->dev); pm_runtime_get_sync(&pdev->dev); -- 2.25.1