Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3557393pxb; Mon, 4 Apr 2022 21:12:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxhJ+iprcQx+uKiHQbs665oM+lYt3wPzEtWLqAcy2kScdJOOXZOf2PptDwKhBweY2bJfiL X-Received: by 2002:a17:902:f789:b0:14e:ebbc:264b with SMTP id q9-20020a170902f78900b0014eebbc264bmr1392839pln.169.1649131953437; Mon, 04 Apr 2022 21:12:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649131953; cv=none; d=google.com; s=arc-20160816; b=BhYgyQ0MX2IQLAGEbP7j6Aa1vtmXeMVhq1DVwFLu8r7uxUYkWkABduUIPpUNH4B5tB GTY9482LCHthm9fe/aYx92T7D0OmnQygBC4cZN+nHdri3yfVdpAD2IIu6P/ALyTIxPif aquM1VwAVrpLOuamMcks2kIpo1yUtleEgjZ9DZf5cY8Ws5U/sCh9bQsA4NtKBIwvQoQ7 w0F2vWVs1D9MBydJLCsrw2UzRJeXJUn9mX2xSIuIRiqe4VFICeES8xVuoP5yzVUWlKRZ BpfMqfRnGh0/VKNaI+P+uymHHA9B4MfIU/dmIL2qNys+WuSH33Exl14S32pQ92UrYNgD 5PZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:dlp-filter:cms-type :content-transfer-encoding:mime-version:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=CKTKAhXTaSx818utW4r9R7NQFknJNHgDoVip59njvEw=; b=XnsSbNFQRVrSggGtYq21JBHxqIwQbsYgmZ9qssvsbNITcth/n05LrXmI21F+0SXp7r AHrv/Q7teXVS6Vc/BrHs/NCWWN2yaPu/YFsNVaqf4Gq3moZ8cwAoeKj3BodW4h7JcevE sJdI3U6qX3qSUGNGnHxpTj8LRSUqHbasq5m9fE92LsOyB/BXgI/fUhy2/A1t7NgAXvZx AcnrG6jAe55WlZVFsqIlY/zrsNHyQmA9s9LhFvSmmsRIXbdaLwboG5d0u0V5GHu1H8C8 3RP0JoQLgJ8WQPPCSynJsuPVVh1+6Sgia/sZje0CWBVg0JEWnhAd3bsjhuEdHlQlesUB hrHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=PaZJYMkV; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id rm12-20020a17090b3ecc00b001bd14e01fc9si858973pjb.183.2022.04.04.21.12.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 21:12:33 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=PaZJYMkV; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 75F36140B6; Mon, 4 Apr 2022 20:35:22 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230329AbiDEDhM (ORCPT + 99 others); Mon, 4 Apr 2022 23:37:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230295AbiDEDhC (ORCPT ); Mon, 4 Apr 2022 23:37:02 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5AC7BC1D for ; Mon, 4 Apr 2022 20:35:04 -0700 (PDT) Received: from epcas2p3.samsung.com (unknown [182.195.41.55]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20220405033455epoutp046e9c34c5e304f13b0e644acf32353fd1~i4rhf6XBY3079030790epoutp04n for ; Tue, 5 Apr 2022 03:34:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20220405033455epoutp046e9c34c5e304f13b0e644acf32353fd1~i4rhf6XBY3079030790epoutp04n 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 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprBJsWRmVeSWpSXmKPExsWy7bCmme7NHd5JBie281k8mLeNzeLyfm2L 5sXr2Sx2NBxhtXg3V8bi/PkN7BabHl9jtbi8aw6bxYzz+5gszizuZXfg8ti0qpPNY//cNewe m5fUe/RtW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PTlydsrCuW0tRjd3fvW9+/TJ3/xr2f4lE5VYijMSDbWYi4oTAbJX4gUrBAAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrCLMWRmVeSWpSXmKPExsWy7bCSvO6NHd5JBive61o8mLeNzeLyfm2L 5sXr2Sx2NBxhtXg3V8bi/PkN7BabHl9jtbi8aw6bxYzz+5gszizuZXfg8ti0qpPNY//cNewe m5fUe/RtWcXo8XmTXABrFJdNSmpOZllqkb5dAlfGxmPXmAv+cVb83zaPsYFxMUcXIyeHhICJ xMotO9i6GLk4hAR2MErMbOxmgkjISCx/1scGYQtL3G85wgpR9J5RYuHplWAJNgFtie/rF4Ml RATOM0pMfvwGbBSzwB5GiTWzvzODVAkLREis2XaGEcRmEVCVaLh7gRXE5hWwk/i8bjorxAp5 ie5/f1i6GDk4OAXsJba+jAQJCwGVHGu6xA5RLihxcuYTFhCbGai8eets5gmMArOQpGYhSS1g ZFrFKJlaUJybnltsWGCUl1quV5yYW1yal66XnJ+7iREc8FpaOxj3rPqgd4iRiYPxEKMEB7OS CG9OkGeSEG9KYmVValF+fFFpTmrxIUZpDhYlcd4LXSfjhQTSE0tSs1NTC1KLYLJMHJxSDUzy DM72esfanXqNlk94yXwzNa1IfOWLOZ8MbD01djolqTMbyLfsnqvx+Onb/57m29ayKf9T6fhh maxyMGtf3ZUqn+yEbb3ePxdbWhuzvlPj+SW2Q7Lgx6Wfb5tDVugFFLB4XrXIrshIXXs75vTt 2OuuaVO2zexfsXIR1wUpjpgUpcjFb3VDkuVZE732B/qq73k/zz50Rlz+jr93Js88cYqhzGBv +hn333cj1KTtliuwNKuuWShWbfB4mvb/V7GL5KYEKP9mdFxof9424FVS9Ts+D/aV39k7Qt8v VXsgP2H71Z7ob2fPaurH3nzyuyfm3bqwxkI5nQudye+Nfr9PdN+27/uRtZZ3ym7VXjw+KU+J pTgj0VCLuag4EQATeZFy5wIAAA== X-CMS-MailID: 20220405033448epcas2p397080e15c54369d24eaf94c2a27bd06c X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" 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-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 */ -- 2.35.1