qemu_timer.c: add timer_deadline_ms() helper
The pSeries machine is using QEMUTimer internals to return the timeout in seconds for a timer object, in hw/ppc/spapr.c, function spapr_drc_unplug_timeout_remaining_sec(). Create a helper in qemu-timer.c to retrieve the deadline for a QEMUTimer object, in ms, to avoid exposing timer internals to the PPC code. CC: Paolo Bonzini <pbonzini@redhat.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com> Message-Id: <20210301124133.23800-2-danielhb413@gmail.com> Reviewed-by: Greg Kurz <groug@kaod.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
e35dfbd227
commit
4515a5f786
@ -421,9 +421,8 @@ void spapr_drc_unplug_request(SpaprDrc *drc)
|
|||||||
|
|
||||||
int spapr_drc_unplug_timeout_remaining_sec(SpaprDrc *drc)
|
int spapr_drc_unplug_timeout_remaining_sec(SpaprDrc *drc)
|
||||||
{
|
{
|
||||||
if (drc->unplug_requested && timer_pending(drc->unplug_timeout_timer)) {
|
if (drc->unplug_requested) {
|
||||||
return (qemu_timeout_ns_to_ms(drc->unplug_timeout_timer->expire_time) -
|
return timer_deadline_ms(drc->unplug_timeout_timer) / 1000;
|
||||||
qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL)) / 1000;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -795,6 +795,14 @@ static inline int64_t get_max_clock_jump(void)
|
|||||||
return 60 * NANOSECONDS_PER_SECOND;
|
return 60 * NANOSECONDS_PER_SECOND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* timer_deadline_ms:
|
||||||
|
*
|
||||||
|
* Returns the remaining miliseconds for @timer to expire, or zero
|
||||||
|
* if the timer is no longer pending.
|
||||||
|
*/
|
||||||
|
int64_t timer_deadline_ms(QEMUTimer *timer);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Low level clock functions
|
* Low level clock functions
|
||||||
*/
|
*/
|
||||||
|
@ -243,6 +243,19 @@ int64_t timerlist_deadline_ns(QEMUTimerList *timer_list)
|
|||||||
return delta;
|
return delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns the time remaining for the deadline, in ms.
|
||||||
|
*/
|
||||||
|
int64_t timer_deadline_ms(QEMUTimer *timer)
|
||||||
|
{
|
||||||
|
if (timer_pending(timer)) {
|
||||||
|
return qemu_timeout_ns_to_ms(timer->expire_time) -
|
||||||
|
qemu_clock_get_ms(timer->timer_list->clock->type);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Calculate the soonest deadline across all timerlists attached
|
/* Calculate the soonest deadline across all timerlists attached
|
||||||
* to the clock. This is used for the icount timeout so we
|
* to the clock. This is used for the icount timeout so we
|
||||||
* ignore whether or not the clock should be used in deadline
|
* ignore whether or not the clock should be used in deadline
|
||||||
|
Loading…
x
Reference in New Issue
Block a user