-
Notifications
You must be signed in to change notification settings - Fork 1.5k
drivers/mtd: Optimizations for RRAM/MRAM Compatibility and Erase Logic Robustness #17845
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
Conversation
When there's no erase function for mtd, we decide if we need erase_buffer based on this: 1. If we've got bad block marking, we still need the erase buffer. If a write fails, it's used to read back the entire bad block's contents before writing to a new block. 2. If we don't have bad block marking, the erase buffer isn't needed and can be skipped. Signed-off-by: jingfei <[email protected]>
Accessing RRAM/MRAM from the FTL interface can cause errors because RRAM lacks an erase interface. To make RRAM/MRAM compatible with FTL, the FTL layer erase interface needs to be modified. Signed-off-by: jingfei <[email protected]>
Since there is a storage device like RRAM that doesn't require erasing, the MTD erase function may not exist. Here, we should first check whether the erase interface exists before performing the erasing operation. Signed-off-by: jingfei <[email protected]>
the MTD ERASE interface has inconsistent return values. Some implementations return the number of erased sectors, while others return OK (0). It is currently recommended to uniformly treat ERASE success as OK. Therefore, the logic for judging the return value of MTD_ERASE in the FTL erase interface should be changed to check if it is greater than 0. Signed-off-by: jingfei <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for non-erase-required storage devices (RRAM/MRAM) to the FTL and MTD subsystems by making erase operations optional and improving error handling for devices that don't support erase operations.
Changes:
- Modified MTD partition layer to conditionally assign erase function based on parent device capability
- Enhanced FTL erase function to handle -ENOSYS return code for devices without erase support
- Added fast path in FTL flush function for devices without erase capability and bad block management
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| drivers/mtd/mtd_partition.c | Conditionally assigns erase function pointer only if parent MTD device supports erase |
| drivers/mtd/ftl.c | Adds -ENOSYS handling to ftl_mtd_erase and implements direct write path for non-erase devices in ftl_flush |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
This PR contains a series of optimizations and compatibility adjustments for the FTL (Flash Translation Layer) and MTD (Memory Technology Device) subsystems, primarily to:
Impact
Enables FTL/MTD subsystems to support non-traditional storage devices (RRAM/MRAM) that do not require erase operations, expanding the applicable scenario of the system.
Unifies the return value judgment standard of the MTD erase interface, avoiding potential errors caused by inconsistent return values; adds pre-check of the erase interface to prevent invalid operations.
Testing
We have actually tested RRAM/MRAM devices, confirming that no errors are reported when accessing them via the FTL interface, and the write/read functions work normally as expected.