Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1301606

Re: [RFC v5 5/6] Add PTP_SYS_OFFSET_PRECISE for driver crosstimestamping

From Richard Cochran <richardcochran@gmail.com>
Newsgroups linux.kernel
Subject Re: [RFC v5 5/6] Add PTP_SYS_OFFSET_PRECISE for driver crosstimestamping
Date 2016-01-05 16:30 +0100
Message-ID <qNBID-4FF-43@gated-at.bofh.it> (permalink)
References <qNjsm-7U0-13@gated-at.bofh.it> <qNjso-7U0-51@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC v5 0/6] Patchset enabling hardware based cross-timestamps for next gen Intel platforms "Christopher S. Hall" <christopher.s.hall@intel.com> - 2016-01-04 21:00 +0100
  [RFC v5 4/6] Remove duplicate code from ktime_get_raw_and_real code "Christopher S. Hall" <christopher.s.hall@intel.com> - 2016-01-04 21:00 +0100
    Re: [RFC v5 4/6] Remove duplicate code from ktime_get_raw_and_real code John Stultz <john.stultz@linaro.org> - 2016-01-06 20:50 +0100
  [RFC v5 3/6] Add history to cross timestamp interface supporting slower devices "Christopher S. Hall" <christopher.s.hall@intel.com> - 2016-01-04 21:00 +0100
    Re: [RFC v5 3/6] Add history to cross timestamp interface supporting  slower devices John Stultz <john.stultz@linaro.org> - 2016-01-06 20:40 +0100
      Re: [RFC v5 3/6] Add history to cross timestamp interface supporting  slower devices "Christopher Hall" <christopher.s.hall@intel.com> - 2016-01-08 02:10 +0100
        Re: [RFC v5 3/6] Add history to cross timestamp interface supporting  slower devices John Stultz <john.stultz@linaro.org> - 2016-01-08 02:20 +0100
        Re: [RFC v5 3/6] Add history to cross timestamp interface supporting  slower devices Thomas Gleixner <tglx@linutronix.de> - 2016-01-08 15:10 +0100
          Re: [RFC v5 3/6] Add history to cross timestamp interface supporting  slower devices "Christopher Hall" <christopher.s.hall@intel.com> - 2016-01-08 23:30 +0100
  [RFC v5 6/6] Adds hardware supported cross timestamp "Christopher S. Hall" <christopher.s.hall@intel.com> - 2016-01-04 21:00 +0100
  [RFC v5 2/6] Always Running Timer (ART) correlated clocksource "Christopher S. Hall" <christopher.s.hall@intel.com> - 2016-01-04 21:00 +0100
  [RFC v5 1/6] Timekeeping cross timestamp interface for device drivers "Christopher S. Hall" <christopher.s.hall@intel.com> - 2016-01-04 21:00 +0100
    Re: [RFC v5 1/6] Timekeeping cross timestamp interface for device drivers John Stultz <john.stultz@linaro.org> - 2016-01-06 20:00 +0100
      Re: [RFC v5 1/6] Timekeeping cross timestamp interface for device  drivers "Christopher Hall" <christopher.s.hall@intel.com> - 2016-01-08 01:50 +0100
        Re: [RFC v5 1/6] Timekeeping cross timestamp interface for device drivers John Stultz <john.stultz@linaro.org> - 2016-01-08 02:10 +0100
          Re: [RFC v5 1/6] Timekeeping cross timestamp interface for device  drivers Richard Cochran <richardcochran@gmail.com> - 2016-01-08 10:20 +0100
  [RFC v5 5/6] Add PTP_SYS_OFFSET_PRECISE for driver crosstimestamping "Christopher S. Hall" <christopher.s.hall@intel.com> - 2016-01-04 21:00 +0100
    Re: [RFC v5 5/6] Add PTP_SYS_OFFSET_PRECISE for driver  crosstimestamping Richard Cochran <richardcochran@gmail.com> - 2016-01-05 16:30 +0100
      Re: [RFC v5 5/6] Add PTP_SYS_OFFSET_PRECISE for driver  crosstimestamping "Christopher Hall" <christopher.s.hall@intel.com> - 2016-01-07 02:50 +0100

csiph-web