drivers/mtd_flashpage: improve _write_page#20173
Merged
github-merge-queue[bot] merged 1 commit intoRIOT-OS:masterfrom Jan 2, 2024
Merged
drivers/mtd_flashpage: improve _write_page#20173github-merge-queue[bot] merged 1 commit intoRIOT-OS:masterfrom
github-merge-queue[bot] merged 1 commit intoRIOT-OS:masterfrom
Conversation
benpicco
reviewed
Dec 14, 2023
|
|
||
| offset = addr % FLASHPAGE_WRITE_BLOCK_ALIGNMENT; | ||
| size = MIN(size, FLASHPAGE_WRITE_BLOCK_ALIGNMENT - offset); | ||
| size = MIN(size, FLASHPAGE_WRITE_BLOCK_SIZE); |
Contributor
There was a problem hiding this comment.
Why not
Suggested change
| size = MIN(size, FLASHPAGE_WRITE_BLOCK_SIZE); | |
| size = MIN(size, FLASHPAGE_WRITE_BLOCK_SIZE - offset); |
Contributor
Author
There was a problem hiding this comment.
I tried that it was wrong in some cases. I don´t remember in which cases. I will post an example later.
Contributor
Author
There was a problem hiding this comment.
I enabled the DEBUG() and tried an application with FLashDB. From the output it seems to be the same 🤔. I don´t know why I wrote it like this back then.
benpicco
reviewed
Dec 18, 2023
|
|
||
| DEBUG("flashpage: write %"PRIu32" unaligned bytes\n", size); | ||
| if (offset + size > FLASHPAGE_WRITE_BLOCK_SIZE) { | ||
| size = ((offset + size) & ~(FLASHPAGE_WRITE_BLOCK_SIZE - 1)) - offset; |
Contributor
There was a problem hiding this comment.
Can you add a comment how you arrived at this formula?
a5be0a1 to
37c39d0
Compare
benpicco
approved these changes
Jan 2, 2024
Contributor
|
This seems to be causing issues (at least) on the |
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.
Contribution description
Some time ago I noticed that the mtd_flashpage driver was not writing the size of a full block (
FLASHPAGE_WRITE_BLOCK_SIZE) when it could be, on unaligned access.It was only writing
FLASHPAGE_WRITE_BLOCK_ALIGNMENT.So this PR is just a tiny performance improvement.
Testing procedure
That case even happens in the test
tests/drivers/mtd_flashpage.And with his change it still passes on
same54-xpro.Issues/PRs references