Repository navigation
mtd/cfi: add rwsem to serialize CFI command sequences - #22019
Open
jingfei195887 wants to merge 1 commit into
Open
jingfei195887 wants to merge 1 commit into
jingfei195887 wants to merge 1 commit into
Conversation
CFI command sequences were not serialized, so a read/write/erase on one partition could interleave with a write on another partition of the same flash and corrupt both. Add a per-device read-write lock: reads are shared, write and erase are exclusive until read array. Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com> Signed-off-by: jingfei <jingfei@xiaomi.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.
Summary
CFI command sequences were not serialized, so a read, write or erase on
one partition could interleave with a write on another partition of the
same flash and corrupt both: a write or erase leaves the chip out of
read-array mode until it completes. Add a per-device read-write lock
(
rw_semaphore_t) tostruct cfi_dev_s: reads are shared, write anderase are exclusive until the chip is back in read-array mode.
Impact
every other access to the same device.
Testing
Host: Ubuntu 22.04 x86_64, Arm GNU Toolchain 13.2.rel1.
qemu-armv7a:full(CONFIG_MTD_CFI, littlefs mounted on/dev/cfi-flash1at/data), run withqemu-system-arm -cpu cortex-a7 -machine virt,highmem=off,virtualization=off,gic-version=2:The output is identical on master fc8d354 and with this change. The
concurrent interleaving was not reproduced on QEMU; the test shows that
reads, writes and erases through the lock still work.
./tools/checkpatch.sh -g master..HEAD: all checks pass.sim:nshwithCONFIG_MTDandCONFIG_MTD_CFI: Make and CMake buildspass with no new warnings in the changed files;
ostestexits withstatus 0.
qemu-armv7a:full: build passes, run log above.PR verification Self-Check