@@ -181,33 +181,22 @@ bool init_cycle_counter(bool bIsSysTickOccupied)
181
181
*/
182
182
__STATIC_INLINE int64_t check_systick (void )
183
183
{
184
- int64_t lLoad = perfc_port_get_system_timer_top () + 1 ;
185
184
int64_t lTemp = perfc_port_get_system_timer_elapsed ();
186
185
187
186
/* Since we cannot stop counting temporarily, there are several
188
187
* conditions which we should take into consideration:
189
188
* - Condition 1: when assigning nTemp with the register value (LOAD-VAL),
190
189
* the underflow didn't happen but when we check the PENDSTSET bit,
191
- * the underflow happens, for this condition, we should not
192
- * do any compensation. When this happens, the (LOAD-nTemp) is
193
- * smaller than PERF_CNT_COMPENSATION_THRESHOLD (a small value) as
194
- * long as LOAD is bigger than (or equals to) the
195
- * PERF_CNT_COMPENSATION_THRESHOLD;
196
- * - Condition 2: when assigning nTemp with the register value (LOAD-VAL),
197
- * the VAL is zero and underflow happened and the PENDSTSET bit
198
- * is set, for this condition, we should not do any compensation.
199
- * When this happens, the (LOAD-nTemp) is equals to zero.
200
- * - Condition 3: when assigning nTemp with the register value (LOAD-VAL),
201
- * the underflow has already happened, hence the PENDSTSET
202
- * is set, for this condition, we should compensate the return
203
- * value. When this happens, the (LOAD-nTemp) is bigger than (or
204
- * equals to) PERF_CNT_COMPENSATION_THRESHOLD.
190
+ * the underflow happens, for this condition, we should recall the
191
+ * perfc_port_get_system_timer_elapsed().
205
192
* The following code implements an equivalent logic.
206
193
*/
207
194
if (perfc_port_is_system_timer_ovf_pending ()){
208
- //if ((lLoad - lTemp) >= PERF_CNT_COMPENSATION_THRESHOLD) {
209
- lTemp += lLoad ;
210
- //}
195
+ /* refresh the elapsed just in case the counter has just overflowed/underflowed
196
+ * after we called the perfc_port_get_system_timer_elapsed()
197
+ */
198
+ lTemp = perfc_port_get_system_timer_elapsed ();
199
+ lTemp += perfc_port_get_system_timer_top () + 1 ;
211
200
}
212
201
213
202
return lTemp ;
0 commit comments