Handle initial state of scmi clock
Created by: vingu-linaro
While running scmi compliance tests on optee-fvp product, I faced a non conformant clock test 17. The log is available below.
The problem comes from the way the initial state is set at boot and the clock_count is incremented simultaneously. In order to be able to disable a scmi clock, agent must enable it 1st even if the scmi clock get request already returned that the clock is running.
That being said, the problem might come from the scmi compliance test. I haven't seen anything in the specification that agent must (or not) balance the number of clock config set enable/disable.
One problem is that the scmi clock state may no be same as hw clock which create a mismatch and because the action is sent to th real clock when clock_count move between value 0 and 1.
Test log :
505: Clock attributes check
NUM CLOCKS : 7
CLOCK ID: 0
[Check 1] Query clock attribute
MSG HDR : 0x03d85003
NUM PARAM : 1
PARAMETER[00] : 0x00000000
CHECK STATUS : PASSED [SCMI_STATUS_SUCCES]
CHECK HEADER : PASSED [0x03d85003]
RETURN COUNT : 5
RETURN[00] : 0x00000001 <--- Clock ID 0 state is 1
RETURN[01] : 0x434f4c43
RETURN[02] : 0x00305f4b
RETURN[03] : 0x00000000
RETURN[04] : 0x00000000
CHECK RSVD BITS: PASSED
CLOCK_ENABLED: 1
CLOCK_NAME: CLOCK_0
...
517: Clock config set check
NUM CLOCKS : 7
CLOCK ID: 0
[Check 1] Set config with attributes :0
MSG HDR : 0x05105007
NUM PARAM : 2
PARAMETER[00] : 0x00000000
PARAMETER[01] : 0x00000000 <--- Set Clock ID 0 to state 0
CHECK HEADER : PASSED [0x05105007]
CHECK STATUS : PASSED [SCMI_STATUS_SUCCES]
RETURN COUNT : 0
[Check 2] Verify the changed attribute
MSG HDR : 0x05145003
NUM PARAM : 1
PARAMETER[00] : 0x00000000
CHECK STATUS : PASSED [SCMI_STATUS_SUCCES]
CHECK HEADER : PASSED [0x05145003]
CHECK RSVD BITS: PASSED
RETURN COUNT : 5
RETURN[00] : 0x00000001 <--- Clock ID 0 state is still 1
RETURN[01] : 0x434f4c43
RETURN[02] : 0x00305f4b
RETURN[03] : 0x00000000
RETURN[04] : 0x00000000
CHECK CLOCK STATUS : FAILED
EXPECTED : 0x00000000
RECEIVED : 0x00000001 : NON CONFORMANT