From patchwork Wed Apr 6 08:22:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaewon Kim X-Patchwork-Id: 12802692 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 568EEC433F5 for ; Wed, 6 Apr 2022 08:19:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:References:MIME-Version:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Dm//qXdqHuAw3lzxpwL9oh/8gZe4dnUls4pIfIN1CN4=; b=nH24V6uk5/d/gU qP/wEwOkLCryWeKa6jHLCwQ/KvpCsdl+dJ5uDn7K25yc1feimgOgCwEcSsCk54kVeWn/dIxwbngyV GEVL/O1mtb5LHxSAHu/5TBrjeA2tJfJkvAPOQbLtBehQNvC1rF82I7mFYABlAoeCopP6HzZOaCNgx CHADVZ46cv4RDuQopq6sD8Vvq5vH8acjt/FWa1kg6MDuKRTVRet0i3LUjwRrGq+1e4E/XQnDyHtqz frI43AMfybJ95d4JIMHbC3AHBfaOhtkZHtfosjHsJKGIL/RNi28Rwi5jPgMXwYah9E/SXYETF1+yy 9N7M5zNtL6z6irWf/2Mg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc0s9-004dzO-PK; Wed, 06 Apr 2022 08:18:37 +0000 Received: from mailout3.samsung.com ([203.254.224.33]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nc0s4-004dw4-BZ for linux-arm-kernel@lists.infradead.org; Wed, 06 Apr 2022 08:18:35 +0000 Received: from epcas2p3.samsung.com (unknown [182.195.41.55]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20220406081827epoutp03b7ffcbe0fcd2ed38cc43269204fd3e05~jQMXfB0Zl1913419134epoutp03d for ; Wed, 6 Apr 2022 08:18:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20220406081827epoutp03b7ffcbe0fcd2ed38cc43269204fd3e05~jQMXfB0Zl1913419134epoutp03d DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1649233107; bh=pZ68lE/yVojdDH0LXtiSiATpeoPKm9HOHcGFlaOhWAo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k31NT6S+v+reWpc0rMoGz1Qow2lqCWqoSg5LeaxqkWaW6Jc9jutbpRxfJ24wSP/tV bo3hE6XmYmYnfq0eK0yGEHpzS2zf90obmolqVy7LG/6TFyIezJXB5GAgMZILaeaMj3 Fs9C9bMJooL9TW90ga6mr5xITQLtS3AtzM9EMLuw= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas2p4.samsung.com (KnoxPortal) with ESMTP id 20220406081826epcas2p4c69bea871ea256d610ba66a73c2ed872~jQMXJl8IV2886628866epcas2p4L; Wed, 6 Apr 2022 08:18:26 +0000 (GMT) Received: from epsmges2p3.samsung.com (unknown [182.195.36.89]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4KYHTF2KFfz4x9Q0; Wed, 6 Apr 2022 08:18:25 +0000 (GMT) Received: from epcas2p2.samsung.com ( [182.195.41.54]) by epsmges2p3.samsung.com (Symantec Messaging Gateway) with SMTP id 41.37.25540.0DC4D426; Wed, 6 Apr 2022 17:18:24 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas2p2.samsung.com (KnoxPortal) with ESMTPA id 20220406081823epcas2p2f7afa27e2402c4fc02c9bee5972bed4f~jQMUbDwbC1713417134epcas2p2K; Wed, 6 Apr 2022 08:18:23 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220406081823epsmtrp19183c8d1a985530de3d2a5eba5063025~jQMUaL53y1921919219epsmtrp1m; Wed, 6 Apr 2022 08:18:23 +0000 (GMT) X-AuditID: b6c32a47-831ff700000063c4-e2-624d4cd0a85f Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 21.1C.03370.FCC4D426; Wed, 6 Apr 2022 17:18:23 +0900 (KST) Received: from localhost.localdomain (unknown [10.229.9.51]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220406081823epsmtip11172b4e3fe7884a960870fbe196feaa6~jQMULi29s2148221482epsmtip1x; Wed, 6 Apr 2022 08:18:23 +0000 (GMT) From: Jaewon Kim To: Krzysztof Kozlowski , Greg Kroah-Hartman , Alim Akhtar , Jiri Slaby , linux-samsung-soc@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Chanho Park , Jaewon Kim Subject: [PATCH 1/1] tty: serial: samsung: add spin_lock for interrupt and console_write Date: Wed, 6 Apr 2022 17:22:16 +0900 Message-Id: <20220406082216.11206-2-jaewon02.kim@samsung.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220406082216.11206-1-jaewon02.kim@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprFJsWRmVeSWpSXmKPExsWy7bCmme4FH98kg6/9PBYP5m1js7i8X9ui efF6NosdDUdYLd7NlbE4f34Du8Wmx9dYLS7vmsNmMeP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MailID: 20220406081823epcas2p2f7afa27e2402c4fc02c9bee5972bed4f X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220406081823epcas2p2f7afa27e2402c4fc02c9bee5972bed4f References: <20220406082216.11206-1-jaewon02.kim@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220406_011833_068748_E6DEA0AC X-CRM114-Status: GOOD ( 17.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The console_write and IRQ handler can run concurrently. Problems may occurs console_write is continuously executed while the IRQ handler is running. Signed-off-by: Jaewon Kim --- drivers/tty/serial/samsung_tty.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c index e1585fbae909..9db479d728b5 100644 --- a/drivers/tty/serial/samsung_tty.c +++ b/drivers/tty/serial/samsung_tty.c @@ -2480,12 +2480,24 @@ s3c24xx_serial_console_write(struct console *co, const char *s, unsigned int count) { unsigned int ucon = rd_regl(cons_uart, S3C2410_UCON); + unsigned long flags; + bool locked = 1; /* not possible to xmit on unconfigured port */ if (!s3c24xx_port_configured(ucon)) return; + if (cons_uart->sysrq) + locked = 0; + else if (oops_in_progress) + locked = spin_trylock_irqsave(&cons_uart->lock, flags); + else + spin_lock_irqsave(&cons_uart->lock, flags); + uart_console_write(cons_uart, s, count, s3c24xx_serial_console_putchar); + + if (locked) + spin_unlock_irqrestore(&cons_uart->lock, flags); } /* Shouldn't be __init, as it can be instantiated from other module */