Skip to content

fs_fat32: Do not dirty the the buffer on non changes#175

Closed
davids5 wants to merge 1 commit intopx4_firmware_nuttx-10.1.0+from
px4_firmware_nuttx-10.1.0+-pr-fat_fix
Closed

fs_fat32: Do not dirty the the buffer on non changes#175
davids5 wants to merge 1 commit intopx4_firmware_nuttx-10.1.0+from
px4_firmware_nuttx-10.1.0+-pr-fat_fix

Conversation

@davids5
Copy link
Copy Markdown
Member

@davids5 davids5 commented Dec 22, 2021

Summary

This the root cause of the seek error. The d-cache is dirty-ed by the in-place Directory information update into fs_buffer. However if the the directory information is the same it will not be written out. This leaves the dirty cache lines in the buffer. On the next read of the FAT Sector, if eviction happens the dirty lines will overwrite the data in the DMA buffer.

Impact

seek fails on the FAT FS. because the in memory copy of the FAT is corrupted.

Testing

16 threads of tests dataman on PX4

davids5 added a commit that referenced this pull request Dec 22, 2021
  For FAT the same buffer is used for read and writes, there
  is a possibility a cache line is dirty. But the fs is
  not dirty and will not write the sector to disk. This can
  be seen  #175

  When the system is busy that cache line can be evicted after the
  RX DMA has completed and overwrite the data in memory. The solution
  is to invalidate before the DMA to prevent an evection causing an
  overwite, and after the DMA it to insure coherency.
davids5 added a commit to nuttx-to-asf/incubator-nuttx that referenced this pull request Dec 22, 2021
  For FAT the same buffer is used for read and writes, there
  is a possibility a cache line is dirty. But the fs is
  not dirty and will not write the sector to disk. This can
  be seen  PX4/NuttX#175

  When the system is busy that cache line can be evicted after the
  RX DMA has completed and overwrite the data in memory. The solution
  is to invalidate before the DMA to prevent an evection causing an
  overwite, and after the DMA it to insure coherency.
xiaoxiang781216 pushed a commit to apache/nuttx that referenced this pull request Dec 23, 2021
  For FAT the same buffer is used for read and writes, there
  is a possibility a cache line is dirty. But the fs is
  not dirty and will not write the sector to disk. This can
  be seen  PX4/NuttX#175

  When the system is busy that cache line can be evicted after the
  RX DMA has completed and overwrite the data in memory. The solution
  is to invalidate before the DMA to prevent an evection causing an
  overwite, and after the DMA it to insure coherency.
dagar pushed a commit that referenced this pull request Dec 23, 2021
…write

  For FAT the same buffer is used for read and writes, there
  is a possibility a cache line is dirty. But the fs is
  not dirty and will not write the sector to disk. This can
  be seen  #175

  When the system is busy that cache line can be evicted after the
  RX DMA has completed and overwrite the data in memory. The solution
  is to invalidate before the DMA to prevent an evection causing an
  overwite, and after the DMA it to insure coherency.
dagar pushed a commit that referenced this pull request Dec 23, 2021
…write

  For FAT the same buffer is used for read and writes, there
  is a possibility a cache line is dirty. But the fs is
  not dirty and will not write the sector to disk. This can
  be seen  #175

  When the system is busy that cache line can be evicted after the
  RX DMA has completed and overwrite the data in memory. The solution
  is to invalidate before the DMA to prevent an evection causing an
  overwite, and after the DMA it to insure coherency.
@davids5
Copy link
Copy Markdown
Member Author

davids5 commented Dec 24, 2021

This is solved at the point of control for all things using FS.
stm32f7:sdmmc invalidate before DMA to avoid eviction overwrite apache/nuttx#5062

@davids5 davids5 closed this Dec 24, 2021
@dagar dagar deleted the px4_firmware_nuttx-10.1.0+-pr-fat_fix branch December 24, 2021 14:31
Gary-Hobson pushed a commit to Gary-Hobson/nuttx that referenced this pull request Jan 18, 2022
  For FAT the same buffer is used for read and writes, there
  is a possibility a cache line is dirty. But the fs is
  not dirty and will not write the sector to disk. This can
  be seen  PX4/NuttX#175

  When the system is busy that cache line can be evicted after the
  RX DMA has completed and overwrite the data in memory. The solution
  is to invalidate before the DMA to prevent an evection causing an
  overwite, and after the DMA it to insure coherency.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant