Skip to content

Conversation

@attie-argentum
Copy link
Member

I encountered issues while mounting a FAT filesystem with D-Cache enabled on an STM32H753.

This patch introduces a call to sys_cache_data_flush_and_invd_range() before HAL_*_ReadBlocks_DMA(), and sys_cache_data_flush_range() before HAL_*_WriteBlocks_DMA().

Fixes #100377

Copy link
Contributor

@etienne-lms etienne-lms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a nitpicking comment.

@attie-argentum
Copy link
Member Author

In light of the discussion, and my brief investigation, I've opted to maintain the F+I before, and I after. The risk stands, comments revised. I've also relocated the F+I to sit alongside the I for better visibility.

I have confirmed that things "work" when aligning FATFS.win[] and the buffer passed to fs_read(), but the knock-on impact may be difficult to deal with in reality...

Introduce steps to maintain cache coherence around DMA accesses to the
underlying SD / eMMC storage.

Signed-off-by: Attie Grande <attie.grande@argentum-systems.co.uk>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 4, 2025

Copy link
Contributor

@mathieuchopstm mathieuchopstm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better than nothing. Hopefully large buffers are naturally aligned enough that the limitation isn't an issue anyways...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

drivers: disk: sdmmc_stm32: Mount fails for H7 with D-Cache enabled

5 participants