Hi All,
Board c6670
Situation: - All 4 cores want to write [more or less simultaneously] into a data structure X [X is in MSMCSRAM].
Theory: - Multiple writers to single end point problem
Practicals: -
option: -
[A]=========================================================
previous sys-bios version (version older than 6.33.06.50)
whichever core wants to access the structure X, he enters critical section acquires a Key [by Hwi_disable] and once done with write, Hwi_enable [thereby exiting the critical section
pseudo code [This code will be accessed by both cores]*****************************
/* Disable the interrupt */
Hwi_disable();
cache_invalid(X,sizeof(X));
X.a = 1;
cache_writeback(X,sizeof(X));
/* Disable the interrupt */
Hwi_enable();
[B]=========================================================
newer sys-bios version (version newer than 6.33.06.50)
blindly access X by any core simultaneously, mfence is within CACHE functions and pass CACHE_FENCE_WAIT as argument.
An example is
/* Writeback the contents of the cache. */
CACHE_wbL1d (ptr, size, CACHE_FENCE_WAIT);
No need of critical section, keys and Hwi disable or enable.
this CACHE_FENCE_WAIT is newer one.
/** No blocking, the call exits after programmation of the
* control registers
*/
CACHE_NOWAIT = 0,
/** Blocking Call, the call exits after the relevant cache
* status registers indicate completion. For block coherence
* this waits on the Word count register to be come 0.
*/
CACHE_WAIT = 1,
/** Blocking Call, For block coherence this uses the MFENCE to
* wait for completion
*/
CACHE_FENCE_WAIT = 2
pseudo code [This code will be accessed by both cores]*****************************
CACHE_wbL1d (X,sizeof(X),CACHE_FENCE_WAIT);
X.a = 1;
cache_writeback(X,sizeof(X),CACHE_FENCE_WAIT);
##############################################################################################how to do in version older than 6.33.06.50 with mfence [no critical section, how hwi disables or enables]
pseudo code [This code will be accessed by both cores]*****************************
CACHE_wbL1d (X,sizeof(X),CACHE_WAIT);
_mfence();
X.a = 1;
cache_writeback(X,sizeof(X),CACHE_WAIT);
_mfence();
1. please note in current version older than 6.33.06.50, i will be using CACHE_WAIT and i want to eliminate/avoid Hwi_disable and enable and use _mfence instead. is the above code correct ?
2. If my understanding is correct,i don't need to use Hwi_disable and enable? please confirm?
3. Thumb Rule is after every cache operation, _mfence() needs to be called. please correct me if i am wrong??
Thanks
RC Reddy