diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/timer/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/timer/base.c index 07dc82b..ae0a1eb 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/timer/base.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/timer/base.c @@ -29,6 +29,19 @@ nvkm_timer_read(struct nvkm_timer *tmr) return tmr->func->read(tmr); } +static void +nvkm_timer_alarm_update_hw(struct nvkm_timer *tmr) +{ + struct nvkm_alarm *alarm; + + if (!list_empty(&tmr->alarms)) { + alarm = list_first_entry(&tmr->alarms, typeof(*alarm), head); + tmr->func->alarm_init(tmr, alarm->timestamp); + } else { + tmr->func->alarm_fini(tmr); + } +} + void nvkm_timer_alarm_trigger(struct nvkm_timer *tmr) { @@ -44,12 +57,7 @@ nvkm_timer_alarm_trigger(struct nvkm_timer *tmr) } /* reschedule interrupt for next alarm time */ - if (!list_empty(&tmr->alarms)) { - alarm = list_first_entry(&tmr->alarms, typeof(*alarm), head); - tmr->func->alarm_init(tmr, alarm->timestamp); - } else { - tmr->func->alarm_fini(tmr); - } + nvkm_timer_alarm_update_hw(tmr); spin_unlock_irqrestore(&tmr->lock, flags); /* execute any pending alarm handlers */ @@ -79,10 +87,10 @@ nvkm_timer_alarm(struct nvkm_timer *tmr, u32 nsec, struct nvkm_alarm *alarm) } list_add_tail(&alarm->head, &list->head); } - spin_unlock_irqrestore(&tmr->lock, flags); - /* process pending alarms */ - nvkm_timer_alarm_trigger(tmr); + /* reschedule interrupt for next alarm time */ + nvkm_timer_alarm_update_hw(tmr); + spin_unlock_irqrestore(&tmr->lock, flags); } void