Commit 7dd0174467a2a1fc99d7dc19b11bbadc80f9c740
Committed by
Jagan Teki
1 parent
156e96f038
Exists in
v2017.01-smarct4x
and in
30 other branches
env: use cache line aligned memory for flash read
Use memalign() with ARCH_DMA_MINALIGN to allocate read buffers. This is required because, flash drivers may use DMA for read operations and may have to invalidate the buffer before read. Signed-off-by: Ravi Babu <ravibabu@ti.com> Signed-off-by: Vignesh R <vigneshr@ti.com> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Jagan Teki <jteki@openedev.com> Tested-by: Jagan Teki <jteki@openedev.com>
Showing 1 changed file with 6 additions and 5 deletions Side-by-side Diff
common/env_sf.c
... | ... | @@ -79,7 +79,7 @@ |
79 | 79 | if (CONFIG_ENV_SECT_SIZE > CONFIG_ENV_SIZE) { |
80 | 80 | saved_size = CONFIG_ENV_SECT_SIZE - CONFIG_ENV_SIZE; |
81 | 81 | saved_offset = env_new_offset + CONFIG_ENV_SIZE; |
82 | - saved_buffer = malloc(saved_size); | |
82 | + saved_buffer = memalign(ARCH_DMA_MINALIGN, saved_size); | |
83 | 83 | if (!saved_buffer) { |
84 | 84 | ret = 1; |
85 | 85 | goto done; |
... | ... | @@ -142,9 +142,10 @@ |
142 | 142 | env_t *tmp_env2 = NULL; |
143 | 143 | env_t *ep = NULL; |
144 | 144 | |
145 | - tmp_env1 = (env_t *)malloc(CONFIG_ENV_SIZE); | |
146 | - tmp_env2 = (env_t *)malloc(CONFIG_ENV_SIZE); | |
147 | - | |
145 | + tmp_env1 = (env_t *)memalign(ARCH_DMA_MINALIGN, | |
146 | + CONFIG_ENV_SIZE); | |
147 | + tmp_env2 = (env_t *)memalign(ARCH_DMA_MINALIGN, | |
148 | + CONFIG_ENV_SIZE); | |
148 | 149 | if (!tmp_env1 || !tmp_env2) { |
149 | 150 | set_default_env("!malloc() failed"); |
150 | 151 | goto out; |
... | ... | @@ -295,7 +296,7 @@ |
295 | 296 | int ret; |
296 | 297 | char *buf = NULL; |
297 | 298 | |
298 | - buf = (char *)malloc(CONFIG_ENV_SIZE); | |
299 | + buf = (char *)memalign(ARCH_DMA_MINALIGN, CONFIG_ENV_SIZE); | |
299 | 300 | env_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, CONFIG_ENV_SPI_CS, |
300 | 301 | CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE); |
301 | 302 | if (!env_flash) { |