From patchwork Sun Aug 9 11:22:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1342600 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=HlqXh3Dt; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BPcCw1bDdz9sR4 for ; Sun, 9 Aug 2020 21:23:21 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C032D81B88; Sun, 9 Aug 2020 13:23:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="HlqXh3Dt"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6612D81E17; Sun, 9 Aug 2020 13:23:13 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 03E1081817 for ; Sun, 9 Aug 2020 13:23:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut@gmail.com Received: by mail-ed1-x543.google.com with SMTP id df16so4393218edb.9 for ; Sun, 09 Aug 2020 04:23:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=wqj8VynyrTPcdZOjbkYMm38SooY9K/0XVDqbHFz/vSo=; b=HlqXh3DtwkW40W147IAeuOMJ+wnhfEL0azcUxAn85+oIweX/uTe4l6a34O9Vdz2qg7 OJHunr+xfZGiJrHA+QimME/tng5Dz1fMTEIsvSpuDMXPcyCfyftIv5uP0BAwI+4ATI0M NGKm5Wrx3SvcYBMiLtab31JZNC3N5sIuO2uQTwySn8CO9tcPpaWQmFisI6hqH7zHuqNS 6cLlPuwns5fWZxWfHBouSepyl5YKPMJTXIqEOGKXHFc+Q4Am2I0atz0FcImFno0cTF27 GucKFTosAXIVy6KifVbZdh5WaJwWYZdYkycrVZDi8Ef7s5ntu9qV+ReLDkZB7h67On9b ginQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=wqj8VynyrTPcdZOjbkYMm38SooY9K/0XVDqbHFz/vSo=; b=BMNETFZAOfksIOmIKwviuFb8keUdqnj0MUxPl3IiZYdJ9Ja+pbvRjIB7TO0x3YeH1A 8mx7uiy0s4oDI5QKLagA9VGZ6rxIjU4sFxaiFtSAyFFfVBBmKJaAV6BN8xWmDXVqjwf+ phiPmPh1zVP8j9bmLGIysPixmvGxPCppd1TH1Qak7wG7mpzJM95GswOz1Mn6QmDTcdRj pi78AY52fNuC0k35Lp6mtIuD9SJKRduybcEy8lQUxZRSKT7Vf9d++xlw7WUlY7QvELN1 xaf6FpLsDFje0CMImnPSDwZkYCyyFyPrZX1Vn0XDMef5lUVz/Io6DEPxB/CtaTiwiaxo rS/w== X-Gm-Message-State: AOAM533EBLaZmMBqzpMUND+gt/2i7I9sF7xEc5XjxuA5/F8OlyU2xXqY d201WuJc3dV60pOsU2PGOjscnV+EDGw= X-Google-Smtp-Source: ABdhPJzS8jMgqIVMKGI2dMaric8EGjArXuNDhm5nLvS4YFn0GBznhW0jrjD5iU211Ntit9QOJUB8pQ== X-Received: by 2002:a05:6402:1855:: with SMTP id v21mr17041665edy.355.1596972190230; Sun, 09 Aug 2020 04:23:10 -0700 (PDT) Received: from desktop.lan (ip-86-49-101-166.net.upcbroadband.cz. [86.49.101.166]) by smtp.gmail.com with ESMTPSA id m24sm10183437eje.80.2020.08.09.04.23.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Aug 2020 04:23:09 -0700 (PDT) From: Marek Vasut X-Google-Original-From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Nobuhiro Iwamatsu Subject: [PATCH] serial: sh: Improve FIFO empty check on RX Date: Sun, 9 Aug 2020 13:22:59 +0200 Message-Id: <20200809112259.7763-1-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean If the SCIF is receiving data quickly enough, it may happen that the SCxSR_RDxF flag is cleared in sh_serial_getc_generic(), while the FIFO still contains data. If that happens, the serial_getc_check() reports no data in the FIFO as the flag is no longer set. Add one more check, if the SCxSR_RDxF is not set, read out the FIFO level and if there are still characters in the FIFO, permit reading them out. Signed-off-by: Marek Vasut Cc: Nobuhiro Iwamatsu --- drivers/serial/serial_sh.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/serial/serial_sh.c b/drivers/serial/serial_sh.c index 13b179f03d..e27d256574 100644 --- a/drivers/serial/serial_sh.c +++ b/drivers/serial/serial_sh.c @@ -116,7 +116,10 @@ static int serial_getc_check(struct uart_port *port) handle_error(port); if (sci_in(port, SCLSR) & SCxSR_ORER(port)) handle_error(port); - return status & (SCIF_DR | SCxSR_RDxF(port)); + status &= (SCIF_DR | SCxSR_RDxF(port)); + if (status) + return status; + return scif_rxfill(port); } static int sh_serial_getc_generic(struct uart_port *port)