Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp208402rdg; Thu, 12 Oct 2023 03:29:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHQpLA54tDdAN2Q2GMmyuZI0XTg8cEnpezNtpHgM1BalzmNIzD/Jtf2iskknIiaYrGLOK+2 X-Received: by 2002:a17:90b:4a8e:b0:278:ff87:4774 with SMTP id lp14-20020a17090b4a8e00b00278ff874774mr20669748pjb.4.1697106595935; Thu, 12 Oct 2023 03:29:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697106595; cv=none; d=google.com; s=arc-20160816; b=s/GiaCBuydIHQTRdhdzNo8Mj0BIlXkfpNxU9srfLuZijPz/G2Ns1gHGQU+cbClCgux ejr2Kvi1uGjHJ1h6mMlTcIV3TNqqeXVT3nxNJmMxC0xARydLMew+oKqgzlUyhoorlT4w BQjOfp74ZqxtRLNCVrYq6V8vKRUeR/LHpPP8XbarT4PZadLcGbnzgJo8RYr53U806F80 9TIXAi4bR4B9RMras+z8W6fVPSU/lpVqZ73ncfTIkjzdHQuG95MxOJTxMn0hW5zdn2sj XvKVz1+bl2LHS8c3t0YFHlKw/N78CqCyqdLZiiFRoiRBwywqOZ1dYu58/j6wiDMul9W9 oZ/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:message-id:date:cc:to :from:subject:references:in-reply-to:importance:sensitivity :mime-version; bh=zLTkc+01IFiwFA9CzYM33MWja8RUo1J+X8jBtPfsF78=; fh=ljszuqVgBa1xTdCGPEnpuUwhoe4BzTAtGQ5TO/4FJJw=; b=HHMdsLZE/hBrH6PQhUvptxyVEllQTiBu917qTHzdPd8ih8ALLgEnZ9htWruSWR4SZL J5sg3+XIyH48p1c5QkaD2AxU1fkGyaM88/T02mO5Hn+1KINS1veujo7CrRABGMy1jHEw O7IzLOVuN0shMLBjuRovOuNk+zdjoqJF85onfPlsf8J8xQoBqRHoMJCSZ8G1lQqcacXN h6BmVsdJH4vILHi9OychtF1KDDqvv+Xlx/wtlxP4Mo6Ov2VFn1vIhTXLXjisZrTweh/C YupfpTzA0Qo7saXKQAafYDeFAx1gh1D7Pnh4rJFqG7+F5Ee8r7XokgjcEZ2aAMfhuZ3F M0KQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=imaqliq.ru Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id m16-20020a63fd50000000b00588d84b1215si1602280pgj.876.2023.10.12.03.29.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 03:29:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=imaqliq.ru Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 247E581A32B3; Thu, 12 Oct 2023 03:29:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377746AbjJLK3p convert rfc822-to-8bit (ORCPT + 99 others); Thu, 12 Oct 2023 06:29:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343654AbjJLK3m (ORCPT ); Thu, 12 Oct 2023 06:29:42 -0400 X-Greylist: delayed 359 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 12 Oct 2023 03:29:38 PDT Received: from postfix2.imaqliq.com (postfix2.imaqliq.com [93.189.151.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3F58B8; Thu, 12 Oct 2023 03:29:38 -0700 (PDT) Received: from verse.imaqliq.com (verse.imaqliq.com [93.189.151.95]) by postfix2.imaqliq.com (Postfix) with ESMTP id 4A93A1C2941; Thu, 12 Oct 2023 13:23:36 +0300 (MSK) MIME-Version: 1.0 Sensitivity: Importance: Normal X-Priority: 3 (Normal) In-Reply-To: References: Subject: [PATCH] tty: serial: meson: hard LOCKUP on crtscts mode From: pkrasavin@imaqliq.ru To: Greg Kroah-Hartman , Jiri Slaby , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, pkrasavin@imaqliq.ru Date: Thu, 12 Oct 2023 10:23:30 +0000 Message-ID: X-Mailer: Lotus Domino Web Server Release 12.0.2 November 03, 2022 X-MIMETrack: Serialize by http on verse/com(Release 12.0.2|November 03, 2022) at 10/12/2023 10:23:30, Serialize complete at 10/12/2023 10:23:30, Serialize by Router on verse/com(Release 12.0.2|November 03, 2022) at 10/12/2023 10:23:35 X-KeepSent: 28B2B8C9:5BC0CD28-00258A46:0037688F; type=4; name=$KeepSent Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-KLMS-Rule-ID: 1 X-KLMS-Message-Action: clean X-KLMS-AntiSpam-Lua-Profiles: 180559 [Oct 12 2023] X-KLMS-AntiSpam-Version: 6.0.0.2 X-KLMS-AntiSpam-Envelope-From: pkrasavin@imaqliq.ru X-KLMS-AntiSpam-Rate: 10 X-KLMS-AntiSpam-Status: not_detected X-KLMS-AntiSpam-Method: none X-KLMS-AntiSpam-Auth: dmarc=fail header.from=imaqliq.ru policy=none;spf=softfail smtp.mailfrom=imaqliq.ru;dkim=none X-KLMS-AntiSpam-Info: LuaCore: 539 539 807534d9021bfe9ca369c363d15ac993cd93d4d9, {rep_avail}, {Tracking_from_domain_doesnt_match_to}, d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;gdc.ru:7.1.1;127.0.0.199:7.1.2;imaqliq.ru:7.1.1;verse.imaqliq.com:7.1.1;93.189.151.95:7.1.2, FromAlignment: s, {Tracking_dmark_f}, ApMailHostAddress: 93.189.151.95 X-MS-Exchange-Organization-SCL: -1 X-KLMS-AntiSpam-Interceptor-Info: scan successful X-KLMS-AntiPhishing: Clean, bases: 2023/10/12 08:55:00 X-KLMS-AntiVirus: Kaspersky Security for Linux Mail Server, version 8.0.3.30, bases: 2023/10/12 01:34:00 #22164647 X-KLMS-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 12 Oct 2023 03:29:53 -0700 (PDT) There might be hard lockup if we set crtscts mode on port without RTS/CTS configured: # stty -F /dev/ttyAML6 crtscts; echo 1 > /dev/ttyAML6; echo 2 > /dev/ttyAML6 [ 95.890386] rcu: INFO: rcu_preempt detected stalls on CPUs/tasks: [ 95.890857] rcu: 3-...0: (201 ticks this GP) idle=e33c/1/0x4000000000000000 softirq=5844/5846 fqs=4984 [ 95.900212] rcu: (detected by 2, t=21016 jiffies, g=7753, q=296 ncpus=4) [ 95.906972] Task dump for CPU 3: [ 95.910178] task:bash state:R running task stack:0 pid:205 ppid:1 flags:0x00000202 [ 95.920059] Call trace: [ 95.922485] __switch_to+0xe4/0x168 [ 95.925951] 0xffffff8003477508 [ 95.974379] watchdog: Watchdog detected hard LOCKUP on cpu 3 [ 95.974424] Modules linked in: 88x2cs(O) rtc_meson_vrtc Possible solution would be to not allow to setup crtscts on such port. Tested on S905X3 based board. Signed-off-by: Pavel Krasavin --- a/drivers/tty/serial/meson_uart.c 2023-08-22 12:46:50.933814528 +0300 +++ b/drivers/tty/serial/meson_uart.c 2023-08-22 14:48:15.593169948 +0300 @@ -380,10 +380,15 @@ static void meson_uart_set_termios(struc else val |= AML_UART_STOP_BIT_1SB; - if (cflags & CRTSCTS) - val &= ~AML_UART_TWO_WIRE_EN; - else + if (cflags & CRTSCTS) { + if (port->flags & UPF_HARD_FLOW) { + val &= ~AML_UART_TWO_WIRE_EN; + } else { + termios->c_cflag &= ~CRTSCTS; + } + } else { val |= AML_UART_TWO_WIRE_EN; + } writel(val, port->membase + AML_UART_CONTROL); @@ -705,6 +710,7 @@ static int meson_uart_probe(struct platf u32 fifosize = 64; /* Default is 64, 128 for EE UART_0 */ int ret = 0; int irq; + bool has_rtscts; if (pdev->dev.of_node) pdev->id = of_alias_get_id(pdev->dev.of_node, "serial"); @@ -732,6 +738,7 @@ static int meson_uart_probe(struct platf return irq; of_property_read_u32(pdev->dev.of_node, "fifo-size", &fifosize); + has_rtscts = of_property_read_bool(pdev->dev.of_node, "uart-has-rtscts"); if (meson_ports[pdev->id]) { return dev_err_probe(&pdev->dev, -EBUSY, @@ -762,6 +769,8 @@ static int meson_uart_probe(struct platf port->mapsize = resource_size(res_mem); port->irq = irq; port->flags = UPF_BOOT_AUTOCONF | UPF_LOW_LATENCY; + if (has_rtscts) + port->flags |= UPF_HARD_FLOW; port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_MESON_CONSOLE); port->dev = &pdev->dev; port->line = pdev->id;