Repository navigation
Conversation
brcmf_pcie_bus_console_read() copies the firmware console ring until its read index reaches the write index the firmware publishes. The read index wraps at bufsize, so a write index of bufsize or more is never reached and the loop does not end. With error set, as on the reset path and on the brcmf_pcie_setup() failure path, every line it passes is printed with brcmf_err(). The setup failure path is where a bad index is likely. The console description is read again only after a successful firmware download, so when the download fails after a reset, the read goes through the previous firmware's description into memory the failed boot left. Return with a rate-limited error when the write index, the read index or the buffer size cannot describe a position in the ring. Within those bounds the loop wraps at most once and ends. Signed-off-by: Net Mojo <56850867+netmojo@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
brcmf_pcie_bus_console_read()copies the firmware console ring until its read index reaches the write index the firmware publishes. The read index wraps atbufsize, so a write index ofbufsizeor more is never reached and the loop does not end. Witherrorset, on the reset path and on thebrcmf_pcie_setup()failure path, every line it passes is logged unconditionally through__brcmf_err().console_intervaldoes not affect these forced reads.The console description is read again only after a successful firmware download. Reading the source, a download that fails after a reset leaves the previous firmware's description in place, and that stale description can yield an invalid index.
The patch returns, with one rate-limited error, when the write index, the read index or the buffer size cannot describe a position in the ring. Inside those bounds the loop wraps at most once. The check comes after the
error/FWCON gate, so a non-forced call with console logging off still reads nothing.Testing
bufsize, a write index ofUINT32_MAX,bufsize == 0, a read index equal tobufsizeand a read index ofUINT32_MAXeach return before any byte read and invoke the diagnostic hook once.FW failed to initialize. Its index was not captured, so whether this patch would have stopped it is not known.W=1, plain andCONFIG_BRCMDBG. The only warning is Kbuild's notice that the compiler differs from the kernel's, also present when building the base tree.The patch does not validate
buf_addragainst the TCM size, and does not refresh a stale console description. An in-range stale index can still print up to one ring of old data.