Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[uart,rtl] Increase buffer size to 128 #17829

Merged
merged 2 commits into from
Apr 21, 2023
Merged

Conversation

GregAC
Copy link
Contributor

@GregAC GregAC commented Apr 5, 2023

This a draft as it's incomplete but creating the PR now for visibility.

There are regression failures with this change I have yet to look into plus we need to discuss the appropriate size to move to and what we switch watermark levels to.

Fixes #16549

hw/ip/uart/rtl/uart_core.sv Outdated Show resolved Hide resolved
hw/ip/uart/rtl/uart_core.sv Outdated Show resolved Hide resolved
@GregAC
Copy link
Contributor Author

GregAC commented Apr 5, 2023

@jesultra this increases UART buffer sizes to 64 from 32. Can you confirm:

  • If 64 is the appropriate buffer size
  • If the new watermarking levels are appropriate, see table below
TX/RXILVL setting RX watermark level TX watermark level
0 1 4
1 8 8
2 16 16
3 32 32
4 62 -

@johngt
Copy link

johngt commented Apr 14, 2023

Based on conversations - the understanding is to move to 128 bytes and increase watermark bits; 3 to 4.

@GregAC GregAC marked this pull request as ready for review April 17, 2023 15:28
@GregAC GregAC requested review from a team as code owners April 17, 2023 15:28
@GregAC GregAC requested review from jdonjdon and alphan and removed request for a team April 17, 2023 15:28
@GregAC
Copy link
Contributor Author

GregAC commented Apr 17, 2023

This is now ready to go. Following discussion we've decided to expand the size of the watermark level fields and just provide more levels to deal with the expanded FIFO size. The new settings are:

TX/RXILVL setting RX watermark level TX watermark level
0 1 2
1 4 4
2 8 8
3 16 16
4 32 32
5 64 64
6 126 -

I note in the DIF we have a single enum for both the TX and RX settings which is a little awkward as the 0 level is different for TX and RX. The current enum looks like this:

typedef enum dif_uart_watermark {
  /**
   * Indicates a one-byte watermark.
   */
  kDifUartWatermarkByte1 = 0,

Which isn't strictly correct. Something to fix but not something I want to gate this PR on. We can create a separate issue for it.

@msfschaffner @jesultra @cfrantz any comments? In particular are we happy with the watermarking levels?

@GregAC GregAC changed the title [uart,rtl] Increase buffer size to 64 [uart,rtl] Increase buffer size to 128 Apr 17, 2023
@jesultra
Copy link
Contributor

The watermarking levels and the FIFO size of 128 bytes fully cover the needs of ChromeOS.

@cfrantz
Copy link
Contributor

cfrantz commented Apr 17, 2023

I note in the DIF we have a single enum for both the TX and RX settings which is a little awkward as the 0 level is different for TX and RX.

We already have a discrepancy like this for the current watermark levels, so I don't think its a big problem. Out of curiosity, how difficult would it be to make the TX and RX watermark levels symmetric such that the levels are always 2**n up to the last one which is 2**n - k (where k currently is 2).

@GregAC
Copy link
Contributor Author

GregAC commented Apr 17, 2023

I note in the DIF we have a single enum for both the TX and RX settings which is a little awkward as the 0 level is different for TX and RX.

We already have a discrepancy like this for the current watermark levels, so I don't think its a big problem. Out of curiosity, how difficult would it be to make the TX and RX watermark levels symmetric such that the levels are always 2**n up to the last one which is 2**n - k (where k currently is 2).

Trivial I was just going with what was already there but extended for 128 bytes.

To confirm you want settings like this?

TX/RXILVL setting RX watermark level TX watermark level
0 1 1
1 2 2
2 4 4
3 8 8
4 16 16
5 32 32
6 64 64
7 126 -

We can of course have a 126 level for the TX as well but maybe doesn't make a huge amount of sense (RX FIFO almost full obviously useful, TX FIFO just beginning to empty less so).

@cfrantz
Copy link
Contributor

cfrantz commented Apr 17, 2023

To confirm you want settings like this?

[snip]
We can of course have a 126 level for the TX as well but maybe doesn't make a huge amount of sense (RX FIFO almost full obviously useful, TX FIFO just beginning to empty less so).

Agreed about 126 for TX. I also think the TX watermark level of 1 is dubious, but I'm giving consideration to the value of symmetry in the programming interface.

As long is it isn't burdensome to implement, your previous table (1-126 for RX, 1-64 for TX) looks good to me.

Copy link
Contributor

@msfschaffner msfschaffner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @GregAC - I am fine with these changes.

Regarding the levels, I have a slight preference towards symmetry as well.

Copy link
Contributor

@marnovandermaas marnovandermaas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks Greg!

@marnovandermaas
Copy link
Contributor

Rerunning failed CI tests.

Fixes lowRISC#16549

Signed-off-by: Greg Chadwick <gac@lowrisc.org>
@GregAC
Copy link
Contributor Author

GregAC commented Apr 20, 2023

The watermark changes proved to be fiddlier than first expected as it uncovered some testbench bugs. These are fixed in the second commit of this PR.

Issue from CI failure has also been fixed.

@jdonjdon @msfschaffner would you mind taking a look at the testbench changes?

Watermarking changes highlighted some edge cases in the modelling
causing regression failures. Details are given in the comments added by
this commit.

Signed-off-by: Greg Chadwick <gac@lowrisc.org>
Copy link
Contributor

@msfschaffner msfschaffner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@GregAC GregAC merged commit 5a58555 into lowRISC:master Apr 21, 2023
@GregAC GregAC deleted the uart_fifo_size branch April 21, 2023 08:58
dmcardle added a commit to dmcardle/opentitan that referenced this pull request Apr 21, 2023
PR lowRISC#17829 updated the FIFO size, but this constant was stale.

Signed-off-by: Dan McArdle <dmcardle@opentitan.org>
dmcardle added a commit to dmcardle/opentitan that referenced this pull request Apr 21, 2023
PR lowRISC#17829 updated the FIFO size, but this constant was stale.

Signed-off-by: Dan McArdle <dmcardle@opentitan.org>
dmcardle added a commit to dmcardle/opentitan that referenced this pull request Apr 24, 2023
PR lowRISC#17829 updated the FIFO size, but this constant was stale.

Signed-off-by: Dan McArdle <dmcardle@opentitan.org>
dmcardle added a commit to dmcardle/opentitan that referenced this pull request Apr 24, 2023
PR lowRISC#17829 updated the FIFO size, but the constant in this macro was
still stale.

Signed-off-by: Dan McArdle <dmcardle@opentitan.org>
dmcardle added a commit to dmcardle/opentitan that referenced this pull request Apr 25, 2023
PR lowRISC#17829 updated the FIFO size, but this constant was stale.

Signed-off-by: Dan McArdle <dmcardle@opentitan.org>
dmcardle added a commit to dmcardle/opentitan that referenced this pull request Apr 25, 2023
PR lowRISC#17829 updated the FIFO size, but the constant in this macro was
still stale.

Signed-off-by: Dan McArdle <dmcardle@opentitan.org>
dmcardle added a commit to dmcardle/opentitan that referenced this pull request Apr 28, 2023
PR lowRISC#17829 updated the FIFO size, but this constant was stale.

Signed-off-by: Dan McArdle <dmcardle@opentitan.org>
dmcardle added a commit to dmcardle/opentitan that referenced this pull request Apr 28, 2023
PR lowRISC#17829 updated the FIFO size, but the constant in this macro was
still stale.

Signed-off-by: Dan McArdle <dmcardle@opentitan.org>
dmcardle added a commit to dmcardle/opentitan that referenced this pull request May 1, 2023
PR lowRISC#17829 updated the FIFO size, but this constant was stale.

Signed-off-by: Dan McArdle <dmcardle@opentitan.org>
dmcardle added a commit to dmcardle/opentitan that referenced this pull request May 1, 2023
PR lowRISC#17829 updated the FIFO size, but the constant in this macro was
still stale.

Signed-off-by: Dan McArdle <dmcardle@opentitan.org>
dmcardle added a commit that referenced this pull request May 1, 2023
PR #17829 updated the FIFO size, but this constant was stale.

Signed-off-by: Dan McArdle <dmcardle@opentitan.org>
dmcardle added a commit that referenced this pull request May 1, 2023
PR #17829 updated the FIFO size, but the constant in this macro was
still stale.

Signed-off-by: Dan McArdle <dmcardle@opentitan.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hardware assisted UART -> USB forwarding
6 participants