Received: by 2002:aa6:c429:0:b029:98:93ff:f56f with SMTP id g9csp3397727lkq; Mon, 23 Nov 2020 04:48:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJyTnrAtaMptqCCfhYIt9Xuz7ysPOKc2XBJxSOzn0r1vprfVHSgQfakZwoxHV+sDp50lAeib X-Received: by 2002:a50:f98b:: with SMTP id q11mr47913210edn.345.1606135716848; Mon, 23 Nov 2020 04:48:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606135716; cv=none; d=google.com; s=arc-20160816; b=RVK4mxqbMLR9HS+m2res+DchpdKlvTcAp2xJfaaWbGWAJeyScGkM6AHthsPCUAmZNG j4Ll3WF04UEEKcM+r7vvGjuWz9IcFyiStoQNra/B++K8V+O5mlLJmKxdMN9LoOtj2fQ+ bxzjlGwlzukEbhjByi1Xo7BpetgYh4ExMCgHe/HRJvk9GtUgcErnS8BTAjc20iFthNvW pob+SJiGLnJLVIC14bD0KOc2EsBZOTdo5lAy0m/KhnnQeqppsVsQdMouXNETceeG+ILk pQ42Q/M2rxo5GTnfgB6cagV8M4tQkNBJbUx0rBduLygcLldRBtKqIuaMNWENO604ua+s 8QSg== 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=cgtn/ELbZgcuB8QVAoersZ1vzMbPsk5cu+4+oYzf+NA=; b=J/R6CcrJPDN8+02TDzmKkk2ka4L6Kk+adK0mPPHkt+JLd3o8rU05Ro6SaWWkWECIGJ Sutgx7LZjiTk48GMPG7nO0DldtGKVtujXJwejLoMqQYlCzvtm7xDZBAZg3WCgMyLGJN/ lqnI9po60OYv8x606las/zMsWlG2uVKzXuWQwFZHSHHE6NpKnxuReHZYzYqCpNkUO6ow gkvFTbZIN0PcdiPP2PYdPNawnVoBe/nAom18PmH2mU9zypBY1oxHZD1CjDtDcL/Dsu7e UHxohbYGF7Pu7LLeN4A6eQxqajygU8F3t9cem/xGbCHzH/KyZPuVuI15PS1FgAkR3af6 G7Dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vvyyP28F; 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 cf25si6607446edb.205.2020.11.23.04.48.14; Mon, 23 Nov 2020 04:48:36 -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=vvyyP28F; 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 S1732520AbgKWMki (ORCPT + 99 others); Mon, 23 Nov 2020 07:40:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:53484 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732517AbgKWMkg (ORCPT ); Mon, 23 Nov 2020 07:40:36 -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 BF0CE20732; Mon, 23 Nov 2020 12:40:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606135236; bh=AmD7T3beoWo/DzHnBurLwTXjZxHiMjYyblxw0C8IgR8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vvyyP28FpgIEZvrYCoeijTj/cKR6wJa9cFqblAW4M9oxcX3dhH7z3qfmCBMjtSgpj lqY+QkqhW7cpL+uLf4PK/1h7aUXECkjh/Z7XZmn/NG/QCDyUV/F15QSIAVHlWF2PR2 L5tHHLd889Cn/UzE6S/E4b/M2p+9VNmGoyX9Kf8Y= 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 5.4 124/158] tty: serial: imx: keep console clocks always on Date: Mon, 23 Nov 2020 13:22:32 +0100 Message-Id: <20201123121825.914709199@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121819.943135899@linuxfoundation.org> References: <20201123121819.943135899@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 @@ -1942,16 +1942,6 @@ imx_uart_console_write(struct console *c 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; @@ -1987,9 +1977,6 @@ imx_uart_console_write(struct console *c if (locked) spin_unlock_irqrestore(&sport->port.lock, flags); - - clk_disable(sport->clk_ipg); - clk_disable(sport->clk_per); } /* @@ -2090,15 +2077,14 @@ imx_uart_console_setup(struct console *c 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;