Skip to content

Commit 4a0e315

Browse files
authored
Merge pull request #76 from chvvkumar/Dev
bug: fix cache misalignment
2 parents 308a502 + 5d04577 commit 4a0e315

4 files changed

Lines changed: 9 additions & 5 deletions

File tree

.github/workflows/arduino-compile.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Arduino Compilation Check
22

33
on:
44
push:
5-
branches: [ main, Snd, Dev ]
5+
branches: [ main ]
66
paths-ignore:
77
- '**.md'
88
- 'docs/**'

.github/workflows/file-structure.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: File Structure Validation
22

33
on:
44
push:
5-
branches: [ main, Snd, Dev ]
5+
branches: [ main ]
66
pull_request:
77
branches: [ main, Snd, Dev ]
88
workflow_dispatch:

.github/workflows/memory-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Memory Usage Analysis
22

33
on:
44
push:
5-
branches: [ main, Snd, Dev ]
5+
branches: [ main ]
66
pull_request:
77
branches: [ main, Snd, Dev ]
88
workflow_dispatch:

ppa_accelerator.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ bool PPAAccelerator::scaleRotateImage(uint16_t* srcPixels, int16_t srcWidth, int
131131
memcpy(ppa_src_buffer, srcPixels, srcSize);
132132

133133
// Ensure cache coherency for DMA operations
134-
esp_cache_msync(ppa_src_buffer, srcSize, ESP_CACHE_MSYNC_FLAG_DIR_C2M);
134+
// Size must be aligned to cache line size (64 bytes)
135+
size_t srcSizeAligned = (srcSize + 63) & ~63;
136+
esp_cache_msync(ppa_src_buffer, srcSizeAligned, ESP_CACHE_MSYNC_FLAG_DIR_C2M);
135137

136138
// Configure PPA scaling and rotation operation
137139
ppa_srm_oper_config_t srm_oper_config = {};
@@ -184,7 +186,9 @@ bool PPAAccelerator::scaleRotateImage(uint16_t* srcPixels, int16_t srcWidth, int
184186
}
185187

186188
// Ensure cache coherency for reading results
187-
esp_cache_msync(ppa_dst_buffer, dstSize, ESP_CACHE_MSYNC_FLAG_DIR_M2C);
189+
// Size must be aligned to cache line size (64 bytes)
190+
size_t dstSizeAligned = (dstSize + 63) & ~63;
191+
esp_cache_msync(ppa_dst_buffer, dstSizeAligned, ESP_CACHE_MSYNC_FLAG_DIR_M2C);
188192

189193
// Copy result to destination buffer
190194
memcpy(dstPixels, ppa_dst_buffer, dstSize);

0 commit comments

Comments
 (0)