Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp914784rdf; Tue, 21 Nov 2023 23:36:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IHQtS57HLVlonh1mZtapDKuv73oMUtFI1MzFC+4Os8KUehpVLNwRUqJPS+3tb42QICEbHlU X-Received: by 2002:a17:902:9304:b0:1cc:1ee2:d41d with SMTP id bc4-20020a170902930400b001cc1ee2d41dmr1385260plb.39.1700638578101; Tue, 21 Nov 2023 23:36:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700638578; cv=none; d=google.com; s=arc-20160816; b=oRQ3l63DFwjRnm78RAl8QUSkAHi4OIuyNtET+3mQa2SbA5oFCnnCsTcEJQdtttqXZ2 QGvtyHNedBrW+kc2FYBsFrRGO88f8NKGBxcXI1hnPu2oDQjeB7mJJVRQACltIt2sp9BF RGW/izgqQtXF4++F7DTJRFmtjrcf0sMYje8u3RsVvpaHwk3nenjHxFxd+09AwYrZZciq Oc7dDxa2qQ5epb/SOQoc3PaVKLEY/c7TwQtKO+8ykDBdF6+Qxy/3FZDN10DT++7lJe3k UxD0yDZr3JTEEyVUWEYFrpgqgN+UiYFEyzMG0fgo+ETTLz34bH+SMTTsNp51H4ZKTN4k szYg== 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=trcGs/znHsziF3e3fiWMRO4nSe6DjBMq0ETKu7mII2E=; fh=Qn7pAV2GZgdSx6AEcCuHpGIZzq//SQphPFMwRquWzgI=; b=F4yW10Dtv9JAl2DnzjxLIEUt0UjhOrQGfqINZR2ZvCITIiHSakPlMvtuY8BlZDYaRI bQ7AkFt+Ww8RWn2PFRXBehJ4gTTTKjIxPQfeZurZnkYA9kz10QMGlYPlU/oSTN3FhBKO mngch9Ue/+qSlHWdSt3TtdeARTiMMovJCUi7LUY9jSPM+npO27EdfyQaJS09FySbdImj TVAKmqHm+efmeUHcdDMCCuhlCdkilxYipRANXmEd46tO+AyJ72mNHRGet8736HLRWWut u5xZRrCYhvtU1p94uzTlT3pUE4Llo6CeagNgjo8mcWxukmCAg1m8Szzer0lFfzP1sF1W AQsw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id q14-20020a170902dace00b001ce5b8081a5si12470831plx.382.2023.11.21.23.36.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 23:36:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 8FABB80FF282; Tue, 21 Nov 2023 23:36:15 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230173AbjKVHf6 (ORCPT + 99 others); Wed, 22 Nov 2023 02:35:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229931AbjKVHf5 (ORCPT ); Wed, 22 Nov 2023 02:35:57 -0500 Received: from mail.bugwerft.de (mail.bugwerft.de [46.23.86.59]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7D033F4; Tue, 21 Nov 2023 23:35:52 -0800 (PST) Received: from hq-00595.holoplot.net (unknown [62.214.9.170]) by mail.bugwerft.de (Postfix) with ESMTPSA id 66FBE281506; Wed, 22 Nov 2023 07:35:50 +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 v4] serial: sc16is7xx: address RX timeout interrupt errata Date: Wed, 22 Nov 2023 08:35:41 +0100 Message-ID: <20231122073541.1200457-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 agentk.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 (agentk.vger.email [0.0.0.0]); Tue, 21 Nov 2023 23:36:15 -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 doesn't explicitly mention that, but tests have shown and the vendor has confirmed that the RXLVL register 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 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 Cc: stable@vger.kernel.org --- Meanwhile, NXP has confirmed this fix to be correct. 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