[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <874jc83l9g.ffs@tglx>
Date: Thu, 11 Apr 2024 00:28:43 +0200
From: Thomas Gleixner <tglx@...utronix.de>
To: lakshmi.sowjanya.d@...el.com, jstultz@...gle.com, giometti@...eenne.com,
corbet@....net, linux-kernel@...r.kernel.org
Cc: x86@...nel.org, netdev@...r.kernel.org, linux-doc@...r.kernel.org,
intel-wired-lan@...ts.osuosl.org, andriy.shevchenko@...ux.intel.com,
eddie.dong@...el.com, christopher.s.hall@...el.com,
jesse.brandeburg@...el.com, davem@...emloft.net,
alexandre.torgue@...s.st.com, joabreu@...opsys.com,
mcoquelin.stm32@...il.com, perex@...ex.cz, linux-sound@...r.kernel.org,
anthony.l.nguyen@...el.com, peter.hilber@...nsynergy.com,
pandith.n@...el.com, subramanian.mohan@...el.com,
thejesh.reddy.t.r@...el.com, lakshmi.sowjanya.d@...el.com
Subject: Re: [PATCH v6 09/11] pps: generators: Add PPS Generator TIO Driver
On Wed, Apr 10 2024 at 17:18, lakshmi.sowjanya.d@...el.com wrote:
> +static bool pps_generate_next_pulse(struct pps_tio *tio, ktime_t expires)
> +{
> + u64 art;
> +
> + if (!ktime_real_to_base_clock(expires, CSID_X86_ART, &art)) {
> + pps_tio_disable(tio);
> + return false;
> + }
> +
> + pps_compv_write(tio, art - ART_HW_DELAY_CYCLES);
> + return true;
> +}
> +
> +static enum hrtimer_restart hrtimer_callback(struct hrtimer *timer)
> +{
> + struct pps_tio *tio = container_of(timer, struct pps_tio, timer);
> + ktime_t expires, now;
> + u32 event_count;
> +
> + guard(spinlock)(&tio->lock);
> +
> + /* Check if any event is missed. If an event is missed, TIO will be disabled*/
> + event_count = pps_tio_read(tio, TIOEC);
> + if (!tio->prev_count && tio->prev_count == event_count)
> + goto err;
> + tio->prev_count = event_count;
> + expires = hrtimer_get_expires(timer);
> + now = ktime_get_real();
> +
> + if (now - expires < SAFE_TIME_NS) {
> + if (!pps_generate_next_pulse(tio, expires + SAFE_TIME_NS))
> + goto err;
> + }
If the hrtimer callback is invoked late so that now - expires is >=
SAFE_TIME_NS then this just forwards the timer and tries again.
This lacks any form of explanation why this is correct as obviously
there will be a missing pulse, no?
> + hrtimer_forward(timer, now, NSEC_PER_SEC / 2);
> + return HRTIMER_RESTART;
> +err:
> + dev_err(tio->dev, "Event missed, Disabling Timed I/O");
> + pps_tio_disable(tio);
Why does this disable it again? The failure path in
pps_generate_next_pulse() does so already, no?
> + return HRTIMER_NORESTART;
> +}
> +
Thanks,
tglx
Powered by blists - more mailing lists