Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1593405pxb; Wed, 20 Oct 2021 08:06:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygKSNH3jLYT6LJAkRURf0NMIq9yLIfrVgRAvPtjuFV6o21z4n+pNOBwiydN1pope3cI2QY X-Received: by 2002:a05:6a00:815:b0:44d:2193:f688 with SMTP id m21-20020a056a00081500b0044d2193f688mr592032pfk.4.1634742400983; Wed, 20 Oct 2021 08:06:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634742400; cv=none; d=google.com; s=arc-20160816; b=unfBJ8j/6yCuzovH32in+1U4Kw2zXA+4V9sitFIfvdvWZpu43o7/FBsENig6VItEsn uKHkxBOBXS1kzZVcYtoibDQpXZ+asPpaZc3tZfMBOsIIGuCbOTy+nJQ38Wkzha80SxDK PmaGXZrHtD7yh2OsWaIKnj5PD9FKZ8Fb6C6+DTkV3+L0pZBqbkzLwjg/0l9XShVHJz8J hMZj2kRWRlPOQUrnhUq4yxdyk7yvNf8sxkwKsZlWZU0h5pHuwCmO5SMGDbi9HBUd8KzY wQzn6t4zrP82cSDdBsjxdWNS5n9cLeIupsU9TtGoiVTqUIKCSVcLqlhyejrcJkw2YVmT 123w== 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:dkim-signature; bh=VgNN4lYkgAjQBY6zs4BxlgI9Yl9IfFb5xKJg4XO1+OA=; b=I03nfddqRj6zGVuo6VmXdtMGutxPCxqkRYbu4qiLPVRay7qtuHpUwvWoJMPWHxCdl/ KzstuwiDFsWXzO/r59VdbMNHU1bWi/N0oV+wLS2LMMQiWClQHjhbnBe6yBQeXg2WrVng TwniAEHwTmXxt9j0KLHBnz9lIIh27HxexvLMsDdMGYFJ6KkSHq+x121D42rg42+HbmWO ZpOqoKUO1qFchPtxUAQTgudOUwJHYY0CS4OSDA4255zFCDN7ZvBSXz7IcccmbO4aLlpq PxxCmlVCEb8q/hAa2zpukhHHHNi+MR7hs3D+JGBEey6RknrEkh/GUUDZSi0mhpUHXNfV x6kA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=QnbtXrMk; 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=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u8si4012911plf.235.2021.10.20.08.06.11; Wed, 20 Oct 2021 08:06:40 -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; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=QnbtXrMk; 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=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230416AbhJTPGW (ORCPT + 99 others); Wed, 20 Oct 2021 11:06:22 -0400 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:57608 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230369AbhJTPGQ (ORCPT ); Wed, 20 Oct 2021 11:06:16 -0400 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 Content-Type: text/plain 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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; } -- 2.17.1