get_time_ns does a simplistic delta = cycle_now - cycle_last. It is possible that the h/w counter reached max and reset back to 0.
This patch addresses this issue by checking for rollover condition.
NOTE 1: This does not guarentee that you cannot confuse get_time_ns. You could possibly wait for two reset cycles and then get a messed up value.
To fix that we may need interrupt mode timer tick - something on the lines of jiffies on linux.
NOTE 2: the question of cs->mask is not clear. if the mask is for the tick, then it is better done with (cycle_now & cs->mask) - (cs->cycle_last & cs->mask).
Signed-off-by: Nishanth Menon<email@example.com>