All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Cochran <richardcochran@gmail.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [RFC v5 5/6] Add PTP_SYS_OFFSET_PRECISE for driver crosstimestamping
Date: Tue, 5 Jan 2016 16:27:32 +0100	[thread overview]
Message-ID: <20160105152731.GA24372@netboy> (raw)
In-Reply-To: <1451911523-8534-6-git-send-email-christopher.s.hall@intel.com>

On Mon, Jan 04, 2016 at 04:45:22AM -0800, Christopher S. Hall wrote:
> @@ -138,6 +142,7 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg)
>  		caps.n_per_out = ptp->info->n_per_out;
>  		caps.pps = ptp->info->pps;
>  		caps.n_pins = ptp->info->n_pins;
> +		caps.cross_timestamping = ptp->info->getsynctime != NULL;
>  		if (copy_to_user((void __user *)arg, &caps, sizeof(caps)))
>  			err = -EFAULT;
>  		break;
> @@ -180,6 +185,32 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg)
>  		err = ops->enable(ops, &req, enable);
>  		break;
>  
> +	case PTP_SYS_OFFSET_PRECISE:
> +		if (!ptp->info->getsynctime) {
> +			err = -EINVAL;

-EOPNOTSUPP would be better here.

> +			break;
> +		}
> +		err = ptp->info->getsynctime(ptp->info, &xtstamp);
> +		if (err)
> +			break;
> +
> +		precise_offset.sys_real.sec =
> +			div_u64_rem(ktime_to_ns(xtstamp.sys_realtime),
> +				    NSEC_PER_SEC, &rem);
> +		precise_offset.sys_real.nsec = rem;

How about this instead:

		ts = ktime_to_timespec64(xtstamp.sys_realtime);
		precise_offset.sys_real.sec = ts.tv_sec;
		precise_offset.sys_real.nsec = ts.tv_nsec;

> +		precise_offset.sys_raw.sec =
> +			div_u64_rem(ktime_to_ns(xtstamp.sys_monoraw),
> +				    NSEC_PER_SEC, &rem);
> +		precise_offset.sys_raw.nsec = rem;
> +		precise_offset.dev.sec =
> +			div_u64_rem(ktime_to_ns(xtstamp.device), NSEC_PER_SEC,
> +				    &rem);
> +		precise_offset.dev.nsec = rem;

And for these as well.

Thanks,
Richard

WARNING: multiple messages have this Message-ID (diff)
From: Richard Cochran <richardcochran@gmail.com>
To: "Christopher S. Hall" <christopher.s.hall@intel.com>
Cc: tglx@linutronix.de, mingo@redhat.com, john.stultz@linaro.org,
	hpa@zytor.com, jeffrey.t.kirsher@intel.com, x86@kernel.org,
	linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org,
	netdev@vger.kernel.org, kevin.b.stanton@intel.com
Subject: Re: [RFC v5 5/6] Add PTP_SYS_OFFSET_PRECISE for driver crosstimestamping
Date: Tue, 5 Jan 2016 16:27:32 +0100	[thread overview]
Message-ID: <20160105152731.GA24372@netboy> (raw)
In-Reply-To: <1451911523-8534-6-git-send-email-christopher.s.hall@intel.com>

On Mon, Jan 04, 2016 at 04:45:22AM -0800, Christopher S. Hall wrote:
> @@ -138,6 +142,7 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg)
>  		caps.n_per_out = ptp->info->n_per_out;
>  		caps.pps = ptp->info->pps;
>  		caps.n_pins = ptp->info->n_pins;
> +		caps.cross_timestamping = ptp->info->getsynctime != NULL;
>  		if (copy_to_user((void __user *)arg, &caps, sizeof(caps)))
>  			err = -EFAULT;
>  		break;
> @@ -180,6 +185,32 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg)
>  		err = ops->enable(ops, &req, enable);
>  		break;
>  
> +	case PTP_SYS_OFFSET_PRECISE:
> +		if (!ptp->info->getsynctime) {
> +			err = -EINVAL;

-EOPNOTSUPP would be better here.

> +			break;
> +		}
> +		err = ptp->info->getsynctime(ptp->info, &xtstamp);
> +		if (err)
> +			break;
> +
> +		precise_offset.sys_real.sec =
> +			div_u64_rem(ktime_to_ns(xtstamp.sys_realtime),
> +				    NSEC_PER_SEC, &rem);
> +		precise_offset.sys_real.nsec = rem;

