Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4347483imw; Tue, 12 Jul 2022 06:31:18 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vHBRv1sbdtMeAhI8ijpVzmowglliTHQPRhSWpn1UVnVSUK6sqqgOyeDakX0X3FVlboZkFL X-Received: by 2002:a17:906:49:b0:6f3:bb5e:54a8 with SMTP id 9-20020a170906004900b006f3bb5e54a8mr23171041ejg.534.1657632678261; Tue, 12 Jul 2022 06:31:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657632678; cv=none; d=google.com; s=arc-20160816; b=wigjqPywpRGuIpYyuR2wo/BTtyd9ZPik6OEwO0gaq8UL1XQXGjeraY+5a2C3TziRiF sMhRCn4tDY+JH5fvt35aNaXxsgQU5J46NDPIG0gZYnUnzx8vT43ase1KLomFSaZEnLsZ NKK/BiUByJhqA1IPFWO1ZfISY7ctgugcU03yZUwA+81OXUj4njqTZnqMtKdARoC6zeHh J6ZNXAzQeBgi8cgtV2eMixwn8kXargVZj1a5kxJc17uDstN06BWevp6JtbLENhBFt21n 5/TM6UVV96cVN3cuEBaBdbWWvnFLu0mY2NTQzO1DWl4ZkCayRKunDTZK3RlcIGYw1HtQ d0BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=Jj15qoURj3emWvHLxBH2nPwiIzzLvd3mSNd7M20V7kc=; b=v/hyQXNtim1Z+phfx98y2Cgho2jk0n36LT4ooy+BCCVED+g9WKKF8Ig3IeBe27iOJp E9l1Xmyzqiq/kTRuJxJ6/8/KIAH6pE1Fhn3jcSJRsM9NPwtR5VoS48/mMQWdhSUt2Dxq l5ocR0teEzHvnCHzlLsgPc3WDEeqkekQ98T4GcgpG18pAt5WRAU0H6qfnQLlCVJOV+SC eKDjvdPCfLBAQxNfZKkcSG6vpsv5DuRrBOMXdgp3wwZ9u0ELWR504OCzf34NMa7u3N8E IVYhDrlsOxRnOi132JygZLu2H08GFK1iDPetZVy3BNcwHqSIuXd4zbnsUHYxhpHDoZVk 4gPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=VrvPmlW1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l17-20020a056402255100b0043a737c28desi9629640edb.279.2022.07.12.06.30.53; Tue, 12 Jul 2022 06:31:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=VrvPmlW1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229762AbiGLNPf (ORCPT + 99 others); Tue, 12 Jul 2022 09:15:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229703AbiGLNPd (ORCPT ); Tue, 12 Jul 2022 09:15:33 -0400 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA7B3564DB for ; Tue, 12 Jul 2022 06:15:30 -0700 (PDT) Received: by mail-pg1-x54a.google.com with SMTP id d66-20020a636845000000b0040a88edd9c1so3304886pgc.13 for ; Tue, 12 Jul 2022 06:15:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=Jj15qoURj3emWvHLxBH2nPwiIzzLvd3mSNd7M20V7kc=; b=VrvPmlW1Mw9Qie6nuTLyJIEdvtB1q9qnbj5yZHc5WAz2gmilCGbHrAqHW+nbHnr1Yt QYCVTeIud8NWMDpleRg/psfMwA6QarcShJmRgGOPwCri+9+7X2GBA4+Tj+c4G58JlOR2 AAnOp9AzxbNQ7LsrvFRsrxgHUqqbYI38rxnkXJYQf4VtAcxDHSqE1u2CVWElkavoprVq MLPLZF4KKZ2n+NFw/z5bjZirvOBQtqzV8bEJ7ZcxpbnMBWkTdx+DSdszCF38jbVzKw1N v+nA8OfSDnRpifHP6YFfv5eLm0pP+A8Sl89jwczzX/VKEppia8uaYMmSmotBlTP99use TmPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=Jj15qoURj3emWvHLxBH2nPwiIzzLvd3mSNd7M20V7kc=; b=UpUM2zz7JY3sN4DcNmwQLGo4JHJ8GzdSqtlYkUlfcgRgF3/SdAc/dmVY02q3eAbf05 RBazSwoOhO83VnSOP3SGeJW+o6kMewtD4/50GdFlclXM7YpsC6BbjpuwdNu0PEpgb8So ed1CmX5ZyiWLAyBvv/7MsEYDOrlxKGeF94TRK9eRfaKqmo8t+r4anB15v+eIPOV4+4FM IxFZK3UPUkd8VyDvAxBkcpLA142/iJNens+khuptKr/Tl2EHc952LeUMKiHBfFYH5pm4 c9VIzUaRu1N5ieYAeyniGA6s5w0WhTri7UzTdz/9NpWgmaECAImP/oWiuM9J13Qf2BER RuSQ== X-Gm-Message-State: AJIora/453Cm0/h/TzJp+jBWn2TfqCn5f4V1vfi57bgNIJijAVpvToql 6zq9nDbMjafLuPbFZvYZV0ZX0fA79V/Z9twq/AxJ X-Received: from vamshig51.c.googlers.com ([fda3:e722:ac3:cc00:3:22c1:c0a8:70c]) (user=vamshigajjela job=sendgmr) by 2002:a17:90b:247:b0:1f0:1192:7c22 with SMTP id fz7-20020a17090b024700b001f011927c22mr4471560pjb.232.1657631730301; Tue, 12 Jul 2022 06:15:30 -0700 (PDT) Date: Tue, 12 Jul 2022 18:45:23 +0530 Message-Id: <20220712131523.1874428-1-vamshigajjela@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.37.0.144.g8ac04bfd2-goog Subject: [PATCH] serial: 8250_dw: Avoid pslverr on reading empty receiver fifo From: Vamshi Gajjela To: Andy Shevchenko , Greg Kroah-Hartman , Jiri Slaby Cc: Miquel Raynal , Phil Edworthy , Emil Renner Berthing , Heikki Krogerus , Johan Hovold , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, VAMSHI GAJJELA Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: VAMSHI GAJJELA With PSLVERR_RESP_EN parameter set to 1, device generates an error response when an attempt to read empty RBR with FIFO enabled. This happens when LCR writes are ignored when UART is busy. dw8250_check_lcr() in retries to updateLCR, invokes dw8250_force_idle() to clear and reset fifo and eventually reads UART_RX causing pslverr. Avoid this by not reading RBR/UART_RX when no data is available. Signed-off-by: VAMSHI GAJJELA --- drivers/tty/serial/8250/8250_dw.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c index f57bbd32ef11..a83222839884 100644 --- a/drivers/tty/serial/8250/8250_dw.c +++ b/drivers/tty/serial/8250/8250_dw.c @@ -81,9 +81,19 @@ static inline int dw8250_modify_msr(struct uart_port *p, int offset, int value) static void dw8250_force_idle(struct uart_port *p) { + unsigned int lsr; struct uart_8250_port *up = up_to_u8250p(p); serial8250_clear_and_reinit_fifos(up); + + /* + * With PSLVERR_RESP_EN parameter set to 1, device generates pslverr + * error response when an attempt to read empty RBR with FIFO enabled + */ + lsr = p->serial_in(p, UART_LSR); + if ((up->fcr & UART_FCR_ENABLE_FIFO) && !(lsr & UART_LSR_DR)) + return; + (void)p->serial_in(p, UART_RX); } -- 2.37.0.144.g8ac04bfd2-goog