From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F560C48BDF for ; Tue, 22 Jun 2021 23:29:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 22C5461040 for ; Tue, 22 Jun 2021 23:29:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229849AbhFVXbz (ORCPT ); Tue, 22 Jun 2021 19:31:55 -0400 Received: from thoth.sbs.de ([192.35.17.2]:42196 "EHLO thoth.sbs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229501AbhFVXbz (ORCPT ); Tue, 22 Jun 2021 19:31:55 -0400 X-Greylist: delayed 1951 seconds by postgrey-1.27 at vger.kernel.org; Tue, 22 Jun 2021 19:31:54 EDT Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by thoth.sbs.de (8.15.2/8.15.2) with ESMTPS id 15MMuVSg027778 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Jun 2021 00:56:31 +0200 Received: from [167.87.93.200] ([167.87.93.200]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id 15MMuQ3p002566; Wed, 23 Jun 2021 00:56:27 +0200 Subject: Re: [PATCH v2] serial: 8250: 8250_omap: Fix possible interrupt storm on K3 SoCs To: Vignesh Raghavendra , Greg Kroah-Hartman , Jiri Slaby Cc: Tony Lindgren , linux-serial@vger.kernel.org, linux-omap@vger.kernel.org, Linux ARM Mailing List References: <20210622145704.11168-1-vigneshr@ti.com> From: Jan Kiszka Message-ID: Date: Wed, 23 Jun 2021 00:56:25 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <20210622145704.11168-1-vigneshr@ti.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org On 22.06.21 16:57, Vignesh Raghavendra wrote: > On K3 family of SoCs (which includes AM654 SoC), it is observed that RX > TIMEOUT is signalled after RX FIFO has been drained, in which case a > dummy read of RX FIFO is required to clear RX TIMEOUT condition. > Otherwise, this would lead to an interrupt storm. > > Fix this by introducing UART_RX_TIMEOUT_QUIRK flag and doing a dummy > read in IRQ handler when RX TIMEOUT is reported with no data in RX FIFO. > > Fixes: be70874498f3 ("serial: 8250_omap: Add support for AM654 UART controller") > Reported-by: Jan Kiszka > Signed-off-by: Vignesh Raghavendra > --- > v2: > Restrict workaround to K3 family of devices only (ti,am654-uart) where > issue was reported. > > v1: https://lore.kernel.org/r/20210511151955.28071-1-vigneshr@ti.com > > drivers/tty/serial/8250/8250_omap.c | 20 +++++++++++++++++++- > 1 file changed, 19 insertions(+), 1 deletion(-) > > diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c > index c06631ced414..79418d4beb48 100644 > --- a/drivers/tty/serial/8250/8250_omap.c > +++ b/drivers/tty/serial/8250/8250_omap.c > @@ -43,6 +43,7 @@ > #define UART_ERRATA_CLOCK_DISABLE (1 << 3) > #define UART_HAS_EFR2 BIT(4) > #define UART_HAS_RHR_IT_DIS BIT(5) > +#define UART_RX_TIMEOUT_QUIRK BIT(6) > > #define OMAP_UART_FCR_RX_TRIG 6 > #define OMAP_UART_FCR_TX_TRIG 4 > @@ -104,6 +105,9 @@ > #define UART_OMAP_EFR2 0x23 > #define UART_OMAP_EFR2_TIMEOUT_BEHAVE BIT(6) > > +/* RX FIFO occupancy indicator */ > +#define UART_OMAP_RX_LVL 0x64 > + > struct omap8250_priv { > int line; > u8 habit; > @@ -611,6 +615,7 @@ static int omap_8250_dma_handle_irq(struct uart_port *port); > static irqreturn_t omap8250_irq(int irq, void *dev_id) > { > struct uart_port *port = dev_id; > + struct omap8250_priv *priv = port->private_data; > struct uart_8250_port *up = up_to_u8250p(port); > unsigned int iir; > int ret; > @@ -625,6 +630,18 @@ static irqreturn_t omap8250_irq(int irq, void *dev_id) > serial8250_rpm_get(up); > iir = serial_port_in(port, UART_IIR); > ret = serial8250_handle_irq(port, iir); > + > + /* > + * On K3 SoCs, it is observed that RX TIMEOUT is signalled after > + * FIFO has been drained, in which case a dummy read of RX FIFO > + * is required to clear RX TIMEOUT condition. > + */ > + if (priv->habit & UART_RX_TIMEOUT_QUIRK && > + (iir & UART_IIR_RX_TIMEOUT) == UART_IIR_RX_TIMEOUT && > + serial_port_in(port, UART_OMAP_RX_LVL) == 0) { > + serial_port_in(port, UART_RX); > + } > + > serial8250_rpm_put(up); > > return IRQ_RETVAL(ret); > @@ -1218,7 +1235,8 @@ static struct omap8250_dma_params am33xx_dma = { > > static struct omap8250_platdata am654_platdata = { > .dma_params = &am654_dma, > - .habit = UART_HAS_EFR2 | UART_HAS_RHR_IT_DIS, > + .habit = UART_HAS_EFR2 | UART_HAS_RHR_IT_DIS | > + UART_RX_TIMEOUT_QUIRK, > }; > > static struct omap8250_platdata am33xx_platdata = { > Tested-by: Jan Kiszka Thanks, Jan -- Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5AA6CC2B9F4 for ; Tue, 22 Jun 2021 22:58:29 +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 1CD9561042 for ; Tue, 22 Jun 2021 22:58:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1CD9561042 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=siemens.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@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:In-Reply-To:MIME-Version:Date: Message-ID:From:References:Cc:To:Subject:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=UwotqbHRWxwCis3Gpese00S2NJGBJi3bxo52u2g1Tv0=; b=giM33zHgksSElvhCD0EZEglFp5 owRvcCSQ5p4r1WpcAC1CnYl9nzzIyy/A94GMVDIpj4oUkw9p0HxqDMJvmUMRx+4MSIrYe92KYttmg QjZvNliT52s3R16xxmsamAv5TFvhyg/n8vjrLTLFj4lYMVwZEamUivGzBM4yNOnAxdcAnsYBEc/2D 5lK9acD5yL6HrbwfND2wSQ1K8far33Gqd8dYAqoulBsdxRO+NN0smd/Bs8k9UIA454ZN8Lj5PXFCk R5uEG6CeK1N4eT+m2zlvoBqRY2jnTC9TuZwhNGs7N6dY4eX4c/9g8Mx/39+/140E9+9I6CIY+uHZP ULp4BSlg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvpKA-008gqz-Sd; Tue, 22 Jun 2021 22:56:55 +0000 Received: from thoth.sbs.de ([192.35.17.2]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvpK5-008gpZ-RZ for linux-arm-kernel@lists.infradead.org; Tue, 22 Jun 2021 22:56:52 +0000 Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by thoth.sbs.de (8.15.2/8.15.2) with ESMTPS id 15MMuVSg027778 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Jun 2021 00:56:31 +0200 Received: from [167.87.93.200] ([167.87.93.200]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id 15MMuQ3p002566; Wed, 23 Jun 2021 00:56:27 +0200 Subject: Re: [PATCH v2] serial: 8250: 8250_omap: Fix possible interrupt storm on K3 SoCs To: Vignesh Raghavendra , Greg Kroah-Hartman , Jiri Slaby Cc: Tony Lindgren , linux-serial@vger.kernel.org, linux-omap@vger.kernel.org, Linux ARM Mailing List References: <20210622145704.11168-1-vigneshr@ti.com> From: Jan Kiszka Message-ID: Date: Wed, 23 Jun 2021 00:56:25 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <20210622145704.11168-1-vigneshr@ti.com> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210622_155650_789435_BD7398CC X-CRM114-Status: GOOD ( 27.44 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 22.06.21 16:57, Vignesh Raghavendra wrote: > On K3 family of SoCs (which includes AM654 SoC), it is observed that RX > TIMEOUT is signalled after RX FIFO has been drained, in which case a > dummy read of RX FIFO is required to clear RX TIMEOUT condition. > Otherwise, this would lead to an interrupt storm. > > Fix this by introducing UART_RX_TIMEOUT_QUIRK flag and doing a dummy > read in IRQ handler when RX TIMEOUT is reported with no data in RX FIFO. > > Fixes: be70874498f3 ("serial: 8250_omap: Add support for AM654 UART controller") > Reported-by: Jan Kiszka > Signed-off-by: Vignesh Raghavendra > --- > v2: > Restrict workaround to K3 family of devices only (ti,am654-uart) where > issue was reported. > > v1: https://lore.kernel.org/r/20210511151955.28071-1-vigneshr@ti.com > > drivers/tty/serial/8250/8250_omap.c | 20 +++++++++++++++++++- > 1 file changed, 19 insertions(+), 1 deletion(-) > > diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c > index c06631ced414..79418d4beb48 100644 > --- a/drivers/tty/serial/8250/8250_omap.c > +++ b/drivers/tty/serial/8250/8250_omap.c > @@ -43,6 +43,7 @@ > #define UART_ERRATA_CLOCK_DISABLE (1 << 3) > #define UART_HAS_EFR2 BIT(4) > #define UART_HAS_RHR_IT_DIS BIT(5) > +#define UART_RX_TIMEOUT_QUIRK BIT(6) > > #define OMAP_UART_FCR_RX_TRIG 6 > #define OMAP_UART_FCR_TX_TRIG 4 > @@ -104,6 +105,9 @@ > #define UART_OMAP_EFR2 0x23 > #define UART_OMAP_EFR2_TIMEOUT_BEHAVE BIT(6) > > +/* RX FIFO occupancy indicator */ > +#define UART_OMAP_RX_LVL 0x64 > + > struct omap8250_priv { > int line; > u8 habit; > @@ -611,6 +615,7 @@ static int omap_8250_dma_handle_irq(struct uart_port *port); > static irqreturn_t omap8250_irq(int irq, void *dev_id) > { > struct uart_port *port = dev_id; > + struct omap8250_priv *priv = port->private_data; > struct uart_8250_port *up = up_to_u8250p(port); > unsigned int iir; > int ret; > @@ -625,6 +630,18 @@ static irqreturn_t omap8250_irq(int irq, void *dev_id) > serial8250_rpm_get(up); > iir = serial_port_in(port, UART_IIR); > ret = serial8250_handle_irq(port, iir); > + > + /* > + * On K3 SoCs, it is observed that RX TIMEOUT is signalled after > + * FIFO has been drained, in which case a dummy read of RX FIFO > + * is required to clear RX TIMEOUT condition. > + */ > + if (priv->habit & UART_RX_TIMEOUT_QUIRK && > + (iir & UART_IIR_RX_TIMEOUT) == UART_IIR_RX_TIMEOUT && > + serial_port_in(port, UART_OMAP_RX_LVL) == 0) { > + serial_port_in(port, UART_RX); > + } > + > serial8250_rpm_put(up); > > return IRQ_RETVAL(ret); > @@ -1218,7 +1235,8 @@ static struct omap8250_dma_params am33xx_dma = { > > static struct omap8250_platdata am654_platdata = { > .dma_params = &am654_dma, > - .habit = UART_HAS_EFR2 | UART_HAS_RHR_IT_DIS, > + .habit = UART_HAS_EFR2 | UART_HAS_RHR_IT_DIS | > + UART_RX_TIMEOUT_QUIRK, > }; > > static struct omap8250_platdata am33xx_platdata = { > Tested-by: Jan Kiszka Thanks, Jan -- Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel