Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp1321940lqz; Mon, 1 Apr 2024 02:31:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXMtDw5jeakUT7z8VKo109M6kbYZ1SI3vPHvwf1J/TQcXbUfCXSqEqOulgJP5sWDwMJo/QkLn/g05Ss5sF97878CEHeAwhhngsO6ucatw== X-Google-Smtp-Source: AGHT+IEoDkofuuygqZ73eepEjGV5P4hnPdHaw9VEjfigaVL2FMdmxufVFP15O3A6z63YTotqXuSh X-Received: by 2002:a05:6a00:2395:b0:6ea:ab85:5fac with SMTP id f21-20020a056a00239500b006eaab855facmr11407694pfc.1.1711963886829; Mon, 01 Apr 2024 02:31:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711963886; cv=pass; d=google.com; s=arc-20160816; b=u6HXqv2axnjuF2CRXvkwX6DmGjmH1Vub5wv03GfJmZbqIrRG4tPhET8P/h91nMLMBk dcGCytzTZhEEhz+19mTkQ8YNpzypH1KrnfE3zRkX5AZJD1k31vcSnvtv5y1ix7cXBmAm 2mlDoSg4MjLFgJF8FbVTjwZyoRNyaMmKDNY8vEiUsNcAmadi/3Tw9VLa0j+SdNz59DYC C1D7MNsh0XET6ns91NJEhst0L9WA4NwjR6quOukcwOgKFoiyr6/axmZNVwy1diBq+N1x ss4QzV1jMcq16lgpYNmmvOuvfzM7lW797H7RJQ4ytYEZ2MFp/71Bp4YaI8SSfVmAEwBL UyTg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from:dkim-signature; bh=YxqPnDDo14p23OJLtufSJq/s7or8qzqTAqRYLxF+pYo=; fh=plbfY8DTBbJj0Kf2ehrO/I9ZAEmwTW1fxhUMj4vRREQ=; b=ZCZivxCFucPao/EZhnKT4BK3qhjA0W2Y9FX0odxpTvHuYHAusgZ3bJUvlbTThIWvUX h35+6LxUZSiNn1+Hx+Y4bJxsn6oi7R+5h4eXTctFoRWpXaIc5PGSnMuMqp/57aJGwiXq 65oI6YdK3RyTnj2uiNiFXnNauSO0YMxyuiIcE0eAEtnte02MQRm5kZS4ADW/9OqNODkP 0oOK7gG2mobEKf15bcwf8yFSOOn5+1fK0awssiIAFe17kw/k3Z66YlItgQDS5hEj6bx/ 7rt7Vkvnn+PH2gtprcUvNFtMF0oArAJrjkq3z0j8+8mC0PgeQgME7S/h2nFAZHDdZVE8 D6Pg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@126.com header.s=s110527 header.b="LXEQ/YTk"; arc=pass (i=1 spf=pass spfdomain=126.com dkim=pass dkdomain=126.com dmarc=pass fromdomain=126.com); spf=pass (google.com: domain of linux-kernel+bounces-126556-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-126556-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=126.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id g1-20020a63f401000000b005e485fc4266si8990750pgi.388.2024.04.01.02.31.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Apr 2024 02:31:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-126556-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@126.com header.s=s110527 header.b="LXEQ/YTk"; arc=pass (i=1 spf=pass spfdomain=126.com dkim=pass dkdomain=126.com dmarc=pass fromdomain=126.com); spf=pass (google.com: domain of linux-kernel+bounces-126556-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-126556-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=126.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7F84A282164 for ; Mon, 1 Apr 2024 09:31:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D6C231118A; Mon, 1 Apr 2024 09:30:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=126.com header.i=@126.com header.b="LXEQ/YTk" Received: from m16.mail.126.com (m16.mail.126.com [117.135.210.7]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0CB39FBFD for ; Mon, 1 Apr 2024 09:30:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711963845; cv=none; b=tukhra438yOwSaKt9MrRVuj2ZWKK/n+xkMcpMPJ6Pm9m3106p9aKYewuOjf+2CsgfMv+d3fpZLbx3j57OLFOO5/6r9KaNkqb4SxmrSUjmwTpcluVZp2BPs9ImMvfhzxQDqY/PWpKjis7ksKLSd9rYj6fzOhF8fqA9p+I1Jc4HbE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711963845; c=relaxed/simple; bh=SR8T3+He2AZJICAKjsYDSLD9RIrMgUNik84zJm/zi7E=; h=From:To:Cc:Subject:Date:Message-Id; b=S5uoq9zgJi4Hh4krAuwGXHzVpZOSRtK6gCqxQOGTheAqiqSI03ksgd6enIZN9z71NWS9VeT1YnC3OuiJvHkgU2bhzLEIRXgjXO7fwjUxzd0FXydopcYe+7zOhhjs463m5LfNN8+6ZzZtuLGSwqla/g4huhpWZMymuwra4lIC0L8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=126.com; spf=pass smtp.mailfrom=126.com; dkim=pass (1024-bit key) header.d=126.com header.i=@126.com header.b=LXEQ/YTk; arc=none smtp.client-ip=117.135.210.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=126.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=126.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id; bh=YxqPnDDo14p23OJLtu fSJq/s7or8qzqTAqRYLxF+pYo=; b=LXEQ/YTkKXCjhQp9GfEWvXDSeKDU9SLmvF XqYVEHOjse0MQPAQCHohaA8G6O5XoUmQcHHmxVLRr6Fhc35iqhIrzKneJfjF6RoC TsKvDbMrpkFE1MSowweE8hJJzYZwc7Jym8kIbOuC/gieCk6Mxgx9OnapbQMd8ehQ bajZxTsL8= Received: from localhost.localdomain (unknown [27.38.213.133]) by gzga-smtp-mta-g0-2 (Coremail) with SMTP id _____wDX_2+hfgpmG2w3Ag--.21976S2; Mon, 01 Apr 2024 17:30:10 +0800 (CST) From: "fengchunguo@126.com" To: ilpo.jarvinen@linux.intel.com, andriy.shevchenko@linux.intel.com, gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: linux-kernel@vger.kernel.org, "chunguo.feng" Subject: [PATCH] tty: serial: fixed uart irq maybe cause irq storm Date: Mon, 1 Apr 2024 17:30:01 +0800 Message-Id: <1711963801-184362-1-git-send-email-fengchunguo@126.com> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID:_____wDX_2+hfgpmG2w3Ag--.21976S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxAry8AF43KrWfAw18Xry3XFb_yoW5Ar1xpF yYqr909FWkXF42ya1Dtr10qF4rXa12yFy7Gr97Gr1UK3W5KryUJF1xtFWSqFy7ArWYyr9r JF47t34j9a4UtaDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jjiihUUUUU= X-CM-SenderInfo: 5ihqwu5kxqw3br6rjloofrz/xtbBdQOzOmSdL3SMRQAAsU Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: From: "chunguo.feng" if not disable uart irq before disable clk, uart irq maybe triggered after disabled clk immediately, then maybe cause irq storm. Reproduced the below call trace, see i2c not be connected, but irq storm was triggered. i2c_designware 30b70000.i2c: controller timed out CPU: 2 PID: 2932 Comm: gnss@1.0-servic Tainted: G O 5.14.61-00094-geaa0149416cc-dirty #8 Hardware name: Semidrive kunlun x9 REF Board (DT) Call trace: [] dump_backtrace+0x0/0x3c0 [] show_stack+0x14/0x1c [] dump_stack+0xc4/0xfc [] __report_bad_irq+0x50/0xe0 [] note_interrupt+0x248/0x28c [] handle_irq_event+0x78/0xa4 [] handle_fasteoi_irq+0xe4/0x1b4 [] __handle_domain_irq+0x7c/0xbc [] gic_handle_irq+0x4c/0xb8 [] el1_irq+0xb0/0x124 [] _raw_spin_unlock_irqrestore+0x10/0x44 [] dw8250_set_termios+0x48/0xf4 [] serial8250_set_termios+0x14/0x28 [] uart_change_speed+0x38/0x10c [] uart_set_termios+0xd0/0x17c [] tty_set_termios+0x160/0x1e4 [] set_termios+0x32c/0x3bc [] tty_mode_ioctl+0x6f0/0x7d8 [] n_tty_ioctl_helper+0x10c/0x1e8 [] n_tty_ioctl+0x120/0x194 [] tty_ioctl+0x658/0xa34 [] do_vfs_ioctl+0x554/0x810 [] SyS_ioctl+0x88/0x94 Exception stack(0xffff00000ccf3ec0 to 0xffff00000ccf4000 Signed-off-by: chunguo.feng --- drivers/tty/serial/8250/8250_dw.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c index c1d43f0..133c24e 100644 --- a/drivers/tty/serial/8250/8250_dw.c +++ b/drivers/tty/serial/8250/8250_dw.c @@ -359,6 +359,12 @@ static void dw8250_set_termios(struct uart_port *p, struct ktermios *termios, rate = clk_round_rate(d->clk, newrate); if (rate > 0 && p->uartclk != rate) { + /*Need disable uart irq before disabled clk, because uart irq maybe triggered after + * disabled clk immediately, then cause irq storm. + */ + if (p->irq) + disabled_irq(p->irq); + clk_disable_unprepare(d->clk); /* * Note that any clock-notifer worker will block in @@ -368,6 +374,9 @@ static void dw8250_set_termios(struct uart_port *p, struct ktermios *termios, if (!ret) p->uartclk = rate; clk_prepare_enable(d->clk); + + if (p->irq) + enable_irq(p->irq); } dw8250_do_set_termios(p, termios, old); -- 2.7.4