summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNick Hu <[email protected]>2025-10-20 14:34:12 +0800
committerAnup Patel <[email protected]>2025-10-28 11:28:06 +0530
commit8f8c39315520acf2c3ba2e65d5e6ed887230011a (patch)
tree27322d6bdbb24487fa2377a69611ca18369c3095 /lib
parent1514a327306b8e6bca7194676ba810543f88938d (diff)
lib: utils/timer: Expose timer update function
Exposing the ACLINT timer update APIs so the user can update the mtimer after waking up from the non-retentive suspend. Reviewed-by: Cyan Yang <[email protected]> Reviewed-by: Anup Patel <[email protected]> Signed-off-by: Nick Hu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
Diffstat (limited to 'lib')
-rw-r--r--lib/utils/timer/aclint_mtimer.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/lib/utils/timer/aclint_mtimer.c b/lib/utils/timer/aclint_mtimer.c
index 3db3c3be..fd6189aa 100644
--- a/lib/utils/timer/aclint_mtimer.c
+++ b/lib/utils/timer/aclint_mtimer.c
@@ -109,28 +109,42 @@ static struct sbi_timer_device mtimer = {
.timer_event_stop = mtimer_event_stop
};
-void aclint_mtimer_sync(struct aclint_mtimer_data *mt)
+struct aclint_mtimer_data *aclint_get_mtimer_data(void)
+{
+ return mtimer_get_hart_data_ptr(sbi_scratch_thishart_ptr());
+}
+
+void aclint_mtimer_update(struct aclint_mtimer_data *mt,
+ struct aclint_mtimer_data *ref)
{
u64 v1, v2, mv, delta;
u64 *mt_time_val, *ref_time_val;
- struct aclint_mtimer_data *reference;
- /* Sync-up non-shared MTIME if reference is available */
- if (mt->has_shared_mtime || !mt->time_delta_reference)
+ if (!mt || !ref || !mt->time_rd || !mt->time_wr || !ref->time_rd)
return;
- reference = mt->time_delta_reference;
mt_time_val = (void *)mt->mtime_addr;
- ref_time_val = (void *)reference->mtime_addr;
+ ref_time_val = (void *)ref->mtime_addr;
if (!atomic_raw_xchg_ulong(&mt->time_delta_computed, 1)) {
v1 = mt->time_rd(mt_time_val);
- mv = reference->time_rd(ref_time_val);
+ mv = ref->time_rd(ref_time_val);
v2 = mt->time_rd(mt_time_val);
delta = mv - ((v1 / 2) + (v2 / 2));
mt->time_wr(false, mt->time_rd(mt_time_val) + delta,
mt_time_val);
}
+}
+void aclint_mtimer_sync(struct aclint_mtimer_data *mt)
+{
+ struct aclint_mtimer_data *reference;
+
+ /* Sync-up non-shared MTIME if reference is available */
+ if (mt->has_shared_mtime || !mt->time_delta_reference)
+ return;
+
+ reference = mt->time_delta_reference;
+ aclint_mtimer_update(mt, reference);
}
void aclint_mtimer_set_reference(struct aclint_mtimer_data *mt,