Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp161104rdh; Wed, 22 Nov 2023 23:28:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IF01xPAIGjYp1kHRTPF+VNik495aAa6rVMydK1JADdK9NpU+i/q+tw8P47XHa5FkXoxSI+x X-Received: by 2002:a05:6358:4407:b0:16d:abc7:bfab with SMTP id z7-20020a056358440700b0016dabc7bfabmr5721757rwc.15.1700724520571; Wed, 22 Nov 2023 23:28:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700724520; cv=none; d=google.com; s=arc-20160816; b=LlPG3CU12/4xD41YMP33kTsnRP72u0V67Pepu49C2T2SbguZ8UA7Vt4pXQ9RjvrEH8 KZBzYaWt7ZNkRwdz7avq1YohoBS6DHI/gOxfhhuYQ8tperYHDiUX9Fk3COR0/CDHSKHF spzrDI7u48MbGVdksrMp+yb5cMdkfgCeKf4HH29p2An9Op98JtJAYiCyLhpmTGqraxpd Gn9mM7R4C0J/m5gmJ8i7+R6uz2m4/IYvlgIpjwkSI6kUQ4wUzrnuS/XFPJ5AissaL9vN xjIkuNVkLUJar/m1pcqQrmB7z0923vYm66HtMf8o+OY7+KiUN8zl8UXP+Npgyk0BRZqW Y5Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Vm+Vl7CbM35M+q/0o1zEylFDQqG6v2YRmeQ0pvk7EYk=; fh=Qn7pAV2GZgdSx6AEcCuHpGIZzq//SQphPFMwRquWzgI=; b=yYn4nTscWYEwWN77hh/uw+DEAHB2SMnFS21M2u/N2B5nfZDUiPrvVYoyV4+Yy/57KE K90XZZzUQGZK5lkCf9bJ72iTfUkuYgQioVw7ZCaWNI3QQ4v0Q48DY4HcJP/+PhB9Skmn EZIaPdsRLChfyya+Ryov0dxwieB5Bivf6ocpsDoGu2R/9qAvWwpPSuu2BvsYbU1913EZ APtf1Mo1MY4Efb1ltzUL5HI/hrsCrBdiJGikpwkYrxw3/tve9QLAopSYf3ZM7GszulwJ RT5Q2AJ+UGM/+K+xx7oSBF1OEJZVGLPsZVuS7RvH8WhjkAWl2bGZxLFhv/a9VW+fGJbk gP8w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id d7-20020a656207000000b005c2135c5018si763361pgv.571.2023.11.22.23.28.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 23:28:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 3359C807750A; Wed, 22 Nov 2023 23:28:38 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230353AbjKWH2W (ORCPT + 99 others); Thu, 23 Nov 2023 02:28:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229995AbjKWH2V (ORCPT ); Thu, 23 Nov 2023 02:28:21 -0500 Received: from mail.bugwerft.de (mail.bugwerft.de [46.23.86.59]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A030EE7; Wed, 22 Nov 2023 23:28:27 -0800 (PST) Received: from hq-00595.holoplot.net (unknown [62.214.9.170]) by mail.bugwerft.de (Postfix) with ESMTPSA id 1041A2806ED; Thu, 23 Nov 2023 07:28:26 +0000 (UTC) From: Daniel Mack To: gregkh@linuxfoundation.org, jirislaby@kernel.org, lech.perczak@camlingroup.com, u.kleine-koenig@pengutronix.de Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Daniel Mack , Maxim Popov , stable@vger.kernel.org Subject: [PATCH v5] serial: sc16is7xx: address RX timeout interrupt errata Date: Thu, 23 Nov 2023 08:28:18 +0100 Message-ID: <20231123072818.1394539-1-daniel@zonque.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 22 Nov 2023 23:28:38 -0800 (PST) This device has a silicon bug that makes it report a timeout interrupt but no data in the FIFO. The datasheet states the following in the errata section 18.1.4: "If the host reads the receive FIFO at the same time as a time-out interrupt condition happens, the host might read 0xCC (time-out) in the Interrupt Indication Register (IIR), but bit 0 of the Line Status Register (LSR) is not set (means there is no data in the receive FIFO)." The errata description seems to indicate it concerns only polled mode of operation when reading bit 0 of the LSR register. However, tests have shown and NXP has confirmed that the RXLVL register also yields 0 when the bug is triggered, and hence the IRQ driven implementation in this driver is equally affected. This bug has hit us on production units and when it does, sc16is7xx_irq() would spin forever because sc16is7xx_port_irq() keeps seeing an interrupt in the IIR register that is not cleared because the driver does not call into sc16is7xx_handle_rx() unless the RXLVL register reports at least one byte in the FIFO. Fix this by always reading one byte from the FIFO when this condition is detected in order to clear the interrupt. This approach was confirmed to be correct by NXP through their support channels. Signed-off-by: Daniel Mack Co-Developed-by: Maxim Popov Tested by: Hugo Villeneuve Cc: stable@vger.kernel.org --- v5: slightly reworded commit log again, added Hugo's Tested-By v4: NXP has confirmed the fix; update the commit log accordingly v3: re-added the additional Co-Developed-by and stable@ tags v2: reworded the commit log a bit for more context. drivers/tty/serial/sc16is7xx.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index 289ca7d4e566..76f76e510ed1 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -765,6 +765,18 @@ static bool sc16is7xx_port_irq(struct sc16is7xx_port *s, int portno) case SC16IS7XX_IIR_RTOI_SRC: case SC16IS7XX_IIR_XOFFI_SRC: rxlen = sc16is7xx_port_read(port, SC16IS7XX_RXLVL_REG); + + /* + * There is a silicon bug that makes the chip report a + * time-out interrupt but no data in the FIFO. This is + * described in errata section 18.1.4. + * + * When this happens, read one byte from the FIFO to + * clear the interrupt. + */ + if (iir == SC16IS7XX_IIR_RTOI_SRC && !rxlen) + rxlen = 1; + if (rxlen) sc16is7xx_handle_rx(port, rxlen, iir); break; -- 2.41.0