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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 597C4CA5FF0 for ; Mon, 5 Oct 2026 11:44:37 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xDh7F-0006vJ-5O; Mon, 05 Oct 2026 07:44:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xDh77-0006uc-HX for qemu-devel@nongnu.org; Mon, 05 Oct 2026 07:44:13 -0400 Received: from mta-snd-e05.mail.nifty.com ([106.153.227.181]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xDh73-0001Wz-Qu for qemu-devel@nongnu.org; Mon, 05 Oct 2026 07:44:12 -0400 Received: from sakura.ysato.name by mta-snd-e05.mail.nifty.com with ESMTP id <20261005114407105.SDBI.102121.sakura.ysato.name@nifty.com>; Mon, 5 Oct 2026 20:44:07 +0900 Received: from SIOS1075.ysato.ml (ZM005235.ppp.dion.ne.jp [222.8.5.235]) by sakura.ysato.name (Postfix) with ESMTPSA id BAAED1C0019; Mon, 5 Oct 2026 20:44:06 +0900 (JST) Date: Mon, 05 Oct 2026 20:44:06 +0900 Message-ID: <87wlrws77d.wl-yoshinori.sato@nifty.com> From: yoshinori.sato@nifty.com To: =?ISO-8859-1?Q?Marc-Andr=E9?= Lureau Cc: qemu-devel@nongnu.org, Pavee Hui , Paolo Bonzini Subject: Re: [PATCH 37/63] hw/char/sh_serial: use rx_cnt for available FIFO space In-Reply-To: <20261004-issue-4560-v1-37-ccbef537cbeb@redhat.com> References: <20261004-issue-4560-v1-0-ccbef537cbeb@redhat.com> <20261004-issue-4560-v1-37-ccbef537cbeb@redhat.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=default-1th84yt82rvi; t=1791200647; bh=gbWyQ6KUNUvOiDrC6UvcJUouP/0LIEQHBpniRNe3M8U=; h=Date:From:To:Cc:Subject:In-Reply-To; b=WUo8n3bgjpFlje1oMSX2OpPWe6nBtB8xciSFIfSt7GVgBaDYKrFTLtikGbpIgBctifoAgE+5 WQpDPZXZVXXl5JJTrusyRwSo179rC1IkI3nt7iBytOlzbLOA5ROjcl7LyvjUn2Pn5gqjTiu48q SJMd0Mon61NLq4iJgBBd9JJbiwjEc3YSdI+0kIvdkEDbvBlrw3tMeWRcN9iU+MwAi4sFu4W9Jb sesH+1z0ZIJ5aLCS6xOO1VSzzv78db3FztmM6t42M2q5GB/ZIba681sJ4pPN77bhlT3X6D02Ax q0W6po6YCD/wrpGLHBN+CTu9SuJZTOX4LSE+mDoPMdg7bkOg== Received-SPF: pass client-ip=106.153.227.181; envelope-from=yoshinori.sato@nifty.com; helo=mta-snd-e05.mail.nifty.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org On Sun, 04 Oct 2026 19:23:51 +0900, Marc-Andr=E9 Lureau wrote: >=20 > sh_serial_can_receive() used rx_head (the circular buffer write pointer) > to compute available space. Since rx_head wraps around, this could > overestimate or underestimate the remaining capacity. Use rx_cnt, which > tracks the actual number of buffered bytes. >=20 > Reported-by: Pavee Hui > Fixes: 543671d9907f ("hw/char/sh_serial: Return correct number of empty R= X FIFO elements") > Signed-off-by: Marc-Andr=E9 Lureau > --- > hw/char/sh_serial.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/hw/char/sh_serial.c b/hw/char/sh_serial.c > index 30a22ea2d1c0..8728842b84e0 100644 > --- a/hw/char/sh_serial.c > +++ b/hw/char/sh_serial.c > @@ -316,7 +316,7 @@ static uint64_t sh_serial_read(void *opaque, hwaddr o= ffs, > =20 > static int sh_serial_can_receive(SHSerialState *s) > { > - return s->scr & (1 << 4) ? SH_RX_FIFO_LENGTH - s->rx_head : 0; > + return s->scr & (1 << 4) ? SH_RX_FIFO_LENGTH - s->rx_cnt : 0; > } > =20 > static void sh_serial_receive_break(SHSerialState *s) >=20 > --=20 > 2.56.0.rc0.29.g47ce80527c56 >=20 Reviewed-by: Yoshinori Sato --=20 Yosinori Sato