Received: by 2002:a05:7412:bc1a:b0:d7:7d3a:4fe2 with SMTP id ki26csp492506rdb; Sat, 19 Aug 2023 09:50:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGAhjmGvSnoTY7atXI0T3V/W8ULM1kLDYZhSTCYP8yUdd0rxcHYYXzK+l8vQrBbcHfpLUoH X-Received: by 2002:a17:902:dacd:b0:1bc:496c:8eda with SMTP id q13-20020a170902dacd00b001bc496c8edamr2853153plx.4.1692463847396; Sat, 19 Aug 2023 09:50:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692463847; cv=none; d=google.com; s=arc-20160816; b=jb4w4pb2iVmxroZQMLCestfhm5I3DjBO/dqGnJ3qQOjnzaJAqk0I8RQmKNub/p8QhI D0Kv1k+DIumxmul4FkkPP7ZNY2FO/7PDZYgi+Q47QKHv+H2cttrR0BmTq5+XwzRd1Ur5 Jn/eh74KIN3FpXfmhd9O+XIo1RxFq1Ihh+87f+6GHjax/cjkqStjZ8NrPTCQBeCfejpT bAlZVLw4I11wSzpRDG4l4lfesQx1Gr9+GBXopH3gMHoMXoVd7qy6PeF6J1FP20e1zzm4 +jMLosmK2EVAu0cdvAQCbdZ2R1rnKEcKh1lLSxpkJBU9AyFyWj62CbQpMdvvhTYVugCu Qhhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=hPQImROb4Q1EzBKzV0lqwZEuPVcPyo0bFFa3s54cioU=; fh=GRi4pV8uVWXeM1/OfQfXLqqNEAwIv4GpLiwXHeYq0FA=; b=bsBsW0uX1HPiSOYTWCsw6RLBIFxtCHMgzurQ5BFKL9XHyhOaKM3YGuKa/gO4vVFHZj d6ijrpE3vejLx+jE63Ab5HY95PNsR6yni4H9I2MdGwVp5bqaekA0IwMZRALd5pl4Qftz 8WMdm/kX6hbnuAMw81QxoB4rSy2OwtiDzHhndEMmx1vhqLe0lxWfPQlR+AYROhDoP3D0 vy6cFT8B6Xq18QeR9XFM3vQOMjum3Ho1H15Ked7EBW7JiPpd7pYggg6PYXLJLL5hmfSy 4rBaEYKxwebLTPZmC2CszP1uTQpxNOMi1mlYFkU/zDDnJqSjBWmHe42KLIooFz236Z+H bqtA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id ip11-20020a17090b314b00b0024769a264fcsi5706451pjb.10.2023.08.19.09.50.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 09:50:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3F21711DA40; Sat, 19 Aug 2023 01:52:54 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357488AbjHRDQZ (ORCPT + 99 others); Thu, 17 Aug 2023 23:16:25 -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 Content-Type: text/plain 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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 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; -- 2.17.1