Re: [PATCH] Clockevents: Always call clockevents_program_event
From: Thomas Gleixner
Date: Tue Oct 24 2017 - 06:13:18 EST
On Tue, 24 Oct 2017, Sodagudi Prasad wrote:
> On 2017-10-24 01:37, Thomas Gleixner wrote:
> > On Tue, 24 Oct 2017, Prasad Sodagudi wrote:
> >
> > > Currently tick_program_event function is not calling
> > > clockevents_program_event when 'expires == KTIME_MAX',
> > > it is just updating clockevent state to CLOCK_EVT_STATE_ONESHOT_STOPPED.
> > > clockevents_program_event function updates clockevent
> > > device next_event by checking clockevent device state,
> > > so always call clockevents_program_event() from tick_program_event.
> >
> > No. This is fundmentally wrong. If the clockevent is in oneshot stopped
> > mode then you cannot call clockevents_program_event(). There is even a
> > warning in that code which will trigger.
>
> <Prasad> Yes. There is warning and I overlooked at that part of the code and
> thought
> it would return from the clockevents_program_event function after next_event
> update.
> dev->next_event = expires;
>
> if (clockevent_state_shutdown(dev))
> return 0;
>
> Thanks tglx for reviewing patch.
>
> How to clean next next_event from clockevent device in the ONESHOT_STOPPED
> state from tick_program_event()?
>
> Shall I update the next patch set with following condition? Or Any other
> suggestions to fix this path?
>
> diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
> index 4237e07..21104b6 100644
> --- a/kernel/time/clockevents.c
> +++ b/kernel/time/clockevents.c
> @@ -317,7 +317,8 @@ int clockevents_program_event(struct clock_event_device
> *dev, ktime_t expires,
>
> dev->next_event = expires;
>
> - if (clockevent_state_shutdown(dev))
> + if (clockevent_state_shutdown(dev) ||
> + clockevent_state_oneshot_stopped(dev))
> return 0;
This needs more thought than that.
Thanks,
tglx