mbox series

[0/9] fifo8: add fifo8_peek(), fifo8_peek_buf() and tests

Message ID 20240828122258.928947-1-mark.cave-ayland@ilande.co.uk (mailing list archive)
Headers show
Series fifo8: add fifo8_peek(), fifo8_peek_buf() and tests | expand

Message

Mark Cave-Ayland Aug. 28, 2024, 12:22 p.m. UTC
This is something I've had lying around for a little while as a follow on from
Phil's recent work on Fifo8 with a few updates, but also adding the missing
fifo8_peek() and fifo8_peek_buf() functions along with some relevant tests.

The reason for sending this now is that there are couple of recent series
(https://patchew.org/QEMU/20240819113148.3007047-1-alistair.francis@wdc.com/ and
https://patchew.org/QEMU/20240817102606.3996242-1-tavip@google.com/) which can
benefit from these changes: in particular the fifo8_peek_buf() function, unlike the
existing fifo8_peek_bufptr() function, will correctly handle FIFO wraparound. This
occurs when the FIFO head drifts due to not popping the entire FIFO content in one
go, which often happens when trying to send FIFO data to a chardev.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>


Mark Cave-Ayland (9):
  fifo8: rename fifo8_peekpop_buf() to fifo8_peekpop_bufptr()
  fifo8: introduce head variable for fifo8_peekpop_bufptr()
  fifo8: add skip parameter to fifo8_peekpop_bufptr()
  fifo8: replace fifo8_pop_bufptr() with fifo8_peekpop_bufptr() in
    fifo8_pop_buf()
  fifo8: rename fifo8_pop_buf() to fifo8_peekpop_buf()
  fifo8: honour do_pop argument in fifo8_peekpop_buf()
  fifo8: add fifo8_peek_buf() function
  fifo8: introduce fifo8_peek() function
  tests/unit: add test-fifo unit test

 include/qemu/fifo8.h   |  25 ++++
 tests/unit/meson.build |   1 +
 tests/unit/test-fifo.c | 256 +++++++++++++++++++++++++++++++++++++++++
 util/fifo8.c           |  42 +++++--
 4 files changed, 313 insertions(+), 11 deletions(-)
 create mode 100644 tests/unit/test-fifo.c

Comments

Philippe Mathieu-Daudé Sept. 6, 2024, 1:14 p.m. UTC | #1
Hi Mark,

On 28/8/24 14:22, Mark Cave-Ayland wrote:

> Mark Cave-Ayland (9):
>    fifo8: rename fifo8_peekpop_buf() to fifo8_peekpop_bufptr()
>    fifo8: introduce head variable for fifo8_peekpop_bufptr()
>    fifo8: add skip parameter to fifo8_peekpop_bufptr()
>    fifo8: replace fifo8_pop_bufptr() with fifo8_peekpop_bufptr() in
>      fifo8_pop_buf()
>    fifo8: rename fifo8_pop_buf() to fifo8_peekpop_buf()
>    fifo8: honour do_pop argument in fifo8_peekpop_buf()
>    fifo8: add fifo8_peek_buf() function
>    fifo8: introduce fifo8_peek() function
>    tests/unit: add test-fifo unit test

For this series:
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>

I'm OK to queue it but took some notes while reviewing:
https://lore.kernel.org/qemu-devel/20240906131217.78159-1-philmd@linaro.org/
If you can have a look, I'll queue both together.

Thanks!

Phil.
Mark Cave-Ayland Sept. 6, 2024, 8:51 p.m. UTC | #2
On 06/09/2024 14:14, Philippe Mathieu-Daudé wrote:

> Hi Mark,
> 
> On 28/8/24 14:22, Mark Cave-Ayland wrote:
> 
>> Mark Cave-Ayland (9):
>>    fifo8: rename fifo8_peekpop_buf() to fifo8_peekpop_bufptr()
>>    fifo8: introduce head variable for fifo8_peekpop_bufptr()
>>    fifo8: add skip parameter to fifo8_peekpop_bufptr()
>>    fifo8: replace fifo8_pop_bufptr() with fifo8_peekpop_bufptr() in
>>      fifo8_pop_buf()
>>    fifo8: rename fifo8_pop_buf() to fifo8_peekpop_buf()
>>    fifo8: honour do_pop argument in fifo8_peekpop_buf()
>>    fifo8: add fifo8_peek_buf() function
>>    fifo8: introduce fifo8_peek() function
>>    tests/unit: add test-fifo unit test
> 
> For this series:
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> 
> I'm OK to queue it but took some notes while reviewing:
> https://lore.kernel.org/qemu-devel/20240906131217.78159-1-philmd@linaro.org/
> If you can have a look, I'll queue both together.

Thanks Phil!

I've just spotted a few minor issues with the series which I've just replied to: 
would you like me to send a v2, or is it easier just for you to correct them yourself?


ATB,

Mark.
Philippe Mathieu-Daudé Sept. 7, 2024, 4:51 a.m. UTC | #3
On 6/9/24 22:51, Mark Cave-Ayland wrote:
> On 06/09/2024 14:14, Philippe Mathieu-Daudé wrote:
> 
>> Hi Mark,

>> I'm OK to queue it but took some notes while reviewing:
>> https://lore.kernel.org/qemu-devel/20240906131217.78159-1-philmd@linaro.org/
>> If you can have a look, I'll queue both together.
> 
> Thanks Phil!
> 
> I've just spotted a few minor issues with the series which I've just 
> replied to: would you like me to send a v2, or is it easier just for you 
> to correct them yourself?

Fixed locally (and wrapped to 72 columns), thanks!