From patchwork Wed Oct 20 15:03:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erwan LE RAY X-Patchwork-Id: 12572597 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54402C433EF for ; Wed, 20 Oct 2021 15:27:37 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 10DCC61371 for ; Wed, 20 Oct 2021 15:27:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 10DCC61371 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=foss.st.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wJrsjqLhnUzRhQ1+RpJ/+8/tDrzJ7It7AzDaXgkUhcs=; b=ZEta5NEoZfhw14 fJdvRrTDWhX1SshShcSRuevCd7eQBHKwvOWOZvhJLYEzGaek9Prs6t095ctiKnOFOx1gGCKtmdj/3 HyOeH1a6CDcIvzjEmc+KDNEwXOm+Wp5XC2McZPygn++aHV57wiKs8SczgNimtaILZ9SWYL2Uu4DUQ 3YPogCfTJdpDV5+rf4LwFbtEfendfqSKA02RdfcwBwGGULllU8MXfMwyEURAHeybkVxxyeGYLnrHJ 8F0Kizmn34fVcETLBq8uBSuTXrQfpS690XiRN2v7A1CE3HO7jZmKJte3XXOt4sk3E1Z1ycaM36LQL AfwbJdcnfEGu9TD2T3Sw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mdDTY-0050P2-FG; Wed, 20 Oct 2021 15:25:57 +0000 Received: from mx07-00178001.pphosted.com ([185.132.182.106]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mdD8G-004tZM-Si for linux-arm-kernel@lists.infradead.org; Wed, 20 Oct 2021 15:03:59 +0000 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19KD3e7L009481; Wed, 20 Oct 2021 17:03:51 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=VgNN4lYkgAjQBY6zs4BxlgI9Yl9IfFb5xKJg4XO1+OA=; b=QnbtXrMkuWfIGAx20zTFNdHwGNgyFbRmYEJ3of/jI+DR7GVj430gKYQutHv4TcvgPO6M RfqupEzVr5YJDKWAN9JV42r0h1OUNIOX3i8ShiYRi0n76oT1cxrO4UafcuinT0ze2VZl xSUxCLVHQtbfyuaBtoXdukAuMQY0oNZFNqH2zyxTH2htAViby250Z9eLYSP/eKv0r6ye 1hUCuHpEpxsm2q92H9dfZmIYcChfMFp6KVJmpW1OFFTMUsYKnFLRW/LTmyjY1qTe+ljC MFdeGtd3YvbIUzTf+n+rUOV1voWvuPPupxUNG8tYu7mR5alfa2voOS7aFdZ6KGDNKzkN YA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 3btknp8ps5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Oct 2021 17:03:51 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 09481100034; Wed, 20 Oct 2021 17:03:51 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag2node2.st.com [10.75.127.5]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 0126A22A6E8; Wed, 20 Oct 2021 17:03:51 +0200 (CEST) Received: from localhost (10.75.127.47) by SFHDAG2NODE2.st.com (10.75.127.5) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 20 Oct 2021 17:03:50 +0200 From: Erwan Le Ray To: Greg Kroah-Hartman , Jiri Slaby , Maxime Coquelin , Alexandre Torgue CC: , , , , Erwan Le Ray , Fabrice Gasnier , Valentin Caron , Amelie Delaunay Subject: [PATCH 1/3] serial: stm32: re-introduce an irq flag condition in usart_receive_chars Date: Wed, 20 Oct 2021 17:03:30 +0200 Message-ID: <20211020150332.10214-2-erwan.leray@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211020150332.10214-1-erwan.leray@foss.st.com> References: <20211020150332.10214-1-erwan.leray@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG2NODE2.st.com (10.75.127.5) To SFHDAG2NODE2.st.com (10.75.127.5) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-10-20_05,2021-10-20_02,2020-04-07_01 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211020_080357_283516_A0D64E3C X-CRM114-Status: GOOD ( 17.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Re-introduce an irq flag condition in usart_receive_chars. This condition has been deleted by commit 75f4e830fa9c ("serial: do not restore interrupt state in sysrq helper"). This code was present to handle threaded case, and has been removed because it is no more needed in this case. Nevertheless an irq safe lock is still needed in some cases, when DMA should be stopped to receive errors or breaks in PIO mode. This patch is a precursor to the complete rework or stm32 serial driver DMA implementation. Signed-off-by: Erwan Le Ray diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c index 8f032e77b954..848e063db2ae 100644 --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c @@ -209,19 +209,22 @@ static unsigned long stm32_usart_get_char(struct uart_port *port, u32 *sr, return c; } -static void stm32_usart_receive_chars(struct uart_port *port, bool threaded) +static void stm32_usart_receive_chars(struct uart_port *port, bool irqflag) { struct tty_port *tport = &port->state->port; struct stm32_port *stm32_port = to_stm32_port(port); const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; - unsigned long c; + unsigned long c, flags; u32 sr; char flag; - spin_lock(&port->lock); + if (irqflag) + spin_lock_irqsave(&port->lock, flags); + else + spin_lock(&port->lock); while (stm32_usart_pending_rx(port, &sr, &stm32_port->last_res, - threaded)) { + irqflag)) { sr |= USART_SR_DUMMY_RX; flag = TTY_NORMAL; @@ -275,7 +278,10 @@ static void stm32_usart_receive_chars(struct uart_port *port, bool threaded) uart_insert_char(port, sr, USART_SR_ORE, c, flag); } - uart_unlock_and_check_sysrq(port); + if (irqflag) + uart_unlock_and_check_sysrq_irqrestore(port, irqflag); + else + uart_unlock_and_check_sysrq(port); tty_flip_buffer_push(tport); } @@ -496,10 +502,9 @@ static irqreturn_t stm32_usart_interrupt(int irq, void *ptr) static irqreturn_t stm32_usart_threaded_interrupt(int irq, void *ptr) { struct uart_port *port = ptr; - struct stm32_port *stm32_port = to_stm32_port(port); - if (stm32_port->rx_ch) - stm32_usart_receive_chars(port, true); + /* Receiver timeout irq for DMA RX */ + stm32_usart_receive_chars(port, false); return IRQ_HANDLED; }