Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp841363pxu; Mon, 23 Nov 2020 05:38:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJyRrrjhDHhxMQG4QGleK6GHPe0RbvEI2nxZOQOnuKQ3JhLmnfn/02t6ECzg+/RjN730e25v X-Received: by 2002:a17:906:4e90:: with SMTP id v16mr45825518eju.477.1606138730242; Mon, 23 Nov 2020 05:38:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606138730; cv=none; d=google.com; s=arc-20160816; b=lFfztPEcvERfd/4s2yu1D2D1f39d/wUzuJDasbgls7Xl929n/3Zhwz87IosQHr1q1K a3uQijovyZrJI5RUK/p4LvW7il3uTTOj7nTqHdboNoBIgE0zJAshn9xPrU1TzL6rdOGG BeDki8xJRN49uLhMcUmMtn6Hp1Q04CisxAqUgSBwOcpAEf4O4EVguuDafP9++FTG/knw KIWCpMjPBaLFkVfjjK5PTQTD/RAjz5u1D4YqSFISnVGXZAL6+T9HwdzVa2a/sb03V48O 4q2T3KNjX7ltcGOPVWkny/tz1ZZb0rHHXsBiC+JKlGrgmtYdHPAqsqRP+PmghCE9p9J8 DJsQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XlJvWFMZJBvV7z1TYmLeLpqVWZItAZe62milnxWVbOk=; b=0HpaAhlxXx0zESZpoIW2DPJmMo5TiSf5rtA5oOZtia2DBOjEOm8AJlAwnhZusbJWSV m8mU93bs9/HSFRn4jNloBMaZIMzJkSjmQj3+D/hk8xZxpt7g+rJxG/vXa26VWjam43do GUdsL0sWWe93KhyxhFFpmJUUqqvWAji3G42oUk5rMgp0rUr4bDjJ7XEpYfw+awws4EBc Wj+w4AJ1FuPXbcG5LtihV2ZCjrne5riTlZl84RBtVzQPrRLFHOSqrh+F8EyxJOwQHYCK sWr5UJYXRUdSjY2zWPbdzq/NsyjPLpFJaU4RbzoxopZdd2Bia+FswrjO2zufQUcR91LK ObzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0dolPQ8H; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cc8si6833998edb.163.2020.11.23.05.38.27; Mon, 23 Nov 2020 05:38:50 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=0dolPQ8H; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730842AbgKWNdm (ORCPT + 99 others); Mon, 23 Nov 2020 08:33:42 -0500 Received: from mail.kernel.org ([198.145.29.99]:35344 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730040AbgKWMZp (ORCPT ); Mon, 23 Nov 2020 07:25:45 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 BA11C208C3; Mon, 23 Nov 2020 12:25:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606134343; bh=beepN1enpIkIqzm43BzJnt/q7Dpf/K7nNG/A2pLSkbo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0dolPQ8HoJ8FRjKrYrKf8j/MV8ecOpbKtQYTSmcqkGPVle3vybMTETD/iDZv/pv7H vZAoPTB2fk4LeXDQPWOrTk74SPPTf4rH7FsmCkgbq6N+ghtSuiden5EfTykndGFbHR FWMXffydJDCu7UkEDl/aHluXLWw2py+AdPZ76nbA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Fugang Duan Subject: [PATCH 4.9 37/47] tty: serial: imx: keep console clocks always on Date: Mon, 23 Nov 2020 13:22:23 +0100 Message-Id: <20201123121807.348822035@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121805.530891002@linuxfoundation.org> References: <20201123121805.530891002@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fugang Duan commit e67c139c488e84e7eae6c333231e791f0e89b3fb upstream. For below code, there has chance to cause deadlock in SMP system: Thread 1: clk_enable_lock(); pr_info("debug message"); clk_enable_unlock(); Thread 2: imx_uart_console_write() clk_enable() clk_enable_lock(); Thread 1: Acuired clk enable_lock -> printk -> console_trylock_spinning Thread 2: console_unlock() -> imx_uart_console_write -> clk_disable -> Acquite clk enable_lock So the patch is to keep console port clocks always on like other console drivers. Fixes: 1cf93e0d5488 ("serial: imx: remove the uart_console() check") Acked-by: Uwe Kleine-König Signed-off-by: Fugang Duan Link: https://lore.kernel.org/r/20201111025136.29818-1-fugang.duan@nxp.com Cc: stable [fix up build warning - gregkh] Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/imx.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -1787,16 +1787,6 @@ imx_console_write(struct console *co, co unsigned int ucr1; unsigned long flags = 0; int locked = 1; - int retval; - - retval = clk_enable(sport->clk_per); - if (retval) - return; - retval = clk_enable(sport->clk_ipg); - if (retval) { - clk_disable(sport->clk_per); - return; - } if (sport->port.sysrq) locked = 0; @@ -1832,9 +1822,6 @@ imx_console_write(struct console *co, co if (locked) spin_unlock_irqrestore(&sport->port.lock, flags); - - clk_disable(sport->clk_ipg); - clk_disable(sport->clk_per); } /* @@ -1935,15 +1922,14 @@ imx_console_setup(struct console *co, ch retval = uart_set_options(&sport->port, co, baud, parity, bits, flow); - clk_disable(sport->clk_ipg); if (retval) { - clk_unprepare(sport->clk_ipg); + clk_disable_unprepare(sport->clk_ipg); goto error_console; } - retval = clk_prepare(sport->clk_per); + retval = clk_prepare_enable(sport->clk_per); if (retval) - clk_unprepare(sport->clk_ipg); + clk_disable_unprepare(sport->clk_ipg); error_console: return retval;