Received: by 2002:aa6:c429:0:b029:98:93ff:f56f with SMTP id g9csp3384544lkq; Mon, 23 Nov 2020 04:28:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJwZQwTl5VuYSy5zPHSMCIvL8GAMvkfk01KsBBEcuVSerq7kinXRPHue5EP5BfSzZtKMKhTX X-Received: by 2002:a17:906:e24d:: with SMTP id gq13mr26887696ejb.262.1606134511888; Mon, 23 Nov 2020 04:28:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606134511; cv=none; d=google.com; s=arc-20160816; b=LNUA7ldL+hYcVJ1IS9ZhRNR++U8nbnPVlNAojle4vyutbYkiQAT1Li2XOF2n5B41zh 3GqdONeQtE8WjuOVATKe0NXO9PnROhqYTmmASzWOiXVTmT8gOT9erpouRyGpx6byBC61 gBH+XvXynMApuAPs2UPnFPzQNidojYuMY3YxUNs6/cJxCrbIz/TD0wFQUCp8WZNiMibb skvcIkQ/lUJRpF6lFgd4A0hJB48fjuezD6s1oBQ6TMKtNE94UWWA6gmrvHpwXZADzwHO s56LFpaV/ew8WVKM2EX9PBj5uwleOY0DgML7/wbm09QSAsxxTvaBkXCF2DlvqXXBAH57 92mA== 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=Z4SUOEJMiKrJ9TG6cUYZeTLfNvFMK7zIBdSPvQ0SJWQ=; b=cqiOC2xVDm4RNcXu12DZmnWe9HHjc1jxZOoFcYoHrkdb/T05qOs99w9MRSJc8G+ieL AX2ewmjeK7/ejT8eVsI2+eJFvcmOB1IobaSCIlkWNnftY93DYefsvQs+D+NBKe+Csk4j zWHCJqqB2SV1DS9GhvFa5h/0puByVt3kGWTytHebUnWV3hZt8bTZELqQlgvnvTqNE55v t4kTlEphvr5bbMmNE673fM+4PaQ+hicYgE3RxrAht8Zi1tLLnv0oI1wb5vAg7aXD93Xb KzmtMijqXf0UoZ9T5rcGz7NmTcXO3LU18k/GFBFQxMSYLA9FBdlID7KBmcR1CC0qxdz9 w/0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jDE4BRZO; 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 r4si7506004edc.537.2020.11.23.04.28.09; Mon, 23 Nov 2020 04:28:31 -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=jDE4BRZO; 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 S1729636AbgKWMXh (ORCPT + 99 others); Mon, 23 Nov 2020 07:23:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:60918 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729628AbgKWMXf (ORCPT ); Mon, 23 Nov 2020 07:23:35 -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 CE08820728; Mon, 23 Nov 2020 12:23:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606134214; bh=bqw6qU+5X5MmwD9qU7kwwgdLK1D7iiI5JKFbbpQqt1c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jDE4BRZOx/wCt3VDeSuWzhOxfo3iXI9XbZErcE/8mCQIC7kv4uR3TiKzyfDCZJpAb uLyC/uJHgDv7jaXrHV3GhskcK9yIrxSRABWbNa8CG++SEaaiorCwJ2rK7MhL/8swwr p/faDL5q5nfDZqjindKrbje5XTFFSakVFnXExyqo= 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.4 29/38] tty: serial: imx: keep console clocks always on Date: Mon, 23 Nov 2020 13:22:15 +0100 Message-Id: <20201123121805.699690339@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121804.306030358@linuxfoundation.org> References: <20201123121804.306030358@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 @@ -1628,16 +1628,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; @@ -1673,9 +1663,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); } /* @@ -1776,15 +1763,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;