Hi,
It is written on "PowerPC e500 Core Family Reference Manual, Rev. 1" document "Table 3-3. Data Access Synchronization Requirements"
that "tlbwe" command requires using CSI before and after and possibly msync.
1. In what cases should I use msync?
2. Should I use "tlbsync" instead CSI + msync after the "tlbwe" command?
Note: CSI indicates any context-synchronizing instruction (that is, sc, isync, rfci or rfi).
Your first question is answered by footnote 6 in table 3-3: "The context-synchronizing instruction after tlbwe or tlbivax ensures that subsequent accesses (data and instruction) use the updated value in any TLB entries affected. It does not ensure that all accesses previously translated by TLB entries being updated have completed with respect to memory; if these completions must be ensured, tlbwe or tlbivax must be followed by an msync and by a context-synchronizing instruction."
No, you shouldn't use tlbsync with tlbwe. tlbsync is only used after tlbivax, to ensure that the effects of the tlbivax have been seen on other processors. Note that software must ensure only one cpu is executing tlbsync at a time, and the tlbsync is in addition to msync, not instead of it.