qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: Re: [PATCH 3/3] util/fifo8: Introduce fifo8_change_capacity()
Date: Mon, 22 Jul 2024 12:55:50 +0200	[thread overview]
Message-ID: <69df9510-1b1a-434e-bbbe-1df7acf49f58@linaro.org> (raw)
In-Reply-To: <e49735e8-1c33-42cb-9181-662a0c010b97@ilande.co.uk>

On 19/7/24 22:21, Mark Cave-Ayland wrote:
> On 19/07/2024 16:16, Philippe Mathieu-Daudé wrote:
> 
>> FIFOs can be resized at runtime. Introduce the
>> fifo8_change_capacity() method to do that.
>> When capacity is changed, the FIFO must be reset.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>>   include/qemu/fifo8.h | 10 ++++++++++
>>   util/fifo8.c         |  7 +++++++
>>   2 files changed, 17 insertions(+)
>>
>> diff --git a/include/qemu/fifo8.h b/include/qemu/fifo8.h
>> index c6295c6ff0..9fe0555a24 100644
>> --- a/include/qemu/fifo8.h
>> +++ b/include/qemu/fifo8.h
>> @@ -31,6 +31,16 @@ void fifo8_create(Fifo8 *fifo, uint32_t capacity);
>>   void fifo8_destroy(Fifo8 *fifo);
>> +/**
>> + * fifo8_change_capacity:
>> + * @fifo: struct Fifo8 to change the capacity
>> + * @capacity: new capacity of the FIFO
>> + *
>> + * Change a FIFO capacity to the specified size. The FIFO is reset.
>> + */
>> +
>> +void fifo8_change_capacity(Fifo8 *fifo, uint32_t capacity);
>> +
>>   /**
>>    * fifo8_push:
>>    * @fifo: FIFO to push to
>> diff --git a/util/fifo8.c b/util/fifo8.c
>> index 2925fe5611..c453afd774 100644
>> --- a/util/fifo8.c
>> +++ b/util/fifo8.c
>> @@ -34,6 +34,13 @@ void fifo8_destroy(Fifo8 *fifo)
>>       g_free(fifo->data);
>>   }
>> +void fifo8_change_capacity(Fifo8 *fifo, uint32_t capacity)
>> +{
>> +    fifo->data = g_renew(uint8_t, fifo->data, capacity);
>> +    fifo->capacity = capacity;
>> +    fifo8_reset(fifo);
>> +}
>> +
>>   void fifo8_push(Fifo8 *fifo, uint8_t data)
>>   {
>>       assert(fifo->num < fifo->capacity);
> 
> The changes look okay, however I'm a little confused as to why this is 
> needed as generally hardware FIFOs are a fixed size? Presumably this is 
> related to the PL011 series?

Indeed, this is to model trying to stay as close as possible to
the datasheet, which states:

   2.4.3 UART operation

     Disabling the FIFOs

       Additionally, you can disable the FIFOs. In this case,
       the transmit and receive sides of the UART have 1-byte
       holding registers (the bottom entry of the FIFOs). The
       overrun bit is set when a word has been received, and
       the previous one was not yet read. In this implementation,
       the FIFOs are not physically disabled, but the flags are
       manipulated to give the illusion of a 1-byte register.



  reply	other threads:[~2024-07-22 10:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-19 15:16 [PATCH 0/3] util/fifo8: Introduce fifo8_change_capacity() Philippe Mathieu-Daudé
2024-07-19 15:16 ` [PATCH 1/3] chardev/char-fe: Document returned value on error Philippe Mathieu-Daudé
2024-07-19 20:18   ` Mark Cave-Ayland
2024-07-19 15:16 ` [PATCH 2/3] util/fifo8: Use fifo8_reset() in fifo8_create() Philippe Mathieu-Daudé
2024-07-19 20:19   ` Mark Cave-Ayland
2024-07-19 15:16 ` [PATCH 3/3] util/fifo8: Introduce fifo8_change_capacity() Philippe Mathieu-Daudé
2024-07-19 20:21   ` Mark Cave-Ayland
2024-07-22 10:55     ` Philippe Mathieu-Daudé [this message]
2024-07-22 11:52       ` Peter Maydell
2024-07-22 12:20         ` 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=69df9510-1b1a-434e-bbbe-1df7acf49f58@linaro.org \
    --to=philmd@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=marcandre.lureau@redhat.com \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).