linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: subramanian.mohan@intel.com
Cc: gregkh@linuxfoundation.org, tglx@linutronix.de,
	giometti@enneenne.com, corbet@lwn.net,
	linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
	eddie.dong@intel.com, christopher.s.hall@intel.com,
	pandith.n@intel.com, thejesh.reddy.t.r@intel.com,
	david.zage@intel.com, srinivasan.chinnadurai@intel.com
Subject: Re: [PATCH v12 1/3] pps: generators: Add PPS Generator TIO Driver
Date: Fri, 23 Aug 2024 17:22:36 +0300	[thread overview]
Message-ID: <ZsibLHt0iNJM4d02@smile.fi.intel.com> (raw)
In-Reply-To: <20240823070109.27815-2-subramanian.mohan@intel.com>

On Fri, Aug 23, 2024 at 12:31:06PM +0530, subramanian.mohan@intel.com wrote:
> From: Subramanian Mohan <subramanian.mohan@intel.com>
> 
> The Intel Timed IO PPS generator driver outputs a PPS signal using
> dedicated hardware that is more accurate than software actuated PPS.
> The Timed IO hardware generates output events using the ART timer.
> The ART timer period varies based on platform type, but is less than 100
> nanoseconds for all current platforms. Timed IO output accuracy is
> within 1 ART period.
> 
> PPS output is enabled by writing '1' the 'enable' sysfs attribute. The
> driver uses hrtimers to schedule a wake-up 10 ms before each event
> (edge) target time. At wakeup, the driver converts the target time in
> terms of CLOCK_REALTIME to ART trigger time and writes this to the Timed
> IO hardware. The Timed IO hardware generates an event precisely at the
> requested system time without software involvement.

...

> +#include <linux/bits.h>
> +#include <linux/bitfield.h>

These two should be swapped in ordering

> +#include <linux/cleanup.h>
> +#include <linux/container_of.h>
> +#include <linux/cpu.h>
> +#include <linux/device.h>
> +#include <linux/err.h>
> +#include <linux/hrtimer.h>
> +#include <linux/io-64-nonatomic-hi-lo.h>
> +#include <linux/kstrtox.h>
> +#include <linux/mod_devicetable.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/spinlock.h>
> +#include <linux/sysfs.h>
> +#include <linux/timekeeping.h>
> +#include <linux/types.h>

...

> +#define SAFE_TIME_NS			(10 * NSEC_PER_MSEC) /* Safety time to set hrtimer early */

It's better to have

/* ...comment... */
...definition...

...

> +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*/

/*
 * Missing space at the of the comment. But since it's two-sentences comment,
 * make it multi-line like in this example.
 */

> +	event_count = pps_tio_read(tio, TIOEC);
> +	if (tio->prev_count && tio->prev_count == event_count)
> +		goto err;
> +	tio->prev_count = event_count;

+ Blank line.

> +	expires = hrtimer_get_expires(timer);

(1)

> +	now = ktime_get_real();
> +

The location of this blank line seems incorrect and should be moved to (1) above.

> +	if (now - expires >= SAFE_TIME_NS)
> +		goto err;
> +
> +	tio->enabled = pps_generate_next_pulse(tio, expires + SAFE_TIME_NS);
> +	if (!tio->enabled)
> +		return HRTIMER_NORESTART;
> +
> +	hrtimer_forward(timer, now, NSEC_PER_SEC / 2);
> +	return HRTIMER_RESTART;

+ Blank line.

> +err:
> +	dev_err(tio->dev, "Event missed, Disabling Timed I/O");
> +	pps_tio_disable(tio);
> +	return HRTIMER_NORESTART;
> +}

...

Note, the above are nit-picks and may be applied if you ever need a v13 to be
sent. For now let's wait for the more serious comments against the series.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2024-08-23 14:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-23  7:01 [PATCH v12 0/3] Add support for Intel PPS Generator subramanian.mohan
2024-08-23  7:01 ` [PATCH v12 1/3] pps: generators: Add PPS Generator TIO Driver subramanian.mohan
2024-08-23 14:22   ` Andy Shevchenko [this message]
2024-08-23  7:01 ` [PATCH v12 2/3] Documentation: driver-api: pps: Add Intel Timed I/O PPS generator subramanian.mohan
2024-08-24  2:21   ` Greg KH
2024-08-27 13:09     ` Rodolfo Giometti
2024-09-03 10:25       ` Greg KH
2024-09-25 21:55         ` Hall, Christopher S
2024-09-26  8:46           ` Rodolfo Giometti
2024-09-26  9:34             ` Greg KH
2024-08-23  7:01 ` [PATCH v12 3/3] ABI: pps: Add ABI documentation for Intel TIO subramanian.mohan
2024-08-23 14:24   ` Andy Shevchenko
2024-08-24  2:20   ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZsibLHt0iNJM4d02@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=christopher.s.hall@intel.com \
    --cc=corbet@lwn.net \
    --cc=david.zage@intel.com \
    --cc=eddie.dong@intel.com \
    --cc=giometti@enneenne.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pandith.n@intel.com \
    --cc=srinivasan.chinnadurai@intel.com \
    --cc=subramanian.mohan@intel.com \
    --cc=tglx@linutronix.de \
    --cc=thejesh.reddy.t.r@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).