How about this instead:

		ts = ktime_to_timespec64(xtstamp.sys_realtime);
		precise_offset.sys_real.sec = ts.tv_sec;
		precise_offset.sys_real.nsec = ts.tv_nsec;

> +		precise_offset.sys_raw.sec =
> +			div_u64_rem(ktime_to_ns(xtstamp.sys_monoraw),
> +				    NSEC_PER_SEC, &rem);
> +		precise_offset.sys_raw.nsec = rem;
> +		precise_offset.dev.sec =
> +			div_u64_rem(ktime_to_ns(xtstamp.device), NSEC_PER_SEC,
> +				    &rem);
> +		precise_offset.dev.nsec = rem;

And for these as well.

Thanks,
Richard

  reply	other threads:[~2016-01-05 15:27 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-04 12:45 [Intel-wired-lan] [RFC v5 0/6] Patchset enabling hardware based cross-timestamps for next gen Intel platforms Christopher S. Hall
2016-01-04 12:45 ` Christopher S. Hall
2016-01-04 12:45 ` [Intel-wired-lan] [RFC v5 1/6] Timekeeping cross timestamp interface for device drivers Christopher S. Hall
2016-01-04 12:45   ` Christopher S. Hall
2016-01-06 18:55   ` [Intel-wired-lan] " John Stultz
2016-01-06 18:55     ` John Stultz
2016-01-08  0:42     ` [Intel-wired-lan] " Christopher Hall
2016-01-08  0:42       ` Christopher Hall
2016-01-08  1:05       ` [Intel-wired-lan] " John Stultz
2016-01-08  1:05         ` John Stultz
2016-01-08  9:13         ` [Intel-wired-lan] " Richard Cochran
2016-01-08  9:13           ` Richard Cochran
2016-01-04 12:45 ` [Intel-wired-lan] [RFC v5 2/6] Always Running Timer (ART) correlated clocksource Christopher S. Hall
2016-01-04 12:45   ` Christopher S. Hall
2016-01-04 12:45 ` [Intel-wired-lan] [RFC v5 3/6] Add history to cross timestamp interface supporting slower devices Christopher S. Hall
2016-01-04 12:45   ` Christopher S. Hall
2016-01-06 19:37   ` [Intel-wired-lan] " John Stultz
2016-01-06 19:37     ` John Stultz
2016-01-08  1:07     ` [Intel-wired-lan] " Christopher Hall
2016-01-08  1:07       ` Christopher Hall
2016-01-08  1:12       ` [Intel-wired-lan] " John Stultz
2016-01-08  1:12         ` John Stultz
2016-01-08 14:04       ` [Intel-wired-lan] " Thomas Gleixner
2016-01-08 14:04         ` Thomas Gleixner
2016-01-08 22:28         ` [Intel-wired-lan] " Christopher Hall
2016-01-08 22:28           ` Christopher Hall
2016-01-04 12:45 ` [Intel-wired-lan] [RFC v5 4/6] Remove duplicate code from ktime_get_raw_and_real code Christopher S. Hall
2016-01-04 12:45   ` Christopher S. Hall
2016-01-06 19:42   ` [Intel-wired-lan] " John Stultz
2016-01-06 19:42     ` John Stultz
2016-01-04 12:45 ` [Intel-wired-lan] [RFC v5 5/6] Add PTP_SYS_OFFSET_PRECISE for driver crosstimestamping Christopher S. Hall
2016-01-04 12:45   ` Christopher S. Hall
2016-01-05 15:27   ` Richard Cochran [this message]
2016-01-05 15:27     ` Richard Cochran
2016-01-07  1:42     ` [Intel-wired-lan] " Christopher Hall
2016-01-07  1:42       ` Christopher Hall
2016-01-04 12:45 ` [Intel-wired-lan] [RFC v5 6/6] Adds hardware supported cross timestamp Christopher S. Hall
2016-01-04 12:45   ` Christopher S. Hall

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=20160105152731.GA24372@netboy \
    --to=richardcochran@gmail.com \
    --cc=intel-wired-lan@osuosl.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.