From patchwork Fri Aug 18 03:15:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenhua Lin X-Patchwork-Id: 714969 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 438ECC001DE for ; Fri, 18 Aug 2023 03:16:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357463AbjHRDQY (ORCPT ); Thu, 17 Aug 2023 23:16:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357539AbjHRDQR (ORCPT ); Thu, 17 Aug 2023 23:16:17 -0400 Received: from SHSQR01.spreadtrum.com (unknown [222.66.158.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63E1330E6; Thu, 17 Aug 2023 20:16:15 -0700 (PDT) Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 37I3FmmH046282; Fri, 18 Aug 2023 11:15:48 +0800 (+08) (envelope-from Wenhua.Lin@unisoc.com) Received: from SHDLP.spreadtrum.com (shmbx06.spreadtrum.com [10.0.1.11]) by dlp.unisoc.com (SkyGuard) with ESMTPS id 4RRn5B5lddz2Q25wW; Fri, 18 Aug 2023 11:13:34 +0800 (CST) Received: from xm9614pcu.spreadtrum.com (10.13.2.29) by shmbx06.spreadtrum.com (10.0.1.11) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Fri, 18 Aug 2023 11:15:46 +0800 From: Wenhua Lin To: Greg Kroah-Hartman CC: Orson Zhai , Baolin Wang , Chunyan Zhang , , , wenhua lin , Wenhua Lin , Xiongpeng Wu , Zhirong Qiu , Zhaochen Su Subject: [PATCH] tty/serial: Cancel work queue before closing uart Date: Fri, 18 Aug 2023 11:15:32 +0800 Message-ID: <20230818031532.15591-1-Wenhua.Lin@unisoc.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.13.2.29] X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To shmbx06.spreadtrum.com (10.0.1.11) X-MAIL: SHSQR01.spreadtrum.com 37I3FmmH046282 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org When the system constantly sleeps and wankes up, plugging and unplugging the USB will probalility trigger a kernel crash problem. The reason is that at this time, the system entered deep and turned off uart, and the abnormal behavior of plugging and upplugging the USB triggered the read data process of uart, causing access to uart to hang. The final solution we came up with is to cancel the work queue before shutting down uart , while ensuring that there is no uart business. Signed-off-by: Wenhua Lin --- drivers/tty/serial/sprd_serial.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/tty/serial/sprd_serial.c b/drivers/tty/serial/sprd_serial.c index b58f51296ace..eddff4360155 100644 --- a/drivers/tty/serial/sprd_serial.c +++ b/drivers/tty/serial/sprd_serial.c @@ -20,6 +20,7 @@ #include #include #include +#include "../tty.h" /* device name */ #define UART_NR_MAX 8 @@ -1221,7 +1222,10 @@ static int sprd_probe(struct platform_device *pdev) static int sprd_suspend(struct device *dev) { struct sprd_uart_port *sup = dev_get_drvdata(dev); + struct uart_port *uport = &sup->port; + struct tty_port *tty = &uport->state->port; + tty_buffer_cancel_work(tty); uart_suspend_port(&sprd_uart_driver, &sup->port); return 0;