drivers: cache: nrf: Fix case when driver may hang
Driver was disabling cache before full range operations and that was causing hanging on polling for cache busy status since state was never changing (because cache was disabled). Additionally, added flushing to data cache disabling. If flushing is not performed then execution fails since data in cache is lost. Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
parent
73d4f58b98
commit
b83a11281d
25
drivers/cache/cache_nrf.c
vendored
25
drivers/cache/cache_nrf.c
vendored
|
@ -68,14 +68,6 @@ static inline int _cache_all(NRF_CACHE_Type *cache, enum k_nrf_cache_op op)
|
|||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
k_spinlock_key_t key = k_spin_lock(&lock);
|
||||
|
||||
/*
|
||||
* Invalidating the whole cache is dangerous. For good measure
|
||||
* disable the cache.
|
||||
*/
|
||||
nrf_cache_disable(cache);
|
||||
|
||||
wait_for_cache(cache);
|
||||
|
||||
switch (op) {
|
||||
|
@ -102,10 +94,6 @@ static inline int _cache_all(NRF_CACHE_Type *cache, enum k_nrf_cache_op op)
|
|||
|
||||
wait_for_cache(cache);
|
||||
|
||||
nrf_cache_enable(cache);
|
||||
|
||||
k_spin_unlock(&lock, key);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -202,11 +190,6 @@ void cache_data_enable(void)
|
|||
nrf_cache_enable(NRF_DCACHE);
|
||||
}
|
||||
|
||||
void cache_data_disable(void)
|
||||
{
|
||||
nrf_cache_disable(NRF_DCACHE);
|
||||
}
|
||||
|
||||
int cache_data_flush_all(void)
|
||||
{
|
||||
#if NRF_CACHE_HAS_TASK_CLEAN
|
||||
|
@ -216,6 +199,14 @@ int cache_data_flush_all(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
void cache_data_disable(void)
|
||||
{
|
||||
if (nrf_cache_enable_check(NRF_DCACHE)) {
|
||||
(void)cache_data_flush_all();
|
||||
}
|
||||
nrf_cache_disable(NRF_DCACHE);
|
||||
}
|
||||
|
||||
int cache_data_invd_all(void)
|
||||
{
|
||||
return _cache_checks(NRF_DCACHE, K_NRF_CACHE_INVD, NULL, 0, false);
|
||||
|
|
Loading…
Reference in a new issue