From patchwork Tue Apr 5 03:38:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaewon Kim X-Patchwork-Id: 12801011 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 43CF6C433EF for ; Tue, 5 Apr 2022 03:36:38 +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=uGbKlzGdDGulUlZ4LhDoxwfOk0GoolkcMDEGJfPwb3k=; b=FxDP8Zy389a+YR S/oNctlTXgZ2bK4cngQIPTOmGt/55geC6XmqbgKKqv41LiXeTxr+pPrxPVuZw1BtYl4uwTDAGQ+Dj EfWorVPPSIrxQsH0m1W+uY1OW8LbnsTmUiRWDSBsNDWs8v27QZpXoiR3NfmkcG6PbB/0KIdChaGjk g17koyPR0ejz/NtfYzAQZ63Ipi32adyr6OkJOjFbM7/2ajWHJ4PT5LtmtGjo7LJgIruXR7ccQpf6c 4wMzm6+1FTS+8iKNrCArCybOXnxqnzzlBV8g6Bjhz0jGRu4q0EQcNaZux0LJ1Bux491L9PaY+gUZx pTkEaZpMPmndwPN+7StQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nbZyN-00H1Mg-1g; Tue, 05 Apr 2022 03:35:15 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nbZyB-00H1I0-2N for linux-arm-kernel@lists.infradead.org; Tue, 05 Apr 2022 03:35:04 +0000 Received: from epcas2p3.samsung.com (unknown [182.195.41.55]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20220405033455epoutp01df238ce8ea4400124d5318aa357984d8~i4rhf_a6o1539515395epoutp01s for ; Tue, 5 Apr 2022 03:34:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20220405033455epoutp01df238ce8ea4400124d5318aa357984d8~i4rhf_a6o1539515395epoutp01s DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1649129695; bh=CKTKAhXTaSx818utW4r9R7NQFknJNHgDoVip59njvEw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PaZJYMkVYO9PT1djcso0sVT7G4l0lk5xddDLzi5RcDlZW8nN+FX/NUivvnJitQgn+ 0GTakD1V/wsnY5F0WfebyoDI1m2ST0qWUxAbxWRgLfxnqizOHUWETbg0EaK4SmZn/G VQPifUkDjrffQB4Foi4EY56TVFbenxoRQauJLod8= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas2p2.samsung.com (KnoxPortal) with ESMTP id 20220405033454epcas2p20c8c15c5d6c17d6d5c65ee844359d970~i4rhK1ujC2545725457epcas2p2P; Tue, 5 Apr 2022 03:34:54 +0000 (GMT) Received: from epsmges2p2.samsung.com (unknown [182.195.36.99]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4KXYDY2jssz4x9Q9; Tue, 5 Apr 2022 03:34:53 +0000 (GMT) Received: from epcas2p2.samsung.com ( [182.195.41.54]) by epsmges2p2.samsung.com (Symantec Messaging Gateway) with SMTP id 0B.F4.16040.9D8BB426; Tue, 5 Apr 2022 12:34:49 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas2p3.samsung.com (KnoxPortal) with ESMTPA id 20220405033448epcas2p397080e15c54369d24eaf94c2a27bd06c~i4rbwDbjo2389723897epcas2p3d; Tue, 5 Apr 2022 03:34:48 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220405033448epsmtrp29b3065ec2163fe09f31a320f899fc47f~i4rbvKhax2074420744epsmtrp2U; Tue, 5 Apr 2022 03:34:48 +0000 (GMT) X-AuditID: b6c32a46-bffff70000023ea8-4a-624bb8d933b8 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 8A.95.03370.8D8BB426; Tue, 5 Apr 2022 12:34:48 +0900 (KST) Received: from localhost.localdomain (unknown [10.229.9.51]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220405033448epsmtip2cbcbbdfff2c9e41e4affa517ea08a2dd~i4rbd6IhO0865608656epsmtip2e; Tue, 5 Apr 2022 03:34:48 +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: Tue, 5 Apr 2022 12:38:54 +0900 Message-Id: <20220405033854.110374-2-jaewon02.kim@samsung.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405033854.110374-1-jaewon02.kim@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprBJsWRmVeSWpSXmKPExsWy7bCmme7NHd5JBie281k8mLeNzeLyfm2L 5sXr2Sx2NBxhtXg3V8bi/PkN7BabHl9jtbi8aw6bxYzz+5gsziz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epcas2p397080e15c54369d24eaf94c2a27bd06c X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220405033448epcas2p397080e15c54369d24eaf94c2a27bd06c References: <20220405033854.110374-1-jaewon02.kim@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220404_203503_584570_3A126F16 X-CRM114-Status: GOOD ( 19.29 ) 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 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c index e1585fbae909..d362e8e114f1 100644 --- a/drivers/tty/serial/samsung_tty.c +++ b/drivers/tty/serial/samsung_tty.c @@ -2480,12 +2480,26 @@ 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; + int locked = 1; /* not possible to xmit on unconfigured port */ if (!s3c24xx_port_configured(ucon)) return; + local_irq_save(flags); + if (cons_uart->sysrq) + locked = 0; + else if (oops_in_progress) + locked = spin_trylock(&cons_uart->lock); + else + spin_lock(&cons_uart->lock); + uart_console_write(cons_uart, s, count, s3c24xx_serial_console_putchar); + + if (locked) + spin_unlock(&cons_uart->lock); + local_irq_restore(flags); } /* Shouldn't be __init, as it can be instantiated from other module */