Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5725934pxv; Wed, 28 Jul 2021 18:50:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyj20xVz7zSmGh31kS+SZaUc4nHewGVvLyMkdFNM+GRXOPYCzUZ+tvRaoq9GxHlWPb1naxa X-Received: by 2002:a17:907:2058:: with SMTP id pg24mr2259601ejb.315.1627523447440; Wed, 28 Jul 2021 18:50:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627523447; cv=none; d=google.com; s=arc-20160816; b=irPOBd89ngGu81R+ncfCixFtUiW2hVH8hlQlnNfWL5L3iYmclTxIHqP7H1FiPrKkd0 xkbJom1mnm5Oy73j+kw5w/t1ppCARvp61t7UY/KhSgCdlc4i/9xGfLv+1v4JCTF1yLYA qqFVkIGl2ZMh+yHCp37mowljN8xJ0vgzm/lwIoIZjSNVk7kxn+HpQILjWfR1uKKmKS1r ODDotd7qjmg7AOtaHZ7Lk7wUhzL7Lrl3FNhBH8qzB1sqLV12F+iaqjhZUDZ+PJ5m1sZ2 RURn9fDP8Vso4tMONM5Hj6ggvf4VnlmLblqD6SJ8V4OL62DA6gNLFHCznE0RTDIgRRsX 8xRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=v3/f/Cd1NJadXvwmYabBLarTReaOyeeOxdf5BA6T/ew=; b=Xb+NRL8eF26ND/uUBKlE3YrTb9aOSLT0QLKBm7o+aP15cvBUjSnNZp6RIrm9RkvKog KC/p3afRhrTTAB+2k5eD09sngFR0+4YlHXI4t3nJHmRLI4jFA3jUHhXR4fa1aEYd8CfX 9NTPg1qxv+pzGmr7KKVLhJ4G0RQhhoWkxg4zy2fyYv7nvfzuT+HyBkwGMUTiPSBA1Gli 7z2eZP09vyQUnkIZZJKKpv3bg/Lcm4UbcyYws6/BWh2t/CYe3zUHvyWOHB3HJHIMSPj8 awdN2aqyhdqg2Mz5hSVu5XuEEMnr2RLXySEGoeXX0g+YfS3TCrEGY7NnnvbaVedC4JKM lmMQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y8si1466225edw.197.2021.07.28.18.50.24; Wed, 28 Jul 2021 18:50:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233256AbhG2Bs7 (ORCPT + 99 others); Wed, 28 Jul 2021 21:48:59 -0400 Received: from mailgw01.mediatek.com ([60.244.123.138]:58838 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S233142AbhG2Bs6 (ORCPT ); Wed, 28 Jul 2021 21:48:58 -0400 X-UUID: 5e1cf78f69cf47d889255ff36217d3d5-20210729 X-UUID: 5e1cf78f69cf47d889255ff36217d3d5-20210729 Received: from mtkcas07.mediatek.inc [(172.21.101.84)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1674095973; Thu, 29 Jul 2021 09:48:52 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 29 Jul 2021 09:48:51 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 29 Jul 2021 09:48:49 +0800 From: Zhiyong Tao To: , , , , CC: , , , , , , , , , , , Subject: [PATCH v1] serial: 8250_mtk: fix uart corruption issue when rx power off Date: Thu, 29 Jul 2021 09:48:17 +0800 Message-ID: <20210729014817.11879-2-zhiyong.tao@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210729014817.11879-1-zhiyong.tao@mediatek.com> References: <20210729014817.11879-1-zhiyong.tao@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix uart corruption issue when rx power off. Add spin lock in mtk8250_dma_rx_complete function in APDMA mode. Signed-off-by: Zhiyong Tao --- drivers/tty/serial/8250/8250_mtk.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c index f7d3023f860f..fb65dc601b23 100644 --- a/drivers/tty/serial/8250/8250_mtk.c +++ b/drivers/tty/serial/8250/8250_mtk.c @@ -93,10 +93,13 @@ static void mtk8250_dma_rx_complete(void *param) struct dma_tx_state state; int copied, total, cnt; unsigned char *ptr; + unsigned long flags; if (data->rx_status == DMA_RX_SHUTDOWN) return; + spin_lock_irqsave(&up->port.lock, flags); + dmaengine_tx_status(dma->rxchan, dma->rx_cookie, &state); total = dma->rx_size - state.residue; cnt = total; @@ -120,6 +123,8 @@ static void mtk8250_dma_rx_complete(void *param) tty_flip_buffer_push(tty_port); mtk8250_rx_dma(up); + + spin_unlock_irqrestore(&up->port.lock, flags); } static void mtk8250_rx_dma(struct uart_8250_port *up) -- 2.18.0