fs: littlefs: add alignment arg to FS_LITTLEFS_DECLARE_CUSTOM_CONFIG macro

Add alignment parameter to FS_LITTLEFS_DECLARE_CUSTOM_CONFIG macro, it
speeds up read/write operation for SDMMC devices in case when we align
buffers on CONFIG_SDHC_BUFFER_ALIGNMENT, because we can avoid extra copy
of data from card bffer to read/prog buffer. See, how 'card_read_blocks'
function works.

Signed-off-by: Mykola Kvach <mykola_kvach@epam.com>
This commit is contained in:
Mykola Kvach 2023-08-07 15:06:12 +03:00 committed by Carles Cufí
parent e3d5f5072f
commit 26c9721b67
3 changed files with 9 additions and 5 deletions

View file

@ -61,15 +61,17 @@ struct fs_littlefs {
*
* @param name the name for the structure. The defined object has
* file scope.
* @param alignment needed alignment for read/prog buffer for specific device
* @param read_sz see @kconfig{CONFIG_FS_LITTLEFS_READ_SIZE}
* @param prog_sz see @kconfig{CONFIG_FS_LITTLEFS_PROG_SIZE}
* @param cache_sz see @kconfig{CONFIG_FS_LITTLEFS_CACHE_SIZE}
* @param lookahead_sz see @kconfig{CONFIG_FS_LITTLEFS_LOOKAHEAD_SIZE}
*/
#define FS_LITTLEFS_DECLARE_CUSTOM_CONFIG(name, read_sz, prog_sz, cache_sz, lookahead_sz) \
static uint8_t __aligned(4) name ## _read_buffer[cache_sz]; \
static uint8_t __aligned(4) name ## _prog_buffer[cache_sz]; \
static uint32_t name ## _lookahead_buffer[(lookahead_sz) / sizeof(uint32_t)]; \
#define FS_LITTLEFS_DECLARE_CUSTOM_CONFIG(name, alignment, read_sz, prog_sz, cache_sz, \
lookahead_sz) \
static uint8_t __aligned(alignment) name ## _read_buffer[cache_sz]; \
static uint8_t __aligned(alignment) name ## _prog_buffer[cache_sz]; \
static uint32_t name ## _lookahead_buffer[(lookahead_sz) / sizeof(uint32_t)]; \
static struct fs_littlefs name = { \
.cfg = { \
.read_size = (read_sz), \
@ -93,6 +95,7 @@ struct fs_littlefs {
*/
#define FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(name) \
FS_LITTLEFS_DECLARE_CUSTOM_CONFIG(name, \
4, \
CONFIG_FS_LITTLEFS_READ_SIZE, \
CONFIG_FS_LITTLEFS_PROG_SIZE, \
CONFIG_FS_LITTLEFS_CACHE_SIZE, \

View file

@ -27,7 +27,7 @@ struct fs_mount_t testfs_small_mnt = {
};
#if CONFIG_APP_TEST_CUSTOM
FS_LITTLEFS_DECLARE_CUSTOM_CONFIG(medium, MEDIUM_IO_SIZE, MEDIUM_IO_SIZE,
FS_LITTLEFS_DECLARE_CUSTOM_CONFIG(medium, 4, MEDIUM_IO_SIZE, MEDIUM_IO_SIZE,
MEDIUM_CACHE_SIZE, MEDIUM_LOOKAHEAD_SIZE);
struct fs_mount_t testfs_medium_mnt = {
.type = FS_LITTLEFS,

View file

@ -47,6 +47,7 @@ ZTEST(littlefs, test_fs_mkfs_ops_lfs)
/* Custom config with doubled the prog size */
FS_LITTLEFS_DECLARE_CUSTOM_CONFIG(custom_cfg,
4,
CONFIG_FS_LITTLEFS_READ_SIZE,
CONFIG_FS_LITTLEFS_PROG_SIZE * 2,
CONFIG_FS_LITTLEFS_CACHE_SIZE,