From nobody Thu Apr 9 14:58:08 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 640D7C4332F for ; Mon, 7 Nov 2022 11:07:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231573AbiKGLHg (ORCPT ); Mon, 7 Nov 2022 06:07:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231158AbiKGLHX (ORCPT ); Mon, 7 Nov 2022 06:07:23 -0500 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 110F918374; Mon, 7 Nov 2022 03:07:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667819243; x=1699355243; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kwbVN41tr92ZOfdbCaPY/Bzq8aetPvpbAPbc0F2INvo=; b=klRtpQ4bOaQK/8VI5XINYox9qNZZ/XQVh2K8M871OOweASlAInlHhMO2 nYy4qqh1XRLM9D7M9fZ2BdlPG4BPamrwpn5mgLSPp9Z1g7726EUaiWgql U82Am7JIQkC+CyS4w1of2G412nlq9c6SEHC/Se9wvcMy5IzDYL2Fxp7fb 6UQasb5daX/nqtSaYIb/zrO53/0j1+CWACc6jpziC/R/14Rw/SyLSb3vy jtPNh0OQ3DGW8mvFknt2o6dKdyH1315jnhmbVF2pcykXI/NAEwJLMYJf/ kWuRBIrPLEN0d7UnqE4wlEFrB/F8IjO9KPcRbC8vFmyamfXR20ZlhPcGz A==; X-IronPort-AV: E=McAfee;i="6500,9779,10523"; a="290773009" X-IronPort-AV: E=Sophos;i="5.96,143,1665471600"; d="scan'208";a="290773009" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Nov 2022 03:07:22 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10523"; a="586932338" X-IronPort-AV: E=Sophos;i="5.96,143,1665471600"; d="scan'208";a="586932338" Received: from gschoede-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.252.46.211]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Nov 2022 03:07:19 -0800 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: Andy Shevchenko , Greg Kroah-Hartman , Jiri Slaby , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Heikki Krogerus Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , stable@vger.kernel.org, Srikanth Thokala , Aman Kumar Subject: [PATCH 1/4] serial: 8250: Fall back to non-DMA Rx if IIR_RDI occurs Date: Mon, 7 Nov 2022 13:07:05 +0200 Message-Id: <20221107110708.58223-2-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221107110708.58223-1-ilpo.jarvinen@linux.intel.com> References: <20221107110708.58223-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org DW UART sometimes triggers IIR_RDI during DMA Rx when IIR_RX_TIMEOUT should have been triggered instead. Since IIR_RDI has higher priority than IIR_RX_TIMEOUT, this causes the Rx to hang into interrupt loop. The problem seems to occur at least with some combinations of small-sized transfers (I've reproduced the problem on Elkhart Lake PSE UARTs). If there's already an on-going Rx DMA and IIR_RDI triggers, fall graciously back to non-DMA Rx. That is, behave as if IIR_RX_TIMEOUT had occurred. 8250_omap already considers IIR_RDI similar to this change so its nothing unheard of. Fixes: 75df022b5f89 ("serial: 8250_dma: Fix RX handling") Cc: Co-developed-by: Srikanth Thokala Signed-off-by: Srikanth Thokala Co-developed-by: Aman Kumar Signed-off-by: Aman Kumar Signed-off-by: Ilpo J=C3=A4rvinen --- drivers/tty/serial/8250/8250_port.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/= 8250_port.c index fe8662cd9402..92dd18716169 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -1897,6 +1897,10 @@ EXPORT_SYMBOL_GPL(serial8250_modem_status); static bool handle_rx_dma(struct uart_8250_port *up, unsigned int iir) { switch (iir & 0x3f) { + case UART_IIR_RDI: + if (!up->dma->rx_running) + break; + fallthrough; case UART_IIR_RX_TIMEOUT: serial8250_rx_dma_flush(up); fallthrough; --=20 2.30.2 From nobody Thu Apr 9 14:58:08 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2AA7C4332F for ; Mon, 7 Nov 2022 11:07:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231624AbiKGLHm (ORCPT ); Mon, 7 Nov 2022 06:07:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231400AbiKGLH0 (ORCPT ); Mon, 7 Nov 2022 06:07:26 -0500 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 316AA18386; Mon, 7 Nov 2022 03:07:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667819246; x=1699355246; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UtD5WjXlvt+YGgcDoYJMysEl6WyGK5Ld+p1WXJ0fxvY=; b=n28fkNWLHfIASasA6zjuz0HHBIObVZ3prF4BeJY27HUS16Jl5gXbKbeW G/sn44dMeIPapAxm/pxzVB3aUgiUkywnrj3VzMjPo+lckKfvb+hh0LzM3 xakZdCJad2TZQ/vV1LD0URjhAwO/SeVn7GqVXyx9yw04dS3bQTQC9d+j1 UFIDxhzPbAVPIJSbO5U7HSpbePdJGrBdTqquedKMK9lTL3NXw+KbLK0Gm 8YCbD3CAKpmEv9qZcQJVx5DrRXujjF/SHwVQ/bVfrfRITkJsuqTkyP8Wn BpIqCNghusdhthPp9jkRxMXlBIxeRmmj06ca5mgPGwZx7hMZGZZZD7QIY Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10523"; a="290773022" X-IronPort-AV: E=Sophos;i="5.96,143,1665471600"; d="scan'208";a="290773022" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Nov 2022 03:07:25 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10523"; a="586932344" X-IronPort-AV: E=Sophos;i="5.96,143,1665471600"; d="scan'208";a="586932344" Received: from gschoede-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.252.46.211]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Nov 2022 03:07:23 -0800 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: Andy Shevchenko , Greg Kroah-Hartman , Jiri Slaby , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Cc: stable Subject: [PATCH 2/4] serial: 8250_lpss: Configure DMA also w/o DMA filter Date: Mon, 7 Nov 2022 13:07:06 +0200 Message-Id: <20221107110708.58223-3-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221107110708.58223-1-ilpo.jarvinen@linux.intel.com> References: <20221107110708.58223-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the platform doesn't use DMA device filter (as is the case with Elkhart Lake), whole lpss8250_dma_setup() setup is skipped. This results in skipping also *_maxburst setup which is undesirable. Refactor lpss8250_dma_setup() to configure DMA even if filter is not setup. Cc: stable Signed-off-by: Ilpo J=C3=A4rvinen --- drivers/tty/serial/8250/8250_lpss.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/tty/serial/8250/8250_lpss.c b/drivers/tty/serial/8250/= 8250_lpss.c index 44cc755b1a29..ed281445a97d 100644 --- a/drivers/tty/serial/8250/8250_lpss.c +++ b/drivers/tty/serial/8250/8250_lpss.c @@ -277,8 +277,10 @@ static int lpss8250_dma_setup(struct lpss8250 *lpss, s= truct uart_8250_port *port struct dw_dma_slave *rx_param, *tx_param; struct device *dev =3D port->port.dev; =20 - if (!lpss->dma_param.dma_dev) - return 0; + if (!lpss->dma_param.dma_dev) { + dma =3D port->dma; + goto confonly; + } =20 rx_param =3D devm_kzalloc(dev, sizeof(*rx_param), GFP_KERNEL); if (!rx_param) @@ -289,16 +291,20 @@ static int lpss8250_dma_setup(struct lpss8250 *lpss, = struct uart_8250_port *port return -ENOMEM; =20 *rx_param =3D lpss->dma_param; - dma->rxconf.src_maxburst =3D lpss->dma_maxburst; - *tx_param =3D lpss->dma_param; - dma->txconf.dst_maxburst =3D lpss->dma_maxburst; =20 dma->fn =3D lpss8250_dma_filter; dma->rx_param =3D rx_param; dma->tx_param =3D tx_param; =20 port->dma =3D dma; + +confonly: + if (dma) { + dma->rxconf.src_maxburst =3D lpss->dma_maxburst; + dma->txconf.dst_maxburst =3D lpss->dma_maxburst; + } + return 0; } =20 --=20 2.30.2 From nobody Thu Apr 9 14:58:08 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC0F4C433FE for ; Mon, 7 Nov 2022 11:07:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231679AbiKGLHq (ORCPT ); Mon, 7 Nov 2022 06:07:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231356AbiKGLHc (ORCPT ); Mon, 7 Nov 2022 06:07:32 -0500 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7256218364; Mon, 7 Nov 2022 03:07:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667819251; x=1699355251; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gbTRCkxxLdOZW1y6aGgrb7XRmU8BTA5iNZdcQ5OXGmE=; b=TKH12svCttUpMooVWeFxd0W2LsXEOWYvyXaD0JViSkjlGlTvo4q/CgO0 kLPRU1255lpL/Kiqa7ZtfLvRNtX/yCwjHF5simTlPezMC9hmC25W9QF0h z+KDN7btn4j5mZnJ02w7AgftCYk+YJr/RHnhHil78tlUUXbGsOPQoEiOw efwkvLeX/se+ZwYSN7HN3TCkGvTHLOpETc2pKmYFHPsnQzuka21YLNHah QZiv72y2wEJlAIEJM8Y27as5KA4mQgmeog4/RyiqpVc6yR0hUeqsthT/x vZ4B0g57V1tsWq9zHYtGzb6M05z+w8OoIQzX+qxabG/5MJeYP0Q82jVZr A==; X-IronPort-AV: E=McAfee;i="6500,9779,10523"; a="290773035" X-IronPort-AV: E=Sophos;i="5.96,143,1665471600"; d="scan'208";a="290773035" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Nov 2022 03:07:29 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10523"; a="586932376" X-IronPort-AV: E=Sophos;i="5.96,143,1665471600"; d="scan'208";a="586932376" Received: from gschoede-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.252.46.211]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Nov 2022 03:07:26 -0800 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: Andy Shevchenko , Greg Kroah-Hartman , Jiri Slaby , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Cc: stable@vger.kernel.org, Wentong Wu , Srikanth Thokala , Aman Kumar Subject: [PATCH 3/4] serial: 8250_lpss: Use 16B DMA burst with Elkhart Lake Date: Mon, 7 Nov 2022 13:07:07 +0200 Message-Id: <20221107110708.58223-4-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221107110708.58223-1-ilpo.jarvinen@linux.intel.com> References: <20221107110708.58223-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Configure DMA to use 16B burst size with Elkhart Lake. This makes the bus use more efficient and works around an issue which occurs with the previously used 1B. Fixes: 0a9410b981e9 ("serial: 8250_lpss: Enable DMA on Intel Elkhart Lake") Cc: # serial: 8250_lpss: Configure DMA also w/o DM= A filter Reported-by: Wentong Wu Co-developed-by: Srikanth Thokala Signed-off-by: Srikanth Thokala Co-developed-by: Aman Kumar Signed-off-by: Aman Kumar Signed-off-by: Ilpo J=C3=A4rvinen --- I know the list of Co-dev-bys & Sob seems a bit odd for a oneliner. The reason is that I cleaned up this from a more complex patch using the earlier change that I authored myself so only this oneliner remained in this patch. --- drivers/tty/serial/8250/8250_lpss.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/tty/serial/8250/8250_lpss.c b/drivers/tty/serial/8250/= 8250_lpss.c index ed281445a97d..e0b4e1446eac 100644 --- a/drivers/tty/serial/8250/8250_lpss.c +++ b/drivers/tty/serial/8250/8250_lpss.c @@ -174,6 +174,8 @@ static int ehl_serial_setup(struct lpss8250 *lpss, stru= ct uart_port *port) */ up->dma =3D dma; =20 + lpss->dma_maxburst =3D 16; + port->set_termios =3D dw8250_do_set_termios; =20 return 0; --=20 2.30.2 From nobody Thu Apr 9 14:58:08 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DD7AC433FE for ; Mon, 7 Nov 2022 11:07:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231705AbiKGLHs (ORCPT ); Mon, 7 Nov 2022 06:07:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231518AbiKGLHe (ORCPT ); Mon, 7 Nov 2022 06:07:34 -0500 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0239618386; Mon, 7 Nov 2022 03:07:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667819253; x=1699355253; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GX897nypwCJ78jjUOfdNotVKqeArdhyavQ6h8PsVU8c=; b=iBAai1hLFbwA3ysMoxykDt0hyJZiRbCzyzWNyAomHd9iwAdfPIpenazq DAJ4xRaUCowz/bCuNKsj+ayqCsQPHwU5eLHsdLPI4J12fu/Cm1tlh0ztK QSDAkQgYXb7v9lj6SuDozCuXagovBnDlqEwUPXqpGTcwy4BKcBwD46JEK ecZuik8nyNhIB2JLA/og0EDA1NXsDBOLadHV8GEycOEf3eXBscNamUU/k 08zrALZsJb3jXpCG6dZaXL0JtegYjufovr9mxUvOgeRtxf50Wm5wUR+zx /sEK8i7wpdDIzcNZl0u6GumAdST+Qhj6EMcRalvEEz+p3wnkKlR6KJG1J A==; X-IronPort-AV: E=McAfee;i="6500,9779,10523"; a="290773043" X-IronPort-AV: E=Sophos;i="5.96,143,1665471600"; d="scan'208";a="290773043" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Nov 2022 03:07:33 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10523"; a="586932381" X-IronPort-AV: E=Sophos;i="5.96,143,1665471600"; d="scan'208";a="586932381" Received: from gschoede-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.252.46.211]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Nov 2022 03:07:31 -0800 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: Andy Shevchenko , Greg Kroah-Hartman , Jiri Slaby , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Heikki Krogerus Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , stable@vger.kernel.org, Gilles BULOZ Subject: [PATCH 4/4] serial: 8250: Flush DMA Rx on RLSI Date: Mon, 7 Nov 2022 13:07:08 +0200 Message-Id: <20221107110708.58223-5-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221107110708.58223-1-ilpo.jarvinen@linux.intel.com> References: <20221107110708.58223-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Returning true from handle_rx_dma() without flushing DMA first creates a data ordering hazard. If DMA Rx has handled any character at the point when RLSI occurs, the non-DMA path handles any pending characters jumping them ahead of those characters that are pending under DMA. Fixes: 75df022b5f89 ("serial: 8250_dma: Fix RX handling") Cc: Signed-off-by: Ilpo J=C3=A4rvinen --- Cc: Gilles BULOZ drivers/tty/serial/8250/8250_port.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/= 8250_port.c index 92dd18716169..388172289627 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -1901,10 +1901,9 @@ static bool handle_rx_dma(struct uart_8250_port *up,= unsigned int iir) if (!up->dma->rx_running) break; fallthrough; + case UART_IIR_RLSI: case UART_IIR_RX_TIMEOUT: serial8250_rx_dma_flush(up); - fallthrough; - case UART_IIR_RLSI: return true; } return up->dma->rx_dma(up); --=20 2.30.2