write memory barrier
Hi,
I am wondering if/when i should use a barrier: I am changing the settings of the dividers and such operation requires writing to prcm_clkcfg_ctrl after programminig the new set of dividers.
So far it seems to work without barriers, but i'm wodering if i'm just been lucky, while the OMAP2 TRM seems to refer only to interacting with the INTC, when referrinig to memory barriers.
I have also checked the ARM1136 TRM but couldn't find anything that would seem to be related to my problem.
Thanks in advance for any info.
Signature · 4 lines
Cheers, Igor Igor Stoppa <[email protected]> (Nokia Multimedia - CP - OSSO / Helsinki, Finland)
Some more specifics might be helpful.
Generally, the commit of a divider change should happen in SRAM. Much of the effects should be synchronized with the commit for the clocks in listed as delayed. When dividing by 2 SDRC/GPMC timings might require changes to keep their buses visible.
Some clocks do have some side effects of changes, but it might be unlikely you access them quickly enough to see the effect. M/N changes take a while. Depending on I to F clock ratios and posted/non-posted timers might take a bit.
Regards,
Richard W.
Quoted 7 lines
Hi,
I am wondering if/when i should use a barrier: I am changing the settings of the dividers and such operation requires writing toprcm_clkcfg_ctrlafter programminig the new set of dividers.So far it seems to work without barriers, but i'm wodering if i'm just been lucky, while the OMAP2 TRM seems to refer only to interacting
with
Quoted 16 lines
the INTC, when referrinig to memory barriers.
I have also checked the ARM1136 TRM but couldn't find anything that would seem to be related to my problem.
Thanks in advance for any info.
--
Cheers, IgorIgor Stoppa <[email protected]>
(Nokia Multimedia - CP - OSSO / Helsinki, Finland)
_______________________________________________
Linux-omap-open-source mailing list [email protected]
http://linux.omap.com/mailman/listinfo/linux-omap-open-source
Hi Richard,
please find my reply inlined.
Quoted 1 line · Richard
Some more specifics might be helpful.
ok, i'll try to be more clear.
Quoted 1 line
Generally, the commit of a divider change should happen in SRAM.
Or from icache, after an appropriate pre-fetch of the critical section of code that cannot be executed from sdram, right?
Quoted 4 lines
Much
of the effects should be synchronized with the commit for the clocks in listed as delayed. When dividing by 2 SDRC/GPMC timings might require changes to keep their buses visible.
Right.
Quoted 4 lines
Some clocks do have some side effects of changes, but it might be unlikely you access them quickly enough to see the effect. M/N changes take a while. Depending on I to F clock ratios and posted/non-posted timers might take a bit.
Here, if i've understood correctly, you are also referring to hw timing, which certainly have to be considered, but I was thinking about out-of-order execution and the compiler potentially reshuffling the configuration i'm doing.
I'm changing the settings of CM_CLKSEL_* and my understanding is that afterward, to have the changes applied, I have to write 1 to PRCM_CLKCFG_CTRL[VALID_CONFIG]
My concern is that the write order is changed and PRCM_CLKCFG_CTRL[VALID_CONFIG] gets written _before_ proper settings have been programmed into CM_CLKSEL_* thus effectively leadinig to either:
-invalid configuration and changes not been applied at all, which is somehow preferrable to
-valid, but different from the expected, configuration, with some of the new values applied and some of fthe old ones retained
So i guess my question (at the moment) boils down to:
do i have to insert a wmb (or maybe barrier, if the compiler is the only entity that can change the order of execution) between the programming of CM_CLKSEL_* and writing 1 to PRCM_CLKCFG_CTRL[VALID_CONFIG]?
Or: are my writes posted? How can I check/disable the posting or at least make sure that all the settings have been applied before i flush them?
I hope this clarifies the situation.
Cheers, Igor
Igor Stoppa <[email protected]>
(Nokia Multimedia - CP - OSSO / Helsinki, Finland)
Quoted 5 lines
Quoted 2 lines
Generally, the commit of a divider change should happen in SRAM.
Or from icache, after an appropriate pre-fetch of the critical section of code that cannot be executed from sdram, right?
Yep.
Quoted 2 lines
Quoted 2 lines
Some clocks do have some side effects of changes, but it might be unlikely you access them quickly enough to see the effect. M/N
changes
Quoted 1 line
Quoted 1 line
take a while. Depending on I to F clock ratios and
posted/non-posted
Quoted 4 lines
Quoted 1 line
timers might take a bit.
Here, if i've understood correctly, you are also referring to hw
timing,
Quoted 3 lines
which certainly have to be considered, but I was thinking about out-of-order execution and the compiler potentially reshuffling the configuration i'm doing.
Yes, ok.
Quoted 11 lines
I'm changing the settings of CM_CLKSEL_* and my understanding is that afterward, to have the changes applied, I have to write 1 to PRCM_CLKCFG_CTRL[VALID_CONFIG]
My concern is that the write order is changed and PRCM_CLKCFG_CTRL[VALID_CONFIG] gets written _before_ proper settings have been programmed into CM_CLKSEL_* thus effectively leadinig to either:
-invalid configuration and changes not been applied at all, which is somehow preferrable to
-valid, but different from the expected, configuration, with some of
the
Quoted 1 line
new values applied and some of fthe old ones retained
Couple of thoughts:
-1- the clock code usage was set up all the dividers in C code, then jump into assembly in SRAM to do the final commit. In that case the compiler would not have moved anything after the commit.
-2- Yes ARMv6 can complete out of order. However, the ARMv6 memory model defines things such that you can enforce ordering. Internal memory accesses are currently marked as no-cache-strongly-ordered. I think this access in itself serializes instructions around it.
If you just mark things as 'non-cached' then they can be done out-of-order. If you mark things as 'device' Then they will happen in-order but might be posted through the bus below.
Quoted 2 lines
So i guess my question (at the moment) boils down to:
do i have to insert a wmb (or maybe barrier, if the compiler is the
only
Quoted 2 lines
entity that can change the order of execution) between the programming of CM_CLKSEL_* and writing 1 to PRCM_CLKCFG_CTRL[VALID_CONFIG]?
If its happening in-line in some code somewhere I wouldn't hurt, incase the compiler doesn't see any dependency. Below the access should be volatile which should have clobbered optimizations, but an explicit barrier is probably better. I don't think however, with current mappings the hardware would re-order it on you.
-- One tip of the day is you can save some power by setting module-level-auto-idle of some devices even if that device is switched off at I and F clock. Security peripherals are an example which at run time does save like 6-9mA. For security ones, you must be careful around sleep though, as the idle-ack is slow and if you access it (say rng) then wfi before it finishes it can draw an extra 600uA in sleep. Others had reported some of this before, but I've only recently played with the same. For things which have a shared F-Clock, shutting off the local F-Clock result in a hardware usecount dropping, but not necessary a gating of the effect of that clock in the module (unless auto-idle is set).
Regards,
Richard W.