mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-23 22:18:17 +00:00
DM: refine cleanup functionality of virtual RTC
The patch includes: 1. vrtc_cleanup -> vrtc_deinit to align with other devices 2. delete timer created in vrtc_init 3. make call to vrtc_deinit in cleanup path Signed-off-by: Yin Fengwei <fengwei.yin@intel.com> Acked-by: Eddie Dong <Eddie.dong@intel.com>
This commit is contained in:
parent
cf9b9f6ba0
commit
583025fb39
@ -543,6 +543,7 @@ do_close_post(struct vmctx *ctx)
|
|||||||
pci_irq_deinit(ctx);
|
pci_irq_deinit(ctx);
|
||||||
deinit_pci(ctx);
|
deinit_pci(ctx);
|
||||||
atkbdc_deinit(ctx);
|
atkbdc_deinit(ctx);
|
||||||
|
vrtc_deinit(ctx);
|
||||||
vm_destroy(ctx);
|
vm_destroy(ctx);
|
||||||
vm_close(ctx);
|
vm_close(ctx);
|
||||||
}
|
}
|
||||||
|
@ -593,6 +593,12 @@ vrtc_create_timer(struct vrtc *vrtc, time_t sec, time_t nsec, void (*cb)())
|
|||||||
return timerid;
|
return timerid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
vrtc_delete_timer(timer_t timerid)
|
||||||
|
{
|
||||||
|
timer_delete(timerid);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
vrtc_time_update(struct vrtc *vrtc, time_t newtime, time_t newbase)
|
vrtc_time_update(struct vrtc *vrtc, time_t newtime, time_t newbase)
|
||||||
{
|
{
|
||||||
@ -1103,6 +1109,7 @@ vrtc_init(struct vmctx *ctx, int local_time)
|
|||||||
assert(vrtc != NULL);
|
assert(vrtc != NULL);
|
||||||
memset(vrtc, 0, sizeof(struct vrtc));
|
memset(vrtc, 0, sizeof(struct vrtc));
|
||||||
vrtc->vm = ctx;
|
vrtc->vm = ctx;
|
||||||
|
ctx->vrtc = vrtc;
|
||||||
|
|
||||||
pthread_mutex_init(&vrtc->mtx, NULL);
|
pthread_mutex_init(&vrtc->mtx, NULL);
|
||||||
|
|
||||||
@ -1157,7 +1164,24 @@ vrtc_init(struct vmctx *ctx, int local_time)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
vrtc_cleanup(struct vrtc *vrtc)
|
vrtc_deinit(struct vmctx *ctx)
|
||||||
{
|
{
|
||||||
|
struct vrtc *vrtc = ctx->vrtc;
|
||||||
|
struct inout_port iop;
|
||||||
|
|
||||||
|
memset(&iop, 0, sizeof(struct inout_port));
|
||||||
|
iop.name = "rtc";
|
||||||
|
iop.port = IO_RTC;
|
||||||
|
iop.size = 1;
|
||||||
|
unregister_inout(&iop);
|
||||||
|
|
||||||
|
memset(&iop, 0, sizeof(struct inout_port));
|
||||||
|
iop.name = "rtc";
|
||||||
|
iop.port = IO_RTC + 1;
|
||||||
|
iop.size = 1;
|
||||||
|
unregister_inout(&iop);
|
||||||
|
|
||||||
|
vrtc_delete_timer(vrtc->update_timer_id);
|
||||||
free(vrtc);
|
free(vrtc);
|
||||||
|
ctx->vrtc = NULL;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ struct vrtc;
|
|||||||
struct vmctx;
|
struct vmctx;
|
||||||
|
|
||||||
struct vrtc *vrtc_init(struct vmctx *ctx, int local_time);
|
struct vrtc *vrtc_init(struct vmctx *ctx, int local_time);
|
||||||
void vrtc_cleanup(struct vrtc *vrtc);
|
void vrtc_deinit(struct vmctx *ctx);
|
||||||
void vrtc_reset(struct vrtc *vrtc);
|
void vrtc_reset(struct vrtc *vrtc);
|
||||||
time_t vrtc_get_time(struct vrtc *vrtc);
|
time_t vrtc_get_time(struct vrtc *vrtc);
|
||||||
int vrtc_set_time(struct vrtc *vrtc, time_t secs);
|
int vrtc_set_time(struct vrtc *vrtc, time_t secs);
|
||||||
|
@ -59,6 +59,7 @@ struct vmctx {
|
|||||||
|
|
||||||
/* fields to track virtual devices */
|
/* fields to track virtual devices */
|
||||||
struct atkbdc_base *atkbdc_base;
|
struct atkbdc_base *atkbdc_base;
|
||||||
|
struct vrtc *vrtc;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user