qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>,
	qemu-arm@nongnu.org, qemu-devel@nongnu.org
Cc: Tyrone Ting <kfting@nuvoton.com>, Hao Wu <wuhaotsh@google.com>,
	Jason Wang <jasowang@redhat.com>
Subject: Re: [PATCH 3/4] hw/net/npcm_gmac.c: Correct test for when to reallocate packet buffer
Date: Mon, 14 Jul 2025 22:08:05 +0200	[thread overview]
Message-ID: <3138a372-7649-404a-8e8e-53b097c33094@linaro.org> (raw)
In-Reply-To: <20250714165523.1956235-4-peter.maydell@linaro.org>

On 14/7/25 18:55, Peter Maydell wrote:
> In gmac_try_send_next_packet() we have code that does "if this block
> of data won't fit in the buffer, reallocate it".  However, the
> condition it uses is
>    if ((prev_buf_size + tx_buf_len) > sizeof(buf))
> where buf is a uint8_t *.
> 
> This means that sizeof(buf) is always 8 bytes, and the condition will
> almost always be true, so we will reallocate the buffer more often
> than we need to.
> 
> Correct the condition to test against tx_buffer_size, which is
> where we track how big the allocated buffer is.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   hw/net/npcm_gmac.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>



  reply	other threads:[~2025-07-14 21:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-14 16:55 [PATCH 0/4] hw/net/npcm_gmac: Various fixes to gmac_try_send_next_packet() Peter Maydell
2025-07-14 16:55 ` [PATCH 1/4] hw/net/npcm_gmac.c: Send the right data for second packet in a row Peter Maydell
2025-07-14 16:55 ` [PATCH 2/4] hw/net/npcm_gmac.c: Unify length and prev_buf_size variables Peter Maydell
2025-07-21 14:03   ` Peter Maydell
2025-07-14 16:55 ` [PATCH 3/4] hw/net/npcm_gmac.c: Correct test for when to reallocate packet buffer Peter Maydell
2025-07-14 20:08   ` Philippe Mathieu-Daudé [this message]
2025-07-15 22:23     ` Hao Wu
2025-07-14 16:55 ` [PATCH 4/4] hw/net/npcm_gmac.c: Drop 'buf' local variable Peter Maydell
2025-07-14 20:06   ` Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3138a372-7649-404a-8e8e-53b097c33094@linaro.org \
    --to=philmd@linaro.org \
    --cc=jasowang@redhat.com \
    --cc=kfting@nuvoton.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=wuhaotsh@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).